blob: fbf933f4c2dcb910b633a08daac881605c4643dd [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20*/
Jeff Johnson295189b2012-06-20 16:38:30 -070021
22/**========================================================================
23
24 \file wlan_hdd_cfg80211.c
25
26 \brief WLAN Host Device Driver implementation
27
Gopichand Nakkala747461f2013-04-24 19:24:45 +053028 Copyright 2008 (c) Qualcomm Technologies, Inc. All Rights Reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070029
Gopichand Nakkala747461f2013-04-24 19:24:45 +053030 Qualcomm Technologies Confidential and Proprietary.
Jeff Johnson295189b2012-06-20 16:38:30 -070031
32 ========================================================================*/
33
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070034/**=========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070035
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070036 EDIT HISTORY FOR FILE
Jeff Johnson295189b2012-06-20 16:38:30 -070037
38
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070039 This section contains comments describing changes made to the module.
40 Notice that changes are listed in reverse chronological order.
Jeff Johnson295189b2012-06-20 16:38:30 -070041
42
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070043 $Header:$ $DateTime: $ $Author: $
Jeff Johnson295189b2012-06-20 16:38:30 -070044
45
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070046 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070047 -------- --- --------------------------------------------------------
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070048 21/12/09 Ashwani Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070049
50 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070051 Ganesh K
Jeff Johnson295189b2012-06-20 16:38:30 -070052 ==========================================================================*/
53
Jeff Johnson295189b2012-06-20 16:38:30 -070054
55#include <linux/version.h>
56#include <linux/module.h>
57#include <linux/kernel.h>
58#include <linux/init.h>
59#include <linux/wireless.h>
60#include <wlan_hdd_includes.h>
61#include <net/arp.h>
62#include <net/cfg80211.h>
63#include <linux/wireless.h>
64#include <wlan_hdd_wowl.h>
65#include <aniGlobal.h>
66#include "ccmApi.h"
67#include "sirParams.h"
68#include "dot11f.h"
69#include "wlan_hdd_assoc.h"
70#include "wlan_hdd_wext.h"
71#include "sme_Api.h"
72#include "wlan_hdd_p2p.h"
73#include "wlan_hdd_cfg80211.h"
74#include "wlan_hdd_hostapd.h"
75#include "sapInternal.h"
76#include "wlan_hdd_softap_tx_rx.h"
77#include "wlan_hdd_main.h"
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053078#include "wlan_hdd_assoc.h"
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053079#include "wlan_hdd_power.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070080#ifdef WLAN_BTAMP_FEATURE
81#include "bap_hdd_misc.h"
82#endif
83#include <qc_sap_ioctl.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080084#ifdef FEATURE_WLAN_TDLS
85#include "wlan_hdd_tdls.h"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053086#include "wlan_hdd_wmm.h"
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053087#include "wlan_qct_wda.h"
Mohit Khanna698ba2a2012-12-04 15:08:18 -080088#endif
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053089#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070090#include "wlan_hdd_dev_pwr.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070091
92#define g_mode_rates_size (12)
93#define a_mode_rates_size (8)
94#define FREQ_BASE_80211G (2407)
95#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070096#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +053097#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -070098#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
99 ((int) OFFSET_OF( tSirBssDescription, ieFields)))
100
101#define HDD2GHZCHAN(freq, chan, flag) { \
102 .band = IEEE80211_BAND_2GHZ, \
103 .center_freq = (freq), \
104 .hw_value = (chan),\
105 .flags = (flag), \
106 .max_antenna_gain = 0 ,\
107 .max_power = 30, \
108}
109
110#define HDD5GHZCHAN(freq, chan, flag) { \
111 .band = IEEE80211_BAND_5GHZ, \
112 .center_freq = (freq), \
113 .hw_value = (chan),\
114 .flags = (flag), \
115 .max_antenna_gain = 0 ,\
116 .max_power = 30, \
117}
118
119#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
120{\
121 .bitrate = rate, \
122 .hw_value = rate_id, \
123 .flags = flag, \
124}
125
Lee Hoonkic1262f22013-01-24 21:59:00 -0800126#ifndef WLAN_FEATURE_TDLS_DEBUG
127#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_INFO
128#else
129#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_ERROR
130#endif
131
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530132#ifdef WLAN_FEATURE_VOWIFI_11R
133#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
134#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
135#endif
136
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530137static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700138{
139 WLAN_CIPHER_SUITE_WEP40,
140 WLAN_CIPHER_SUITE_WEP104,
141 WLAN_CIPHER_SUITE_TKIP,
142#ifdef FEATURE_WLAN_CCX
143#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
144 WLAN_CIPHER_SUITE_KRK,
145 WLAN_CIPHER_SUITE_CCMP,
146#else
147 WLAN_CIPHER_SUITE_CCMP,
148#endif
149#ifdef FEATURE_WLAN_WAPI
150 WLAN_CIPHER_SUITE_SMS4,
151#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700152#ifdef WLAN_FEATURE_11W
153 WLAN_CIPHER_SUITE_AES_CMAC,
154#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700155};
156
157static inline int is_broadcast_ether_addr(const u8 *addr)
158{
159 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
160 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
161}
162
163static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530164{
Jeff Johnson295189b2012-06-20 16:38:30 -0700165 HDD2GHZCHAN(2412, 1, 0) ,
166 HDD2GHZCHAN(2417, 2, 0) ,
167 HDD2GHZCHAN(2422, 3, 0) ,
168 HDD2GHZCHAN(2427, 4, 0) ,
169 HDD2GHZCHAN(2432, 5, 0) ,
170 HDD2GHZCHAN(2437, 6, 0) ,
171 HDD2GHZCHAN(2442, 7, 0) ,
172 HDD2GHZCHAN(2447, 8, 0) ,
173 HDD2GHZCHAN(2452, 9, 0) ,
174 HDD2GHZCHAN(2457, 10, 0) ,
175 HDD2GHZCHAN(2462, 11, 0) ,
176 HDD2GHZCHAN(2467, 12, 0) ,
177 HDD2GHZCHAN(2472, 13, 0) ,
178 HDD2GHZCHAN(2484, 14, 0) ,
179};
180
Jeff Johnson295189b2012-06-20 16:38:30 -0700181static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
182{
183 HDD2GHZCHAN(2412, 1, 0) ,
184 HDD2GHZCHAN(2437, 6, 0) ,
185 HDD2GHZCHAN(2462, 11, 0) ,
186};
Jeff Johnson295189b2012-06-20 16:38:30 -0700187
188static struct ieee80211_channel hdd_channels_5_GHZ[] =
189{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700190 HDD5GHZCHAN(4920, 240, 0) ,
191 HDD5GHZCHAN(4940, 244, 0) ,
192 HDD5GHZCHAN(4960, 248, 0) ,
193 HDD5GHZCHAN(4980, 252, 0) ,
194 HDD5GHZCHAN(5040, 208, 0) ,
195 HDD5GHZCHAN(5060, 212, 0) ,
196 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700197 HDD5GHZCHAN(5180, 36, 0) ,
198 HDD5GHZCHAN(5200, 40, 0) ,
199 HDD5GHZCHAN(5220, 44, 0) ,
200 HDD5GHZCHAN(5240, 48, 0) ,
201 HDD5GHZCHAN(5260, 52, 0) ,
202 HDD5GHZCHAN(5280, 56, 0) ,
203 HDD5GHZCHAN(5300, 60, 0) ,
204 HDD5GHZCHAN(5320, 64, 0) ,
205 HDD5GHZCHAN(5500,100, 0) ,
206 HDD5GHZCHAN(5520,104, 0) ,
207 HDD5GHZCHAN(5540,108, 0) ,
208 HDD5GHZCHAN(5560,112, 0) ,
209 HDD5GHZCHAN(5580,116, 0) ,
210 HDD5GHZCHAN(5600,120, 0) ,
211 HDD5GHZCHAN(5620,124, 0) ,
212 HDD5GHZCHAN(5640,128, 0) ,
213 HDD5GHZCHAN(5660,132, 0) ,
214 HDD5GHZCHAN(5680,136, 0) ,
215 HDD5GHZCHAN(5700,140, 0) ,
216 HDD5GHZCHAN(5745,149, 0) ,
217 HDD5GHZCHAN(5765,153, 0) ,
218 HDD5GHZCHAN(5785,157, 0) ,
219 HDD5GHZCHAN(5805,161, 0) ,
220 HDD5GHZCHAN(5825,165, 0) ,
221};
222
223static struct ieee80211_rate g_mode_rates[] =
224{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530225 HDD_G_MODE_RATETAB(10, 0x1, 0),
226 HDD_G_MODE_RATETAB(20, 0x2, 0),
227 HDD_G_MODE_RATETAB(55, 0x4, 0),
228 HDD_G_MODE_RATETAB(110, 0x8, 0),
229 HDD_G_MODE_RATETAB(60, 0x10, 0),
230 HDD_G_MODE_RATETAB(90, 0x20, 0),
231 HDD_G_MODE_RATETAB(120, 0x40, 0),
232 HDD_G_MODE_RATETAB(180, 0x80, 0),
233 HDD_G_MODE_RATETAB(240, 0x100, 0),
234 HDD_G_MODE_RATETAB(360, 0x200, 0),
235 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700236 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530237};
Jeff Johnson295189b2012-06-20 16:38:30 -0700238
239static struct ieee80211_rate a_mode_rates[] =
240{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530241 HDD_G_MODE_RATETAB(60, 0x10, 0),
242 HDD_G_MODE_RATETAB(90, 0x20, 0),
243 HDD_G_MODE_RATETAB(120, 0x40, 0),
244 HDD_G_MODE_RATETAB(180, 0x80, 0),
245 HDD_G_MODE_RATETAB(240, 0x100, 0),
246 HDD_G_MODE_RATETAB(360, 0x200, 0),
247 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700248 HDD_G_MODE_RATETAB(540, 0x800, 0),
249};
250
251static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
252{
253 .channels = hdd_channels_2_4_GHZ,
254 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
255 .band = IEEE80211_BAND_2GHZ,
256 .bitrates = g_mode_rates,
257 .n_bitrates = g_mode_rates_size,
258 .ht_cap.ht_supported = 1,
259 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
260 | IEEE80211_HT_CAP_GRN_FLD
261 | IEEE80211_HT_CAP_DSSSCCK40
262 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
263 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
264 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
265 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
266 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
267 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
268};
269
Jeff Johnson295189b2012-06-20 16:38:30 -0700270static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
271{
272 .channels = hdd_social_channels_2_4_GHZ,
273 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
274 .band = IEEE80211_BAND_2GHZ,
275 .bitrates = g_mode_rates,
276 .n_bitrates = g_mode_rates_size,
277 .ht_cap.ht_supported = 1,
278 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
279 | IEEE80211_HT_CAP_GRN_FLD
280 | IEEE80211_HT_CAP_DSSSCCK40
281 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
282 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
283 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
284 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
285 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
286 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
287};
Jeff Johnson295189b2012-06-20 16:38:30 -0700288
289static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
290{
291 .channels = hdd_channels_5_GHZ,
292 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
293 .band = IEEE80211_BAND_5GHZ,
294 .bitrates = a_mode_rates,
295 .n_bitrates = a_mode_rates_size,
296 .ht_cap.ht_supported = 1,
297 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
298 | IEEE80211_HT_CAP_GRN_FLD
299 | IEEE80211_HT_CAP_DSSSCCK40
300 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
301 | IEEE80211_HT_CAP_SGI_40
302 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
303 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
304 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
305 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
306 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
307 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
308};
309
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530310/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700311 TX/RX direction for each kind of interface */
312static const struct ieee80211_txrx_stypes
313wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
314 [NL80211_IFTYPE_STATION] = {
315 .tx = 0xffff,
316 .rx = BIT(SIR_MAC_MGMT_ACTION) |
317 BIT(SIR_MAC_MGMT_PROBE_REQ),
318 },
319 [NL80211_IFTYPE_AP] = {
320 .tx = 0xffff,
321 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
322 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
323 BIT(SIR_MAC_MGMT_PROBE_REQ) |
324 BIT(SIR_MAC_MGMT_DISASSOC) |
325 BIT(SIR_MAC_MGMT_AUTH) |
326 BIT(SIR_MAC_MGMT_DEAUTH) |
327 BIT(SIR_MAC_MGMT_ACTION),
328 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700329 [NL80211_IFTYPE_ADHOC] = {
330 .tx = 0xffff,
331 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
332 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
333 BIT(SIR_MAC_MGMT_PROBE_REQ) |
334 BIT(SIR_MAC_MGMT_DISASSOC) |
335 BIT(SIR_MAC_MGMT_AUTH) |
336 BIT(SIR_MAC_MGMT_DEAUTH) |
337 BIT(SIR_MAC_MGMT_ACTION),
338 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700339 [NL80211_IFTYPE_P2P_CLIENT] = {
340 .tx = 0xffff,
341 .rx = BIT(SIR_MAC_MGMT_ACTION) |
342 BIT(SIR_MAC_MGMT_PROBE_REQ),
343 },
344 [NL80211_IFTYPE_P2P_GO] = {
345 /* This is also same as for SoftAP */
346 .tx = 0xffff,
347 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
348 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
349 BIT(SIR_MAC_MGMT_PROBE_REQ) |
350 BIT(SIR_MAC_MGMT_DISASSOC) |
351 BIT(SIR_MAC_MGMT_AUTH) |
352 BIT(SIR_MAC_MGMT_DEAUTH) |
353 BIT(SIR_MAC_MGMT_ACTION),
354 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700355};
356
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800357#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800358static const struct ieee80211_iface_limit
359wlan_hdd_iface_limit[] = {
360 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800361 /* max = 3 ; Our driver create two interfaces during driver init
362 * wlan0 and p2p0 interfaces. p2p0 is considered as station
363 * interface until a group is formed. In JB architecture, once the
364 * group is formed, interface type of p2p0 is changed to P2P GO or
365 * Client.
366 * When supplicant remove the group, it first issue a set interface
367 * cmd to change the mode back to Station. In JB this works fine as
368 * we advertize two station type interface during driver init.
369 * Some vendors create separate interface for P2P GO/Client,
370 * after group formation(Third one). But while group remove
371 * supplicant first tries to change the mode(3rd interface) to STATION
372 * But as we advertized only two sta type interfaces nl80211 was
373 * returning error for the third one which was leading to failure in
374 * delete interface. Ideally while removing the group, supplicant
375 * should not try to change the 3rd interface mode to Station type.
376 * Till we get a fix in wpa_supplicant, we advertize max STA
377 * interface type to 3
378 */
379 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800380 .types = BIT(NL80211_IFTYPE_STATION),
381 },
382 {
383 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700384 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800385 },
386 {
387 .max = 1,
388 .types = BIT(NL80211_IFTYPE_P2P_GO) |
389 BIT(NL80211_IFTYPE_P2P_CLIENT),
390 },
391};
392
393/* By default, only single channel concurrency is allowed */
394static struct ieee80211_iface_combination
395wlan_hdd_iface_combination = {
396 .limits = wlan_hdd_iface_limit,
397 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800398 /*
399 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
400 * and p2p0 interfaces during driver init
401 * Some vendors create separate interface for P2P operations.
402 * wlan0: STA interface
403 * p2p0: P2P Device interface, action frames goes
404 * through this interface.
405 * p2p-xx: P2P interface, After GO negotiation this interface is
406 * created for p2p operations(GO/CLIENT interface).
407 */
408 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800409 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
410 .beacon_int_infra_match = false,
411};
412#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800413
Jeff Johnson295189b2012-06-20 16:38:30 -0700414static struct cfg80211_ops wlan_hdd_cfg80211_ops;
415
416/* Data rate 100KBPS based on IE Index */
417struct index_data_rate_type
418{
419 v_U8_t beacon_rate_index;
420 v_U16_t supported_rate[4];
421};
422
423/* 11B, 11G Rate table include Basic rate and Extended rate
424 The IDX field is the rate index
425 The HI field is the rate when RSSI is strong or being ignored
426 (in this case we report actual rate)
427 The MID field is the rate when RSSI is moderate
428 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
429 The LO field is the rate when RSSI is low
430 (in this case we don't report rates, actual current rate used)
431 */
432static const struct
433{
434 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700435 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700436} supported_data_rate[] =
437{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700438/* IDX HI HM LM LO (RSSI-based index */
439 {2, { 10, 10, 10, 0}},
440 {4, { 20, 20, 10, 0}},
441 {11, { 55, 20, 10, 0}},
442 {12, { 60, 55, 20, 0}},
443 {18, { 90, 55, 20, 0}},
444 {22, {110, 55, 20, 0}},
445 {24, {120, 90, 60, 0}},
446 {36, {180, 120, 60, 0}},
447 {44, {220, 180, 60, 0}},
448 {48, {240, 180, 90, 0}},
449 {66, {330, 180, 90, 0}},
450 {72, {360, 240, 90, 0}},
451 {96, {480, 240, 120, 0}},
452 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700453};
454
455/* MCS Based rate table */
456static struct index_data_rate_type supported_mcs_rate[] =
457{
458/* MCS L20 L40 S20 S40 */
459 {0, {65, 135, 72, 150}},
460 {1, {130, 270, 144, 300}},
461 {2, {195, 405, 217, 450}},
462 {3, {260, 540, 289, 600}},
463 {4, {390, 810, 433, 900}},
464 {5, {520, 1080, 578, 1200}},
465 {6, {585, 1215, 650, 1350}},
466 {7, {650, 1350, 722, 1500}}
467};
468
Leo Chang6f8870f2013-03-26 18:11:36 -0700469#ifdef WLAN_FEATURE_11AC
470
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530471#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700472
473struct index_vht_data_rate_type
474{
475 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530476 v_U16_t supported_VHT80_rate[2];
477 v_U16_t supported_VHT40_rate[2];
478 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700479};
480
481typedef enum
482{
483 DATA_RATE_11AC_MAX_MCS_7,
484 DATA_RATE_11AC_MAX_MCS_8,
485 DATA_RATE_11AC_MAX_MCS_9,
486 DATA_RATE_11AC_MAX_MCS_NA
487} eDataRate11ACMaxMcs;
488
489/* MCS Based VHT rate table */
490static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
491{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530492/* MCS L80 S80 L40 S40 L20 S40*/
493 {0, {293, 325}, {135, 150}, {65, 72}},
494 {1, {585, 650}, {270, 300}, {130, 144}},
495 {2, {878, 975}, {405, 450}, {195, 217}},
496 {3, {1170, 1300}, {540, 600}, {260, 289}},
497 {4, {1755, 1950}, {810, 900}, {390, 433}},
498 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
499 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
500 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
501 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
502 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700503};
504#endif /* WLAN_FEATURE_11AC */
505
Jeff Johnson295189b2012-06-20 16:38:30 -0700506extern struct net_device_ops net_ops_struct;
507
Leo Chang9056f462013-08-01 19:21:11 -0700508#ifdef WLAN_NL80211_TESTMODE
509enum wlan_hdd_tm_attr
510{
511 WLAN_HDD_TM_ATTR_INVALID = 0,
512 WLAN_HDD_TM_ATTR_CMD = 1,
513 WLAN_HDD_TM_ATTR_DATA = 2,
514 WLAN_HDD_TM_ATTR_TYPE = 3,
515 /* keep last */
516 WLAN_HDD_TM_ATTR_AFTER_LAST,
517 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
518};
519
520enum wlan_hdd_tm_cmd
521{
522 WLAN_HDD_TM_CMD_WLAN_HB = 1,
523};
524
525#define WLAN_HDD_TM_DATA_MAX_LEN 5000
526
527static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
528{
529 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
530 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
531 .len = WLAN_HDD_TM_DATA_MAX_LEN },
532};
533#endif /* WLAN_NL80211_TESTMODE */
534
Jeff Johnson295189b2012-06-20 16:38:30 -0700535/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530536 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530537 * This function is called by hdd_wlan_startup()
538 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530539 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -0700540 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530541struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -0700542{
543 struct wiphy *wiphy;
544 ENTER();
545
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530546 /*
547 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -0700548 */
549 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
550
551 if (!wiphy)
552 {
553 /* Print error and jump into err label and free the memory */
554 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
555 return NULL;
556 }
557
558 return wiphy;
559}
560
561/*
562 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530563 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -0700564 * private ioctl to change the band value
565 */
566int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
567{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530568 int i, j;
569 eNVChannelEnabledType channelEnabledState;
570
Jeff Johnsone7245742012-09-05 17:12:55 -0700571 ENTER();
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530572 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700573 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530574
575 if (NULL == wiphy->bands[i])
576 {
577 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
578 __func__, i);
579 continue;
580 }
581
582 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
583 {
584 struct ieee80211_supported_band *band = wiphy->bands[i];
585
586 channelEnabledState = vos_nv_getChannelEnabledState(
587 band->channels[j].hw_value);
588
589 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
590 {
591 // Enable Social channels for P2P
592 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq) &&
593 NV_CHANNEL_ENABLE == channelEnabledState)
594 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
595 else
596 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
597 continue;
598 }
599 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
600 {
601 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
602 continue;
603 }
604
605 if (NV_CHANNEL_DISABLE == channelEnabledState ||
606 NV_CHANNEL_INVALID == channelEnabledState)
607 {
608 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
609 }
610 else if (NV_CHANNEL_DFS == channelEnabledState)
611 {
612 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
613 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
614 }
615 else
616 {
617 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
618 |IEEE80211_CHAN_RADAR);
619 }
620 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700621 }
622 return 0;
623}
624/*
625 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530626 * This function is called by hdd_wlan_startup()
627 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 * This function is used to initialize and register wiphy structure.
629 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530630int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -0700631 struct wiphy *wiphy,
632 hdd_config_t *pCfg
633 )
634{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530635 int i, j;
Jeff Johnsone7245742012-09-05 17:12:55 -0700636 ENTER();
637
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 /* Now bind the underlying wlan device with wiphy */
639 set_wiphy_dev(wiphy, dev);
640
641 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -0700642
Kiet Lam6c583332013-10-14 05:37:09 +0530643#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -0700644 /* the flag for the other case would be initialzed in
645 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -0700646 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +0530647#endif
Amar Singhala49cbc52013-10-08 18:37:44 -0700648
Amar Singhalfddc28c2013-09-05 13:03:40 -0700649 /* This will disable updating of NL channels from passive to
650 * active if a beacon is received on passive channel. */
651 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Amar Singhalf0073192013-09-20 12:34:56 -0700652
Amar Singhalfddc28c2013-09-05 13:03:40 -0700653
Amar Singhala49cbc52013-10-08 18:37:44 -0700654
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700655#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -0700656 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
657 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
658 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -0700659 | WIPHY_FLAG_OFFCHAN_TX;
Kiet Lam6c583332013-10-14 05:37:09 +0530660 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700661#endif
Amar Singhala49cbc52013-10-08 18:37:44 -0700662
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700663#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
664 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -0800665#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700666 || pCfg->isFastRoamIniFeatureEnabled
667#endif
668#ifdef FEATURE_WLAN_CCX
669 || pCfg->isCcxIniFeatureEnabled
670#endif
671 )
672 {
673 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
674 }
James Zmuda77fb5ae2013-01-29 08:00:17 -0800675#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800676#ifdef FEATURE_WLAN_TDLS
677 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
678 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
679#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530680#ifdef FEATURE_WLAN_SCAN_PNO
681 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
Madan Mohan Koyyalamudi75de0102013-09-17 14:56:29 +0530682 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530683 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +0530684 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530685#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800686
Amar Singhalfddc28c2013-09-05 13:03:40 -0700687#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700688 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
689 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -0700690 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700691 driver need to determine what to do with both
692 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -0700693
694 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -0700695#else
696 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -0700697#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700698
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530699 wiphy->max_scan_ssids = MAX_SCAN_SSID;
700
Madan Mohan Koyyalamudi6815b162013-07-19 17:17:46 +0530701 wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700702
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +0530703 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
704
Jeff Johnson295189b2012-06-20 16:38:30 -0700705 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530706 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -0700707 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -0700708 | BIT(NL80211_IFTYPE_P2P_CLIENT)
709 | BIT(NL80211_IFTYPE_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 | BIT(NL80211_IFTYPE_AP);
711
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800712#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800713 if( pCfg->enableMCC )
714 {
715 /* Currently, supports up to two channels */
716 wlan_hdd_iface_combination.num_different_channels = 2;
717
718 if( !pCfg->allowMCCGODiffBI )
719 wlan_hdd_iface_combination.beacon_int_infra_match = true;
720
721 }
722 wiphy->iface_combinations = &wlan_hdd_iface_combination;
723 wiphy->n_iface_combinations = 1;
724#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800725
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 /* Before registering we need to update the ht capabilitied based
727 * on ini values*/
728 if( !pCfg->ShortGI20MhzEnable )
729 {
730 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
731 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
732 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
733 }
734
735 if( !pCfg->ShortGI40MhzEnable )
736 {
737 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
738 }
739
740 if( !pCfg->nChannelBondingMode5GHz )
741 {
742 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
743 }
744
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530745 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
746 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
747
748 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
749 {
750
751 if (NULL == wiphy->bands[i])
752 {
753 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
754 __func__, i);
755 continue;
756 }
757
758 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
759 {
760 struct ieee80211_supported_band *band = wiphy->bands[i];
761
762 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
763 {
764 // Enable social channels for P2P
765 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
766 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
767 else
768 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
769 continue;
770 }
771 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
772 {
773 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
774 continue;
775 }
776 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700777 }
778 /*Initialise the supported cipher suite details*/
779 wiphy->cipher_suites = hdd_cipher_suites;
780 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
781
782 /*signal strength in mBm (100*dBm) */
783 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
784
785#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnson295189b2012-06-20 16:38:30 -0700786 wiphy->max_remain_on_channel_duration = 1000;
787#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700788
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530789 EXIT();
790 return 0;
791}
792
793/* In this function we are registering wiphy. */
794int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
795{
796 ENTER();
797 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700798 if (0 > wiphy_register(wiphy))
799 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530800 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -0700801 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
802 return -EIO;
803 }
804
805 EXIT();
806 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530807}
Jeff Johnson295189b2012-06-20 16:38:30 -0700808
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530809/* In this function we are updating channel list when,
810 regulatory domain is FCC and country code is US.
811 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
812 As per FCC smart phone is not a indoor device.
813 GO should not opeate on indoor channels */
814void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
815{
816 int j;
817 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
818 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
819 //Default counrtycode from NV at the time of wiphy initialization.
820 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
821 &defaultCountryCode[0]))
822 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700823 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530824 }
825 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
826 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530827 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
828 {
829 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
830 return;
831 }
832 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
833 {
834 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
835 // Mark UNII -1 band channel as passive
836 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
837 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
838 }
839 }
840}
841
Jeff Johnson295189b2012-06-20 16:38:30 -0700842/* In this function we will do all post VOS start initialization.
843 In this function we will register for all frame in which supplicant
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530844 is interested.
Jeff Johnson295189b2012-06-20 16:38:30 -0700845*/
846void wlan_hdd_cfg80211_post_voss_start(hdd_adapter_t* pAdapter)
847{
Jeff Johnson295189b2012-06-20 16:38:30 -0700848 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
849 /* Register for all P2P action, public action etc frames */
850 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
851
Jeff Johnsone7245742012-09-05 17:12:55 -0700852 ENTER();
853
Jeff Johnson295189b2012-06-20 16:38:30 -0700854 /* Right now we are registering these frame when driver is getting
855 initialized. Once we will move to 2.6.37 kernel, in which we have
856 frame register ops, we will move this code as a part of that */
857 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530858 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
860
861 /* GAS Initial Response */
862 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
863 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530864
Jeff Johnson295189b2012-06-20 16:38:30 -0700865 /* GAS Comeback Request */
866 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
867 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
868
869 /* GAS Comeback Response */
870 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
871 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
872
873 /* P2P Public Action */
874 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530875 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700876 P2P_PUBLIC_ACTION_FRAME_SIZE );
877
878 /* P2P Action */
879 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
880 (v_U8_t*)P2P_ACTION_FRAME,
881 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700882
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +0530883 /* WNM BSS Transition Request frame */
884 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
885 (v_U8_t*)WNM_BSS_ACTION_FRAME,
886 WNM_BSS_ACTION_FRAME_SIZE );
887
Chet Lanctot186b5732013-03-18 10:26:30 -0700888#ifdef WLAN_FEATURE_11W
889 /* SA Query Response Action Frame */
890 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
891 (v_U8_t*)SA_QUERY_FRAME_RSP,
892 SA_QUERY_FRAME_RSP_SIZE );
893#endif /* WLAN_FEATURE_11W */
Jeff Johnson295189b2012-06-20 16:38:30 -0700894}
895
896void wlan_hdd_cfg80211_pre_voss_stop(hdd_adapter_t* pAdapter)
897{
Jeff Johnson295189b2012-06-20 16:38:30 -0700898 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
899 /* Register for all P2P action, public action etc frames */
900 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
901
Jeff Johnsone7245742012-09-05 17:12:55 -0700902 ENTER();
903
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 /* Right now we are registering these frame when driver is getting
905 initialized. Once we will move to 2.6.37 kernel, in which we have
906 frame register ops, we will move this code as a part of that */
907 /* GAS Initial Request */
908
909 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
910 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
911
912 /* GAS Initial Response */
913 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
914 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530915
Jeff Johnson295189b2012-06-20 16:38:30 -0700916 /* GAS Comeback Request */
917 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
918 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
919
920 /* GAS Comeback Response */
921 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
922 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
923
924 /* P2P Public Action */
925 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530926 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700927 P2P_PUBLIC_ACTION_FRAME_SIZE );
928
929 /* P2P Action */
930 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
931 (v_U8_t*)P2P_ACTION_FRAME,
932 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700933
934#ifdef WLAN_FEATURE_11W
935 /* SA Query Response Action Frame */
936 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
937 (v_U8_t*)SA_QUERY_FRAME_RSP,
938 SA_QUERY_FRAME_RSP_SIZE );
939#endif /* WLAN_FEATURE_11W */
Jeff Johnson295189b2012-06-20 16:38:30 -0700940}
941
942#ifdef FEATURE_WLAN_WAPI
943void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
944 const u8 *mac_addr, u8 *key , int key_Len)
945{
946 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
947 tCsrRoamSetKey setKey;
948 v_BOOL_t isConnected = TRUE;
949 int status = 0;
950 v_U32_t roamId= 0xFF;
951 tANI_U8 *pKeyPtr = NULL;
952 int n = 0;
953
954 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
955 __func__,pAdapter->device_mode);
956
Gopichand Nakkalae7480202013-02-11 15:24:22 +0530957 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -0700958 setKey.keyId = key_index; // Store Key ID
959 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
960 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
961 setKey.paeRole = 0 ; // the PAE role
962 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
963 {
964 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
965 }
966 else
967 {
968 isConnected = hdd_connIsConnected(pHddStaCtx);
969 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
970 }
971 setKey.keyLength = key_Len;
972 pKeyPtr = setKey.Key;
973 memcpy( pKeyPtr, key, key_Len);
974
975 hddLog(VOS_TRACE_LEVEL_INFO,"\n%s: WAPI KEY LENGTH:0x%04x",
976 __func__, key_Len);
977 for (n = 0 ; n < key_Len; n++)
978 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
979 __func__,n,setKey.Key[n]);
980
981 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
982 if ( isConnected )
983 {
984 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
985 pAdapter->sessionId, &setKey, &roamId );
986 }
987 if ( status != 0 )
988 {
989 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
990 "[%4d] sme_RoamSetKey returned ERROR status= %d",
991 __LINE__, status );
992 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
993 }
994}
995#endif /* FEATURE_WLAN_WAPI*/
996
997#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530998int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700999 beacon_data_t **ppBeacon,
1000 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001001#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301002int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001003 beacon_data_t **ppBeacon,
1004 struct cfg80211_beacon_data *params,
1005 int dtim_period)
1006#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301007{
Jeff Johnson295189b2012-06-20 16:38:30 -07001008 int size;
1009 beacon_data_t *beacon = NULL;
1010 beacon_data_t *old = NULL;
1011 int head_len,tail_len;
1012
Jeff Johnsone7245742012-09-05 17:12:55 -07001013 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001014 if (params->head && !params->head_len)
1015 return -EINVAL;
1016
1017 old = pAdapter->sessionCtx.ap.beacon;
1018
1019 if (!params->head && !old)
1020 return -EINVAL;
1021
Jeff Johnson295189b2012-06-20 16:38:30 -07001022#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
1023 /* Kernel 3.0 is not updating dtim_period for set beacon */
1024 if (!params->dtim_period)
1025 return -EINVAL;
1026#endif
1027
1028 if(params->head)
1029 head_len = params->head_len;
1030 else
1031 head_len = old->head_len;
1032
1033 if(params->tail || !old)
1034 tail_len = params->tail_len;
1035 else
1036 tail_len = old->tail_len;
1037
1038 size = sizeof(beacon_data_t) + head_len + tail_len;
1039
1040 beacon = kzalloc(size, GFP_KERNEL);
1041
1042 if( beacon == NULL )
1043 return -ENOMEM;
1044
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001045#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001046 if(params->dtim_period || !old )
1047 beacon->dtim_period = params->dtim_period;
1048 else
1049 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001050#else
1051 if(dtim_period || !old )
1052 beacon->dtim_period = dtim_period;
1053 else
1054 beacon->dtim_period = old->dtim_period;
1055#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301056
Jeff Johnson295189b2012-06-20 16:38:30 -07001057 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
1058 beacon->tail = beacon->head + head_len;
1059 beacon->head_len = head_len;
1060 beacon->tail_len = tail_len;
1061
1062 if(params->head) {
1063 memcpy (beacon->head,params->head,beacon->head_len);
1064 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301065 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001066 if(old)
1067 memcpy (beacon->head,old->head,beacon->head_len);
1068 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301069
Jeff Johnson295189b2012-06-20 16:38:30 -07001070 if(params->tail) {
1071 memcpy (beacon->tail,params->tail,beacon->tail_len);
1072 }
1073 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301074 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07001075 memcpy (beacon->tail,old->tail,beacon->tail_len);
1076 }
1077
1078 *ppBeacon = beacon;
1079
1080 kfree(old);
1081
1082 return 0;
1083
1084}
Jeff Johnson295189b2012-06-20 16:38:30 -07001085
1086v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
1087{
1088 int left = length;
1089 v_U8_t *ptr = pIes;
1090 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301091
Jeff Johnson295189b2012-06-20 16:38:30 -07001092 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301093 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001094 elem_id = ptr[0];
1095 elem_len = ptr[1];
1096 left -= 2;
1097 if(elem_len > left)
1098 {
1099 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001100 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001101 eid,elem_len,left);
1102 return NULL;
1103 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301104 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07001105 {
1106 return ptr;
1107 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301108
Jeff Johnson295189b2012-06-20 16:38:30 -07001109 left -= elem_len;
1110 ptr += (elem_len + 2);
1111 }
1112 return NULL;
1113}
1114
Jeff Johnson295189b2012-06-20 16:38:30 -07001115/* Check if rate is 11g rate or not */
1116static int wlan_hdd_rate_is_11g(u8 rate)
1117{
Sanjay Devnani28322e22013-06-21 16:13:40 -07001118 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 u8 i;
1120 for (i = 0; i < 8; i++)
1121 {
1122 if(rate == gRateArray[i])
1123 return TRUE;
1124 }
1125 return FALSE;
1126}
1127
1128/* Check for 11g rate and set proper 11g only mode */
1129static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
1130 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
1131{
1132 u8 i, num_rates = pIe[0];
1133
1134 pIe += 1;
1135 for ( i = 0; i < num_rates; i++)
1136 {
1137 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
1138 {
1139 /* If rate set have 11g rate than change the mode to 11G */
1140 *pSapHw_mode = eSAP_DOT11_MODE_11g;
1141 if (pIe[i] & BASIC_RATE_MASK)
1142 {
1143 /* If we have 11g rate as basic rate, it means mode
1144 is 11g only mode.
1145 */
1146 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
1147 *pCheckRatesfor11g = FALSE;
1148 }
1149 }
1150 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
1151 {
1152 *require_ht = TRUE;
1153 }
1154 }
1155 return;
1156}
1157
1158static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
1159{
1160 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1161 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1162 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1163 u8 checkRatesfor11g = TRUE;
1164 u8 require_ht = FALSE;
1165 u8 *pIe=NULL;
1166
1167 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
1168
1169 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
1170 pBeacon->head_len, WLAN_EID_SUPP_RATES);
1171 if (pIe != NULL)
1172 {
1173 pIe += 1;
1174 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1175 &pConfig->SapHw_mode);
1176 }
1177
1178 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1179 WLAN_EID_EXT_SUPP_RATES);
1180 if (pIe != NULL)
1181 {
1182
1183 pIe += 1;
1184 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1185 &pConfig->SapHw_mode);
1186 }
1187
1188 if( pConfig->channel > 14 )
1189 {
1190 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
1191 }
1192
1193 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1194 WLAN_EID_HT_CAPABILITY);
1195
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301196 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001197 {
1198 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
1199 if(require_ht)
1200 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
1201 }
1202}
1203
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301204static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
1205 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
1206{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001207 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301208 v_U8_t *pIe = NULL;
1209 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1210
1211 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
1212 pBeacon->tail, pBeacon->tail_len);
1213
1214 if (pIe)
1215 {
1216 ielen = pIe[1] + 2;
1217 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1218 {
1219 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
1220 }
1221 else
1222 {
1223 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
1224 return -EINVAL;
1225 }
1226 *total_ielen += ielen;
1227 }
1228 return 0;
1229}
1230
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001231static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
1232 v_U8_t *genie, v_U8_t *total_ielen)
1233{
1234 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1235 int left = pBeacon->tail_len;
1236 v_U8_t *ptr = pBeacon->tail;
1237 v_U8_t elem_id, elem_len;
1238 v_U16_t ielen = 0;
1239
1240 if ( NULL == ptr || 0 == left )
1241 return;
1242
1243 while (left >= 2)
1244 {
1245 elem_id = ptr[0];
1246 elem_len = ptr[1];
1247 left -= 2;
1248 if (elem_len > left)
1249 {
1250 hddLog( VOS_TRACE_LEVEL_ERROR,
1251 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
1252 elem_id, elem_len, left);
1253 return;
1254 }
1255 if (IE_EID_VENDOR == elem_id)
1256 {
1257 /* skipping the VSIE's which we don't want to include or
1258 * it will be included by existing code
1259 */
1260 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
1261#ifdef WLAN_FEATURE_WFD
1262 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
1263#endif
1264 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1265 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1266 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
1267 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1268 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
1269 {
1270 ielen = ptr[1] + 2;
1271 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1272 {
1273 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
1274 *total_ielen += ielen;
1275 }
1276 else
1277 {
1278 hddLog( VOS_TRACE_LEVEL_ERROR,
1279 "IE Length is too big "
1280 "IEs eid=%d elem_len=%d total_ie_lent=%d",
1281 elem_id, elem_len, *total_ielen);
1282 }
1283 }
1284 }
1285
1286 left -= elem_len;
1287 ptr += (elem_len + 2);
1288 }
1289 return;
1290}
1291
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001292#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001293static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1294 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001295#else
1296static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1297 struct cfg80211_beacon_data *params)
1298#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001299{
1300 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301301 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001302 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07001303 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001304
1305 genie = vos_mem_malloc(MAX_GENIE_LEN);
1306
1307 if(genie == NULL) {
1308
1309 return -ENOMEM;
1310 }
1311
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301312 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1313 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001314 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301315 ret = -EINVAL;
1316 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001317 }
1318
1319#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301320 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1321 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
1322 {
1323 ret = -EINVAL;
1324 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001325 }
1326#endif
1327
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301328 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1329 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301331 ret = -EINVAL;
1332 goto done;
1333 }
1334
1335 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
1336 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001337 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001338 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001339
1340 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1341 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
1342 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
1343 {
1344 hddLog(LOGE,
1345 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001346 ret = -EINVAL;
1347 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001348 }
1349
1350 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1351 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
1352 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1353 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1354 ==eHAL_STATUS_FAILURE)
1355 {
1356 hddLog(LOGE,
1357 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001358 ret = -EINVAL;
1359 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001360 }
1361
1362 // Added for ProResp IE
1363 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
1364 {
1365 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
1366 u8 probe_rsp_ie_len[3] = {0};
1367 u8 counter = 0;
1368 /* Check Probe Resp Length if it is greater then 255 then Store
1369 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
1370 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
1371 Store More then 255 bytes into One Variable.
1372 */
1373 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
1374 {
1375 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
1376 {
1377 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
1378 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
1379 }
1380 else
1381 {
1382 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
1383 rem_probe_resp_ie_len = 0;
1384 }
1385 }
1386
1387 rem_probe_resp_ie_len = 0;
1388
1389 if (probe_rsp_ie_len[0] > 0)
1390 {
1391 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1392 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
1393 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1394 probe_rsp_ie_len[0], NULL,
1395 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1396 {
1397 hddLog(LOGE,
1398 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001399 ret = -EINVAL;
1400 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001401 }
1402 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
1403 }
1404
1405 if (probe_rsp_ie_len[1] > 0)
1406 {
1407 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1408 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
1409 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1410 probe_rsp_ie_len[1], NULL,
1411 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1412 {
1413 hddLog(LOGE,
1414 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001415 ret = -EINVAL;
1416 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 }
1418 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
1419 }
1420
1421 if (probe_rsp_ie_len[2] > 0)
1422 {
1423 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1424 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
1425 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1426 probe_rsp_ie_len[2], NULL,
1427 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1428 {
1429 hddLog(LOGE,
1430 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001431 ret = -EINVAL;
1432 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001433 }
1434 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
1435 }
1436
1437 if (probe_rsp_ie_len[1] == 0 )
1438 {
1439 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1440 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
1441 eANI_BOOLEAN_FALSE) )
1442 {
1443 hddLog(LOGE,
1444 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM\n");
1445 }
1446 }
1447
1448 if (probe_rsp_ie_len[2] == 0 )
1449 {
1450 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1451 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
1452 eANI_BOOLEAN_FALSE) )
1453 {
1454 hddLog(LOGE,
1455 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM\n");
1456 }
1457 }
1458
1459 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1460 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
1461 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1462 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1463 == eHAL_STATUS_FAILURE)
1464 {
1465 hddLog(LOGE,
1466 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001467 ret = -EINVAL;
1468 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001469 }
1470 }
1471 else
1472 {
1473 // Reset WNI_CFG_PROBE_RSP Flags
1474 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
1475
1476 hddLog(VOS_TRACE_LEVEL_INFO,
1477 "%s: No Probe Response IE received in set beacon",
1478 __func__);
1479 }
1480
1481 // Added for AssocResp IE
1482 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
1483 {
1484 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1485 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
1486 params->assocresp_ies_len, NULL,
1487 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1488 {
1489 hddLog(LOGE,
1490 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001491 ret = -EINVAL;
1492 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001493 }
1494
1495 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1496 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
1497 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1498 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1499 == eHAL_STATUS_FAILURE)
1500 {
1501 hddLog(LOGE,
1502 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001503 ret = -EINVAL;
1504 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001505 }
1506 }
1507 else
1508 {
1509 hddLog(VOS_TRACE_LEVEL_INFO,
1510 "%s: No Assoc Response IE received in set beacon",
1511 __func__);
1512
1513 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1514 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
1515 eANI_BOOLEAN_FALSE) )
1516 {
1517 hddLog(LOGE,
1518 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
1519 }
1520 }
1521
Jeff Johnsone7245742012-09-05 17:12:55 -07001522done:
Jeff Johnson295189b2012-06-20 16:38:30 -07001523 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301524 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001525}
Jeff Johnson295189b2012-06-20 16:38:30 -07001526
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301527/*
Jeff Johnson295189b2012-06-20 16:38:30 -07001528 * FUNCTION: wlan_hdd_validate_operation_channel
1529 * called by wlan_hdd_cfg80211_start_bss() and
1530 * wlan_hdd_cfg80211_set_channel()
1531 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301532 * channel list.
1533 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001534VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001535{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301536
Jeff Johnson295189b2012-06-20 16:38:30 -07001537 v_U32_t num_ch = 0;
1538 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1539 u32 indx = 0;
1540 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301541 v_U8_t fValidChannel = FALSE, count = 0;
1542 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301543
Jeff Johnson295189b2012-06-20 16:38:30 -07001544 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1545
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301546 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001547 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301548 /* Validate the channel */
1549 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001550 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301551 if ( channel == rfChannels[count].channelNum )
1552 {
1553 fValidChannel = TRUE;
1554 break;
1555 }
1556 }
1557 if (fValidChannel != TRUE)
1558 {
1559 hddLog(VOS_TRACE_LEVEL_ERROR,
1560 "%s: Invalid Channel [%d]", __func__, channel);
1561 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001562 }
1563 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301564 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001565 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301566 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1567 valid_ch, &num_ch))
1568 {
1569 hddLog(VOS_TRACE_LEVEL_ERROR,
1570 "%s: failed to get valid channel list", __func__);
1571 return VOS_STATUS_E_FAILURE;
1572 }
1573 for (indx = 0; indx < num_ch; indx++)
1574 {
1575 if (channel == valid_ch[indx])
1576 {
1577 break;
1578 }
1579 }
1580
1581 if (indx >= num_ch)
1582 {
1583 hddLog(VOS_TRACE_LEVEL_ERROR,
1584 "%s: Invalid Channel [%d]", __func__, channel);
1585 return VOS_STATUS_E_FAILURE;
1586 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001587 }
1588 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301589
Jeff Johnson295189b2012-06-20 16:38:30 -07001590}
1591
Viral Modi3a32cc52013-02-08 11:14:52 -08001592/**
1593 * FUNCTION: wlan_hdd_cfg80211_set_channel
1594 * This function is used to set the channel number
1595 */
1596static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
1597 struct ieee80211_channel *chan,
1598 enum nl80211_channel_type channel_type
1599 )
1600{
1601 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07001602 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08001603 hdd_adapter_t *pAdapter = NULL;
1604 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301605 hdd_context_t *pHddCtx;
1606 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001607
1608 ENTER();
1609
1610 if( NULL == dev )
1611 {
1612 hddLog(VOS_TRACE_LEVEL_ERROR,
1613 "%s: Called with dev = NULL.\n", __func__);
1614 return -ENODEV;
1615 }
1616 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
1617
1618 hddLog(VOS_TRACE_LEVEL_INFO,
1619 "%s: device_mode = %d freq = %d \n",__func__,
1620 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301621
1622 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1623 status = wlan_hdd_validate_context(pHddCtx);
1624
1625 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08001626 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301627 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1628 "%s: HDD context is not valid", __func__);
1629 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001630 }
1631
1632 /*
1633 * Do freq to chan conversion
1634 * TODO: for 11a
1635 */
1636
1637 channel = ieee80211_frequency_to_channel(freq);
1638
1639 /* Check freq range */
1640 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
1641 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
1642 {
1643 hddLog(VOS_TRACE_LEVEL_ERROR,
1644 "%s: Channel [%d] is outside valid range from %d to %d\n",
1645 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
1646 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1647 return -EINVAL;
1648 }
1649
1650 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1651
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05301652 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
1653 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08001654 {
1655 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
1656 {
1657 hddLog(VOS_TRACE_LEVEL_ERROR,
1658 "%s: Invalid Channel [%d] \n", __func__, channel);
1659 return -EINVAL;
1660 }
1661 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1662 "%s: set channel to [%d] for device mode =%d",
1663 __func__, channel,pAdapter->device_mode);
1664 }
1665 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08001666 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08001667 )
1668 {
1669 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1670 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
1671 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1672
1673 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
1674 {
1675 /* Link is up then return cant set channel*/
1676 hddLog( VOS_TRACE_LEVEL_ERROR,
1677 "%s: IBSS Associated, can't set the channel\n", __func__);
1678 return -EINVAL;
1679 }
1680
1681 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
1682 pHddStaCtx->conn_info.operationChannel = channel;
1683 pRoamProfile->ChannelInfo.ChannelList =
1684 &pHddStaCtx->conn_info.operationChannel;
1685 }
1686 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08001687 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08001688 )
1689 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301690 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
1691 {
1692 if(VOS_STATUS_SUCCESS !=
1693 wlan_hdd_validate_operation_channel(pAdapter,channel))
1694 {
1695 hddLog(VOS_TRACE_LEVEL_ERROR,
1696 "%s: Invalid Channel [%d] \n", __func__, channel);
1697 return -EINVAL;
1698 }
1699 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1700 }
1701 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08001702 {
1703 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1704
1705 /* If auto channel selection is configured as enable/ 1 then ignore
1706 channel set by supplicant
1707 */
1708 if ( cfg_param->apAutoChannelSelection )
1709 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301710 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
1711 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08001712 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1713 "%s: set channel to auto channel (0) for device mode =%d",
1714 __func__, pAdapter->device_mode);
1715 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301716 else
1717 {
1718 if(VOS_STATUS_SUCCESS !=
1719 wlan_hdd_validate_operation_channel(pAdapter,channel))
1720 {
1721 hddLog(VOS_TRACE_LEVEL_ERROR,
1722 "%s: Invalid Channel [%d] \n", __func__, channel);
1723 return -EINVAL;
1724 }
1725 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1726 }
Viral Modi3a32cc52013-02-08 11:14:52 -08001727 }
1728 }
1729 else
1730 {
1731 hddLog(VOS_TRACE_LEVEL_FATAL,
1732 "%s: Invalid device mode failed to set valid channel", __func__);
1733 return -EINVAL;
1734 }
1735 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301736 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001737}
1738
Jeff Johnson295189b2012-06-20 16:38:30 -07001739#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
1740static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1741 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001742#else
1743static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1744 struct cfg80211_beacon_data *params,
1745 const u8 *ssid, size_t ssid_len,
1746 enum nl80211_hidden_ssid hidden_ssid)
1747#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001748{
1749 tsap_Config_t *pConfig;
1750 beacon_data_t *pBeacon = NULL;
1751 struct ieee80211_mgmt *pMgmt_frame;
1752 v_U8_t *pIe=NULL;
1753 v_U16_t capab_info;
1754 eCsrAuthType RSNAuthType;
1755 eCsrEncryptionType RSNEncryptType;
1756 eCsrEncryptionType mcRSNEncryptType;
1757 int status = VOS_STATUS_SUCCESS;
1758 tpWLAN_SAPEventCB pSapEventCallback;
1759 hdd_hostapd_state_t *pHostapdState;
1760 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
1761 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301762 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001763 struct qc_mac_acl_entry *acl_entry = NULL;
1764 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08001765 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001766
1767 ENTER();
1768
1769 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
1770
1771 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1772
1773 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1774
1775 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1776
1777 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
1778
1779 //channel is already set in the set_channel Call back
1780 //pConfig->channel = pCommitConfig->channel;
1781
1782 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301783 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07001784 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
1785
1786 pConfig->dtim_period = pBeacon->dtim_period;
1787
1788 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***\n",
1789 pConfig->dtim_period);
1790
1791
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08001792 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07001793 {
1794 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001795 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05301796 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
1797 {
1798 tANI_BOOLEAN restartNeeded;
1799 pConfig->ieee80211d = 1;
1800 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
1801 sme_setRegInfo(hHal, pConfig->countryCode);
1802 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
1803 }
1804 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001805 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07001806 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07001807 pConfig->ieee80211d = 1;
1808 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
1809 sme_setRegInfo(hHal, pConfig->countryCode);
1810 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07001811 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001812 else
1813 {
1814 pConfig->ieee80211d = 0;
1815 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301816 /*
1817 * If auto channel is configured i.e. channel is 0,
1818 * so skip channel validation.
1819 */
1820 if( AUTO_CHANNEL_SELECT != pConfig->channel )
1821 {
1822 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
1823 {
1824 hddLog(VOS_TRACE_LEVEL_ERROR,
1825 "%s: Invalid Channel [%d] \n", __func__, pConfig->channel);
1826 return -EINVAL;
1827 }
1828 }
1829 else
1830 {
1831 if(1 != pHddCtx->is_dynamic_channel_range_set)
1832 {
1833 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
1834 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
1835 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
1836 }
1837 pHddCtx->is_dynamic_channel_range_set = 0;
1838 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001839 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001840 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001841 {
1842 pConfig->ieee80211d = 0;
1843 }
1844 pConfig->authType = eSAP_AUTO_SWITCH;
1845
1846 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301847
1848 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07001849 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
1850
1851 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
1852
1853 /*Set wps station to configured*/
1854 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
1855
1856 if(pIe)
1857 {
1858 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
1859 {
1860 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***\n");
1861 return -EINVAL;
1862 }
1863 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
1864 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001865 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07001866 /* Check 15 bit of WPS IE as it contain information for wps state
1867 * WPS state
1868 */
1869 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
1870 {
1871 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
1872 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
1873 {
1874 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
1875 }
1876 }
1877 }
1878 else
1879 {
1880 pConfig->wps_state = SAP_WPS_DISABLED;
1881 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301882 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07001883
1884 pConfig->RSNWPAReqIELength = 0;
1885 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301886 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001887 WLAN_EID_RSN);
1888 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301889 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001890 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1891 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1892 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301893 /* The actual processing may eventually be more extensive than
1894 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07001895 * by the app.
1896 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301897 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001898 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1899 &RSNEncryptType,
1900 &mcRSNEncryptType,
1901 &RSNAuthType,
1902 pConfig->pRSNWPAReqIE[1]+2,
1903 pConfig->pRSNWPAReqIE );
1904
1905 if( VOS_STATUS_SUCCESS == status )
1906 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301907 /* Now copy over all the security attributes you have
1908 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001909 * */
1910 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1911 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1912 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1913 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301914 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001915 "EncryptionType = %d mcEncryptionType = %d\n"),
1916 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1917 }
1918 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301919
Jeff Johnson295189b2012-06-20 16:38:30 -07001920 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1921 pBeacon->tail, pBeacon->tail_len);
1922
1923 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
1924 {
1925 if (pConfig->pRSNWPAReqIE)
1926 {
1927 /*Mixed mode WPA/WPA2*/
1928 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
1929 pConfig->RSNWPAReqIELength += pIe[1] + 2;
1930 }
1931 else
1932 {
1933 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1934 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1935 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301936 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001937 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1938 &RSNEncryptType,
1939 &mcRSNEncryptType,
1940 &RSNAuthType,
1941 pConfig->pRSNWPAReqIE[1]+2,
1942 pConfig->pRSNWPAReqIE );
1943
1944 if( VOS_STATUS_SUCCESS == status )
1945 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301946 /* Now copy over all the security attributes you have
1947 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001948 * */
1949 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1950 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1951 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1952 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301953 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001954 "EncryptionType = %d mcEncryptionType = %d\n"),
1955 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1956 }
1957 }
1958 }
1959
Jeff Johnson4416a782013-03-25 14:17:50 -07001960 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
1961 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
1962 return -EINVAL;
1963 }
1964
Jeff Johnson295189b2012-06-20 16:38:30 -07001965 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
1966
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001967#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001968 if (params->ssid != NULL)
1969 {
1970 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
1971 pConfig->SSIDinfo.ssid.length = params->ssid_len;
1972 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1973 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1974 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001975#else
1976 if (ssid != NULL)
1977 {
1978 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
1979 pConfig->SSIDinfo.ssid.length = ssid_len;
1980 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1981 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1982 }
1983#endif
1984
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301985 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07001986 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301987
Jeff Johnson295189b2012-06-20 16:38:30 -07001988 /* default value */
1989 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
1990 pConfig->num_accept_mac = 0;
1991 pConfig->num_deny_mac = 0;
1992
1993 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1994 pBeacon->tail, pBeacon->tail_len);
1995
1996 /* pIe for black list is following form:
1997 type : 1 byte
1998 length : 1 byte
1999 OUI : 4 bytes
2000 acl type : 1 byte
2001 no of mac addr in black list: 1 byte
2002 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302003 */
2004 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002005 {
2006 pConfig->SapMacaddr_acl = pIe[6];
2007 pConfig->num_deny_mac = pIe[7];
2008 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d\n",
2009 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302010 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
2011 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002012 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
2013 for (i = 0; i < pConfig->num_deny_mac; i++)
2014 {
2015 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
2016 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302017 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002018 }
2019 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
2020 pBeacon->tail, pBeacon->tail_len);
2021
2022 /* pIe for white list is following form:
2023 type : 1 byte
2024 length : 1 byte
2025 OUI : 4 bytes
2026 acl type : 1 byte
2027 no of mac addr in white list: 1 byte
2028 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302029 */
2030 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002031 {
2032 pConfig->SapMacaddr_acl = pIe[6];
2033 pConfig->num_accept_mac = pIe[7];
2034 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d\n",
2035 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302036 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
2037 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002038 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
2039 for (i = 0; i < pConfig->num_accept_mac; i++)
2040 {
2041 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
2042 acl_entry++;
2043 }
2044 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302045
Jeff Johnson295189b2012-06-20 16:38:30 -07002046 wlan_hdd_set_sapHwmode(pHostapdAdapter);
2047
Jeff Johnsone7245742012-09-05 17:12:55 -07002048#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002049 /* Overwrite the hostapd setting for HW mode only for 11ac.
Kiet Lam0f320422013-11-21 19:29:17 +05302050 * This is valid only if mode is set to 11n in hostapd, either AUTO or
2051 * 11ac in .ini and 11ac is supported by both host and firmware.
2052 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
2053 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002054 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
2055 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302056 (((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_AUTO) ||
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002057 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac) ||
Kiet Lam0f320422013-11-21 19:29:17 +05302058 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY)) &&
2059 (sme_IsFeatureSupportedByDriver(DOT11AC)) && (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07002060 {
2061 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07002062
2063 /* Disable VHT support in 2.4 GHz band */
2064 if (pConfig->channel <= 14 &&
2065 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->enableVhtFor24GHzBand == FALSE)
2066 {
2067 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
2068 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002069 }
2070#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302071
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07002072 if ( AUTO_CHANNEL_SELECT != pConfig->channel )
2073 {
2074 sme_SelectCBMode(hHal,
2075 sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode),
2076 pConfig->channel);
2077 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002078 // ht_capab is not what the name conveys,this is used for protection bitmap
2079 pConfig->ht_capab =
2080 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
2081
2082 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
2083 {
2084 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
2085 return -EINVAL;
2086 }
2087
2088 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302089 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07002090 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
2091 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302092 pConfig->obssProtEnabled =
2093 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07002094
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302095 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR"\n"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002096 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302097 hddLog(LOGW,FL("ssid =%s\n"), pConfig->SSIDinfo.ssid.ssId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002098 hddLog(LOGW,FL("beaconint=%d, channel=%d\n"), (int)pConfig->beacon_int,
2099 (int)pConfig->channel);
2100 hddLog(LOGW,FL("hw_mode=%x\n"), pConfig->SapHw_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302101 hddLog(LOGW,FL("privacy=%d, authType=%d\n"), pConfig->privacy,
2102 pConfig->authType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002103 hddLog(LOGW,FL("RSN/WPALen=%d, \n"),(int)pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302104 hddLog(LOGW,FL("Uapsd = %d\n"),pConfig->UapsdEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002105 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d\n"),
2106 pConfig->protEnabled, pConfig->obssProtEnabled);
2107
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302108 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07002109 {
2110 //Bss already started. just return.
2111 //TODO Probably it should update some beacon params.
2112 hddLog( LOGE, "Bss Already started...Ignore the request");
2113 EXIT();
2114 return 0;
2115 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302116
Jeff Johnson295189b2012-06-20 16:38:30 -07002117 pConfig->persona = pHostapdAdapter->device_mode;
2118
2119 pSapEventCallback = hdd_hostapd_SAPEventCB;
2120 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
2121 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
2122 {
2123 hddLog(LOGE,FL("SAP Start Bss fail\n"));
2124 return -EINVAL;
2125 }
2126
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302127 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002128 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
2129
2130 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302131
Jeff Johnson295189b2012-06-20 16:38:30 -07002132 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302133 {
2134 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07002135 ("ERROR: HDD vos wait for single_event failed!!\n"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07002136 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002137 VOS_ASSERT(0);
2138 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302139
Jeff Johnson295189b2012-06-20 16:38:30 -07002140 //Succesfully started Bss update the state bit.
2141 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
2142
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002143#ifdef WLAN_FEATURE_P2P_DEBUG
2144 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
2145 {
2146 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
2147 {
2148 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2149 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002150 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002151 }
2152 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
2153 {
2154 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2155 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002156 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002157 }
2158 }
2159#endif
2160
Jeff Johnson295189b2012-06-20 16:38:30 -07002161 pHostapdState->bCommit = TRUE;
2162 EXIT();
2163
2164 return 0;
2165}
2166
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002167#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302168static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
2169 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002170 struct beacon_parameters *params)
2171{
2172 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302173 hdd_context_t *pHddCtx;
2174 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002175
2176 ENTER();
2177
2178 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d\n",pAdapter->device_mode);
2179
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302180 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2181 status = wlan_hdd_validate_context(pHddCtx);
2182
2183 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002184 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302185 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2186 "%s: HDD context is not valid", __func__);
2187 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002188 }
2189
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302190 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002191 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002192 )
2193 {
2194 beacon_data_t *old,*new;
2195
2196 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302197
Jeff Johnson295189b2012-06-20 16:38:30 -07002198 if (old)
2199 return -EALREADY;
2200
2201 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2202
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302203 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002204 {
2205 hddLog(VOS_TRACE_LEVEL_FATAL,
2206 "%s:Error!!! Allocating the new beacon\n",__func__);
2207 return -EINVAL;
2208 }
2209
2210 pAdapter->sessionCtx.ap.beacon = new;
2211
2212 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2213 }
2214
2215 EXIT();
2216 return status;
2217}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302218
2219static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07002220 struct net_device *dev,
2221 struct beacon_parameters *params)
2222{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302223 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302224 hdd_context_t *pHddCtx;
2225 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002226
2227 ENTER();
2228
2229 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2230 __func__,pAdapter->device_mode);
2231
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302232 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2233 status = wlan_hdd_validate_context(pHddCtx);
2234
2235 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002236 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302237 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2238 "%s: HDD context is not valid", __func__);
2239 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002240 }
2241
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302242 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002243 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302244 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002245 {
2246 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302247
Jeff Johnson295189b2012-06-20 16:38:30 -07002248 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302249
Jeff Johnson295189b2012-06-20 16:38:30 -07002250 if (!old)
2251 return -ENOENT;
2252
2253 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2254
2255 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302256 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07002257 "%s: Error!!! Allocating the new beacon\n",__func__);
2258 return -EINVAL;
2259 }
2260
2261 pAdapter->sessionCtx.ap.beacon = new;
2262
2263 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2264 }
2265
2266 EXIT();
2267 return status;
2268}
2269
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002270#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
2271
2272#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002273static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
2274 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002275#else
2276static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
2277 struct net_device *dev)
2278#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002279{
2280 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07002281 hdd_context_t *pHddCtx = NULL;
2282 hdd_scaninfo_t *pScanInfo = NULL;
2283 hdd_adapter_t *staAdapter = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302284 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002285
2286 ENTER();
2287
2288 if (NULL == pAdapter)
2289 {
2290 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002291 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002292 return -ENODEV;
2293 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002294
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302295 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2296 status = wlan_hdd_validate_context(pHddCtx);
2297
2298 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002299 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302300 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2301 "%s: HDD context is not valid", __func__);
2302 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07002303 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002304
2305 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
2306 if (NULL == staAdapter)
2307 {
2308 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
2309 if (NULL == staAdapter)
2310 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002311 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2312 "%s: HDD adapter context for STA/P2P-CLI is Null",
2313 __func__);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002314 }
2315 }
2316
2317 pScanInfo = &pHddCtx->scan_info;
2318
Jeff Johnson295189b2012-06-20 16:38:30 -07002319 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2320 __func__,pAdapter->device_mode);
2321
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002322 if ((pScanInfo != NULL) && pScanInfo->mScanPending && staAdapter)
Jeff Johnsone7245742012-09-05 17:12:55 -07002323 {
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002324 INIT_COMPLETION(pScanInfo->abortscan_event_var);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05302325 hdd_abort_mac_scan(staAdapter->pHddCtx, pAdapter->sessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002326 status = wait_for_completion_interruptible_timeout(
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002327 &pScanInfo->abortscan_event_var,
Jeff Johnsone7245742012-09-05 17:12:55 -07002328 msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN));
2329 if (!status)
2330 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002331 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson902c9832012-12-10 14:28:09 -08002332 "%s: Timeout occurred while waiting for abortscan" ,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002333 __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07002334 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07002335 }
2336 }
2337
Jeff Johnson295189b2012-06-20 16:38:30 -07002338 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002339 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002340 )
2341 {
2342 beacon_data_t *old;
2343
2344 old = pAdapter->sessionCtx.ap.beacon;
2345
2346 if (!old)
2347 return -ENOENT;
2348
Jeff Johnson295189b2012-06-20 16:38:30 -07002349 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002350
2351 mutex_lock(&pHddCtx->sap_lock);
2352 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
2353 {
Jeff Johnson4416a782013-03-25 14:17:50 -07002354 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002355 {
2356 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
2357
2358 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
2359
2360 if (!VOS_IS_STATUS_SUCCESS(status))
2361 {
2362 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2363 ("ERROR: HDD vos wait for single_event failed!!\n"));
2364 VOS_ASSERT(0);
2365 }
2366 }
2367 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
2368 }
2369 mutex_unlock(&pHddCtx->sap_lock);
2370
2371 if(status != VOS_STATUS_SUCCESS)
2372 {
2373 hddLog(VOS_TRACE_LEVEL_FATAL,
2374 "%s:Error!!! Stopping the BSS\n",__func__);
2375 return -EINVAL;
2376 }
2377
Jeff Johnson4416a782013-03-25 14:17:50 -07002378 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002379 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
2380 ==eHAL_STATUS_FAILURE)
2381 {
2382 hddLog(LOGE,
2383 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM\n");
2384 }
2385
Jeff Johnson4416a782013-03-25 14:17:50 -07002386 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002387 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
2388 eANI_BOOLEAN_FALSE) )
2389 {
2390 hddLog(LOGE,
2391 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
2392 }
2393
2394 // Reset WNI_CFG_PROBE_RSP Flags
2395 wlan_hdd_reset_prob_rspies(pAdapter);
2396
2397 pAdapter->sessionCtx.ap.beacon = NULL;
2398 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002399#ifdef WLAN_FEATURE_P2P_DEBUG
2400 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
2401 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
2402 {
2403 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
2404 "GO got removed");
2405 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
2406 }
2407#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002408 }
2409 EXIT();
2410 return status;
2411}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002412
2413#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2414
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302415static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
2416 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002417 struct cfg80211_ap_settings *params)
2418{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302419 hdd_adapter_t *pAdapter;
2420 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302421 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002422
2423 ENTER();
2424
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302425 if (NULL == dev)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002426 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302427 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302428 "%s: Device is Null", __func__);
2429 return -ENODEV;
2430 }
2431
2432 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2433 if (NULL == pAdapter)
2434 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302435 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302436 "%s: HDD adapter is Null", __func__);
2437 return -ENODEV;
2438 }
2439
2440 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
2441 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302442 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302443 "%s: HDD adapter magic is invalid", __func__);
2444 return -ENODEV;
2445 }
2446
2447 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302448 status = wlan_hdd_validate_context(pHddCtx);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302449
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302450 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302451 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302452 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2453 "%s: HDD context is not valid", __func__);
2454 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302455 }
2456
2457 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %d",
2458 __func__, pAdapter->device_mode);
2459
2460 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002461 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002462 )
2463 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302464 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002465
2466 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302467
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002468 if (old)
2469 return -EALREADY;
2470
2471 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, &params->beacon, params->dtim_period);
2472
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302473 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002474 {
2475 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302476 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002477 return -EINVAL;
2478 }
2479 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08002480#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07002481 wlan_hdd_cfg80211_set_channel(wiphy, dev,
2482#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
2483 params->channel, params->channel_type);
2484#else
2485 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
2486#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08002487#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002488 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
2489 params->ssid_len, params->hidden_ssid);
2490 }
2491
2492 EXIT();
2493 return status;
2494}
2495
2496
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302497static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002498 struct net_device *dev,
2499 struct cfg80211_beacon_data *params)
2500{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302501 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302502 hdd_context_t *pHddCtx;
2503 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002504
2505 ENTER();
2506
2507 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2508 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302509
2510 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2511 status = wlan_hdd_validate_context(pHddCtx);
2512
2513 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002514 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302515 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2516 "%s: HDD context is not valid", __func__);
2517 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002518 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002519
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302520 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002521 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302522 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002523 {
2524 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302525
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002526 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302527
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002528 if (!old)
2529 return -ENOENT;
2530
2531 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
2532
2533 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302534 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002535 "%s: Error!!! Allocating the new beacon\n",__func__);
2536 return -EINVAL;
2537 }
2538
2539 pAdapter->sessionCtx.ap.beacon = new;
2540
2541 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
2542 }
2543
2544 EXIT();
2545 return status;
2546}
2547
2548#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2549
Jeff Johnson295189b2012-06-20 16:38:30 -07002550
2551static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
2552 struct net_device *dev,
2553 struct bss_parameters *params)
2554{
2555 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2556
2557 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302558
Jeff Johnson295189b2012-06-20 16:38:30 -07002559 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2560 __func__,pAdapter->device_mode);
2561
2562 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002563 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302564 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002565 {
2566 /* ap_isolate == -1 means that in change bss, upper layer doesn't
2567 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302568 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07002569 {
2570 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302571 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002572 }
2573
2574 EXIT();
2575 return 0;
2576}
2577
Kiet Lam10841362013-11-01 11:36:50 +05302578/* FUNCTION: wlan_hdd_change_country_code_cd
2579* to wait for contry code completion
2580*/
2581void* wlan_hdd_change_country_code_cb(void *pAdapter)
2582{
2583 hdd_adapter_t *call_back_pAdapter = pAdapter;
2584 complete(&call_back_pAdapter->change_country_code);
2585 return NULL;
2586}
2587
Jeff Johnson295189b2012-06-20 16:38:30 -07002588/*
2589 * FUNCTION: wlan_hdd_cfg80211_change_iface
2590 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
2591 */
2592int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
2593 struct net_device *ndev,
2594 enum nl80211_iftype type,
2595 u32 *flags,
2596 struct vif_params *params
2597 )
2598{
2599 struct wireless_dev *wdev;
2600 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
2601 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Mohit Khanna0f232092012-09-11 14:46:08 -07002602 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002603 tCsrRoamProfile *pRoamProfile = NULL;
2604 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302605 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 eMib_dot11DesiredBssType connectedBssType;
2607 VOS_STATUS status;
2608
2609 ENTER();
2610
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302611 status = wlan_hdd_validate_context(pHddCtx);
2612
2613 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302615 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2616 "%s: HDD context is not valid", __func__);
2617 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002618 }
2619
2620 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
2621 __func__, pAdapter->device_mode);
2622
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302623 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07002624 wdev = ndev->ieee80211_ptr;
2625
2626#ifdef WLAN_BTAMP_FEATURE
2627 if((NL80211_IFTYPE_P2P_CLIENT == type)||
2628 (NL80211_IFTYPE_ADHOC == type)||
2629 (NL80211_IFTYPE_AP == type)||
2630 (NL80211_IFTYPE_P2P_GO == type))
2631 {
2632 pHddCtx->isAmpAllowed = VOS_FALSE;
2633 // stop AMP traffic
2634 status = WLANBAP_StopAmp();
2635 if(VOS_STATUS_SUCCESS != status )
2636 {
2637 pHddCtx->isAmpAllowed = VOS_TRUE;
2638 hddLog(VOS_TRACE_LEVEL_FATAL,
2639 "%s: Failed to stop AMP", __func__);
2640 return -EINVAL;
2641 }
2642 }
2643#endif //WLAN_BTAMP_FEATURE
2644 /* Reset the current device mode bit mask*/
2645 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
2646
2647 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07002648 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07002649 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002650 )
2651 {
2652 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2653 pRoamProfile = &pWextState->roamProfile;
2654 LastBSSType = pRoamProfile->BSSType;
2655
2656 switch (type)
2657 {
2658 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002659 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002660 hddLog(VOS_TRACE_LEVEL_INFO,
2661 "%s: setting interface Type to INFRASTRUCTURE", __func__);
2662 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002663#ifdef WLAN_FEATURE_11AC
2664 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
2665 {
2666 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
2667 }
2668#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302669 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07002670 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002671 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002672 //Check for sub-string p2p to confirm its a p2p interface
2673 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302674 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002675 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2676 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2677 }
2678 else
2679 {
2680 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002681 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002682 }
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05302683#ifdef FEATURE_WLAN_TDLS
2684 /* The open adapter for the p2p shall skip initializations in
2685 * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for
2686 * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke
2687 * tdls_init when the change_iface sets the device mode to
2688 * WLAN_HDD_P2P_CLIENT.
2689 */
2690
2691 if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2692 {
2693 if (0 != wlan_hdd_tdls_init (pAdapter))
2694 {
2695 return -EINVAL;
2696 }
2697 }
2698#endif
2699
Jeff Johnson295189b2012-06-20 16:38:30 -07002700 break;
2701 case NL80211_IFTYPE_ADHOC:
2702 hddLog(VOS_TRACE_LEVEL_INFO,
2703 "%s: setting interface Type to ADHOC", __func__);
2704 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2705 pRoamProfile->phyMode =
2706 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002707 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002708 wdev->iftype = type;
2709 break;
2710
2711 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002712 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002713 {
2714 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2715 "%s: setting interface Type to %s", __func__,
2716 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
2717
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002718 //Cancel any remain on channel for GO mode
2719 if (NL80211_IFTYPE_P2P_GO == type)
2720 {
2721 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
2722 }
Mohit Khanna0f232092012-09-11 14:46:08 -07002723 if (NL80211_IFTYPE_AP == type)
2724 {
2725 /* As Loading WLAN Driver one interface being created for p2p device
2726 * address. This will take one HW STA and the max number of clients
2727 * that can connect to softAP will be reduced by one. so while changing
2728 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
2729 * interface as it is not required in SoftAP mode.
2730 */
2731
2732 // Get P2P Adapter
2733 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
2734
2735 if (pP2pAdapter)
2736 {
2737 hdd_stop_adapter(pHddCtx, pP2pAdapter);
2738 hdd_deinit_adapter(pHddCtx, pP2pAdapter);
2739 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
2740 }
2741 }
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302742#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07002743
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302744 /* A Mutex Lock is introduced while changing the mode to
2745 * protect the concurrent access for the Adapters by TDLS
2746 * module.
2747 */
2748 if (mutex_lock_interruptible(&pHddCtx->tdls_lock))
2749 {
2750 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2751 "%s: unable to lock list", __func__);
2752 return -EINVAL;
2753 }
2754#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002755 //De-init the adapter.
2756 hdd_stop_adapter( pHddCtx, pAdapter );
2757 hdd_deinit_adapter( pHddCtx, pAdapter );
2758 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07002759 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2760 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302761#ifdef FEATURE_WLAN_TDLS
2762 mutex_unlock(&pHddCtx->tdls_lock);
2763#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07002764
2765 //Disable BMPS and IMPS if enabled
2766 //before starting Go
2767 if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
2768 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302769 if(VOS_STATUS_E_FAILURE ==
Jeff Johnson32d95a32012-09-10 13:15:23 -07002770 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
2771 {
2772 //Fail to Exit BMPS
2773 VOS_ASSERT(0);
2774 }
2775 }
2776
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07002777 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
2778 (pConfig->apRandomBssidEnabled))
2779 {
2780 /* To meet Android requirements create a randomized
2781 MAC address of the form 02:1A:11:Fx:xx:xx */
2782 get_random_bytes(&ndev->dev_addr[3], 3);
2783 ndev->dev_addr[0] = 0x02;
2784 ndev->dev_addr[1] = 0x1A;
2785 ndev->dev_addr[2] = 0x11;
2786 ndev->dev_addr[3] |= 0xF0;
2787 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
2788 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08002789 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
2790 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07002791 }
2792
Jeff Johnson295189b2012-06-20 16:38:30 -07002793 hdd_set_ap_ops( pAdapter->dev );
2794
Kiet Lam10841362013-11-01 11:36:50 +05302795 /* This is for only SAP mode where users can
2796 * control country through ini.
2797 * P2P GO follows station country code
2798 * acquired during the STA scanning. */
2799 if((NL80211_IFTYPE_AP == type) &&
2800 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
2801 {
2802 int status = 0;
2803 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
2804 "%s: setting country code from INI ", __func__);
2805 init_completion(&pAdapter->change_country_code);
2806 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
2807 (void *)(tSmeChangeCountryCallback)
2808 wlan_hdd_change_country_code_cb,
2809 pConfig->apCntryCode, pAdapter,
2810 pHddCtx->pvosContext,
2811 VOS_FALSE);
2812 if (eHAL_STATUS_SUCCESS == status)
2813 {
2814 /* Wait for completion */
2815 status = wait_for_completion_interruptible_timeout(
2816 &pAdapter->change_country_code,
2817 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
2818 if (status <= 0)
2819 {
2820 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2821 "%s: SME Timed out while setting country code ",
2822 __func__);
2823 }
2824 }
2825 else
2826 {
2827 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2828 "%s: SME Change Country code failed \n",__func__);
2829 return -EINVAL;
2830 }
2831 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002832 status = hdd_init_ap_mode(pAdapter);
2833 if(status != VOS_STATUS_SUCCESS)
2834 {
2835 hddLog(VOS_TRACE_LEVEL_FATAL,
2836 "%s: Error initializing the ap mode", __func__);
2837 return -EINVAL;
2838 }
2839 hdd_set_conparam(1);
2840
Jeff Johnson295189b2012-06-20 16:38:30 -07002841 /*interface type changed update in wiphy structure*/
2842 if(wdev)
2843 {
2844 wdev->iftype = type;
2845 pHddCtx->change_iface = type;
2846 }
2847 else
2848 {
2849 hddLog(VOS_TRACE_LEVEL_ERROR,
2850 "%s: ERROR !!!! Wireless dev is NULL", __func__);
2851 return -EINVAL;
2852 }
2853 goto done;
2854 }
2855
2856 default:
2857 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2858 __func__);
2859 return -EOPNOTSUPP;
2860 }
2861 }
2862 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002863 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002864 )
2865 {
2866 switch(type)
2867 {
2868 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002869 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002870 case NL80211_IFTYPE_ADHOC:
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302871#ifdef FEATURE_WLAN_TDLS
2872
2873 /* A Mutex Lock is introduced while changing the mode to
2874 * protect the concurrent access for the Adapters by TDLS
2875 * module.
2876 */
2877 if (mutex_lock_interruptible(&pHddCtx->tdls_lock))
2878 {
2879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2880 "%s: unable to lock list", __func__);
2881 return -EINVAL;
2882 }
2883#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07002884 hdd_stop_adapter( pHddCtx, pAdapter );
2885 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07002886 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002887 //Check for sub-string p2p to confirm its a p2p interface
2888 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002889 {
2890 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2891 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2892 }
2893 else
2894 {
2895 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002896 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002897 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002898 hdd_set_conparam(0);
2899 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002900 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
2901 hdd_set_station_ops( pAdapter->dev );
2902 status = hdd_init_station_mode( pAdapter );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302903#ifdef FEATURE_WLAN_TDLS
2904 mutex_unlock(&pHddCtx->tdls_lock);
2905#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002906 if( VOS_STATUS_SUCCESS != status )
2907 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07002908 /* In case of JB, for P2P-GO, only change interface will be called,
2909 * This is the right place to enable back bmps_imps()
2910 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302911 if (pHddCtx->hdd_wlan_suspended)
2912 {
2913 hdd_set_pwrparams(pHddCtx);
2914 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002915 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07002916 goto done;
2917 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002918 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002919 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002920 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2921 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002922 goto done;
2923 default:
2924 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2925 __func__);
2926 return -EOPNOTSUPP;
2927
2928 }
2929
2930 }
2931 else
2932 {
2933 return -EOPNOTSUPP;
2934 }
2935
2936
2937 if(pRoamProfile)
2938 {
2939 if ( LastBSSType != pRoamProfile->BSSType )
2940 {
2941 /*interface type changed update in wiphy structure*/
2942 wdev->iftype = type;
2943
2944 /*the BSS mode changed, We need to issue disconnect
2945 if connected or in IBSS disconnect state*/
2946 if ( hdd_connGetConnectedBssType(
2947 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
2948 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
2949 {
2950 /*need to issue a disconnect to CSR.*/
2951 INIT_COMPLETION(pAdapter->disconnect_comp_var);
2952 if( eHAL_STATUS_SUCCESS ==
2953 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
2954 pAdapter->sessionId,
2955 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
2956 {
2957 wait_for_completion_interruptible_timeout(
2958 &pAdapter->disconnect_comp_var,
2959 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
2960 }
2961 }
2962 }
2963 }
2964
2965done:
2966 /*set bitmask based on updated value*/
2967 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07002968
2969 /* Only STA mode support TM now
2970 * all other mode, TM feature should be disabled */
2971 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
2972 (~VOS_STA & pHddCtx->concurrency_mode) )
2973 {
2974 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
2975 }
2976
Jeff Johnson295189b2012-06-20 16:38:30 -07002977#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302978 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002979 (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
2980 {
2981 //we are ok to do AMP
2982 pHddCtx->isAmpAllowed = VOS_TRUE;
2983 }
2984#endif //WLAN_BTAMP_FEATURE
2985 EXIT();
2986 return 0;
2987}
2988
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002989#ifdef FEATURE_WLAN_TDLS
2990static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
2991 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
2992{
2993 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2994 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2995 VOS_STATUS status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002996 hddTdlsPeer_t *pTdlsPeer;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002997
2998 ENTER();
2999
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303000 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003001 {
3002 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3003 "Invalid arguments");
3004 return -EINVAL;
3005 }
Hoonki Lee27511902013-03-14 18:19:06 -07003006
3007 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
3008 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
3009 {
3010 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3011 "%s: TDLS mode is disabled OR not enabled in FW."
3012 MAC_ADDRESS_STR " Request declined.",
3013 __func__, MAC_ADDR_ARRAY(mac));
3014 return -ENOTSUPP;
3015 }
3016
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003017 if (pHddCtx->isLogpInProgress)
3018 {
3019 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3020 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07003021 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003022 return -EBUSY;
3023 }
3024
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303025 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003026
3027 if ( NULL == pTdlsPeer ) {
3028 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3029 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
3030 __func__, MAC_ADDR_ARRAY(mac), update);
3031 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003032 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003033
3034 /* in add station, we accept existing valid staId if there is */
3035 if ((0 == update) &&
3036 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
3037 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003038 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003039 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003040 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003041 " link_status %d. staId %d. add station ignored.",
3042 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
3043 return 0;
3044 }
3045 /* in change station, we accept only when staId is valid */
3046 if ((1 == update) &&
3047 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
3048 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
3049 {
3050 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3051 "%s: " MAC_ADDRESS_STR
3052 " link status %d. staId %d. change station %s.",
3053 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
3054 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
3055 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003056 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003057
3058 /* when others are on-going, we want to change link_status to idle */
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303059 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003060 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003061 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3062 "%s: " MAC_ADDRESS_STR
3063 " TDLS setup is ongoing. Request declined.",
3064 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07003065 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003066 }
3067
3068 /* first to check if we reached to maximum supported TDLS peer.
3069 TODO: for now, return -EPERM looks working fine,
3070 but need to check if any other errno fit into this category.*/
3071 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
3072 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003073 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3074 "%s: " MAC_ADDRESS_STR
3075 " TDLS Max peer already connected. Request declined.",
3076 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07003077 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003078 }
3079 else
3080 {
3081 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303082 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003083 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003084 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003085 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3086 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
3087 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003088 return -EPERM;
3089 }
3090 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003091 if (0 == update)
3092 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003093
Jeff Johnsond75fe012013-04-06 10:53:06 -07003094 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303095 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003096 {
3097 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3098 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003099 if(StaParams->htcap_present)
3100 {
3101 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3102 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
3103 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3104 "ht_capa->extended_capabilities: %0x",
3105 StaParams->HTCap.extendedHtCapInfo);
3106 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003107 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3108 "params->capability: %0x",StaParams->capability);
3109 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003110 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003111 if(StaParams->vhtcap_present)
3112 {
3113 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3114 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
3115 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
3116 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
3117 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003118 {
3119 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003120 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003121 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
3122 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3123 "[%d]: %x ", i, StaParams->supported_rates[i]);
3124 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07003125 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303126 else if ((1 == update) && (NULL == StaParams))
3127 {
3128 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3129 "%s : update is true, but staParams is NULL. Error!", __func__);
3130 return -EPERM;
3131 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003132
3133 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
3134
3135 if (!update)
3136 {
3137 status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3138 pAdapter->sessionId, mac);
3139 }
3140 else
3141 {
3142 status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3143 pAdapter->sessionId, mac, StaParams);
3144 }
3145
3146 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
3147 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
3148
3149 if (!status)
3150 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003151 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003152 "%s: timeout waiting for tdls add station indication",
3153 __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003154 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003155 }
3156 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
3157 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003158 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003159 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003160 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003161 }
3162
3163 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07003164
3165error:
3166 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
3167 return -EPERM;
3168
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003169}
3170#endif
3171
Jeff Johnson295189b2012-06-20 16:38:30 -07003172static int wlan_hdd_change_station(struct wiphy *wiphy,
3173 struct net_device *dev,
3174 u8 *mac,
3175 struct station_parameters *params)
3176{
3177 VOS_STATUS status = VOS_STATUS_SUCCESS;
3178 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkala29149562013-05-10 21:43:41 +05303179 hdd_context_t *pHddCtx;
3180 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003181 v_MACADDR_t STAMacAddress;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003182#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003183 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003184 tANI_U8 isBufSta = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003185#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003186 ENTER();
3187
Gopichand Nakkala29149562013-05-10 21:43:41 +05303188 if ((NULL == pAdapter))
3189 {
3190 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3191 "invalid adapter ");
3192 return -EINVAL;
3193 }
3194
3195 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3196 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3197
3198 if ((NULL == pHddCtx) || (NULL == pHddStaCtx))
3199 {
3200 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3201 "invalid HDD state or HDD station context");
3202 return -EINVAL;
3203 }
3204
3205 if (pHddCtx->isLogpInProgress)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003206 {
3207 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3208 "%s:LOGP in Progress. Ignore!!!", __func__);
3209 return -EAGAIN;
3210 }
3211
Jeff Johnson295189b2012-06-20 16:38:30 -07003212 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
3213
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003214 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
3215 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07003216 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003217 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07003218 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303219 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07003220 WLANTL_STA_AUTHENTICATED);
3221
Gopichand Nakkala29149562013-05-10 21:43:41 +05303222 if (status != VOS_STATUS_SUCCESS)
3223 {
3224 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3225 "%s: Not able to change TL state to AUTHENTICATED", __func__);
3226 return -EINVAL;
3227 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003228 }
3229 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07003230 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
3231 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303232#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003233 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
3234 StaParams.capability = params->capability;
3235 StaParams.uapsd_queues = params->uapsd_queues;
3236 StaParams.max_sp = params->max_sp;
3237
3238 if (0 != params->ext_capab_len)
3239 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
3240 sizeof(StaParams.extn_capability));
3241
3242 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003243 {
3244 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003245 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003246 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003247
3248 StaParams.supported_rates_len = params->supported_rates_len;
3249
3250 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
3251 * The supported_rates array , for all the structures propogating till Add Sta
3252 * to the firmware has to be modified , if the supplicant (ieee80211) is
3253 * modified to send more rates.
3254 */
3255
3256 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
3257 */
3258 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
3259 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
3260
3261 if (0 != StaParams.supported_rates_len) {
3262 int i = 0;
3263 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
3264 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003265 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003266 "Supported Rates with Length %d", StaParams.supported_rates_len);
3267 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003268 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003269 "[%d]: %0x", i, StaParams.supported_rates[i]);
3270 }
3271
3272 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003273 {
3274 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003275 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003276 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003277
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003278 if (0 != params->ext_capab_len ) {
3279 /*Define A Macro : TODO Sunil*/
3280 if ((1<<4) & StaParams.extn_capability[3]) {
3281 isBufSta = 1;
3282 }
3283 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303284 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac, params->uapsd_queues,
3285 params->max_sp, isBufSta);
3286 if (VOS_STATUS_SUCCESS != status) {
3287 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3288 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
3289 return -EINVAL;
3290 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003291 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
3292
3293 if (VOS_STATUS_SUCCESS != status) {
3294 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3295 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
3296 return -EINVAL;
3297 }
3298 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003299#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05303300 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003301 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 return status;
3303}
3304
3305/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003306 * FUNCTION: wlan_hdd_cfg80211_add_key
3307 * This function is used to initialize the key information
3308 */
3309#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003310static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003311 struct net_device *ndev,
3312 u8 key_index, bool pairwise,
3313 const u8 *mac_addr,
3314 struct key_params *params
3315 )
3316#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003317static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003318 struct net_device *ndev,
3319 u8 key_index, const u8 *mac_addr,
3320 struct key_params *params
3321 )
3322#endif
3323{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003324 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003325 tCsrRoamSetKey setKey;
3326 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303327 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003328 v_U32_t roamId= 0xFF;
3329 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003330 hdd_hostapd_state_t *pHostapdState;
3331 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003332 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303333 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003334
3335 ENTER();
3336
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303337 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3338 status = wlan_hdd_validate_context(pHddCtx);
3339
3340 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003341 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303342 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3343 "%s: HDD context is not valid", __func__);
3344 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003345 }
3346
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003347 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
3348 __func__, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003349
3350 if (CSR_MAX_NUM_KEY <= key_index)
3351 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003352 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003353 key_index);
3354
3355 return -EINVAL;
3356 }
3357
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003358 if (CSR_MAX_KEY_LEN < params->key_len)
3359 {
3360 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
3361 params->key_len);
3362
3363 return -EINVAL;
3364 }
3365
3366 hddLog(VOS_TRACE_LEVEL_INFO,
3367 "%s: called with key index = %d & key length %d",
3368 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003369
3370 /*extract key idx, key len and key*/
3371 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3372 setKey.keyId = key_index;
3373 setKey.keyLength = params->key_len;
3374 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
3375
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003376 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07003377 {
3378 case WLAN_CIPHER_SUITE_WEP40:
3379 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3380 break;
3381
3382 case WLAN_CIPHER_SUITE_WEP104:
3383 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3384 break;
3385
3386 case WLAN_CIPHER_SUITE_TKIP:
3387 {
3388 u8 *pKey = &setKey.Key[0];
3389 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3390
3391 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3392
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003393 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07003394
3395 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003396 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003397 |--------------|----------|----------|
3398 <---16bytes---><--8bytes--><--8bytes-->
3399
3400 */
3401 /*Sme expects the 32 bytes key to be in the below order
3402
3403 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003404 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003405 |--------------|----------|----------|
3406 <---16bytes---><--8bytes--><--8bytes-->
3407 */
3408 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003409 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07003410
3411 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003412 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003413
3414 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003415 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003416
3417
3418 break;
3419 }
3420
3421 case WLAN_CIPHER_SUITE_CCMP:
3422 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3423 break;
3424
3425#ifdef FEATURE_WLAN_WAPI
3426 case WLAN_CIPHER_SUITE_SMS4:
3427 {
3428 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3429 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
3430 params->key, params->key_len);
3431 return 0;
3432 }
3433#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003434
Jeff Johnson295189b2012-06-20 16:38:30 -07003435#ifdef FEATURE_WLAN_CCX
3436 case WLAN_CIPHER_SUITE_KRK:
3437 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3438 break;
3439#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003440
3441#ifdef WLAN_FEATURE_11W
3442 case WLAN_CIPHER_SUITE_AES_CMAC:
3443 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07003444 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07003445#endif
3446
Jeff Johnson295189b2012-06-20 16:38:30 -07003447 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003448 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07003449 __func__, params->cipher);
3450 return -EOPNOTSUPP;
3451 }
3452
3453 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
3454 __func__, setKey.encType);
3455
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003456 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07003457#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3458 (!pairwise)
3459#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003460 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07003461#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003462 )
3463 {
3464 /* set group key*/
3465 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3466 "%s- %d: setting Broadcast key",
3467 __func__, __LINE__);
3468 setKey.keyDirection = eSIR_RX_ONLY;
3469 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3470 }
3471 else
3472 {
3473 /* set pairwise key*/
3474 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3475 "%s- %d: setting pairwise key",
3476 __func__, __LINE__);
3477 setKey.keyDirection = eSIR_TX_RX;
3478 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3479 }
3480 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
3481 {
3482 setKey.keyDirection = eSIR_TX_RX;
3483 /*Set the group key*/
3484 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3485 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003486
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003487 if ( 0 != status )
3488 {
3489 hddLog(VOS_TRACE_LEVEL_ERROR,
3490 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3491 return -EINVAL;
3492 }
3493 /*Save the keys here and call sme_RoamSetKey for setting
3494 the PTK after peer joins the IBSS network*/
3495 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
3496 &setKey, sizeof(tCsrRoamSetKey));
3497 return status;
3498 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05303499 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
3500 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
3501 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003502 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003503 if( pHostapdState->bssState == BSS_START )
3504 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003505 status = WLANSAP_SetKeySta( pVosContext, &setKey);
3506
3507 if ( status != eHAL_STATUS_SUCCESS )
3508 {
3509 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3510 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3511 __LINE__, status );
3512 }
3513 }
3514
3515 /* Saving WEP keys */
3516 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
3517 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
3518 {
3519 //Save the wep key in ap context. Issue setkey after the BSS is started.
3520 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3521 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
3522 }
3523 else
3524 {
3525 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003526 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003527 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
3528 }
3529 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003530 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
3531 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003532 {
3533 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3534 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3535
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303536#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3537 if (!pairwise)
3538#else
3539 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
3540#endif
3541 {
3542 /* set group key*/
3543 if (pHddStaCtx->roam_info.deferKeyComplete)
3544 {
3545 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3546 "%s- %d: Perform Set key Complete",
3547 __func__, __LINE__);
3548 hdd_PerformRoamSetKeyComplete(pAdapter);
3549 }
3550 }
3551
Jeff Johnson295189b2012-06-20 16:38:30 -07003552 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
3553
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08003554 pWextState->roamProfile.Keys.defaultIndex = key_index;
3555
3556
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003557 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003558 params->key, params->key_len);
3559
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303560
Jeff Johnson295189b2012-06-20 16:38:30 -07003561 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3562
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303563 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003564 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303565 __func__, setKey.peerMac[0], setKey.peerMac[1],
3566 setKey.peerMac[2], setKey.peerMac[3],
3567 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003568 setKey.keyDirection);
3569
3570 vos_status = wlan_hdd_check_ula_done(pAdapter);
3571
3572 if ( vos_status != VOS_STATUS_SUCCESS )
3573 {
3574 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3575 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3576 __LINE__, vos_status );
3577
3578 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3579
3580 return -EINVAL;
3581
3582 }
3583
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003584#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303585 /* The supplicant may attempt to set the PTK once pre-authentication
3586 is done. Save the key in the UMAC and include it in the ADD BSS
3587 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003588 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303589 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003590 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303591 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3592 "%s: Update PreAuth Key success", __func__);
3593 return 0;
3594 }
3595 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3596 {
3597 hddLog(VOS_TRACE_LEVEL_ERROR,
3598 "%s: Update PreAuth Key failed", __func__);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05303599 return -EINVAL;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003600 }
3601#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07003602
3603 /* issue set key request to SME*/
3604 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3605 pAdapter->sessionId, &setKey, &roamId );
3606
3607 if ( 0 != status )
3608 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303609 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003610 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3611 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3612 return -EINVAL;
3613 }
3614
3615
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303616 /* in case of IBSS as there was no information available about WEP keys during
3617 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07003618 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303619 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
3620 !( ( IW_AUTH_KEY_MGMT_802_1X
3621 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003622 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
3623 )
3624 &&
3625 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
3626 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
3627 )
3628 )
3629 {
3630 setKey.keyDirection = eSIR_RX_ONLY;
3631 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3632
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303633 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003634 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303635 __func__, setKey.peerMac[0], setKey.peerMac[1],
3636 setKey.peerMac[2], setKey.peerMac[3],
3637 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003638 setKey.keyDirection);
3639
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303640 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003641 pAdapter->sessionId, &setKey, &roamId );
3642
3643 if ( 0 != status )
3644 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303645 hddLog(VOS_TRACE_LEVEL_ERROR,
3646 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003647 __func__, status);
3648 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3649 return -EINVAL;
3650 }
3651 }
3652 }
3653
3654 return 0;
3655}
3656
3657/*
3658 * FUNCTION: wlan_hdd_cfg80211_get_key
3659 * This function is used to get the key information
3660 */
3661#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303662static int wlan_hdd_cfg80211_get_key(
3663 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003664 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303665 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003666 const u8 *mac_addr, void *cookie,
3667 void (*callback)(void *cookie, struct key_params*)
3668 )
3669#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303670static int wlan_hdd_cfg80211_get_key(
3671 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003672 struct net_device *ndev,
3673 u8 key_index, const u8 *mac_addr, void *cookie,
3674 void (*callback)(void *cookie, struct key_params*)
3675 )
3676#endif
3677{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303678 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003679 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3680 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3681 struct key_params params;
3682
3683 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303684
Jeff Johnson295189b2012-06-20 16:38:30 -07003685 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
3686 __func__,pAdapter->device_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303687
Jeff Johnson295189b2012-06-20 16:38:30 -07003688 memset(&params, 0, sizeof(params));
3689
3690 if (CSR_MAX_NUM_KEY <= key_index)
3691 {
3692 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303693 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003694
3695 switch(pRoamProfile->EncryptionType.encryptionType[0])
3696 {
3697 case eCSR_ENCRYPT_TYPE_NONE:
3698 params.cipher = IW_AUTH_CIPHER_NONE;
3699 break;
3700
3701 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3702 case eCSR_ENCRYPT_TYPE_WEP40:
3703 params.cipher = WLAN_CIPHER_SUITE_WEP40;
3704 break;
3705
3706 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3707 case eCSR_ENCRYPT_TYPE_WEP104:
3708 params.cipher = WLAN_CIPHER_SUITE_WEP104;
3709 break;
3710
3711 case eCSR_ENCRYPT_TYPE_TKIP:
3712 params.cipher = WLAN_CIPHER_SUITE_TKIP;
3713 break;
3714
3715 case eCSR_ENCRYPT_TYPE_AES:
3716 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
3717 break;
3718
3719 default:
3720 params.cipher = IW_AUTH_CIPHER_NONE;
3721 break;
3722 }
3723
3724 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
3725 params.seq_len = 0;
3726 params.seq = NULL;
3727 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
3728 callback(cookie, &params);
3729 return 0;
3730}
3731
3732/*
3733 * FUNCTION: wlan_hdd_cfg80211_del_key
3734 * This function is used to delete the key information
3735 */
3736#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303737static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003738 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303739 u8 key_index,
3740 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003741 const u8 *mac_addr
3742 )
3743#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303744static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003745 struct net_device *ndev,
3746 u8 key_index,
3747 const u8 *mac_addr
3748 )
3749#endif
3750{
3751 int status = 0;
3752
3753 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303754 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07003755 //it is observed that this is invalidating peer
3756 //key index whenever re-key is done. This is affecting data link.
3757 //It should be ok to ignore del_key.
3758#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303759 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
3760 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003761 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3762 tCsrRoamSetKey setKey;
3763 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303764
Jeff Johnson295189b2012-06-20 16:38:30 -07003765 ENTER();
3766
3767 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
3768 __func__,pAdapter->device_mode);
3769
3770 if (CSR_MAX_NUM_KEY <= key_index)
3771 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303772 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003773 key_index);
3774
3775 return -EINVAL;
3776 }
3777
3778 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3779 setKey.keyId = key_index;
3780
3781 if (mac_addr)
3782 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3783 else
3784 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
3785
3786 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3787
3788 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07003789 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303790 )
3791 {
3792
3793 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07003794 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
3795 if( pHostapdState->bssState == BSS_START)
3796 {
3797 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303798
Jeff Johnson295189b2012-06-20 16:38:30 -07003799 if ( status != eHAL_STATUS_SUCCESS )
3800 {
3801 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3802 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3803 __LINE__, status );
3804 }
3805 }
3806 }
3807 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303808 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07003809 )
3810 {
3811 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3812
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303813 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3814
3815 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003816 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303817 __func__, setKey.peerMac[0], setKey.peerMac[1],
3818 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07003819 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303820 if(pAdapter->sessionCtx.station.conn_info.connState ==
3821 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07003822 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303823 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003824 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303825
Jeff Johnson295189b2012-06-20 16:38:30 -07003826 if ( 0 != status )
3827 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303828 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003829 "%s: sme_RoamSetKey failure, returned %d",
3830 __func__, status);
3831 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3832 return -EINVAL;
3833 }
3834 }
3835 }
3836#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003837 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003838 return status;
3839}
3840
3841/*
3842 * FUNCTION: wlan_hdd_cfg80211_set_default_key
3843 * This function is used to set the default tx key index
3844 */
3845#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3846static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3847 struct net_device *ndev,
3848 u8 key_index,
3849 bool unicast, bool multicast)
3850#else
3851static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3852 struct net_device *ndev,
3853 u8 key_index)
3854#endif
3855{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303856 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303857 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05303858 hdd_wext_state_t *pWextState;
3859 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303860 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003861
3862 ENTER();
3863
Gopichand Nakkala29149562013-05-10 21:43:41 +05303864 if ((NULL == pAdapter))
3865 {
3866 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3867 "invalid adapter");
3868 return -EINVAL;
3869 }
3870
3871 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3872 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3873
3874 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3875 {
3876 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3877 "invalid Wext state or HDD context");
3878 return -EINVAL;
3879 }
3880
Jeff Johnson295189b2012-06-20 16:38:30 -07003881 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d \n",
3882 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303883
Jeff Johnson295189b2012-06-20 16:38:30 -07003884 if (CSR_MAX_NUM_KEY <= key_index)
3885 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303886 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003887 key_index);
3888
3889 return -EINVAL;
3890 }
3891
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303892 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3893 status = wlan_hdd_validate_context(pHddCtx);
3894
3895 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003896 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303897 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3898 "%s: HDD context is not valid", __func__);
3899 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003900 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303901
Jeff Johnson295189b2012-06-20 16:38:30 -07003902 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07003903 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303904 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003905 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303906 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08003907 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303908 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08003909 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07003910 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303911 {
3912 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07003913 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303914
Jeff Johnson295189b2012-06-20 16:38:30 -07003915 tCsrRoamSetKey setKey;
3916 v_U32_t roamId= 0xFF;
3917 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303918
3919 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003920 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303921
Jeff Johnson295189b2012-06-20 16:38:30 -07003922 Keys->defaultIndex = (u8)key_index;
3923 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3924 setKey.keyId = key_index;
3925 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303926
3927 vos_mem_copy(&setKey.Key[0],
3928 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003929 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303930
Gopichand Nakkala29149562013-05-10 21:43:41 +05303931 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303932
3933 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07003934 &pHddStaCtx->conn_info.bssId[0],
3935 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303936
Gopichand Nakkala29149562013-05-10 21:43:41 +05303937 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
3938 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
3939 eCSR_ENCRYPT_TYPE_WEP104)
3940 {
3941 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
3942 even though ap is configured for WEP-40 encryption. In this canse the key length
3943 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
3944 type(104) and switching encryption type to 40*/
3945 pWextState->roamProfile.EncryptionType.encryptionType[0] =
3946 eCSR_ENCRYPT_TYPE_WEP40;
3947 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
3948 eCSR_ENCRYPT_TYPE_WEP40;
3949 }
3950
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303951 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07003952 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303953
Jeff Johnson295189b2012-06-20 16:38:30 -07003954 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303955 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003956 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303957
Jeff Johnson295189b2012-06-20 16:38:30 -07003958 if ( 0 != status )
3959 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303960 hddLog(VOS_TRACE_LEVEL_ERROR,
3961 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003962 status);
3963 return -EINVAL;
3964 }
3965 }
3966 }
3967
3968 /* In SoftAp mode setting key direction for default mode */
3969 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
3970 {
3971 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
3972 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
3973 (eCSR_ENCRYPT_TYPE_AES !=
3974 pWextState->roamProfile.EncryptionType.encryptionType[0])
3975 )
3976 {
3977 /* Saving key direction for default key index to TX default */
3978 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3979 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
3980 }
3981 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303982
Jeff Johnson295189b2012-06-20 16:38:30 -07003983 return status;
3984}
3985
Jeff Johnson295189b2012-06-20 16:38:30 -07003986/*
3987 * FUNCTION: wlan_hdd_cfg80211_inform_bss
3988 * This function is used to inform the BSS details to nl80211 interface.
3989 */
3990static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
3991 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
3992{
3993 struct net_device *dev = pAdapter->dev;
3994 struct wireless_dev *wdev = dev->ieee80211_ptr;
3995 struct wiphy *wiphy = wdev->wiphy;
3996 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
3997 int chan_no;
3998 int ie_length;
3999 const char *ie;
4000 unsigned int freq;
4001 struct ieee80211_channel *chan;
4002 int rssi = 0;
4003 struct cfg80211_bss *bss = NULL;
4004
4005 ENTER();
4006
4007 if( NULL == pBssDesc )
4008 {
4009 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL\n", __func__);
4010 return bss;
4011 }
4012
4013 chan_no = pBssDesc->channelId;
4014 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
4015 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
4016
4017 if( NULL == ie )
4018 {
4019 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL\n", __func__);
4020 return bss;
4021 }
4022
4023#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
4024 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
4025 {
4026 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4027 }
4028 else
4029 {
4030 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4031 }
4032#else
4033 freq = ieee80211_channel_to_frequency(chan_no);
4034#endif
4035
4036 chan = __ieee80211_get_channel(wiphy, freq);
4037
4038 bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId,
4039 &roamProfile->SSID.ssId[0], roamProfile->SSID.length,
4040 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
4041 if (bss == NULL)
4042 {
4043 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
4044
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304045 return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
4046 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07004047 pBssDesc->capabilityInfo,
4048 pBssDesc->beaconInterval, ie, ie_length,
4049 rssi, GFP_KERNEL ));
4050}
4051 else
4052 {
4053 return bss;
4054 }
4055}
4056
4057
4058
4059/*
4060 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
4061 * This function is used to inform the BSS details to nl80211 interface.
4062 */
4063struct cfg80211_bss*
4064wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
4065 tSirBssDescription *bss_desc
4066 )
4067{
4068 /*
4069 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
4070 already exists in bss data base of cfg80211 for that particular BSS ID.
4071 Using cfg80211_inform_bss_frame to update the bss entry instead of
4072 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
4073 now there is no possibility to get the mgmt(probe response) frame from PE,
4074 converting bss_desc to ieee80211_mgmt(probe response) and passing to
4075 cfg80211_inform_bss_frame.
4076 */
4077 struct net_device *dev = pAdapter->dev;
4078 struct wireless_dev *wdev = dev->ieee80211_ptr;
4079 struct wiphy *wiphy = wdev->wiphy;
4080 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004081#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4082 qcom_ie_age *qie_age = NULL;
4083 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
4084#else
Jeff Johnson295189b2012-06-20 16:38:30 -07004085 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004086#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004087 const char *ie =
4088 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
4089 unsigned int freq;
4090 struct ieee80211_channel *chan;
4091 struct ieee80211_mgmt *mgmt =
4092 kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
4093 struct cfg80211_bss *bss_status = NULL;
4094 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
4095 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07004096 hdd_context_t *pHddCtx;
4097 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07004098#ifdef WLAN_OPEN_SOURCE
4099 struct timespec ts;
4100#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004101
4102 ENTER();
4103
Wilson Yangf80a0542013-10-07 13:02:37 -07004104 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4105 status = wlan_hdd_validate_context(pHddCtx);
4106
4107 /*bss_update is not allowed during wlan driver loading or unloading*/
4108 if (pHddCtx->isLoadUnloadInProgress)
4109 {
4110 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4111 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
4112 return NULL;
4113 }
4114
4115
4116 if (0 != status)
4117 {
4118 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4119 "%s: HDD context is not valid", __func__);
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07004120 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07004121 }
4122
4123
4124 if (!mgmt)
4125 {
4126 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4127 "%s: memory allocation failed ", __func__);
4128 return NULL;
4129 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07004130
Jeff Johnson295189b2012-06-20 16:38:30 -07004131 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07004132
4133#ifdef WLAN_OPEN_SOURCE
4134 /* Android does not want the timestamp from the frame.
4135 Instead it wants a monotonic increasing value */
4136 get_monotonic_boottime(&ts);
4137 mgmt->u.probe_resp.timestamp =
4138 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
4139#else
4140 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07004141 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
4142 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07004143
4144#endif
4145
Jeff Johnson295189b2012-06-20 16:38:30 -07004146 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
4147 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004148
4149#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4150 /* GPS Requirement: need age ie per entry. Using vendor specific. */
4151 /* Assuming this is the last IE, copy at the end */
4152 ie_length -=sizeof(qcom_ie_age);
4153 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
4154 qie_age->element_id = QCOM_VENDOR_IE_ID;
4155 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
4156 qie_age->oui_1 = QCOM_OUI1;
4157 qie_age->oui_2 = QCOM_OUI2;
4158 qie_age->oui_3 = QCOM_OUI3;
4159 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
4160 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
4161#endif
4162
Jeff Johnson295189b2012-06-20 16:38:30 -07004163 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05304164 if (bss_desc->fProbeRsp)
4165 {
4166 mgmt->frame_control |=
4167 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
4168 }
4169 else
4170 {
4171 mgmt->frame_control |=
4172 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
4173 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004174
4175#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304176 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004177 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
4178 {
4179 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4180 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304181 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004182 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
4183
4184 {
4185 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4186 }
4187 else
4188 {
4189 kfree(mgmt);
4190 return NULL;
4191 }
4192#else
4193 freq = ieee80211_channel_to_frequency(chan_no);
4194#endif
4195 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004196 /*when the band is changed on the fly using the GUI, three things are done
4197 * 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)
4198 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
4199 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
4200 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
4201 * and discards the channels correponding to previous band and calls back with zero bss results.
4202 * 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
4203 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
4204 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
4205 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
4206 * So drop the bss and continue to next bss.
4207 */
4208 if(chan == NULL)
4209 {
4210 hddLog(VOS_TRACE_LEVEL_INFO, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07004211 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004212 return NULL;
4213 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004214 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304215 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07004216 * */
4217 if (( eConnectionState_Associated ==
4218 pAdapter->sessionCtx.station.conn_info.connState ) &&
4219 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
4220 pAdapter->sessionCtx.station.conn_info.bssId,
4221 WNI_CFG_BSSID_LEN)))
4222 {
4223 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
4224 rssi = (pAdapter->rssi * 100);
4225 }
4226 else
4227 {
4228 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
4229 }
4230
4231 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
4232 frame_len, rssi, GFP_KERNEL);
4233 kfree(mgmt);
4234 return bss_status;
4235}
4236
4237/*
4238 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
4239 * This function is used to update the BSS data base of CFG8011
4240 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304241struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004242 tCsrRoamInfo *pRoamInfo
4243 )
4244{
4245 tCsrRoamConnectedProfile roamProfile;
4246 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4247 struct cfg80211_bss *bss = NULL;
4248
4249 ENTER();
4250
4251 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
4252 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
4253
4254 if (NULL != roamProfile.pBssDesc)
4255 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304256 bss = wlan_hdd_cfg80211_inform_bss(pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004257 &roamProfile);
4258
4259 if (NULL == bss)
4260 {
4261 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
4262 __func__);
4263 }
4264
4265 sme_RoamFreeConnectProfile(hHal, &roamProfile);
4266 }
4267 else
4268 {
4269 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
4270 __func__);
4271 }
4272 return bss;
4273}
4274
4275/*
4276 * FUNCTION: wlan_hdd_cfg80211_update_bss
4277 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304278static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
4279 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07004280 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304281{
Jeff Johnson295189b2012-06-20 16:38:30 -07004282 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4283 tCsrScanResultInfo *pScanResult;
4284 eHalStatus status = 0;
4285 tScanResultHandle pResult;
4286 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07004287 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004288
4289 ENTER();
4290
Wilson Yangf80a0542013-10-07 13:02:37 -07004291 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4292
4293 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -07004294 {
Wilson Yangf80a0542013-10-07 13:02:37 -07004295 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4296 "%s:LOGP in Progress. Ignore!!!",__func__);
4297 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004298 }
4299
Wilson Yangf80a0542013-10-07 13:02:37 -07004300
4301 /*bss_update is not allowed during wlan driver loading or unloading*/
4302 if (pHddCtx->isLoadUnloadInProgress)
4303 {
4304 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4305 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
4306 return VOS_STATUS_E_PERM;
4307 }
4308
4309
Jeff Johnson295189b2012-06-20 16:38:30 -07004310 /*
4311 * start getting scan results and populate cgf80211 BSS database
4312 */
4313 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
4314
4315 /* no scan results */
4316 if (NULL == pResult)
4317 {
4318 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result\n", __func__);
4319 return status;
4320 }
4321
4322 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
4323
4324 while (pScanResult)
4325 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304326 /*
4327 * cfg80211_inform_bss() is not updating ie field of bss entry, if
4328 * entry already exists in bss data base of cfg80211 for that
4329 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
4330 * bss entry instead of cfg80211_inform_bss, But this call expects
4331 * mgmt packet as input. As of now there is no possibility to get
4332 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07004333 * ieee80211_mgmt(probe response) and passing to c
4334 * fg80211_inform_bss_frame.
4335 * */
4336
4337 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
4338 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304339
Jeff Johnson295189b2012-06-20 16:38:30 -07004340
4341 if (NULL == bss_status)
4342 {
4343 hddLog(VOS_TRACE_LEVEL_INFO,
4344 "%s: NULL returned by cfg80211_inform_bss\n", __func__);
4345 }
4346 else
4347 {
Yue Maf49ba872013-08-19 12:04:25 -07004348 cfg80211_put_bss(
4349#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
4350 wiphy,
4351#endif
4352 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004353 }
4354
4355 pScanResult = sme_ScanResultGetNext(hHal, pResult);
4356 }
4357
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304358 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07004359
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304360 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004361}
4362
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004363void
4364hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
4365{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304366 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -08004367 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004368} /****** end hddPrintMacAddr() ******/
4369
4370void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004371hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004372{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304373 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004374 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
4375 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
4376 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
4377 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004378} /****** end hddPrintPmkId() ******/
4379
4380//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
4381//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
4382
4383//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
4384//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
4385
4386#define dump_bssid(bssid) \
4387 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004388 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
4389 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
4390 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004391 }
4392
4393#define dump_pmkid(pMac, pmkid) \
4394 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004395 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
4396 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
4397 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004398 }
4399
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004400#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004401/*
4402 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
4403 * This function is used to notify the supplicant of a new PMKSA candidate.
4404 */
4405int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304406 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004407 int index, bool preauth )
4408{
Jeff Johnsone7245742012-09-05 17:12:55 -07004409#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004410 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004411 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004412
4413 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07004414 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004415
4416 if( NULL == pRoamInfo )
4417 {
4418 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL\n", __func__);
4419 return -EINVAL;
4420 }
4421
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004422 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
4423 {
4424 dump_bssid(pRoamInfo->bssid);
4425 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004426 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004427 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004428#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304429 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004430}
4431#endif //FEATURE_WLAN_LFR
4432
Yue Maef608272013-04-08 23:09:17 -07004433#ifdef FEATURE_WLAN_LFR_METRICS
4434/*
4435 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
4436 * 802.11r/LFR metrics reporting function to report preauth initiation
4437 *
4438 */
4439#define MAX_LFR_METRICS_EVENT_LENGTH 100
4440VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
4441 tCsrRoamInfo *pRoamInfo)
4442{
4443 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4444 union iwreq_data wrqu;
4445
4446 ENTER();
4447
4448 if (NULL == pAdapter)
4449 {
4450 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4451 return VOS_STATUS_E_FAILURE;
4452 }
4453
4454 /* create the event */
4455 memset(&wrqu, 0, sizeof(wrqu));
4456 memset(metrics_notification, 0, sizeof(metrics_notification));
4457
4458 wrqu.data.pointer = metrics_notification;
4459 wrqu.data.length = scnprintf(metrics_notification,
4460 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
4461 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
4462
4463 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4464
4465 EXIT();
4466
4467 return VOS_STATUS_SUCCESS;
4468}
4469
4470/*
4471 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
4472 * 802.11r/LFR metrics reporting function to report preauth completion
4473 * or failure
4474 */
4475VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
4476 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
4477{
4478 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4479 union iwreq_data wrqu;
4480
4481 ENTER();
4482
4483 if (NULL == pAdapter)
4484 {
4485 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4486 return VOS_STATUS_E_FAILURE;
4487 }
4488
4489 /* create the event */
4490 memset(&wrqu, 0, sizeof(wrqu));
4491 memset(metrics_notification, 0, sizeof(metrics_notification));
4492
4493 scnprintf(metrics_notification, sizeof(metrics_notification),
4494 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
4495 MAC_ADDR_ARRAY(pRoamInfo->bssid));
4496
4497 if (1 == preauth_status)
4498 strncat(metrics_notification, " TRUE", 5);
4499 else
4500 strncat(metrics_notification, " FALSE", 6);
4501
4502 wrqu.data.pointer = metrics_notification;
4503 wrqu.data.length = strlen(metrics_notification);
4504
4505 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4506
4507 EXIT();
4508
4509 return VOS_STATUS_SUCCESS;
4510}
4511
4512/*
4513 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
4514 * 802.11r/LFR metrics reporting function to report handover initiation
4515 *
4516 */
4517VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
4518 tCsrRoamInfo *pRoamInfo)
4519{
4520 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4521 union iwreq_data wrqu;
4522
4523 ENTER();
4524
4525 if (NULL == pAdapter)
4526 {
4527 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4528 return VOS_STATUS_E_FAILURE;
4529 }
4530
4531 /* create the event */
4532 memset(&wrqu, 0, sizeof(wrqu));
4533 memset(metrics_notification, 0, sizeof(metrics_notification));
4534
4535 wrqu.data.pointer = metrics_notification;
4536 wrqu.data.length = scnprintf(metrics_notification,
4537 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
4538 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
4539
4540 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4541
4542 EXIT();
4543
4544 return VOS_STATUS_SUCCESS;
4545}
4546#endif
4547
Jeff Johnson295189b2012-06-20 16:38:30 -07004548/*
4549 * FUNCTION: hdd_cfg80211_scan_done_callback
4550 * scanning callback function, called after finishing scan
4551 *
4552 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304553static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -07004554 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
4555{
4556 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304557 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004558 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004559 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4560 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07004561 struct cfg80211_scan_request *req = NULL;
4562 int ret = 0;
4563
4564 ENTER();
4565
4566 hddLog(VOS_TRACE_LEVEL_INFO,
4567 "%s called with halHandle = %p, pContext = %p,"
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304568 "scanID = %d, returned status = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07004569 __func__, halHandle, pContext, (int) scanId, (int) status);
4570
Kiet Lamac06e2c2013-10-23 16:25:07 +05304571 pScanInfo->mScanPendingCounter = 0;
4572
Jeff Johnson295189b2012-06-20 16:38:30 -07004573 //Block on scan req completion variable. Can't wait forever though.
4574 ret = wait_for_completion_interruptible_timeout(
4575 &pScanInfo->scan_req_completion_event,
4576 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
4577 if (!ret)
4578 {
4579 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004580 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004581 }
4582
Yue Maef608272013-04-08 23:09:17 -07004583 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004584 {
4585 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004586 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004587 }
4588
4589 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304590 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -07004591 {
4592 hddLog(VOS_TRACE_LEVEL_INFO,
4593 "%s called with mismatched scanId pScanInfo->scanId = %d "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304594 "scanId = %d \n", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004595 (int) scanId);
4596 }
4597
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304598 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004599 pAdapter);
4600
4601 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304602 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004603
4604
4605 /* If any client wait scan result through WEXT
4606 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004607 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07004608 {
4609 /* The other scan request waiting for current scan finish
4610 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004611 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004612 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004613 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07004614 }
4615 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004616 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004617 {
4618 struct net_device *dev = pAdapter->dev;
4619 union iwreq_data wrqu;
4620 int we_event;
4621 char *msg;
4622
4623 memset(&wrqu, '\0', sizeof(wrqu));
4624 we_event = SIOCGIWSCAN;
4625 msg = NULL;
4626 wireless_send_event(dev, we_event, &wrqu, msg);
4627 }
4628 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004629 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004630
4631 /* Get the Scan Req */
4632 req = pAdapter->request;
4633
4634 if (!req)
4635 {
4636 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL\n");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004637 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004638 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004639 }
4640
4641 /*
4642 * setting up 0, just in case.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304643 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004644 req->n_ssids = 0;
4645 req->n_channels = 0;
4646 req->ie = 0;
4647
Jeff Johnson295189b2012-06-20 16:38:30 -07004648 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07004649 /* Scan is no longer pending */
4650 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004651
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -07004652 /*
4653 * cfg80211_scan_done informing NL80211 about completion
4654 * of scanning
4655 */
4656 cfg80211_scan_done(req, false);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08004657 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07004658
Jeff Johnsone7245742012-09-05 17:12:55 -07004659allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004660 /* release the wake lock at the end of the scan*/
4661 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07004662
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004663 /* Acquire wakelock to handle the case where APP's tries to suspend
4664 * immediatly after the driver gets connect request(i.e after scan)
4665 * from supplicant, this result in app's is suspending and not able
4666 * to process the connect request to AP */
Amar Singhal6144c002013-05-03 16:11:42 -07004667 hdd_allow_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004668
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004669#ifdef FEATURE_WLAN_TDLS
4670 wlan_hdd_tdls_scan_done_callback(pAdapter);
4671#endif
4672
Jeff Johnson295189b2012-06-20 16:38:30 -07004673 EXIT();
4674 return 0;
4675}
4676
4677/*
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004678 * FUNCTION: hdd_isScanAllowed
4679 * Go through each adapter and check if scan allowed
4680 *
4681 */
4682v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx )
4683{
4684 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
4685 hdd_station_ctx_t *pHddStaCtx = NULL;
4686 hdd_adapter_t *pAdapter = NULL;
4687 VOS_STATUS status = 0;
4688 v_U8_t staId = 0;
4689 v_U8_t *staMac = NULL;
4690
4691 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
4692
4693 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
4694 {
4695 pAdapter = pAdapterNode->pAdapter;
4696
4697 if( pAdapter )
4698 {
4699 hddLog(VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304700 "%s: Adapter with device mode %d exists",
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004701 __func__, pAdapter->device_mode);
4702 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
4703 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4704 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
4705 {
4706 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4707 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
4708 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
4709 {
4710 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
4711 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08004712 "%s: client " MAC_ADDRESS_STR
4713 " is in the middle of WPS/EAPOL exchange.", __func__,
4714 MAC_ADDR_ARRAY(staMac));
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004715 return VOS_FALSE;
4716 }
4717 }
4718 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
4719 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
4720 {
4721 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
4722 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304723 if ((pAdapter->aStaInfo[staId].isUsed) &&
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004724 (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState))
4725 {
4726 staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
4727
4728 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08004729 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
4730 "middle of WPS/EAPOL exchange.", __func__,
4731 MAC_ADDR_ARRAY(staMac));
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004732 return VOS_FALSE;
4733 }
4734 }
4735 }
4736 }
4737 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
4738 pAdapterNode = pNext;
4739 }
4740 hddLog(VOS_TRACE_LEVEL_INFO,
4741 "%s: Scan allowed", __func__);
4742 return VOS_TRUE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304743}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004744
4745/*
Jeff Johnson295189b2012-06-20 16:38:30 -07004746 * FUNCTION: wlan_hdd_cfg80211_scan
4747 * this scan respond to scan trigger and update cfg80211 scan database
4748 * later, scan dump command can be used to recieve scan results
4749 */
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08004750int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
4751#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4752 struct net_device *dev,
4753#endif
4754 struct cfg80211_scan_request *request)
4755{
4756#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
4757 struct net_device *dev = request->wdev->netdev;
4758#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304759 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07004760 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4761 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304762 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004763 tCsrScanRequest scanRequest;
4764 tANI_U8 *channelList = NULL, i;
4765 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304766 int status;
4767 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004768 v_U8_t* pP2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004769
4770 ENTER();
4771
4772 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
4773 __func__,pAdapter->device_mode);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004774
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304775 status = wlan_hdd_validate_context(pHddCtx);
4776
4777 if (0 != status)
4778 {
4779 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4780 "%s: HDD context is not valid", __func__);
4781 return status;
4782 }
4783
4784 cfg_param = pHddCtx->cfg_ini;
4785 pScanInfo = &pHddCtx->scan_info;
4786
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004787 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004788 (eConnectionState_Connecting ==
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004789 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004790 {
4791 hddLog(VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08004792 "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \
4793 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004794 return -EBUSY;
4795 }
4796
Jeff Johnson295189b2012-06-20 16:38:30 -07004797#ifdef WLAN_BTAMP_FEATURE
4798 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004799 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -07004800 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004801 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004802 "%s: No scanning when AMP is on", __func__);
4803 return -EOPNOTSUPP;
4804 }
4805#endif
4806 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004807 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07004808 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004809 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004810 "%s: Not scanning on device_mode = %d",
4811 __func__, pAdapter->device_mode);
4812 return -EOPNOTSUPP;
4813 }
4814
4815 if (TRUE == pScanInfo->mScanPending)
4816 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05304817 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
4818 {
4819 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
4820 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004821 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004822 }
4823
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304824 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -07004825 //Channel and action frame is pending
4826 //Otherwise Cancel Remain On Channel and allow Scan
4827 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004828 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -07004829 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05304830 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -07004831 return -EBUSY;
4832 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004833#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004834 /* if tdls disagree scan right now, return immediately.
4835 tdls will schedule the scan when scan is allowed. (return SUCCESS)
4836 or will reject the scan if any TDLS is in progress. (return -EBUSY)
4837 */
4838 status = wlan_hdd_tdls_scan_callback (pAdapter,
4839 wiphy,
4840#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4841 dev,
Gopichand Nakkalac3c42b92013-03-20 19:42:34 -07004842#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004843 request);
4844 if(status <= 0)
4845 {
4846 hddLog(VOS_TRACE_LEVEL_INFO, "%s: TDLS Pending %d", __func__, status);
4847 return status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004848 }
4849#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07004850
Jeff Johnson295189b2012-06-20 16:38:30 -07004851 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
4852 {
4853 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -08004854 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004855 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304856 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004857 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
4858 {
4859 hddLog(VOS_TRACE_LEVEL_WARN,
4860 "%s: MAX TM Level Scan not allowed", __func__);
4861 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304862 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004863 }
4864 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
4865
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004866 /* Check if scan is allowed at this point of time.
4867 */
4868 if (!hdd_isScanAllowed(pHddCtx))
4869 {
4870 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
4871 return -EBUSY;
4872 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304873
Jeff Johnson295189b2012-06-20 16:38:30 -07004874 vos_mem_zero( &scanRequest, sizeof(scanRequest));
4875
4876 if (NULL != request)
4877 {
4878 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304879 (int)request->n_ssids);
Jeff Johnson295189b2012-06-20 16:38:30 -07004880
4881 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
4882 * Becasue of this, driver is assuming that this is not wildcard scan and so
4883 * is not aging out the scan results.
4884 */
Jeff Johnson32d95a32012-09-10 13:15:23 -07004885 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004886 {
4887 request->n_ssids = 0;
4888 }
4889
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004890 if ((request->ssids) && (0 < request->n_ssids))
Jeff Johnson295189b2012-06-20 16:38:30 -07004891 {
4892 tCsrSSIDInfo *SsidInfo;
4893 int j;
4894 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
4895 /* Allocate num_ssid tCsrSSIDInfo structure */
4896 SsidInfo = scanRequest.SSIDs.SSIDList =
4897 ( tCsrSSIDInfo *)vos_mem_malloc(
4898 request->n_ssids*sizeof(tCsrSSIDInfo));
4899
4900 if(NULL == scanRequest.SSIDs.SSIDList)
4901 {
4902 hddLog(VOS_TRACE_LEVEL_ERROR,
4903 "memory alloc failed SSIDInfo buffer");
4904 return -ENOMEM;
4905 }
4906
4907 /* copy all the ssid's and their length */
4908 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
4909 {
4910 /* get the ssid length */
4911 SsidInfo->SSID.length = request->ssids[j].ssid_len;
4912 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
4913 SsidInfo->SSID.length);
4914 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
4915 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "SSID number %d: %s",
4916 j, SsidInfo->SSID.ssId);
4917 }
4918 /* set the scan type to active */
4919 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4920 }
4921 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
4922 {
4923 /* set the scan type to active */
4924 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4925 }
4926 else
4927 {
4928 /*Set the scan type to default type, in this case it is ACTIVE*/
4929 scanRequest.scanType = pScanInfo->scan_mode;
4930 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304931 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07004932 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
4933 }
4934 else
4935 {
4936 /* set the scan type to active */
4937 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4938 vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff );
4939
4940 /* set min and max channel time to zero */
4941 scanRequest.minChnTime = 0;
4942 scanRequest.maxChnTime = 0;
4943 }
4944
4945 /* set BSSType to default type */
4946 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
4947
4948 /*TODO: scan the requested channels only*/
4949
4950 /*Right now scanning all the channels */
4951 if( request )
4952 {
4953 if( request->n_channels )
4954 {
4955 channelList = vos_mem_malloc( request->n_channels );
4956 if( NULL == channelList )
4957 {
4958 status = -ENOMEM;
4959 goto free_mem;
4960 }
4961
4962 for( i = 0 ; i < request->n_channels ; i++ )
4963 channelList[i] = request->channels[i]->hw_value;
4964 }
4965
4966 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
4967 scanRequest.ChannelInfo.ChannelList = channelList;
4968
4969 /* set requestType to full scan */
4970 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304971
4972 /* Flush the scan results(only p2p beacons) for STA scan and P2P
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004973 * search (Flush on both full scan and social scan but not on single
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304974 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004975 */
4976
4977 /* Supplicant does single channel scan after 8-way handshake
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304978 * and in that case driver shoudnt flush scan results. If
4979 * driver flushes the scan results here and unfortunately if
4980 * the AP doesnt respond to our probe req then association
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004981 * fails which is not desired
4982 */
4983
4984 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
4985 {
4986 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
4987 pAdapter->sessionId );
4988 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004989
4990 if( request->ie_len )
4991 {
4992 /* save this for future association (join requires this) */
4993 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
4994 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
4995 pScanInfo->scanAddIE.length = request->ie_len;
4996
4997 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07004998 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4999 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07005000 )
5001 {
5002 pwextBuf->roamProfile.pAddIEScan = pScanInfo->scanAddIE.addIEdata;
5003 pwextBuf->roamProfile.nAddIEScanLength = pScanInfo->scanAddIE.length;
5004 }
5005
5006 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
5007 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
5008
Jeff Johnson295189b2012-06-20 16:38:30 -07005009 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
5010 request->ie_len);
5011 if (pP2pIe != NULL)
5012 {
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07005013#ifdef WLAN_FEATURE_P2P_DEBUG
5014 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
5015 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
5016 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5017 {
5018 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
5019 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
5020 "Go nego completed to Connection is started");
5021 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
5022 "for 8way Handshake");
5023 }
5024 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
5025 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5026 {
5027 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
5028 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
5029 "Disconnected state to Connection is started");
5030 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
5031 "for 4way Handshake");
5032 }
5033#endif
5034
Jeff Johnsone7245742012-09-05 17:12:55 -07005035 /* no_cck will be set during p2p find to disable 11b rates */
5036 if(TRUE == request->no_cck)
Jeff Johnson295189b2012-06-20 16:38:30 -07005037 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005038 hddLog(VOS_TRACE_LEVEL_INFO,
5039 "%s: This is a P2P Search", __func__);
5040 scanRequest.p2pSearch = 1;
Jeff Johnsone7245742012-09-05 17:12:55 -07005041
Jeff Johnsone7245742012-09-05 17:12:55 -07005042 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
5043 {
Madan Mohan Koyyalamudi1b1d9e82012-10-21 11:38:33 -07005044 /* set requestType to P2P Discovery */
5045 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
Jeff Johnsone7245742012-09-05 17:12:55 -07005046 }
5047
5048 /*
5049 Skip Dfs Channel in case of P2P Search
5050 if it is set in ini file
5051 */
5052 if(cfg_param->skipDfsChnlInP2pSearch)
5053 {
5054 scanRequest.skipDfsChnlInP2pSearch = 1;
5055 }
5056 else
5057 {
5058 scanRequest.skipDfsChnlInP2pSearch = 0;
5059 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005060
Jeff Johnson295189b2012-06-20 16:38:30 -07005061 }
5062 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005063 }
5064 }
5065
5066 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
5067
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07005068 /* acquire the wakelock to avoid the apps suspend during the scan. To
5069 * address the following issues.
5070 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
5071 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
5072 * for long time, this result in apps running at full power for long time.
5073 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
5074 * be stuck in full power because of resume BMPS
5075 */
5076 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07005077
5078 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005079 pAdapter->sessionId, &scanRequest, &scanId,
5080 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -07005081
Jeff Johnson295189b2012-06-20 16:38:30 -07005082 if (eHAL_STATUS_SUCCESS != status)
5083 {
5084 hddLog(VOS_TRACE_LEVEL_ERROR,
5085 "%s: sme_ScanRequest returned error %d", __func__, status);
5086 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07005087 if(eHAL_STATUS_RESOURCES == status)
5088 {
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07005089 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 -07005090 status = -EBUSY;
5091 } else {
5092 status = -EIO;
5093 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07005094 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07005095 goto free_mem;
5096 }
5097
5098 pScanInfo->mScanPending = TRUE;
5099 pAdapter->request = request;
5100 pScanInfo->scanId = scanId;
5101
5102 complete(&pScanInfo->scan_req_completion_event);
5103
5104free_mem:
5105 if( scanRequest.SSIDs.SSIDList )
5106 {
5107 vos_mem_free(scanRequest.SSIDs.SSIDList);
5108 }
5109
5110 if( channelList )
5111 vos_mem_free( channelList );
5112
5113 EXIT();
5114
5115 return status;
5116}
5117
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005118
5119void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
5120{
5121 v_U8_t iniDot11Mode =
5122 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
5123 eHddDot11Mode hddDot11Mode = iniDot11Mode;
5124
5125 switch ( iniDot11Mode )
5126 {
5127 case eHDD_DOT11_MODE_AUTO:
5128 case eHDD_DOT11_MODE_11ac:
5129 case eHDD_DOT11_MODE_11ac_ONLY:
5130#ifdef WLAN_FEATURE_11AC
5131 hddDot11Mode = eHDD_DOT11_MODE_11ac;
5132#else
5133 hddDot11Mode = eHDD_DOT11_MODE_11n;
5134#endif
5135 break;
5136 case eHDD_DOT11_MODE_11n:
5137 case eHDD_DOT11_MODE_11n_ONLY:
5138 hddDot11Mode = eHDD_DOT11_MODE_11n;
5139 break;
5140 default:
5141 hddDot11Mode = iniDot11Mode;
5142 break;
5143 }
5144 /* This call decides required channel bonding mode */
5145 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
5146 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
5147 operationChannel);
5148}
5149
Jeff Johnson295189b2012-06-20 16:38:30 -07005150/*
5151 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305152 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -07005153 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305154int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -07005155 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07005156{
5157 int status = 0;
5158 hdd_wext_state_t *pWextState;
5159 v_U32_t roamId;
5160 tCsrRoamProfile *pRoamProfile;
5161 eMib_dot11DesiredBssType connectedBssType;
5162 eCsrAuthType RSNAuthType;
5163
5164 ENTER();
5165
5166 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305167
Jeff Johnson295189b2012-06-20 16:38:30 -07005168 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
5169 {
5170 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
5171 return -EINVAL;
5172 }
5173
5174 pRoamProfile = &pWextState->roamProfile;
5175
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305176 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07005177 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005178 int ret = 0;
5179 hdd_station_ctx_t *pHddStaCtx;
5180 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5181 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
5182
5183 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
5184 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
5185 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
Jeff Johnson295189b2012-06-20 16:38:30 -07005186 {
5187 /* Issue disconnect to CSR */
5188 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305189 if( eHAL_STATUS_SUCCESS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07005190 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
5191 pAdapter->sessionId,
5192 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
5193 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005194 ret = wait_for_completion_interruptible_timeout(
5195 &pAdapter->disconnect_comp_var,
5196 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5197 if (0 == ret)
5198 {
5199 VOS_ASSERT(0);
5200 }
5201 }
5202 }
5203 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
5204 {
5205 ret = wait_for_completion_interruptible_timeout(
5206 &pAdapter->disconnect_comp_var,
5207 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5208 if (0 == ret)
5209 {
5210 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005211 }
5212 }
5213
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305214 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07005215 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
5216 {
5217 /*QoS not enabled in cfg file*/
5218 pRoamProfile->uapsd_mask = 0;
5219 }
5220 else
5221 {
5222 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305223 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -07005224 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
5225 }
5226
5227 pRoamProfile->SSIDs.numOfSSIDs = 1;
5228 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
5229 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305230 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005231 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
5232 ssid, ssid_len);
5233
5234 if (bssid)
5235 {
5236 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
5237 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
5238 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305239 /* Save BSSID in seperate variable as well, as RoamProfile
5240 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -07005241 case of join failure we should send valid BSSID to supplicant
5242 */
5243 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
5244 WNI_CFG_BSSID_LEN);
5245 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07005246 else
5247 {
5248 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
5249 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005250
5251 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
5252 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305253 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005254 /*set gen ie*/
5255 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
5256 /*set auth*/
5257 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5258 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005259#ifdef FEATURE_WLAN_WAPI
5260 if (pAdapter->wapi_info.nWapiMode)
5261 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005262 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005263 switch (pAdapter->wapi_info.wapiAuthMode)
5264 {
5265 case WAPI_AUTH_MODE_PSK:
5266 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005267 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005268 pAdapter->wapi_info.wapiAuthMode);
5269 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5270 break;
5271 }
5272 case WAPI_AUTH_MODE_CERT:
5273 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005274 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005275 pAdapter->wapi_info.wapiAuthMode);
5276 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5277 break;
5278 }
5279 } // End of switch
5280 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5281 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
5282 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005283 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005284 pRoamProfile->AuthType.numEntries = 1;
5285 pRoamProfile->EncryptionType.numEntries = 1;
5286 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5287 pRoamProfile->mcEncryptionType.numEntries = 1;
5288 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5289 }
5290 }
5291#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305292#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305293 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305294 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
5295 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5296 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305297 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
5298 sizeof (tSirGtkOffloadParams));
5299 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305300 }
5301#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005302 pRoamProfile->csrPersona = pAdapter->device_mode;
5303
Jeff Johnson32d95a32012-09-10 13:15:23 -07005304 if( operatingChannel )
5305 {
5306 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
5307 pRoamProfile->ChannelInfo.numOfChannels = 1;
5308 }
Chet Lanctot186b5732013-03-18 10:26:30 -07005309 else
5310 {
5311 pRoamProfile->ChannelInfo.ChannelList = NULL;
5312 pRoamProfile->ChannelInfo.numOfChannels = 0;
5313 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005314 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
5315 {
5316 hdd_select_cbmode(pAdapter,operatingChannel);
5317 }
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005318 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
5319 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305320 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005321 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005322 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
5323 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305324 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5325 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005326 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5327 eConnectionState_Connecting);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305328
5329 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005330 pAdapter->sessionId, pRoamProfile, &roamId);
5331
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305332 if ((eHAL_STATUS_SUCCESS != status) &&
5333 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5334 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305335
5336 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005337 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
5338 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
5339 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305340 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005341 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305342 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005343
5344 pRoamProfile->ChannelInfo.ChannelList = NULL;
5345 pRoamProfile->ChannelInfo.numOfChannels = 0;
5346
Jeff Johnson295189b2012-06-20 16:38:30 -07005347 }
5348 else
5349 {
5350 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
5351 return -EINVAL;
5352 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005353 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005354 return status;
5355}
5356
5357/*
5358 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
5359 * This function is used to set the authentication type (OPEN/SHARED).
5360 *
5361 */
5362static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
5363 enum nl80211_auth_type auth_type)
5364{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305365 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005366 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5367
5368 ENTER();
5369
5370 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305371 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -07005372 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005373 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305374 hddLog(VOS_TRACE_LEVEL_INFO,
5375 "%s: set authentication type to AUTOSWITCH", __func__);
5376 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
5377 break;
5378
5379 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07005380#ifdef WLAN_FEATURE_VOWIFI_11R
5381 case NL80211_AUTHTYPE_FT:
5382#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305383 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005384 "%s: set authentication type to OPEN", __func__);
5385 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5386 break;
5387
5388 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305389 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005390 "%s: set authentication type to SHARED", __func__);
5391 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
5392 break;
5393#ifdef FEATURE_WLAN_CCX
5394 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305395 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005396 "%s: set authentication type to CCKM WPA", __func__);
5397 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
5398 break;
5399#endif
5400
5401
5402 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305403 hddLog(VOS_TRACE_LEVEL_ERROR,
5404 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 auth_type);
5406 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
5407 return -EINVAL;
5408 }
5409
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305410 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005411 pHddStaCtx->conn_info.authType;
5412 return 0;
5413}
5414
5415/*
5416 * FUNCTION: wlan_hdd_set_akm_suite
5417 * This function is used to set the key mgmt type(PSK/8021x).
5418 *
5419 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305420static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005421 u32 key_mgmt
5422 )
5423{
5424 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5425 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305426
Jeff Johnson295189b2012-06-20 16:38:30 -07005427 /*set key mgmt type*/
5428 switch(key_mgmt)
5429 {
5430 case WLAN_AKM_SUITE_PSK:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305431#ifdef WLAN_FEATURE_VOWIFI_11R
5432 case WLAN_AKM_SUITE_FT_PSK:
5433#endif
5434 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -07005435 __func__);
5436 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5437 break;
5438
5439 case WLAN_AKM_SUITE_8021X:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305440#ifdef WLAN_FEATURE_VOWIFI_11R
5441 case WLAN_AKM_SUITE_FT_8021X:
5442#endif
5443 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -07005444 __func__);
5445 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5446 break;
5447#ifdef FEATURE_WLAN_CCX
5448#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
5449#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5450 case WLAN_AKM_SUITE_CCKM:
5451 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
5452 __func__);
5453 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
5454 break;
5455#endif
5456
5457 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305458 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005459 __func__, key_mgmt);
5460 return -EINVAL;
5461
5462 }
5463 return 0;
5464}
5465
5466/*
5467 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305468 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -07005469 * (NONE/WEP40/WEP104/TKIP/CCMP).
5470 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305471static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
5472 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -07005473 bool ucast
5474 )
5475{
5476 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305477 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005478 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5479
5480 ENTER();
5481
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305482 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005483 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305484 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -07005485 __func__, cipher);
5486 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5487 }
5488 else
5489 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305490
Jeff Johnson295189b2012-06-20 16:38:30 -07005491 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305492 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005493 {
5494 case IW_AUTH_CIPHER_NONE:
5495 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5496 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305497
Jeff Johnson295189b2012-06-20 16:38:30 -07005498 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305499 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07005500 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305501
Jeff Johnson295189b2012-06-20 16:38:30 -07005502 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305503 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
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_TKIP:
5507 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5508 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305509
Jeff Johnson295189b2012-06-20 16:38:30 -07005510 case WLAN_CIPHER_SUITE_CCMP:
5511 encryptionType = eCSR_ENCRYPT_TYPE_AES;
5512 break;
5513#ifdef FEATURE_WLAN_WAPI
5514 case WLAN_CIPHER_SUITE_SMS4:
5515 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
5516 break;
5517#endif
5518
5519#ifdef FEATURE_WLAN_CCX
5520 case WLAN_CIPHER_SUITE_KRK:
5521 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
5522 break;
5523#endif
5524 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305525 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005526 __func__, cipher);
5527 return -EOPNOTSUPP;
5528 }
5529 }
5530
5531 if (ucast)
5532 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305533 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005534 __func__, encryptionType);
5535 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
5536 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305537 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005538 encryptionType;
5539 }
5540 else
5541 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305542 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005543 __func__, encryptionType);
5544 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
5545 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5546 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
5547 }
5548
5549 return 0;
5550}
5551
5552
5553/*
5554 * FUNCTION: wlan_hdd_cfg80211_set_ie
5555 * This function is used to parse WPA/RSN IE's.
5556 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305557int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
5558 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -07005559 size_t ie_len
5560 )
5561{
5562 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5563 u8 *genie = ie;
5564 v_U16_t remLen = ie_len;
5565#ifdef FEATURE_WLAN_WAPI
5566 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
5567 u16 *tmp;
5568 v_U16_t akmsuiteCount;
5569 int *akmlist;
5570#endif
5571 ENTER();
5572
5573 /* clear previous assocAddIE */
5574 pWextState->assocAddIE.length = 0;
5575 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
5576
5577 while (remLen >= 2)
5578 {
5579 v_U16_t eLen = 0;
5580 v_U8_t elementId;
5581 elementId = *genie++;
5582 eLen = *genie++;
5583 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305584
5585 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005586 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305587
5588 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -07005589 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305590 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005591 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 -07005592 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305593 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005594 "%s: Invalid WPA IE", __func__);
5595 return -EINVAL;
5596 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305597 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -07005598 {
5599 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305600 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005601 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305602
Jeff Johnson295189b2012-06-20 16:38:30 -07005603 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5604 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005605 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
5606 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005607 VOS_ASSERT(0);
5608 return -ENOMEM;
5609 }
5610 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5611 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5612 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305613
Jeff Johnson295189b2012-06-20 16:38:30 -07005614 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
5615 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5616 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5617 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305618 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
5619 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005620 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
5621 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5622 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
5623 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
5624 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
5625 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305626 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +05305627 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -07005628 {
5629 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305630 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005631 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305632
Jeff Johnson295189b2012-06-20 16:38:30 -07005633 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5634 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005635 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5636 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005637 VOS_ASSERT(0);
5638 return -ENOMEM;
5639 }
5640 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5641 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5642 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305643
Jeff Johnson295189b2012-06-20 16:38:30 -07005644 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5645 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5646 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005647#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305648 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
5649 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005650 /*Consider WFD IE, only for P2P Client */
5651 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5652 {
5653 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305654 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005655 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305656
Jeff Johnson295189b2012-06-20 16:38:30 -07005657 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5658 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005659 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5660 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005661 VOS_ASSERT(0);
5662 return -ENOMEM;
5663 }
5664 // WFD IE is saved to Additional IE ; it should be accumulated to handle
5665 // WPS IE + P2P IE + WFD IE
5666 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5667 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305668
Jeff Johnson295189b2012-06-20 16:38:30 -07005669 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5670 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5671 }
5672#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005673 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305674 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005675 HS20_OUI_TYPE_SIZE)) )
5676 {
5677 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305678 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005679 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005680
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005681 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5682 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005683 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5684 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005685 VOS_ASSERT(0);
5686 return -ENOMEM;
5687 }
5688 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5689 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005690
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005691 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5692 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5693 }
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005694
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -07005695 if (WLAN_HDD_IBSS == pAdapter->device_mode) {
5696
5697 /* populating as ADDIE in beacon frames */
5698 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5699 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
5700 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
5701 {
5702 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
5703 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
5704 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5705 {
5706 hddLog(LOGE,
5707 "Coldn't pass "
5708 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
5709 }
5710 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
5711 else
5712 hddLog(LOGE,
5713 "Could not pass on "
5714 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
5715
5716 /* IBSS mode doesn't contain params->proberesp_ies still
5717 beaconIE's need to be populated in probe response frames */
5718 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
5719 {
5720 u16 rem_probe_resp_ie_len = eLen + 2;
5721 u8 probe_rsp_ie_len[3] = {0};
5722 u8 counter = 0;
5723
5724 /* Check Probe Resp Length if it is greater then 255 then
5725 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
5726 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
5727 not able Store More then 255 bytes into One Variable */
5728
5729 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
5730 {
5731 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
5732 {
5733 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
5734 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
5735 }
5736 else
5737 {
5738 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
5739 rem_probe_resp_ie_len = 0;
5740 }
5741 }
5742
5743 rem_probe_resp_ie_len = 0;
5744
5745 if (probe_rsp_ie_len[0] > 0)
5746 {
5747 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5748 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
5749 (tANI_U8*)(genie - 2),
5750 probe_rsp_ie_len[0], NULL,
5751 eANI_BOOLEAN_FALSE)
5752 == eHAL_STATUS_FAILURE)
5753 {
5754 hddLog(LOGE,
5755 "Could not pass"
5756 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
5757 }
5758 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
5759 }
5760
5761 if (probe_rsp_ie_len[1] > 0)
5762 {
5763 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5764 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
5765 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
5766 probe_rsp_ie_len[1], NULL,
5767 eANI_BOOLEAN_FALSE)
5768 == eHAL_STATUS_FAILURE)
5769 {
5770 hddLog(LOGE,
5771 "Could not pass"
5772 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
5773 }
5774 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
5775 }
5776
5777 if (probe_rsp_ie_len[2] > 0)
5778 {
5779 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5780 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
5781 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
5782 probe_rsp_ie_len[2], NULL,
5783 eANI_BOOLEAN_FALSE)
5784 == eHAL_STATUS_FAILURE)
5785 {
5786 hddLog(LOGE,
5787 "Could not pass"
5788 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
5789 }
5790 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
5791 }
5792
5793 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
5794 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
5795 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5796 {
5797 hddLog(LOGE,
5798 "Could not pass"
5799 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
5800 }
5801 }
5802 else
5803 {
5804 // Reset WNI_CFG_PROBE_RSP Flags
5805 wlan_hdd_reset_prob_rspies(pAdapter);
5806
5807 hddLog(VOS_TRACE_LEVEL_INFO,
5808 "%s: No Probe Response IE received in set beacon",
5809 __func__);
5810 }
5811 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -07005812 break;
5813 case DOT11F_EID_RSN:
5814 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
5815 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5816 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
5817 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
5818 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
5819 break;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005820 /* Appending Extended Capabilities with Interworking bit set in Assoc Req */
5821 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305822 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005823 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305824 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005825 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305826
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005827 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5828 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005829 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5830 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005831 VOS_ASSERT(0);
5832 return -ENOMEM;
5833 }
5834 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5835 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305836
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005837 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5838 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5839 break;
5840 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005841#ifdef FEATURE_WLAN_WAPI
5842 case WLAN_EID_WAPI:
5843 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005844 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07005845 pAdapter->wapi_info.nWapiMode);
5846 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305847 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -07005848 akmsuiteCount = WPA_GET_LE16(tmp);
5849 tmp = tmp + 1;
5850 akmlist = (int *)(tmp);
5851 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
5852 {
5853 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
5854 }
5855 else
5856 {
5857 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count\n");
5858 VOS_ASSERT(0);
5859 return -EINVAL;
5860 }
5861
5862 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
5863 {
5864 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005865 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005866 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305867 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005868 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305869 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005870 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005871 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005872 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5873 }
5874 break;
5875#endif
5876 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305877 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005878 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005879 /* when Unknown IE is received we should break and continue
5880 * to the next IE in the buffer instead we were returning
5881 * so changing this to break */
5882 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005883 }
5884 genie += eLen;
5885 remLen -= eLen;
5886 }
5887 EXIT();
5888 return 0;
5889}
5890
5891/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +05305892 * FUNCTION: hdd_isWPAIEPresent
5893 * Parse the received IE to find the WPA IE
5894 *
5895 */
5896static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
5897{
5898 v_U8_t eLen = 0;
5899 v_U16_t remLen = ie_len;
5900 v_U8_t elementId = 0;
5901
5902 while (remLen >= 2)
5903 {
5904 elementId = *ie++;
5905 eLen = *ie++;
5906 remLen -= 2;
5907 if (eLen > remLen)
5908 {
5909 hddLog(VOS_TRACE_LEVEL_ERROR,
5910 "%s: IE length is wrong %d", __func__, eLen);
5911 return FALSE;
5912 }
5913 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
5914 {
5915 /* OUI - 0x00 0X50 0XF2
5916 WPA Information Element - 0x01
5917 WPA version - 0x01*/
5918 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
5919 return TRUE;
5920 }
5921 ie += eLen;
5922 remLen -= eLen;
5923 }
5924 return FALSE;
5925}
5926
5927/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005928 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305929 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005930 * parameters during connect operation.
5931 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305932int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005933 struct cfg80211_connect_params *req
5934 )
5935{
5936 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305937 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005938 ENTER();
5939
5940 /*set wpa version*/
5941 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
5942
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305943 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005944 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +05305945 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005946 {
5947 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
5948 }
5949 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
5950 {
5951 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
5952 }
5953 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305954
5955 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005956 pWextState->wpaVersion);
5957
5958 /*set authentication type*/
5959 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
5960
5961 if (0 > status)
5962 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305963 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005964 "%s: failed to set authentication type ", __func__);
5965 return status;
5966 }
5967
5968 /*set key mgmt type*/
5969 if (req->crypto.n_akm_suites)
5970 {
5971 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
5972 if (0 > status)
5973 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305974 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -07005975 __func__);
5976 return status;
5977 }
5978 }
5979
5980 /*set pairwise cipher type*/
5981 if (req->crypto.n_ciphers_pairwise)
5982 {
5983 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
5984 req->crypto.ciphers_pairwise[0], true);
5985 if (0 > status)
5986 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305987 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005988 "%s: failed to set unicast cipher type", __func__);
5989 return status;
5990 }
5991 }
5992 else
5993 {
5994 /*Reset previous cipher suite to none*/
5995 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
5996 if (0 > status)
5997 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305998 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005999 "%s: failed to set unicast cipher type", __func__);
6000 return status;
6001 }
6002 }
6003
6004 /*set group cipher type*/
6005 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
6006 false);
6007
6008 if (0 > status)
6009 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306010 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -07006011 __func__);
6012 return status;
6013 }
6014
Chet Lanctot186b5732013-03-18 10:26:30 -07006015#ifdef WLAN_FEATURE_11W
6016 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
6017#endif
6018
Jeff Johnson295189b2012-06-20 16:38:30 -07006019 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
6020 if (req->ie_len)
6021 {
6022 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
6023 if ( 0 > status)
6024 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306025 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006026 __func__);
6027 return status;
6028 }
6029 }
6030
6031 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306032 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006033 {
6034 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
6035 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
6036 )
6037 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306038 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -07006039 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
6040 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306041 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07006042 __func__);
6043 return -EOPNOTSUPP;
6044 }
6045 else
6046 {
6047 u8 key_len = req->key_len;
6048 u8 key_idx = req->key_idx;
6049
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306050 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006051 && (CSR_MAX_NUM_KEY > key_idx)
6052 )
6053 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306054 hddLog(VOS_TRACE_LEVEL_INFO,
6055 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006056 __func__, key_idx, key_len);
6057 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306058 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07006059 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306060 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -07006061 (u8)key_len;
6062 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
6063 }
6064 }
6065 }
6066 }
6067
6068 return status;
6069}
6070
6071/*
6072 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306073 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006074 * parameters during connect operation.
6075 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306076static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006077 struct net_device *ndev,
6078 struct cfg80211_connect_params *req
6079 )
6080{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306081 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306082 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006083 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
6084 hdd_context_t *pHddCtx = NULL;
6085
6086 ENTER();
6087
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306088 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006089 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6090
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306091 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6092 status = wlan_hdd_validate_context(pHddCtx);
6093
6094 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006095 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306096 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6097 "%s: HDD context is not valid", __func__);
6098 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006099 }
6100
6101#ifdef WLAN_BTAMP_FEATURE
6102 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306103 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -07006104 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306105 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006106 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08006107 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -07006108 }
6109#endif
6110 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306111 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -07006112
6113 if ( 0 > status)
6114 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306115 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -07006116 __func__);
6117 return status;
6118 }
6119
6120 //If Device Mode is Station Concurrent Sessions Exit BMps
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006121 //P2P Mode will be taken care in Open/close adapter
Jeff Johnson295189b2012-06-20 16:38:30 -07006122 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
6123 (vos_concurrent_sessions_running()))
6124 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306125 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
Jeff Johnson295189b2012-06-20 16:38:30 -07006126 }
6127
Mohit Khanna765234a2012-09-11 15:08:35 -07006128 if ( req->channel )
6129 {
6130 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
6131 req->ssid_len, req->bssid,
6132 req->channel->hw_value);
6133 }
6134 else
6135 {
6136 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306137 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -07006138 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006139
6140 if (0 > status)
6141 {
6142 //ReEnable BMPS if disabled
6143 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
6144 (NULL != pHddCtx))
6145 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306146 if (pHddCtx->hdd_wlan_suspended)
6147 {
6148 hdd_set_pwrparams(pHddCtx);
6149 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006150 //ReEnable Bmps and Imps back
6151 hdd_enable_bmps_imps(pHddCtx);
6152 }
6153
6154 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6155 return status;
6156 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306157 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006158 EXIT();
6159 return status;
6160}
6161
6162
6163/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306164 * FUNCTION: wlan_hdd_disconnect
6165 * This function is used to issue a disconnect request to SME
6166 */
6167int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
6168{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306169 int status;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306170 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306171 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6172
6173 status = wlan_hdd_validate_context(pHddCtx);
6174
6175 if (0 != status)
6176 {
6177 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6178 "%s: HDD context is not valid", __func__);
6179 return status;
6180 }
6181
6182 pHddCtx->isAmpAllowed = VOS_TRUE;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306183 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306184 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306185
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306186 /*issue disconnect*/
6187 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
6188 pAdapter->sessionId, reason);
6189
6190 if ( 0 != status )
6191 {
6192 hddLog(VOS_TRACE_LEVEL_ERROR,
6193 "%s csrRoamDisconnect failure, returned %d \n",
6194 __func__, (int)status );
6195 return -EINVAL;
6196 }
6197 wait_for_completion_interruptible_timeout(
6198 &pAdapter->disconnect_comp_var,
6199 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6200 /*stop tx queues*/
6201 netif_tx_disable(pAdapter->dev);
6202 netif_carrier_off(pAdapter->dev);
6203 return status;
6204}
6205
6206
6207/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006208 * FUNCTION: wlan_hdd_cfg80211_disconnect
6209 * This function is used to issue a disconnect request to SME
6210 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306211static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006212 struct net_device *dev,
6213 u16 reason
6214 )
6215{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306216 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6217 tCsrRoamProfile *pRoamProfile =
Jeff Johnson295189b2012-06-20 16:38:30 -07006218 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306219 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006220 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006221 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306222#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006223 tANI_U8 staIdx;
6224#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306225
Jeff Johnson295189b2012-06-20 16:38:30 -07006226 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306227
6228 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006229 __func__,pAdapter->device_mode);
6230
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306231 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
6232 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006233
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306234 status = wlan_hdd_validate_context(pHddCtx);
6235
6236 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006237 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306238 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6239 "%s: HDD context is not valid", __func__);
6240 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006241 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306242
Jeff Johnson295189b2012-06-20 16:38:30 -07006243 if (NULL != pRoamProfile)
6244 {
6245 /*issue disconnect request to SME, if station is in connected state*/
6246 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated)
6247 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306248 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07006249 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306250 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07006251 switch(reason)
6252 {
6253 case WLAN_REASON_MIC_FAILURE:
6254 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
6255 break;
6256
6257 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
6258 case WLAN_REASON_DISASSOC_AP_BUSY:
6259 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
6260 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
6261 break;
6262
6263 case WLAN_REASON_PREV_AUTH_NOT_VALID:
6264 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
6265 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
6266 break;
6267
6268 case WLAN_REASON_DEAUTH_LEAVING:
6269 default:
6270 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
6271 break;
6272 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306273 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
6274 pScanInfo = &pHddCtx->scan_info;
6275 if (pScanInfo->mScanPending)
6276 {
6277 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
6278 "Aborting Scan");
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306279 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306280 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006281
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006282#ifdef FEATURE_WLAN_TDLS
6283 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006284 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006285 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006286 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
6287 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006288 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006289 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006290 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006291 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006292 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006293 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006294 MAC_ADDR_ARRAY(mac));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006295 sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006296 pAdapter->sessionId,
6297 mac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006298 }
6299 }
6300#endif
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306301 status = wlan_hdd_disconnect(pAdapter, reasonCode);
6302 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -07006303 {
6304 hddLog(VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306305 "%s wlan_hdd_disconnect failure, returned %d \n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006306 __func__, (int)status );
6307 return -EINVAL;
6308 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006309 }
6310 }
6311 else
6312 {
6313 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
6314 }
6315
6316 return status;
6317}
6318
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306319
Jeff Johnson295189b2012-06-20 16:38:30 -07006320/*
6321 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306322 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006323 * settings in IBSS mode.
6324 */
6325static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306326 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006327 struct cfg80211_ibss_params *params
6328 )
6329{
6330 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306331 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006332 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6333 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306334
Jeff Johnson295189b2012-06-20 16:38:30 -07006335 ENTER();
6336
6337 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -07006338 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006339
6340 if (params->ie_len && ( NULL != params->ie) )
6341 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006342 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6343 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006344 {
6345 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
6346 encryptionType = eCSR_ENCRYPT_TYPE_AES;
6347 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006348 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006349 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006350 tDot11fIEWPA dot11WPAIE;
6351 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006352 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006353
Wilson Yang00256342013-10-10 23:13:38 -07006354 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006355 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6356 params->ie_len, DOT11F_EID_WPA);
6357 if ( NULL != ie )
6358 {
6359 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
6360 // Unpack the WPA IE
6361 //Skip past the EID byte and length byte - and four byte WiFi OUI
6362 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
6363 &ie[2+4],
6364 ie[1] - 4,
6365 &dot11WPAIE);
6366 /*Extract the multicast cipher, the encType for unicast
6367 cipher for wpa-none is none*/
6368 encryptionType =
6369 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
6370 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006371 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006372
Jeff Johnson295189b2012-06-20 16:38:30 -07006373 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
6374
6375 if (0 > status)
6376 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306377 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006378 __func__);
6379 return status;
6380 }
6381 }
6382
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306383 pWextState->roamProfile.AuthType.authType[0] =
6384 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -07006385 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6386
6387 if (params->privacy)
6388 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306389 /* Security enabled IBSS, At this time there is no information available
6390 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -07006391 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306392 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -07006393 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306394 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -07006395 *enable privacy bit in beacons */
6396
6397 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6398 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006399 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
6400 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07006401 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
6402 pWextState->roamProfile.EncryptionType.numEntries = 1;
6403 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07006404 return status;
6405}
6406
6407/*
6408 * FUNCTION: wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306409 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006410 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306411static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006412 struct net_device *dev,
6413 struct cfg80211_ibss_params *params
6414 )
6415{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306416 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006417 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6418 tCsrRoamProfile *pRoamProfile;
6419 int status;
krunal sonie9002db2013-11-25 14:24:17 -08006420 bool alloc_bssid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006421 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306422 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006423
6424 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306425
6426 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006427 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6428
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306429 status = wlan_hdd_validate_context(pHddCtx);
6430
6431 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006432 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306433 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6434 "%s: HDD context is not valid", __func__);
6435 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006436 }
6437
6438 if (NULL == pWextState)
6439 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306440 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006441 __func__);
6442 return -EIO;
6443 }
6444
6445 pRoamProfile = &pWextState->roamProfile;
6446
6447 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
6448 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306449 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006450 "%s Interface type is not set to IBSS \n", __func__);
6451 return -EINVAL;
6452 }
6453
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -07006454 /* BSSID is provided by upper layers hence no need to AUTO generate */
6455 if (NULL != params->bssid) {
6456 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
6457 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
6458 hddLog (VOS_TRACE_LEVEL_ERROR,
6459 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
6460 return -EIO;
6461 }
6462 }
krunal sonie9002db2013-11-25 14:24:17 -08006463 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
6464 {
6465 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
6466 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
6467 {
6468 hddLog (VOS_TRACE_LEVEL_ERROR,
6469 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
6470 return -EIO;
6471 }
6472 params->bssid = vos_mem_malloc(sizeof(VOS_MAC_ADDR_SIZE));
6473 if (!params->bssid)
6474 {
6475 hddLog (VOS_TRACE_LEVEL_ERROR,
6476 "%s:Failed memory allocation", __func__);
6477 return -EIO;
6478 }
6479 vos_mem_copy((v_U8_t *)params->bssid,
6480 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
6481 VOS_MAC_ADDR_SIZE);
6482 alloc_bssid = VOS_TRUE;
6483 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -07006484
Jeff Johnson295189b2012-06-20 16:38:30 -07006485 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -07006486 if (NULL !=
6487#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6488 params->chandef.chan)
6489#else
6490 params->channel)
6491#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006492 {
6493 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006494 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6495 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6496 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6497 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006498
6499 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306500 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -07006501 ieee80211_frequency_to_channel(
6502#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6503 params->chandef.chan->center_freq);
6504#else
6505 params->channel->center_freq);
6506#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006507
6508 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6509 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -07006510 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006511 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
6512 __func__);
6513 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -07006514 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006515
6516 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006517 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006518 if (channelNum == validChan[indx])
6519 {
6520 break;
6521 }
6522 }
6523 if (indx >= numChans)
6524 {
6525 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006526 __func__, channelNum);
6527 return -EINVAL;
6528 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006529 /* Set the Operational Channel */
6530 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
6531 channelNum);
6532 pRoamProfile->ChannelInfo.numOfChannels = 1;
6533 pHddStaCtx->conn_info.operationChannel = channelNum;
6534 pRoamProfile->ChannelInfo.ChannelList =
6535 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006536 }
6537
6538 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306539 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -07006540 if (status < 0)
6541 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306542 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -07006543 __func__);
6544 return status;
6545 }
6546
6547 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306548 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006549 params->ssid_len, params->bssid,
6550 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006551
6552 if (0 > status)
6553 {
6554 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6555 return status;
6556 }
6557
krunal sonie9002db2013-11-25 14:24:17 -08006558 if (NULL != params->bssid &&
6559 pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 &&
6560 alloc_bssid == VOS_TRUE)
6561 {
6562 vos_mem_free(params->bssid);
6563 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006564 return 0;
6565}
6566
6567/*
6568 * FUNCTION: wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306569 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006570 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306571static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006572 struct net_device *dev
6573 )
6574{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306575 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006576 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6577 tCsrRoamProfile *pRoamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306578 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6579 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006580
6581 ENTER();
6582
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306583 status = wlan_hdd_validate_context(pHddCtx);
6584
6585 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006586 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306587 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6588 "%s: HDD context is not valid", __func__);
6589 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006590 }
6591
Jeff Johnson295189b2012-06-20 16:38:30 -07006592 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6593 if (NULL == pWextState)
6594 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306595 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006596 __func__);
6597 return -EIO;
6598 }
6599
6600 pRoamProfile = &pWextState->roamProfile;
6601
6602 /* Issue disconnect only if interface type is set to IBSS */
6603 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
6604 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306605 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -07006606 __func__);
6607 return -EINVAL;
6608 }
6609
6610 /* Issue Disconnect request */
6611 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6612 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
6613 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
6614
6615 return 0;
6616}
6617
6618/*
6619 * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params
6620 * This function is used to set the phy parameters
6621 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
6622 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306623static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006624 u32 changed)
6625{
6626 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6627 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306628 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006629
6630 ENTER();
6631
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306632 status = wlan_hdd_validate_context(pHddCtx);
6633
6634 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006635 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306636 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6637 "%s: HDD context is not valid", __func__);
6638 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006639 }
6640
Jeff Johnson295189b2012-06-20 16:38:30 -07006641 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
6642 {
6643 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
6644 WNI_CFG_RTS_THRESHOLD_STAMAX :
6645 wiphy->rts_threshold;
6646
6647 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306648 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -07006649 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306650 hddLog(VOS_TRACE_LEVEL_ERROR,
6651 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006652 __func__, rts_threshold);
6653 return -EINVAL;
6654 }
6655
6656 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
6657 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306658 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006659 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306660 hddLog(VOS_TRACE_LEVEL_ERROR,
6661 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006662 __func__, rts_threshold);
6663 return -EIO;
6664 }
6665
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306666 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006667 rts_threshold);
6668 }
6669
6670 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
6671 {
6672 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
6673 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
6674 wiphy->frag_threshold;
6675
6676 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306677 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006678 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306679 hddLog(VOS_TRACE_LEVEL_ERROR,
6680 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 frag_threshold);
6682 return -EINVAL;
6683 }
6684
6685 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
6686 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306687 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006688 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306689 hddLog(VOS_TRACE_LEVEL_ERROR,
6690 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006691 __func__, frag_threshold);
6692 return -EIO;
6693 }
6694
6695 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
6696 frag_threshold);
6697 }
6698
6699 if ((changed & WIPHY_PARAM_RETRY_SHORT)
6700 || (changed & WIPHY_PARAM_RETRY_LONG))
6701 {
6702 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
6703 wiphy->retry_short :
6704 wiphy->retry_long;
6705
6706 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
6707 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
6708 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306709 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006710 __func__, retry_value);
6711 return -EINVAL;
6712 }
6713
6714 if (changed & WIPHY_PARAM_RETRY_SHORT)
6715 {
6716 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
6717 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306718 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006719 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306720 hddLog(VOS_TRACE_LEVEL_ERROR,
6721 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006722 __func__, retry_value);
6723 return -EIO;
6724 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306725 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006726 __func__, retry_value);
6727 }
6728 else if (changed & WIPHY_PARAM_RETRY_SHORT)
6729 {
6730 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
6731 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306732 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006733 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306734 hddLog(VOS_TRACE_LEVEL_ERROR,
6735 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006736 __func__, retry_value);
6737 return -EIO;
6738 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306739 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006740 __func__, retry_value);
6741 }
6742 }
6743
6744 return 0;
6745}
6746
6747/*
6748 * FUNCTION: wlan_hdd_cfg80211_set_txpower
6749 * This function is used to set the txpower
6750 */
6751static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07006752#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6753 struct wireless_dev *wdev,
6754#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006755#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306756 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006757#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306758 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006759#endif
6760 int dbm)
6761{
6762 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306763 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006764 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6765 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306766 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006767
6768 ENTER();
6769
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306770 status = wlan_hdd_validate_context(pHddCtx);
6771
6772 if (0 != status)
6773 {
6774 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6775 "%s: HDD context is not valid", __func__);
6776 return status;
6777 }
6778
6779 hHal = pHddCtx->hHal;
6780
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306781 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6782 dbm, ccmCfgSetCallback,
6783 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006784 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306785 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006786 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
6787 return -EIO;
6788 }
6789
6790 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
6791 dbm);
6792
6793 switch(type)
6794 {
6795 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
6796 /* Fall through */
6797 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
6798 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
6799 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306800 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
6801 __func__);
6802 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07006803 }
6804 break;
6805 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306806 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07006807 __func__);
6808 return -EOPNOTSUPP;
6809 break;
6810 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306811 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
6812 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006813 return -EIO;
6814 }
6815
6816 return 0;
6817}
6818
6819/*
6820 * FUNCTION: wlan_hdd_cfg80211_get_txpower
6821 * This function is used to read the txpower
6822 */
Yue Maf49ba872013-08-19 12:04:25 -07006823static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
6824#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6825 struct wireless_dev *wdev,
6826#endif
6827 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006828{
6829
6830 hdd_adapter_t *pAdapter;
6831 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306832 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006833
Jeff Johnsone7245742012-09-05 17:12:55 -07006834 ENTER();
6835
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306836 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07006837
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306838 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006839 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306840 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6841 "%s: HDD context is not valid", __func__);
6842 *dbm = 0;
6843 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006844 }
6845
Jeff Johnson295189b2012-06-20 16:38:30 -07006846 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
6847 if (NULL == pAdapter)
6848 {
6849 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
6850 return -ENOENT;
6851 }
6852
6853 wlan_hdd_get_classAstats(pAdapter);
6854 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
6855
Jeff Johnsone7245742012-09-05 17:12:55 -07006856 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006857 return 0;
6858}
6859
6860static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
6861 u8* mac, struct station_info *sinfo)
6862{
6863 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6864 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6865 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
6866 tANI_U8 rate_flags;
6867
6868 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
6869 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07006870
6871 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
6872 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
6873 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
6874 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
6875 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
6876 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
6877 tANI_U16 maxRate = 0;
6878 tANI_U16 myRate;
6879 tANI_U16 currentRate = 0;
6880 tANI_U8 maxSpeedMCS = 0;
6881 tANI_U8 maxMCSIdx = 0;
6882 tANI_U8 rateFlag = 1;
6883 tANI_U8 i, j, rssidx;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07006884 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306885 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006886
Leo Chang6f8870f2013-03-26 18:11:36 -07006887#ifdef WLAN_FEATURE_11AC
6888 tANI_U32 vht_mcs_map;
6889 eDataRate11ACMaxMcs vhtMaxMcs;
6890#endif /* WLAN_FEATURE_11AC */
6891
Jeff Johnsone7245742012-09-05 17:12:55 -07006892 ENTER();
6893
Jeff Johnson295189b2012-06-20 16:38:30 -07006894 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
6895 (0 == ssidlen))
6896 {
6897 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
6898 " Invalid ssidlen, %d", __func__, ssidlen);
6899 /*To keep GUI happy*/
6900 return 0;
6901 }
6902
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306903 status = wlan_hdd_validate_context(pHddCtx);
6904
6905 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006906 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306907 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6908 "%s: HDD context is not valid", __func__);
6909 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006910 }
6911
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07006912 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006913 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
6914
Kiet Lam3b17fc82013-09-27 05:24:08 +05306915 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
6916 sinfo->filled |= STATION_INFO_SIGNAL;
6917
Jeff Johnson295189b2012-06-20 16:38:30 -07006918 //convert to the UI units of 100kbps
6919 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
6920
6921#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -07006922 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 -07006923 sinfo->signal,
6924 pCfg->reportMaxLinkSpeed,
6925 myRate,
6926 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006927 (int) pCfg->linkSpeedRssiMid,
6928 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -07006929 (int) rate_flags,
6930 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07006931#endif //LINKSPEED_DEBUG_ENABLED
6932
6933 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
6934 {
6935 // we do not want to necessarily report the current speed
6936 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
6937 {
6938 // report the max possible speed
6939 rssidx = 0;
6940 }
6941 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
6942 {
6943 // report the max possible speed with RSSI scaling
6944 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
6945 {
6946 // report the max possible speed
6947 rssidx = 0;
6948 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006949 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006950 {
6951 // report middle speed
6952 rssidx = 1;
6953 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006954 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
6955 {
6956 // report middle speed
6957 rssidx = 2;
6958 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006959 else
6960 {
6961 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006962 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07006963 }
6964 }
6965 else
6966 {
6967 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
6968 hddLog(VOS_TRACE_LEVEL_ERROR,
6969 "%s: Invalid value for reportMaxLinkSpeed: %u",
6970 __func__, pCfg->reportMaxLinkSpeed);
6971 rssidx = 0;
6972 }
6973
6974 maxRate = 0;
6975
6976 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306977 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
6978 OperationalRates, &ORLeng))
6979 {
6980 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6981 /*To keep GUI happy*/
6982 return 0;
6983 }
6984
Jeff Johnson295189b2012-06-20 16:38:30 -07006985 for (i = 0; i < ORLeng; i++)
6986 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006987 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006988 {
6989 /* Validate Rate Set */
6990 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
6991 {
6992 currentRate = supported_data_rate[j].supported_rate[rssidx];
6993 break;
6994 }
6995 }
6996 /* Update MAX rate */
6997 maxRate = (currentRate > maxRate)?currentRate:maxRate;
6998 }
6999
7000 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05307001 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
7002 ExtendedRates, &ERLeng))
7003 {
7004 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
7005 /*To keep GUI happy*/
7006 return 0;
7007 }
7008
Jeff Johnson295189b2012-06-20 16:38:30 -07007009 for (i = 0; i < ERLeng; i++)
7010 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007011 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07007012 {
7013 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
7014 {
7015 currentRate = supported_data_rate[j].supported_rate[rssidx];
7016 break;
7017 }
7018 }
7019 /* Update MAX rate */
7020 maxRate = (currentRate > maxRate)?currentRate:maxRate;
7021 }
Kiet Lamb69f8dc2013-11-15 15:34:27 +05307022 /* Get MCS Rate Set --
7023 only if we are connected at MCS rates (or)
7024 if we are always reporting max speed (or)
7025 if we have good rssi */
7026 if (((0 == rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY)) ||
7027 (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed))
Jeff Johnson295189b2012-06-20 16:38:30 -07007028 {
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05307029 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
7030 MCSRates, &MCSLeng))
7031 {
7032 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
7033 /*To keep GUI happy*/
7034 return 0;
7035 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007036 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -07007037#ifdef WLAN_FEATURE_11AC
7038 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307039 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -07007040 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007041 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307042 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -07007043 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -07007044 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007045 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007046 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007047 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -07007048 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007049 maxMCSIdx = 7;
7050 }
7051 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
7052 {
7053 maxMCSIdx = 8;
7054 }
7055 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
7056 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307057 //VHT20 is supporting 0~8
7058 if (rate_flags & eHAL_TX_RATE_VHT20)
7059 maxMCSIdx = 8;
7060 else
7061 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -07007062 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307063
7064 if (rate_flags & eHAL_TX_RATE_VHT80)
7065 {
7066 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
7067 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
7068 }
7069 else if (rate_flags & eHAL_TX_RATE_VHT40)
7070 {
7071 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
7072 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
7073 }
7074 else if (rate_flags & eHAL_TX_RATE_VHT20)
7075 {
7076 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
7077 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
7078 }
7079
Leo Chang6f8870f2013-03-26 18:11:36 -07007080 maxSpeedMCS = 1;
7081 if (currentRate > maxRate)
7082 {
7083 maxRate = currentRate;
7084 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307085
Leo Chang6f8870f2013-03-26 18:11:36 -07007086 }
7087 else
7088#endif /* WLAN_FEATURE_11AC */
7089 {
7090 if (rate_flags & eHAL_TX_RATE_HT40)
7091 {
7092 rateFlag |= 1;
7093 }
7094 if (rate_flags & eHAL_TX_RATE_SGI)
7095 {
7096 rateFlag |= 2;
7097 }
7098
7099 for (i = 0; i < MCSLeng; i++)
7100 {
7101 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
7102 for (j = 0; j < temp; j++)
7103 {
7104 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
7105 {
7106 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
7107 break;
7108 }
7109 }
7110 if ((j < temp) && (currentRate > maxRate))
7111 {
7112 maxRate = currentRate;
7113 maxSpeedMCS = 1;
7114 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
7115 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007116 }
7117 }
7118 }
7119
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307120 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
7121 {
7122 maxRate = myRate;
7123 maxSpeedMCS = 1;
7124 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
7125 }
7126
Jeff Johnson295189b2012-06-20 16:38:30 -07007127 // make sure we report a value at least as big as our current rate
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007128 if (((maxRate < myRate) && (0 == rssidx)) ||
7129 (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -07007130 {
7131 maxRate = myRate;
7132 if (rate_flags & eHAL_TX_RATE_LEGACY)
7133 {
7134 maxSpeedMCS = 0;
7135 }
7136 else
7137 {
7138 maxSpeedMCS = 1;
7139 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
7140 }
7141 }
7142
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307143 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -07007144 {
7145 sinfo->txrate.legacy = maxRate;
7146#ifdef LINKSPEED_DEBUG_ENABLED
7147 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
7148#endif //LINKSPEED_DEBUG_ENABLED
7149 }
7150 else
7151 {
7152 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -07007153#ifdef WLAN_FEATURE_11AC
7154 sinfo->txrate.nss = 1;
7155 if (rate_flags & eHAL_TX_RATE_VHT80)
7156 {
7157 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307158 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -07007159 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307160 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -07007161 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307162 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7163 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7164 }
7165 else if (rate_flags & eHAL_TX_RATE_VHT20)
7166 {
7167 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7168 }
7169#endif /* WLAN_FEATURE_11AC */
7170 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
7171 {
7172 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7173 if (rate_flags & eHAL_TX_RATE_HT40)
7174 {
7175 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7176 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007177 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007178 if (rate_flags & eHAL_TX_RATE_SGI)
7179 {
7180 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7181 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307182
Jeff Johnson295189b2012-06-20 16:38:30 -07007183#ifdef LINKSPEED_DEBUG_ENABLED
7184 pr_info("Reporting MCS rate %d flags %x\n",
7185 sinfo->txrate.mcs,
7186 sinfo->txrate.flags );
7187#endif //LINKSPEED_DEBUG_ENABLED
7188 }
7189 }
7190 else
7191 {
7192 // report current rate instead of max rate
7193
7194 if (rate_flags & eHAL_TX_RATE_LEGACY)
7195 {
7196 //provide to the UI in units of 100kbps
7197 sinfo->txrate.legacy = myRate;
7198#ifdef LINKSPEED_DEBUG_ENABLED
7199 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
7200#endif //LINKSPEED_DEBUG_ENABLED
7201 }
7202 else
7203 {
7204 //must be MCS
7205 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -07007206#ifdef WLAN_FEATURE_11AC
7207 sinfo->txrate.nss = 1;
7208 if (rate_flags & eHAL_TX_RATE_VHT80)
7209 {
7210 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7211 }
7212 else
7213#endif /* WLAN_FEATURE_11AC */
7214 {
7215 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7216 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007217 if (rate_flags & eHAL_TX_RATE_SGI)
7218 {
7219 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7220 }
7221 if (rate_flags & eHAL_TX_RATE_HT40)
7222 {
7223 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7224 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007225#ifdef WLAN_FEATURE_11AC
7226 else if (rate_flags & eHAL_TX_RATE_VHT80)
7227 {
7228 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
7229 }
7230#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -07007231#ifdef LINKSPEED_DEBUG_ENABLED
7232 pr_info("Reporting actual MCS rate %d flags %x\n",
7233 sinfo->txrate.mcs,
7234 sinfo->txrate.flags );
7235#endif //LINKSPEED_DEBUG_ENABLED
7236 }
7237 }
7238 sinfo->filled |= STATION_INFO_TX_BITRATE;
7239
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07007240 sinfo->tx_packets =
7241 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
7242 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
7243 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
7244 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
7245
7246 sinfo->tx_retries =
7247 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
7248 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
7249 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
7250 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
7251
7252 sinfo->tx_failed =
7253 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
7254 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
7255 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
7256 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
7257
7258 sinfo->filled |=
7259 STATION_INFO_TX_PACKETS |
7260 STATION_INFO_TX_RETRIES |
7261 STATION_INFO_TX_FAILED;
7262
7263 EXIT();
7264 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007265}
7266
7267static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -07007268 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -07007269{
7270 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307271 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007272 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307273 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007274
Jeff Johnsone7245742012-09-05 17:12:55 -07007275 ENTER();
7276
Jeff Johnson295189b2012-06-20 16:38:30 -07007277 if (NULL == pAdapter)
7278 {
7279 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
7280 return -ENODEV;
7281 }
7282
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307283 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307284 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307285
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307286 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307287 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307288 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7289 "%s: HDD context is not valid", __func__);
7290 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307291 }
7292
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307293 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
7294 (TRUE == pHddCtx->hdd_wlan_suspended) &&
7295 (pHddCtx->cfg_ini->fhostArpOffload) &&
7296 (eConnectionState_Associated ==
7297 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
7298 {
Amar Singhald53568e2013-09-26 11:03:45 -07007299
7300 hddLog(VOS_TRACE_LEVEL_INFO,
7301 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307302 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307303 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7304 {
7305 hddLog(VOS_TRACE_LEVEL_INFO,
7306 "%s:Failed to enable ARPOFFLOAD Feature %d\n",
7307 __func__, vos_status);
7308 }
7309 }
7310
Jeff Johnson295189b2012-06-20 16:38:30 -07007311 /**The get power cmd from the supplicant gets updated by the nl only
7312 *on successful execution of the function call
7313 *we are oppositely mapped w.r.t mode in the driver
7314 **/
7315 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
7316
Jeff Johnsone7245742012-09-05 17:12:55 -07007317 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007318 if (VOS_STATUS_E_FAILURE == vos_status)
7319 {
7320 return -EINVAL;
7321 }
7322 return 0;
7323}
7324
7325
7326#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7327static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
7328 struct net_device *netdev,
7329 u8 key_index)
7330{
Jeff Johnsone7245742012-09-05 17:12:55 -07007331 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007332 return 0;
7333}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307334#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -07007335
7336#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7337static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7338 struct net_device *dev,
7339 struct ieee80211_txq_params *params)
7340{
Jeff Johnsone7245742012-09-05 17:12:55 -07007341 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007342 return 0;
7343}
7344#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7345static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7346 struct ieee80211_txq_params *params)
7347{
Jeff Johnsone7245742012-09-05 17:12:55 -07007348 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007349 return 0;
7350}
7351#endif //LINUX_VERSION_CODE
7352
7353static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
7354 struct net_device *dev, u8 *mac)
7355{
7356 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307357 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007358 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307359 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007360 v_U8_t staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007361
Jeff Johnsone7245742012-09-05 17:12:55 -07007362 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307363 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -07007364 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307365 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007366 return -EINVAL;
7367 }
7368
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307369 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7370 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007371
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307372 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007373 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307374 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7375 "%s: HDD context is not valid", __func__);
7376 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007377 }
7378
Jeff Johnson295189b2012-06-20 16:38:30 -07007379 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007380 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007381 )
7382 {
7383 if( NULL == mac )
7384 {
7385 v_U16_t i;
7386 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
7387 {
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007388 if ((pAdapter->aStaInfo[i].isUsed) &&
7389 (!pAdapter->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -07007390 {
7391 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
7392 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007393 "%s: Delete STA with MAC::"
7394 MAC_ADDRESS_STR,
7395 __func__, MAC_ADDR_ARRAY(macAddr));
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007396 vos_status = hdd_softap_sta_deauth(pAdapter, macAddr);
7397 if (VOS_IS_STATUS_SUCCESS(vos_status))
7398 pAdapter->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007399 }
7400 }
7401 }
7402 else
7403 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007404
7405 vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId);
7406 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7407 {
7408 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007409 "%s: Skip this DEL STA as this is not used::"
7410 MAC_ADDRESS_STR,
7411 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007412 return -ENOENT;
7413 }
7414
7415 if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE)
7416 {
7417 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007418 "%s: Skip this DEL STA as deauth is in progress::"
7419 MAC_ADDRESS_STR,
7420 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007421 return -ENOENT;
7422 }
7423
7424 pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE;
7425
Jeff Johnson295189b2012-06-20 16:38:30 -07007426 hddLog(VOS_TRACE_LEVEL_INFO,
7427 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -08007428 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007429 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -08007430 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007431
7432 vos_status = hdd_softap_sta_deauth(pAdapter, mac);
7433 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7434 {
7435 pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE;
7436 hddLog(VOS_TRACE_LEVEL_INFO,
7437 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -08007438 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007439 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -08007440 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007441 return -ENOENT;
7442 }
7443
Jeff Johnson295189b2012-06-20 16:38:30 -07007444 }
7445 }
7446
7447 EXIT();
7448
7449 return 0;
7450}
7451
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007452static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
7453 struct net_device *dev, u8 *mac, struct station_parameters *params)
7454{
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007455 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007456#ifdef FEATURE_WLAN_TDLS
7457 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007458 ENTER();
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007459 mask = params->sta_flags_mask;
7460
7461 set = params->sta_flags_set;
7462
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007463#ifdef WLAN_FEATURE_TDLS_DEBUG
7464 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7465 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
7466 __func__, mask, set, MAC_ADDR_ARRAY(mac));
7467#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007468
7469 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
7470 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007471 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007472 }
7473 }
7474#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007475 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007476}
7477
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007478
7479#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -07007480#define MAX_PMKSAIDS_IN_CACHE 8
7481
7482static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD local cache
7483static tANI_U32 PMKIDCacheIndex; // HDD local Cache index
7484
7485
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007486static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07007487 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007488{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307489 tANI_U32 j=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007490 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7491 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307492 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307493 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007494 tANI_U8 BSSIDMatched = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307495 hdd_context_t *pHddCtx;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307496
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007497 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
7498 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07007499
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307500 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307501 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007502 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307503 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007504 return -EINVAL;
7505 }
7506
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307507 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7508 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007509
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307510 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007511 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307512 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7513 "%s: HDD context is not valid", __func__);
7514 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007515 }
7516
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307517 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007518 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7519
Wilson Yang6507c4e2013-10-01 20:11:19 -07007520 for (j = 0; j < PMKIDCacheIndex; j++)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007521 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307522 if(vos_mem_compare(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007523 pmksa->bssid, WNI_CFG_BSSID_LEN))
7524 {
7525 /* BSSID matched previous entry. Overwrite it. */
7526 BSSIDMatched = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307527 vos_mem_copy(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007528 pmksa->bssid, WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307529 vos_mem_copy(PMKIDCache[j].PMKID,
7530 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007531 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307532 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007533 __func__, j );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007534 dump_bssid(pmksa->bssid);
7535 dump_pmkid(halHandle, pmksa->pmkid);
7536 break;
7537 }
7538 }
7539
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007540 /* Check we compared all entries,if then take the first slot now */
Wilson Yang6507c4e2013-10-01 20:11:19 -07007541 if(j == MAX_PMKSAIDS_IN_CACHE) PMKIDCacheIndex=0;
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007542
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007543 if (!BSSIDMatched)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307544 {
7545 // Now, we DON'T have a BSSID match, so take a new entry in the cache.
Wilson Yang6507c4e2013-10-01 20:11:19 -07007546 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].BSSID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307547 pmksa->bssid, ETHER_ADDR_LEN);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007548 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].PMKID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307549 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007550 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307551 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Adding a new cache entry %d.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07007552 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007553 dump_bssid(pmksa->bssid);
7554 dump_pmkid(halHandle, pmksa->pmkid);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307555 // Increment the HDD Local Cache index
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007556 // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME
Wilson Yang6507c4e2013-10-01 20:11:19 -07007557 if (PMKIDCacheIndex <= (MAX_PMKSAIDS_IN_CACHE-1)) PMKIDCacheIndex++; else PMKIDCacheIndex = 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007558 }
7559
7560
7561 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307562 //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007563 // __func__, i );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307564 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07007565 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007566 // Finally set the PMKSA ID Cache in CSR
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307567 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
7568 PMKIDCache,
Wilson Yang6507c4e2013-10-01 20:11:19 -07007569 PMKIDCacheIndex);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007570 return 0;
7571}
7572
7573
Wilson Yang6507c4e2013-10-01 20:11:19 -07007574
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007575static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -07007576 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007577{
Wilson Yang6507c4e2013-10-01 20:11:19 -07007578 tANI_U32 j=0;
7579 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7580 tHalHandle halHandle;
7581 int status;
7582 tANI_U8 BSSIDMatched = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07007583 hdd_context_t *pHddCtx;
7584 int result = 0;
7585
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007586 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
7587 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -07007588
7589 /* Validate pAdapter */
7590 if (NULL == pAdapter)
7591 {
7592 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
7593 return -EINVAL;
7594 }
7595
7596 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7597 status = wlan_hdd_validate_context(pHddCtx);
7598
7599 if (0 != status)
7600 {
7601 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7602 "%s: HDD context is not valid", __func__);
7603 return status;
7604 }
7605
7606 /*Retrieve halHandle*/
7607 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7608
7609 /*in case index is 0,no entry to delete*/
7610 if (0 == PMKIDCacheIndex)
7611 {
7612 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" ,
7613 __func__);
7614 return -EINVAL;
7615 }
7616
7617 /*find the matching PMKSA entry from j=0 to (index-1),
7618 * and delete the matched one
7619 */
7620 for (j = 0; j<PMKIDCacheIndex; j++)
7621 {
7622 if (vos_mem_compare(PMKIDCache[j].BSSID,
7623 pmksa->bssid,
7624 WNI_CFG_BSSID_LEN))
7625 {
7626 /* BSSID matched entry */
7627 BSSIDMatched = 1;
7628
7629 if (j<PMKIDCacheIndex-1)
7630 {
7631 /*replace the matching entry with the last entry in HDD local cache*/
7632 vos_mem_copy(PMKIDCache[j].BSSID,
7633 PMKIDCache[PMKIDCacheIndex-1].BSSID,
7634 WNI_CFG_BSSID_LEN);
7635 vos_mem_copy(PMKIDCache[j].PMKID,
7636 PMKIDCache[PMKIDCacheIndex-1].PMKID,
7637 CSR_RSN_PMKID_SIZE);
7638 }
7639
7640 /*clear the last entry in HDD cache ---[index-1]*/
Wilson Yang6507c4e2013-10-01 20:11:19 -07007641 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].BSSID, WNI_CFG_BSSID_LEN);
7642 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].PMKID, CSR_RSN_PMKID_SIZE);
7643
7644 /*reduce the PMKID array index*/
7645 PMKIDCacheIndex--;
7646
7647 /*delete the last PMKID cache in CSR*/
Kiet Lam8d21d5b2013-10-31 17:18:29 +05307648 result = sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pmksa->bssid);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007649 if (0 != result)
7650 {
7651 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cannot delete PMKSA %d CONTENT.",
7652 __func__,PMKIDCacheIndex);
7653 }
7654
7655 dump_bssid(pmksa->bssid);
7656 dump_pmkid(halHandle,pmksa->pmkid);
7657
7658 break;
7659 }
7660 }
7661
7662 /* we compare all entries,but cannot find matching entry */
7663 if (j == MAX_PMKSAIDS_IN_CACHE && !BSSIDMatched)
7664 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007665 hddLog(VOS_TRACE_LEVEL_FATAL,
7666 "%s: No such PMKSA entry existed " MAC_ADDRESS_STR,
7667 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -07007668 dump_bssid(pmksa->bssid);
7669 dump_pmkid(halHandle, pmksa->pmkid);
7670 return -EINVAL;
7671 }
7672 return result;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007673}
7674
Wilson Yang6507c4e2013-10-01 20:11:19 -07007675
7676
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007677static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
7678{
Wilson Yang6507c4e2013-10-01 20:11:19 -07007679 tANI_U32 j=0;
7680 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7681 tHalHandle halHandle;
7682 hdd_context_t *pHddCtx;
7683 tANI_U8 *pBSSId;
7684 int status;
7685 int result;
7686
7687 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__);
7688
7689 /* Validate pAdapter */
7690 if (NULL == pAdapter)
7691 {
7692 hddLog(VOS_TRACE_LEVEL_ERROR,
7693 "%s: Invalid Adapter" ,__func__);
7694 return -EINVAL;
7695 }
7696
7697 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7698 status = wlan_hdd_validate_context(pHddCtx);
7699
7700 if (0 != status)
7701 {
7702 hddLog(VOS_TRACE_LEVEL_ERROR,
7703 "%s: HDD context is not valid", __func__);
7704 return status;
7705 }
7706
7707 /*Retrieve halHandle*/
7708 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7709
7710 /*in case index is 0,no entry to delete*/
7711 if (0 == PMKIDCacheIndex)
7712 {
7713 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" ,
7714 __func__);
7715 return -EINVAL;
7716 }
7717
7718 /*delete all the PMKSA one by one */
7719 for (j = 0; j<PMKIDCacheIndex; j++)
7720 {
Wilson Yang6507c4e2013-10-01 20:11:19 -07007721 pBSSId =(tANI_U8 *)(PMKIDCache[j].BSSID);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007722
7723 /*delete the PMKID in CSR*/
7724 result = sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId);
7725
7726 if (0!= result)
7727 {
7728 hddLog(VOS_TRACE_LEVEL_ERROR ,"%s cannot flush PMKIDCache %d.",
7729 __func__,j);
7730 }
Kiet Lam8d21d5b2013-10-31 17:18:29 +05307731 /*clear the entry in HDD cache 0--index-1 */
7732 vos_mem_zero(PMKIDCache[j].BSSID, WNI_CFG_BSSID_LEN);
7733 vos_mem_zero(PMKIDCache[j].PMKID, CSR_RSN_PMKID_SIZE);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007734 }
7735
7736 PMKIDCacheIndex = 0;
7737 return result;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007738}
7739#endif
7740
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007741#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307742static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007743 struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie)
7744{
7745 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7746 hdd_station_ctx_t *pHddStaCtx;
7747
7748 if (NULL == pAdapter)
7749 {
7750 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
7751 return -ENODEV;
7752 }
7753
7754 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7755
7756 // Added for debug on reception of Re-assoc Req.
7757 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7758 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307759 hddLog(LOGE, FL("Called with Ie of length = %d when not associated\n"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007760 ftie->ie_len);
7761 hddLog(LOGE, FL("Should be Re-assoc Req IEs\n"));
7762 }
7763
7764#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307765 hddLog(LOGE, FL("%s called with Ie of length = %d\n"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007766 ftie->ie_len);
7767#endif
7768
7769 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +05307770 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
7771 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007772 ftie->ie_len);
7773 return 0;
7774}
7775#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007776
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307777#ifdef FEATURE_WLAN_SCAN_PNO
7778
7779void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
7780 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
7781{
7782 int ret;
7783 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
7784 hdd_context_t *pHddCtx;
7785
7786 if (NULL == pAdapter)
7787 {
7788 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7789 "%s: HDD adapter is Null", __func__);
7790 return ;
7791 }
7792
7793 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7794 if (NULL == pHddCtx)
7795 {
7796 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7797 "%s: HDD context is Null!!!", __func__);
7798 return ;
7799 }
7800
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307801 spin_lock(&pHddCtx->schedScan_lock);
7802 if (TRUE == pHddCtx->isWiphySuspended)
7803 {
7804 pHddCtx->isSchedScanUpdatePending = TRUE;
7805 spin_unlock(&pHddCtx->schedScan_lock);
7806 hddLog(VOS_TRACE_LEVEL_INFO,
7807 "%s: Update cfg80211 scan database after it resume", __func__);
7808 return ;
7809 }
7810 spin_unlock(&pHddCtx->schedScan_lock);
7811
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307812 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
7813
7814 if (0 > ret)
7815 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
7816
7817 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307818 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7819 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307820}
7821
7822/*
7823 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
7824 * NL interface to enable PNO
7825 */
7826static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
7827 struct net_device *dev, struct cfg80211_sched_scan_request *request)
7828{
7829 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7830 tpSirPNOScanReq pPnoRequest = NULL;
7831 hdd_context_t *pHddCtx;
7832 tHalHandle hHal;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05307833 v_U32_t i, indx, num_ch, tempInterval;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307834 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7835 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7836 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
7837 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307838 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307839
7840 if (NULL == pAdapter)
7841 {
7842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7843 "%s: HDD adapter is Null", __func__);
7844 return -ENODEV;
7845 }
7846
7847 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307848 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307849
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307850 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307851 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307852 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7853 "%s: HDD context is not valid", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307854 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307855 }
7856
7857 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7858 if (NULL == hHal)
7859 {
7860 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7861 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307862 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307863 }
7864
7865 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
7866 if (NULL == pPnoRequest)
7867 {
7868 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7869 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307870 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307871 }
7872
Madan Mohan Koyyalamudic3f04352013-09-26 19:21:48 +05307873 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307874 pPnoRequest->enable = 1; /*Enable PNO */
7875 pPnoRequest->ucNetworksCount = request->n_match_sets;
7876
7877 if (( !pPnoRequest->ucNetworksCount ) ||
7878 ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
7879 {
7880 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7881 "Network input is not correct");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307882 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307883 goto error;
7884 }
7885
7886 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
7887 {
7888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7889 "Incorrect number of channels");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307890 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307891 goto error;
7892 }
7893
7894 /* Framework provides one set of channels(all)
7895 * common for all saved profile */
7896 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
7897 channels_allowed, &num_channels_allowed))
7898 {
7899 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7900 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307901 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307902 goto error;
7903 }
7904 /* Checking each channel against allowed channel list */
7905 num_ch = 0;
7906 for (i = 0; i < request->n_channels; i++)
7907 {
7908 for (indx = 0; indx < num_channels_allowed; indx++)
7909 {
7910 if (request->channels[i]->hw_value == channels_allowed[indx])
7911 {
7912 valid_ch[num_ch++] = request->channels[i]->hw_value;
7913 break ;
7914 }
7915 }
7916 }
7917
7918 /* Filling per profile params */
7919 for (i = 0; i < pPnoRequest->ucNetworksCount; i++)
7920 {
7921 pPnoRequest->aNetworks[i].ssId.length =
7922 request->match_sets[i].ssid.ssid_len;
7923
7924 if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) ||
7925 ( pPnoRequest->aNetworks[i].ssId.length > 32 ) )
7926 {
7927 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7928 "SSID Len %d is not correct for network %d",
7929 pPnoRequest->aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307930 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307931 goto error;
7932 }
7933
7934 memcpy(pPnoRequest->aNetworks[i].ssId.ssId,
7935 request->match_sets[i].ssid.ssid,
7936 request->match_sets[i].ssid.ssid_len);
7937 pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
7938 pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/
7939 pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
7940
7941 /*Copying list of valid channel into request */
7942 memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch);
7943 pPnoRequest->aNetworks[i].ucChannelCount = num_ch;
7944
7945 pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value
7946 }
7947
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +05307948 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7949 "request->ie_len = %d", request->ie_len);
7950 if ((0 < request->ie_len) && (NULL != request->ie))
7951 {
7952 pPnoRequest->us24GProbeTemplateLen = request->ie_len;
7953 memcpy(&pPnoRequest->p24GProbeTemplate, request->ie,
7954 pPnoRequest->us24GProbeTemplateLen);
7955
7956 pPnoRequest->us5GProbeTemplateLen = request->ie_len;
7957 memcpy(&pPnoRequest->p5GProbeTemplate, request->ie,
7958 pPnoRequest->us5GProbeTemplateLen);
7959 }
7960
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05307961 /* Driver gets only one time interval which is hardcoded in
7962 * supplicant for 10000ms. Taking power consumption into account 6 timers
7963 * will be used, Timervalue is increased exponentially i.e 10,20,40,
7964 * 80,160,320 secs. And number of scan cycle for each timer
7965 * is configurable through INI param gPNOScanTimerRepeatValue.
7966 * If it is set to 0 only one timer will be used and PNO scan cycle
7967 * will be repeated after each interval specified by supplicant
7968 * till PNO is disabled.
7969 */
7970 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
7971 pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
7972 else
7973 pPnoRequest->scanTimers.ucScanTimersCount =
7974 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
7975
7976 tempInterval = (request->interval)/1000;
7977 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7978 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
7979 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
7980 for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++)
7981 {
7982 pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat =
7983 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
7984 pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval;
7985 tempInterval *= 2;
7986 }
7987 //Repeat last timer until pno disabled.
7988 pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
7989
Madan Mohan Koyyalamudid206c7b2013-09-26 22:54:51 +05307990 pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307991
7992 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
7993 pPnoRequest, pAdapter->sessionId,
7994 hdd_cfg80211_sched_scan_done_callback, pAdapter);
7995 if (eHAL_STATUS_SUCCESS != status)
7996 {
7997 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7998 "Failed to enable PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307999 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308000 goto error;
8001 }
8002
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308003 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8004 "PNO scanRequest offloaded");
8005
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308006error:
8007 vos_mem_free(pPnoRequest);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308008 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308009}
8010
8011/*
8012 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
8013 * NL interface to disable PNO
8014 */
8015static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
8016 struct net_device *dev)
8017{
8018 eHalStatus status = eHAL_STATUS_FAILURE;
8019 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8020 hdd_context_t *pHddCtx;
8021 tHalHandle hHal;
8022 tpSirPNOScanReq pPnoRequest = NULL;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308023 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308024
8025 ENTER();
8026
8027 if (NULL == pAdapter)
8028 {
8029 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8030 "%s: HDD adapter is Null", __func__);
8031 return -ENODEV;
8032 }
8033
8034 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308035
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308036 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308037 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308038 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308039 "%s: HDD context is Null", __func__);
8040 return -ENODEV;
8041 }
8042
8043 /* The return 0 is intentional when isLogpInProgress and
8044 * isLoadUnloadInProgress. We did observe a crash due to a return of
8045 * failure in sched_scan_stop , especially for a case where the unload
8046 * of the happens at the same time. The function __cfg80211_stop_sched_scan
8047 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
8048 * success. If it returns a failure , then its next invocation due to the
8049 * clean up of the second interface will have the dev pointer corresponding
8050 * to the first one leading to a crash.
8051 */
8052 if (pHddCtx->isLogpInProgress)
8053 {
8054 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8055 "%s: LOGP in Progress. Ignore!!!", __func__);
8056 return ret;
8057 }
8058
8059 if (pHddCtx->isLoadUnloadInProgress)
8060 {
8061 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8062 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
8063 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308064 }
8065
8066 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8067 if (NULL == hHal)
8068 {
8069 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8070 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308071 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308072 }
8073
8074 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
8075 if (NULL == pPnoRequest)
8076 {
8077 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8078 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308079 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308080 }
8081
8082 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
8083 pPnoRequest->enable = 0; /* Disable PNO */
8084 pPnoRequest->ucNetworksCount = 0;
8085
8086 status = sme_SetPreferredNetworkList(hHal, pPnoRequest,
8087 pAdapter->sessionId,
8088 NULL, pAdapter);
8089 if (eHAL_STATUS_SUCCESS != status)
8090 {
8091 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8092 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308093 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308094 }
8095
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308096 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8097 "%s: PNO scan disabled", __func__);
8098
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308099 vos_mem_free(pPnoRequest);
8100
8101 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308102 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308103}
8104
8105#endif /*FEATURE_WLAN_SCAN_PNO*/
8106
8107
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008108#ifdef FEATURE_WLAN_TDLS
8109static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
8110 u8 *peer, u8 action_code, u8 dialog_token,
8111 u16 status_code, const u8 *buf, size_t len)
8112{
8113
8114 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8115 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008116 u8 peerMac[6];
8117 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008118 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -08008119 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -07008120 long rc;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008121
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008122 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008123 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308124 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008125 "Invalid arguments");
8126 return -EINVAL;
8127 }
8128
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008129 if (pHddCtx->isLogpInProgress)
8130 {
8131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8132 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008133 wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008134 return -EBUSY;
8135 }
8136
Hoonki Lee27511902013-03-14 18:19:06 -07008137 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008138 {
Hoonki Lee27511902013-03-14 18:19:06 -07008139 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8140 "%s: TDLS mode is disabled OR not enabled in FW."
8141 MAC_ADDRESS_STR " action %d declined.",
8142 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008143 return -ENOTSUPP;
8144 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008145
Hoonki Lee27511902013-03-14 18:19:06 -07008146 /* other than teardown frame, other mgmt frames are not sent if disabled */
8147 if (SIR_MAC_TDLS_TEARDOWN != action_code)
8148 {
8149 /* if tdls_mode is disabled to respond to peer's request */
8150 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
8151 {
8152 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8153 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008154 " TDLS mode is disabled. action %d declined.",
8155 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -07008156
8157 return -ENOTSUPP;
8158 }
8159 }
8160
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008161 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
8162 {
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308163 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008164 {
8165 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008166 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008167 " TDLS setup is ongoing. action %d declined.",
8168 __func__, MAC_ADDR_ARRAY(peer), action_code);
8169 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008170 }
8171 }
8172
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008173 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
8174 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -08008175 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008176 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
Lee Hoonkic1262f22013-01-24 21:59:00 -08008177 {
8178 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
8179 we return error code at 'add_station()'. Hence we have this
8180 check again in addtion to add_station().
8181 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008182 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -08008183 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008184 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8185 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008186 " TDLS Max peer already connected. action %d declined.",
8187 __func__, MAC_ADDR_ARRAY(peer), action_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008188 goto error;
Lee Hoonkic1262f22013-01-24 21:59:00 -08008189 }
8190 else
8191 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008192 /* maximum reached. tweak to send error code to peer and return
8193 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -08008194 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008195 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8196 "%s: " MAC_ADDRESS_STR
8197 " TDLS Max peer already connected send response status %d",
8198 __func__, MAC_ADDR_ARRAY(peer), status_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008199 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008200 /* fall through to send setup resp with failure status
8201 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -08008202 }
8203 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008204 else
8205 {
8206 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308207 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008208 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008209 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008210 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008211 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
8212 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008213 return -EPERM;
8214 }
8215 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008216 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008217 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008218
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008219#ifdef WLAN_FEATURE_TDLS_DEBUG
8220 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008221 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d",
8222 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
8223 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008224#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008225
Hoonki Leea34dd892013-02-05 22:56:02 -08008226 /*Except teardown responder will not be used so just make 0*/
8227 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008228 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -08008229 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008230
8231 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308232 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008233
8234 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
8235 responder = pTdlsPeer->is_responder;
8236 else
Hoonki Leea34dd892013-02-05 22:56:02 -08008237 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008238 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8239 "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d",
8240 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
8241 dialog_token, status_code, len);
8242 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -08008243 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008244 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008245
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308246 /* For explicit trigger of DIS_REQ come out of BMPS for
8247 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -07008248 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308249 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
8250 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -07008251 {
8252 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
8253 {
8254 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308255 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Hoonki Lee14621352013-04-16 17:51:19 -07008256 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
8257 }
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308258 if (SIR_MAC_TDLS_DIS_REQ != action_code)
8259 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
Hoonki Lee14621352013-04-16 17:51:19 -07008260 }
8261
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008262 /* make sure doesn't call send_mgmt() while it is pending */
8263 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
8264 {
8265 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8266 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY\n",
8267 __func__, MAC_ADDR_ARRAY(peer), action_code);
8268 return -EBUSY;
8269 }
8270
8271 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008272 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
8273
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008274 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Hoonki Leea34dd892013-02-05 22:56:02 -08008275 peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008276
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008277 if (VOS_STATUS_SUCCESS != status)
8278 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008279 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8280 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008281 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -07008282 wlan_hdd_tdls_check_bmps(pAdapter);
8283 goto error;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008284 }
8285
Hoonki Leed37cbb32013-04-20 00:31:14 -07008286 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
8287 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
8288
8289 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008290 {
Hoonki Leed37cbb32013-04-20 00:31:14 -07008291 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008292 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -07008293 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008294 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Leed37cbb32013-04-20 00:31:14 -07008295 wlan_hdd_tdls_check_bmps(pAdapter);
8296 goto error;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008297 }
8298
Gopichand Nakkala05922802013-03-14 12:23:19 -07008299 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -07008300 {
8301 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008302 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -07008303 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008304
Hoonki Leea34dd892013-02-05 22:56:02 -08008305 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
8306 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008307 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -08008308 }
8309 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
8310 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008311 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -08008312 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008313
8314 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008315error:
8316 /* max_sta_failed ; we didn't set to CONNECTING for this case,
8317 because we already know that this transaction will be failed,
8318 but we weren't sure if supplicant call DISABLE_LINK or not. So,
8319 to be safe, do not change the state mahine.
8320 */
8321 if(max_sta_failed == 0 &&
8322 (WLAN_IS_TDLS_SETUP_ACTION(action_code)))
8323 wlan_hdd_tdls_set_link_status(pAdapter, peerMac, eTDLS_LINK_IDLE);
8324 return -EPERM;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008325}
8326
8327static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
8328 u8 *peer, enum nl80211_tdls_operation oper)
8329{
8330 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8331 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308332 int status;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008333#ifdef WLAN_FEATURE_TDLS_DEBUG
8334 const char *tdls_oper_str[]= {
8335 "NL80211_TDLS_DISCOVERY_REQ",
8336 "NL80211_TDLS_SETUP",
8337 "NL80211_TDLS_TEARDOWN",
8338 "NL80211_TDLS_ENABLE_LINK",
8339 "NL80211_TDLS_DISABLE_LINK",
Gopichand Nakkala29d00192013-06-20 19:03:52 +05308340 "NL80211_TDLS_UNKNOWN_OPER"};
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008341#endif
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008342 hddTdlsPeer_t *pTdlsPeer;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008343
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308344 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008345 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008346 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07008347 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008348 return -EINVAL;
8349 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008350
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308351 status = wlan_hdd_validate_context(pHddCtx);
8352
8353 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008354 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308355 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8356 "%s: HDD context is not valid", __func__);
8357 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008358 }
8359
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308360 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008361
8362 if ( NULL == pTdlsPeer ) {
8363 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR " (oper %d) not exsting. ignored",
8364 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
8365 return -EINVAL;
8366 }
8367
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008368#ifdef WLAN_FEATURE_TDLS_DEBUG
8369 if((int)oper > 4)
8370 oper = 5;
8371
8372 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008373 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
8374 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008375 tdls_oper_str[(int)oper]);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008376#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008377
8378 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008379 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008380 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008381 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07008382 "TDLS Disabled in INI OR not enabled in FW. "
8383 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008384 return -ENOTSUPP;
8385 }
8386
8387 switch (oper) {
8388 case NL80211_TDLS_ENABLE_LINK:
8389 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008390 VOS_STATUS status;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308391 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008392
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -07008393 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
8394 {
8395 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
8396 MAC_ADDRESS_STR " failed",
8397 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
8398 return -EINVAL;
8399 }
8400
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008401 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008402 {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05308403 long ret;
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308404 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05308405
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308406 if (0 != wlan_hdd_tdls_get_link_establish_params(
8407 pAdapter, peer,&tdlsLinkEstablishParams)) {
8408 return -EINVAL;
8409 }
8410 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308411
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308412 sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter),
8413 pAdapter->sessionId, peer, &tdlsLinkEstablishParams);
8414 /* Send TDLS peer UAPSD capabilities to the firmware and
8415 * register with the TL on after the response for this operation
8416 * is received .
8417 */
8418 ret = wait_for_completion_interruptible_timeout(
8419 &pAdapter->tdls_link_establish_req_comp,
8420 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
8421 if (ret <= 0)
8422 {
8423 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8424 "%s: Link Establish Request Faled Status %ld",
8425 __func__, ret);
8426 return -EINVAL;
8427 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308428 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008429 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED);
Gopichand Nakkala471708b2013-06-04 20:03:01 +05308430 /* Mark TDLS client Authenticated .*/
8431 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
8432 pTdlsPeer->staId,
8433 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008434 if (VOS_STATUS_SUCCESS == status)
8435 {
Hoonki Lee14621352013-04-16 17:51:19 -07008436 if (pTdlsPeer->is_responder == 0)
8437 {
8438 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
8439
8440 wlan_hdd_tdls_timer_restart(pAdapter,
8441 &pTdlsPeer->initiatorWaitTimeoutTimer,
8442 WAIT_TIME_TDLS_INITIATOR);
8443 /* suspend initiator TX until it receives direct packet from the
8444 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
8445 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
8446 &staId, NULL);
8447 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008448 wlan_hdd_tdls_increment_peer_count(pAdapter);
8449 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008450 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308451
8452 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308453 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
8454 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308455 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308456 int ac;
8457 uint8 ucAc[4] = { WLANTL_AC_VO,
8458 WLANTL_AC_VI,
8459 WLANTL_AC_BK,
8460 WLANTL_AC_BE };
8461 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
8462 for(ac=0; ac < 4; ac++)
8463 {
8464 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
8465 pTdlsPeer->staId, ucAc[ac],
8466 tlTid[ac], tlTid[ac], 0, 0,
8467 WLANTL_BI_DIR );
8468 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308469 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008470 }
8471
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008472 }
8473 break;
8474 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -08008475 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008476 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -08008477 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008478 long status;
8479
8480 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
8481
Lee Hoonkic1262f22013-01-24 21:59:00 -08008482 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
8483 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008484
8485 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
8486 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
8487 if (status <= 0)
8488 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008489 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008490 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8491 "%s: Del station failed status %ld",
8492 __func__, status);
8493 return -EPERM;
8494 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008495 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Lee Hoonkic1262f22013-01-24 21:59:00 -08008496 }
8497 else
8498 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008499 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8500 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -08008501 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008502 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008503 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008504 case NL80211_TDLS_TEARDOWN:
8505 case NL80211_TDLS_SETUP:
8506 case NL80211_TDLS_DISCOVERY_REQ:
8507 /* We don't support in-driver setup/teardown/discovery */
8508 return -ENOTSUPP;
8509 default:
8510 return -ENOTSUPP;
8511 }
8512 return 0;
8513}
Chilam NG571c65a2013-01-19 12:27:36 +05308514
8515int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
8516 struct net_device *dev, u8 *peer)
8517{
Arif Hussaina7c8e412013-11-20 11:06:42 -08008518 hddLog(VOS_TRACE_LEVEL_INFO,
8519 "tdls send discover req: "MAC_ADDRESS_STR,
8520 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +05308521
8522 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
8523 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
8524}
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008525#endif
8526
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308527#ifdef WLAN_FEATURE_GTK_OFFLOAD
8528/*
8529 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
8530 * Callback rountine called upon receiving response for
8531 * get offload info
8532 */
8533void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
8534 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
8535{
8536
8537 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308538 tANI_U8 tempReplayCounter[8];
8539 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308540
8541 ENTER();
8542
8543 if (NULL == pAdapter)
8544 {
8545 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8546 "%s: HDD adapter is Null", __func__);
8547 return ;
8548 }
8549
8550 if (NULL == pGtkOffloadGetInfoRsp)
8551 {
8552 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8553 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
8554 return ;
8555 }
8556
8557 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
8558 {
8559 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8560 "%s: wlan Failed to get replay counter value",
8561 __func__);
8562 return ;
8563 }
8564
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308565 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8566 /* Update replay counter */
8567 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
8568 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
8569
8570 {
8571 /* changing from little to big endian since supplicant
8572 * works on big endian format
8573 */
8574 int i;
8575 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
8576
8577 for (i = 0; i < 8; i++)
8578 {
8579 tempReplayCounter[7-i] = (tANI_U8)p[i];
8580 }
8581 }
8582
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308583 /* Update replay counter to NL */
8584 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308585 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308586}
8587
8588/*
8589 * FUNCTION: wlan_hdd_cfg80211_set_rekey_data
8590 * This function is used to offload GTK rekeying job to the firmware.
8591 */
8592int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
8593 struct cfg80211_gtk_rekey_data *data)
8594{
8595 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8596 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8597 hdd_station_ctx_t *pHddStaCtx;
8598 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308599 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308600 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308601 eHalStatus status = eHAL_STATUS_FAILURE;
8602
8603 ENTER();
8604
8605 if (NULL == pAdapter)
8606 {
8607 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8608 "%s: HDD adapter is Null", __func__);
8609 return -ENODEV;
8610 }
8611
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308612 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308613
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308614 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308615 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308616 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8617 "%s: HDD context is not valid", __func__);
8618 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308619 }
8620
8621 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8622 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8623 if (NULL == hHal)
8624 {
8625 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8626 "%s: HAL context is Null!!!", __func__);
8627 return -EAGAIN;
8628 }
8629
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308630 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
8631 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
8632 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
8633 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308634 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308635 {
8636 /* changing from big to little endian since driver
8637 * works on little endian format
8638 */
8639 tANI_U8 *p =
8640 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
8641 int i;
8642
8643 for (i = 0; i < 8; i++)
8644 {
8645 p[7-i] = data->replay_ctr[i];
8646 }
8647 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308648
8649 if (TRUE == pHddCtx->hdd_wlan_suspended)
8650 {
8651 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308652 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
8653 sizeof (tSirGtkOffloadParams));
8654 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308655 pAdapter->sessionId);
8656
8657 if (eHAL_STATUS_SUCCESS != status)
8658 {
8659 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8660 "%s: sme_SetGTKOffload failed, returned %d",
8661 __func__, status);
8662 return status;
8663 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308664 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8665 "%s: sme_SetGTKOffload successfull", __func__);
8666 }
8667 else
8668 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308669 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8670 "%s: wlan not suspended GTKOffload request is stored",
8671 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308672 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308673
8674 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308675}
8676#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
8677
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308678/*
8679 * FUNCTION: wlan_hdd_cfg80211_set_mac_acl
8680 * This function is used to set access control policy
8681 */
8682static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
8683 struct net_device *dev, const struct cfg80211_acl_data *params)
8684{
8685 int i;
8686 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8687 hdd_hostapd_state_t *pHostapdState;
8688 tsap_Config_t *pConfig;
8689 v_CONTEXT_t pVosContext = NULL;
8690 hdd_context_t *pHddCtx;
8691 int status;
8692
8693 ENTER();
8694
8695 if (NULL == pAdapter)
8696 {
8697 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8698 "%s: HDD adapter is Null", __func__);
8699 return -ENODEV;
8700 }
8701
8702 if (NULL == params)
8703 {
8704 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8705 "%s: params is Null", __func__);
8706 return -EINVAL;
8707 }
8708
8709 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8710 status = wlan_hdd_validate_context(pHddCtx);
8711
8712 if (0 != status)
8713 {
8714 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8715 "%s: HDD context is not valid", __func__);
8716 return status;
8717 }
8718
8719 pVosContext = pHddCtx->pvosContext;
8720 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
8721
8722 if (NULL == pHostapdState)
8723 {
8724 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8725 "%s: pHostapdState is Null", __func__);
8726 return -EINVAL;
8727 }
8728
8729 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
8730 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
8731
8732 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
8733 {
8734 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
8735
8736 /* default value */
8737 pConfig->num_accept_mac = 0;
8738 pConfig->num_deny_mac = 0;
8739
8740 /**
8741 * access control policy
8742 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
8743 * listed in hostapd.deny file.
8744 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
8745 * listed in hostapd.accept file.
8746 */
8747 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
8748 {
8749 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
8750 }
8751 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
8752 {
8753 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
8754 }
8755 else
8756 {
8757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8758 "%s:Acl Policy : %d is not supported",
8759 __func__, params->acl_policy);
8760 return -ENOTSUPP;
8761 }
8762
8763 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
8764 {
8765 pConfig->num_accept_mac = params->n_acl_entries;
8766 for (i = 0; i < params->n_acl_entries; i++)
8767 {
8768 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8769 "** Add ACL MAC entry %i in WhiletList :"
8770 MAC_ADDRESS_STR, i,
8771 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8772
8773 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
8774 sizeof(qcmacaddr));
8775 }
8776 }
8777 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
8778 {
8779 pConfig->num_deny_mac = params->n_acl_entries;
8780 for (i = 0; i < params->n_acl_entries; i++)
8781 {
8782 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8783 "** Add ACL MAC entry %i in BlackList :"
8784 MAC_ADDRESS_STR, i,
8785 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8786
8787 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
8788 sizeof(qcmacaddr));
8789 }
8790 }
8791
8792 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
8793 {
8794 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8795 "%s: SAP Set Mac Acl fail", __func__);
8796 return -EINVAL;
8797 }
8798 }
8799 else
8800 {
8801 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8802 "%s: Invalid device_mode = %d",
8803 __func__, pAdapter->device_mode);
8804 return -EINVAL;
8805 }
8806
8807 return 0;
8808}
8809
Leo Chang9056f462013-08-01 19:21:11 -07008810#ifdef WLAN_NL80211_TESTMODE
8811#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -07008812void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -07008813(
8814 void *pAdapter,
8815 void *indCont
8816)
8817{
Leo Changd9df8aa2013-09-26 13:32:26 -07008818 tSirLPHBInd *lphbInd;
8819 struct sk_buff *skb;
Leo Chang9056f462013-08-01 19:21:11 -07008820
8821 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07008822 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -07008823
8824 if (NULL == indCont)
8825 {
8826 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07008827 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -07008828 return;
8829 }
8830
Leo Changd9df8aa2013-09-26 13:32:26 -07008831 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -07008832 skb = cfg80211_testmode_alloc_event_skb(
8833 ((hdd_adapter_t *)pAdapter)->wdev.wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -07008834 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -07008835 GFP_ATOMIC);
8836 if (!skb)
8837 {
8838 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8839 "LPHB timeout, NL buffer alloc fail");
8840 return;
8841 }
8842
Leo Changac3ba772013-10-07 09:47:04 -07008843 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -07008844 {
8845 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8846 "WLAN_HDD_TM_ATTR_CMD put fail");
8847 goto nla_put_failure;
8848 }
Leo Changac3ba772013-10-07 09:47:04 -07008849 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -07008850 {
8851 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8852 "WLAN_HDD_TM_ATTR_TYPE put fail");
8853 goto nla_put_failure;
8854 }
Leo Changac3ba772013-10-07 09:47:04 -07008855 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -07008856 sizeof(tSirLPHBInd), lphbInd))
8857 {
8858 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8859 "WLAN_HDD_TM_ATTR_DATA put fail");
8860 goto nla_put_failure;
8861 }
Leo Chang9056f462013-08-01 19:21:11 -07008862 cfg80211_testmode_event(skb, GFP_ATOMIC);
8863 return;
8864
8865nla_put_failure:
8866 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8867 "NLA Put fail");
8868 kfree_skb(skb);
8869
8870 return;
8871}
8872#endif /* FEATURE_WLAN_LPHB */
8873
8874static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
8875{
8876 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
8877 int err = 0;
8878#ifdef FEATURE_WLAN_LPHB
8879 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -07008880 eHalStatus smeStatus;
Leo Chang9056f462013-08-01 19:21:11 -07008881#endif /* FEATURE_WLAN_LPHB */
8882
8883 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
8884 if (err)
8885 {
8886 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8887 "%s Testmode INV ATTR", __func__);
8888 return err;
8889 }
8890
8891 if (!tb[WLAN_HDD_TM_ATTR_CMD])
8892 {
8893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8894 "%s Testmode INV CMD", __func__);
8895 return -EINVAL;
8896 }
8897
8898 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
8899 {
8900#ifdef FEATURE_WLAN_LPHB
8901 /* Low Power Heartbeat configuration request */
8902 case WLAN_HDD_TM_CMD_WLAN_HB:
8903 {
8904 int buf_len;
8905 void *buf;
8906 tSirLPHBReq *hb_params = NULL;
8907
8908 if (!tb[WLAN_HDD_TM_ATTR_DATA])
8909 {
8910 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8911 "%s Testmode INV DATA", __func__);
8912 return -EINVAL;
8913 }
8914
8915 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
8916 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
8917 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
8918 if (NULL == hb_params)
8919 {
8920 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8921 "%s Request Buffer Alloc Fail", __func__);
8922 return -EINVAL;
8923 }
8924
8925 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -07008926 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
8927 hb_params,
8928 wlan_hdd_cfg80211_lphb_ind_handler);
8929 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -07008930 {
Leo Changd9df8aa2013-09-26 13:32:26 -07008931 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8932 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -07008933 vos_mem_free(hb_params);
8934 }
Leo Chang9056f462013-08-01 19:21:11 -07008935 return 0;
8936 }
8937#endif /* FEATURE_WLAN_LPHB */
8938 default:
8939 return -EOPNOTSUPP;
8940 }
8941
8942 return err;
8943}
8944#endif /* CONFIG_NL80211_TESTMODE */
8945
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308946static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
8947 struct net_device *dev,
8948 int idx, struct survey_info *survey)
8949{
8950 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8951 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +05308952 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308953 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +05308954 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308955 v_S7_t snr,rssi;
8956 int status, i, j, filled = 0;
8957
8958 ENTER();
8959
8960
8961 if (NULL == pAdapter)
8962 {
8963 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8964 "%s: HDD adapter is Null", __func__);
8965 return -ENODEV;
8966 }
8967
8968 if (NULL == wiphy)
8969 {
8970 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8971 "%s: wiphy is Null", __func__);
8972 return -ENODEV;
8973 }
8974
8975 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8976 status = wlan_hdd_validate_context(pHddCtx);
8977
8978 if (0 != status)
8979 {
8980 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8981 "%s: HDD context is not valid", __func__);
8982 return status;
8983 }
8984
Mihir Sheted9072e02013-08-21 17:02:29 +05308985 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8986
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308987 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +05308988 0 != pAdapter->survey_idx ||
8989 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308990 {
8991 /* The survey dump ops when implemented completely is expected to
8992 * return a survey of all channels and the ops is called by the
8993 * kernel with incremental values of the argument 'idx' till it
8994 * returns -ENONET. But we can only support the survey for the
8995 * operating channel for now. survey_idx is used to track
8996 * that the ops is called only once and then return -ENONET for
8997 * the next iteration
8998 */
8999 pAdapter->survey_idx = 0;
9000 return -ENONET;
9001 }
9002
9003 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
9004
9005 wlan_hdd_get_snr(pAdapter, &snr);
9006 wlan_hdd_get_rssi(pAdapter, &rssi);
9007
9008 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
9009 hdd_wlan_get_freq(channel, &freq);
9010
9011
9012 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
9013 {
9014 if (NULL == wiphy->bands[i])
9015 {
9016 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9017 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
9018 continue;
9019 }
9020
9021 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
9022 {
9023 struct ieee80211_supported_band *band = wiphy->bands[i];
9024
9025 if (band->channels[j].center_freq == (v_U16_t)freq)
9026 {
9027 survey->channel = &band->channels[j];
9028 /* The Rx BDs contain SNR values in dB for the received frames
9029 * while the supplicant expects noise. So we calculate and
9030 * return the value of noise (dBm)
9031 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
9032 */
9033 survey->noise = rssi - snr;
9034 survey->filled = SURVEY_INFO_NOISE_DBM;
9035 filled = 1;
9036 }
9037 }
9038 }
9039
9040 if (filled)
9041 pAdapter->survey_idx = 1;
9042 else
9043 {
9044 pAdapter->survey_idx = 0;
9045 return -ENONET;
9046 }
9047
9048 return 0;
9049}
9050
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309051/*
9052 * FUNCTION: wlan_hdd_cfg80211_resume_wlan
9053 * this is called when cfg80211 driver resume
9054 * driver updates latest sched_scan scan result(if any) to cfg80211 database
9055 */
9056int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
9057{
9058 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9059 hdd_adapter_t *pAdapter;
9060 hdd_adapter_list_node_t *pAdapterNode, *pNext;
9061 VOS_STATUS status = VOS_STATUS_SUCCESS;
9062
9063 ENTER();
9064
9065 if ( NULL == pHddCtx )
9066 {
9067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9068 "%s: HddCtx validation failed", __func__);
9069 return 0;
9070 }
9071
9072 if (pHddCtx->isLogpInProgress)
9073 {
9074 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9075 "%s: LOGP in Progress. Ignore!!!", __func__);
9076 return 0;
9077 }
9078
9079 if (pHddCtx->isLoadUnloadInProgress)
9080 {
9081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9082 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
9083 return 0;
9084 }
9085
9086 spin_lock(&pHddCtx->schedScan_lock);
9087 pHddCtx->isWiphySuspended = FALSE;
9088 if (TRUE != pHddCtx->isSchedScanUpdatePending)
9089 {
9090 spin_unlock(&pHddCtx->schedScan_lock);
9091 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9092 "%s: Return resume is not due to PNO indication", __func__);
9093 return 0;
9094 }
9095 // Reset flag to avoid updatating cfg80211 data old results again
9096 pHddCtx->isSchedScanUpdatePending = FALSE;
9097 spin_unlock(&pHddCtx->schedScan_lock);
9098
9099 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
9100
9101 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
9102 {
9103 pAdapter = pAdapterNode->pAdapter;
9104 if ( (NULL != pAdapter) &&
9105 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
9106 {
9107 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
9108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9109 "%s: NO SCAN result", __func__);
9110 else
9111 cfg80211_sched_scan_results(pHddCtx->wiphy);
9112
9113 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9114 "%s : cfg80211 scan result database updated", __func__);
9115
9116 return 0;
9117
9118 }
9119 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
9120 pAdapterNode = pNext;
9121 }
9122
9123 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9124 "%s: Failed to find Adapter", __func__);
9125 return 0;
9126}
9127
9128/*
9129 * FUNCTION: wlan_hdd_cfg80211_suspend_wlan
9130 * this is called when cfg80211 driver suspends
9131 */
9132int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
9133 struct cfg80211_wowlan *wow)
9134{
9135 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9136
9137 ENTER();
9138 if (NULL == pHddCtx)
9139 {
9140 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9141 "%s: HddCtx validation failed", __func__);
9142 return 0;
9143 }
9144
9145 pHddCtx->isWiphySuspended = TRUE;
9146
9147 EXIT();
9148
9149 return 0;
9150}
9151
Jeff Johnson295189b2012-06-20 16:38:30 -07009152/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309153static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -07009154{
9155 .add_virtual_intf = wlan_hdd_add_virtual_intf,
9156 .del_virtual_intf = wlan_hdd_del_virtual_intf,
9157 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
9158 .change_station = wlan_hdd_change_station,
9159#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9160 .add_beacon = wlan_hdd_cfg80211_add_beacon,
9161 .del_beacon = wlan_hdd_cfg80211_del_beacon,
9162 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009163#else
9164 .start_ap = wlan_hdd_cfg80211_start_ap,
9165 .change_beacon = wlan_hdd_cfg80211_change_beacon,
9166 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -07009167#endif
9168 .change_bss = wlan_hdd_cfg80211_change_bss,
9169 .add_key = wlan_hdd_cfg80211_add_key,
9170 .get_key = wlan_hdd_cfg80211_get_key,
9171 .del_key = wlan_hdd_cfg80211_del_key,
9172 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009173#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009174 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009175#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009176 .scan = wlan_hdd_cfg80211_scan,
9177 .connect = wlan_hdd_cfg80211_connect,
9178 .disconnect = wlan_hdd_cfg80211_disconnect,
9179 .join_ibss = wlan_hdd_cfg80211_join_ibss,
9180 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
9181 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
9182 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
9183 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -07009184 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
9185 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
9186 .mgmt_tx = wlan_hdd_action,
9187#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9188 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
9189 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
9190 .set_txq_params = wlan_hdd_set_txq_params,
9191#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009192 .get_station = wlan_hdd_cfg80211_get_station,
9193 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
9194 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009195 .add_station = wlan_hdd_cfg80211_add_station,
9196#ifdef FEATURE_WLAN_LFR
9197 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
9198 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
9199 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
9200#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009201#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
9202 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
9203#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009204#ifdef FEATURE_WLAN_TDLS
9205 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
9206 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
9207#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309208#ifdef WLAN_FEATURE_GTK_OFFLOAD
9209 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
9210#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309211#ifdef FEATURE_WLAN_SCAN_PNO
9212 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
9213 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
9214#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309215 .resume = wlan_hdd_cfg80211_resume_wlan,
9216 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309217 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -07009218#ifdef WLAN_NL80211_TESTMODE
9219 .testmode_cmd = wlan_hdd_cfg80211_testmode,
9220#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309221 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009222};
9223