blob: 7afdcd0fbdc3b679fbdc6de0af2ac0706318d5aa [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20*/
Jeff Johnson295189b2012-06-20 16:38:30 -070021
22/**========================================================================
23
24 \file wlan_hdd_cfg80211.c
25
26 \brief WLAN Host Device Driver implementation
27
Gopichand Nakkala747461f2013-04-24 19:24:45 +053028 Copyright 2008 (c) Qualcomm Technologies, Inc. All Rights Reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070029
Gopichand Nakkala747461f2013-04-24 19:24:45 +053030 Qualcomm Technologies Confidential and Proprietary.
Jeff Johnson295189b2012-06-20 16:38:30 -070031
32 ========================================================================*/
33
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070034/**=========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070035
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070036 EDIT HISTORY FOR FILE
Jeff Johnson295189b2012-06-20 16:38:30 -070037
38
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070039 This section contains comments describing changes made to the module.
40 Notice that changes are listed in reverse chronological order.
Jeff Johnson295189b2012-06-20 16:38:30 -070041
42
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070043 $Header:$ $DateTime: $ $Author: $
Jeff Johnson295189b2012-06-20 16:38:30 -070044
45
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070046 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070047 -------- --- --------------------------------------------------------
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070048 21/12/09 Ashwani Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070049
50 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070051 Ganesh K
Jeff Johnson295189b2012-06-20 16:38:30 -070052 ==========================================================================*/
53
Jeff Johnson295189b2012-06-20 16:38:30 -070054
55#include <linux/version.h>
56#include <linux/module.h>
57#include <linux/kernel.h>
58#include <linux/init.h>
59#include <linux/wireless.h>
60#include <wlan_hdd_includes.h>
61#include <net/arp.h>
62#include <net/cfg80211.h>
63#include <linux/wireless.h>
64#include <wlan_hdd_wowl.h>
65#include <aniGlobal.h>
66#include "ccmApi.h"
67#include "sirParams.h"
68#include "dot11f.h"
69#include "wlan_hdd_assoc.h"
70#include "wlan_hdd_wext.h"
71#include "sme_Api.h"
72#include "wlan_hdd_p2p.h"
73#include "wlan_hdd_cfg80211.h"
74#include "wlan_hdd_hostapd.h"
75#include "sapInternal.h"
76#include "wlan_hdd_softap_tx_rx.h"
77#include "wlan_hdd_main.h"
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053078#include "wlan_hdd_assoc.h"
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053079#include "wlan_hdd_power.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070080#ifdef WLAN_BTAMP_FEATURE
81#include "bap_hdd_misc.h"
82#endif
83#include <qc_sap_ioctl.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080084#ifdef FEATURE_WLAN_TDLS
85#include "wlan_hdd_tdls.h"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053086#include "wlan_hdd_wmm.h"
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053087#include "wlan_qct_wda.h"
Mohit Khanna698ba2a2012-12-04 15:08:18 -080088#endif
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053089#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070090#include "wlan_hdd_dev_pwr.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070091
92#define g_mode_rates_size (12)
93#define a_mode_rates_size (8)
94#define FREQ_BASE_80211G (2407)
95#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070096#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +053097#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -070098#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
99 ((int) OFFSET_OF( tSirBssDescription, ieFields)))
100
101#define HDD2GHZCHAN(freq, chan, flag) { \
102 .band = IEEE80211_BAND_2GHZ, \
103 .center_freq = (freq), \
104 .hw_value = (chan),\
105 .flags = (flag), \
106 .max_antenna_gain = 0 ,\
107 .max_power = 30, \
108}
109
110#define HDD5GHZCHAN(freq, chan, flag) { \
111 .band = IEEE80211_BAND_5GHZ, \
112 .center_freq = (freq), \
113 .hw_value = (chan),\
114 .flags = (flag), \
115 .max_antenna_gain = 0 ,\
116 .max_power = 30, \
117}
118
119#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
120{\
121 .bitrate = rate, \
122 .hw_value = rate_id, \
123 .flags = flag, \
124}
125
Lee Hoonkic1262f22013-01-24 21:59:00 -0800126#ifndef WLAN_FEATURE_TDLS_DEBUG
127#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_INFO
128#else
129#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_ERROR
130#endif
131
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530132#ifdef WLAN_FEATURE_VOWIFI_11R
133#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
134#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
135#endif
136
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530137static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700138{
139 WLAN_CIPHER_SUITE_WEP40,
140 WLAN_CIPHER_SUITE_WEP104,
141 WLAN_CIPHER_SUITE_TKIP,
142#ifdef FEATURE_WLAN_CCX
143#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
144 WLAN_CIPHER_SUITE_KRK,
145 WLAN_CIPHER_SUITE_CCMP,
146#else
147 WLAN_CIPHER_SUITE_CCMP,
148#endif
149#ifdef FEATURE_WLAN_WAPI
150 WLAN_CIPHER_SUITE_SMS4,
151#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700152#ifdef WLAN_FEATURE_11W
153 WLAN_CIPHER_SUITE_AES_CMAC,
154#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700155};
156
157static inline int is_broadcast_ether_addr(const u8 *addr)
158{
159 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
160 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
161}
162
163static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530164{
Jeff Johnson295189b2012-06-20 16:38:30 -0700165 HDD2GHZCHAN(2412, 1, 0) ,
166 HDD2GHZCHAN(2417, 2, 0) ,
167 HDD2GHZCHAN(2422, 3, 0) ,
168 HDD2GHZCHAN(2427, 4, 0) ,
169 HDD2GHZCHAN(2432, 5, 0) ,
170 HDD2GHZCHAN(2437, 6, 0) ,
171 HDD2GHZCHAN(2442, 7, 0) ,
172 HDD2GHZCHAN(2447, 8, 0) ,
173 HDD2GHZCHAN(2452, 9, 0) ,
174 HDD2GHZCHAN(2457, 10, 0) ,
175 HDD2GHZCHAN(2462, 11, 0) ,
176 HDD2GHZCHAN(2467, 12, 0) ,
177 HDD2GHZCHAN(2472, 13, 0) ,
178 HDD2GHZCHAN(2484, 14, 0) ,
179};
180
Jeff Johnson295189b2012-06-20 16:38:30 -0700181static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
182{
183 HDD2GHZCHAN(2412, 1, 0) ,
184 HDD2GHZCHAN(2437, 6, 0) ,
185 HDD2GHZCHAN(2462, 11, 0) ,
186};
Jeff Johnson295189b2012-06-20 16:38:30 -0700187
188static struct ieee80211_channel hdd_channels_5_GHZ[] =
189{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700190 HDD5GHZCHAN(4920, 240, 0) ,
191 HDD5GHZCHAN(4940, 244, 0) ,
192 HDD5GHZCHAN(4960, 248, 0) ,
193 HDD5GHZCHAN(4980, 252, 0) ,
194 HDD5GHZCHAN(5040, 208, 0) ,
195 HDD5GHZCHAN(5060, 212, 0) ,
196 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700197 HDD5GHZCHAN(5180, 36, 0) ,
198 HDD5GHZCHAN(5200, 40, 0) ,
199 HDD5GHZCHAN(5220, 44, 0) ,
200 HDD5GHZCHAN(5240, 48, 0) ,
201 HDD5GHZCHAN(5260, 52, 0) ,
202 HDD5GHZCHAN(5280, 56, 0) ,
203 HDD5GHZCHAN(5300, 60, 0) ,
204 HDD5GHZCHAN(5320, 64, 0) ,
205 HDD5GHZCHAN(5500,100, 0) ,
206 HDD5GHZCHAN(5520,104, 0) ,
207 HDD5GHZCHAN(5540,108, 0) ,
208 HDD5GHZCHAN(5560,112, 0) ,
209 HDD5GHZCHAN(5580,116, 0) ,
210 HDD5GHZCHAN(5600,120, 0) ,
211 HDD5GHZCHAN(5620,124, 0) ,
212 HDD5GHZCHAN(5640,128, 0) ,
213 HDD5GHZCHAN(5660,132, 0) ,
214 HDD5GHZCHAN(5680,136, 0) ,
215 HDD5GHZCHAN(5700,140, 0) ,
216 HDD5GHZCHAN(5745,149, 0) ,
217 HDD5GHZCHAN(5765,153, 0) ,
218 HDD5GHZCHAN(5785,157, 0) ,
219 HDD5GHZCHAN(5805,161, 0) ,
220 HDD5GHZCHAN(5825,165, 0) ,
221};
222
223static struct ieee80211_rate g_mode_rates[] =
224{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530225 HDD_G_MODE_RATETAB(10, 0x1, 0),
226 HDD_G_MODE_RATETAB(20, 0x2, 0),
227 HDD_G_MODE_RATETAB(55, 0x4, 0),
228 HDD_G_MODE_RATETAB(110, 0x8, 0),
229 HDD_G_MODE_RATETAB(60, 0x10, 0),
230 HDD_G_MODE_RATETAB(90, 0x20, 0),
231 HDD_G_MODE_RATETAB(120, 0x40, 0),
232 HDD_G_MODE_RATETAB(180, 0x80, 0),
233 HDD_G_MODE_RATETAB(240, 0x100, 0),
234 HDD_G_MODE_RATETAB(360, 0x200, 0),
235 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700236 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530237};
Jeff Johnson295189b2012-06-20 16:38:30 -0700238
239static struct ieee80211_rate a_mode_rates[] =
240{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530241 HDD_G_MODE_RATETAB(60, 0x10, 0),
242 HDD_G_MODE_RATETAB(90, 0x20, 0),
243 HDD_G_MODE_RATETAB(120, 0x40, 0),
244 HDD_G_MODE_RATETAB(180, 0x80, 0),
245 HDD_G_MODE_RATETAB(240, 0x100, 0),
246 HDD_G_MODE_RATETAB(360, 0x200, 0),
247 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700248 HDD_G_MODE_RATETAB(540, 0x800, 0),
249};
250
251static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
252{
253 .channels = hdd_channels_2_4_GHZ,
254 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
255 .band = IEEE80211_BAND_2GHZ,
256 .bitrates = g_mode_rates,
257 .n_bitrates = g_mode_rates_size,
258 .ht_cap.ht_supported = 1,
259 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
260 | IEEE80211_HT_CAP_GRN_FLD
261 | IEEE80211_HT_CAP_DSSSCCK40
262 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
263 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
264 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
265 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
266 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
267 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
268};
269
Jeff Johnson295189b2012-06-20 16:38:30 -0700270static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
271{
272 .channels = hdd_social_channels_2_4_GHZ,
273 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
274 .band = IEEE80211_BAND_2GHZ,
275 .bitrates = g_mode_rates,
276 .n_bitrates = g_mode_rates_size,
277 .ht_cap.ht_supported = 1,
278 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
279 | IEEE80211_HT_CAP_GRN_FLD
280 | IEEE80211_HT_CAP_DSSSCCK40
281 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
282 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
283 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
284 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
285 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
286 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
287};
Jeff Johnson295189b2012-06-20 16:38:30 -0700288
289static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
290{
291 .channels = hdd_channels_5_GHZ,
292 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
293 .band = IEEE80211_BAND_5GHZ,
294 .bitrates = a_mode_rates,
295 .n_bitrates = a_mode_rates_size,
296 .ht_cap.ht_supported = 1,
297 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
298 | IEEE80211_HT_CAP_GRN_FLD
299 | IEEE80211_HT_CAP_DSSSCCK40
300 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
301 | IEEE80211_HT_CAP_SGI_40
302 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
303 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
304 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
305 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
306 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
307 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
308};
309
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530310/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700311 TX/RX direction for each kind of interface */
312static const struct ieee80211_txrx_stypes
313wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
314 [NL80211_IFTYPE_STATION] = {
315 .tx = 0xffff,
316 .rx = BIT(SIR_MAC_MGMT_ACTION) |
317 BIT(SIR_MAC_MGMT_PROBE_REQ),
318 },
319 [NL80211_IFTYPE_AP] = {
320 .tx = 0xffff,
321 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
322 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
323 BIT(SIR_MAC_MGMT_PROBE_REQ) |
324 BIT(SIR_MAC_MGMT_DISASSOC) |
325 BIT(SIR_MAC_MGMT_AUTH) |
326 BIT(SIR_MAC_MGMT_DEAUTH) |
327 BIT(SIR_MAC_MGMT_ACTION),
328 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700329 [NL80211_IFTYPE_ADHOC] = {
330 .tx = 0xffff,
331 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
332 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
333 BIT(SIR_MAC_MGMT_PROBE_REQ) |
334 BIT(SIR_MAC_MGMT_DISASSOC) |
335 BIT(SIR_MAC_MGMT_AUTH) |
336 BIT(SIR_MAC_MGMT_DEAUTH) |
337 BIT(SIR_MAC_MGMT_ACTION),
338 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700339 [NL80211_IFTYPE_P2P_CLIENT] = {
340 .tx = 0xffff,
341 .rx = BIT(SIR_MAC_MGMT_ACTION) |
342 BIT(SIR_MAC_MGMT_PROBE_REQ),
343 },
344 [NL80211_IFTYPE_P2P_GO] = {
345 /* This is also same as for SoftAP */
346 .tx = 0xffff,
347 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
348 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
349 BIT(SIR_MAC_MGMT_PROBE_REQ) |
350 BIT(SIR_MAC_MGMT_DISASSOC) |
351 BIT(SIR_MAC_MGMT_AUTH) |
352 BIT(SIR_MAC_MGMT_DEAUTH) |
353 BIT(SIR_MAC_MGMT_ACTION),
354 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700355};
356
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800357#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800358static const struct ieee80211_iface_limit
359wlan_hdd_iface_limit[] = {
360 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800361 /* max = 3 ; Our driver create two interfaces during driver init
362 * wlan0 and p2p0 interfaces. p2p0 is considered as station
363 * interface until a group is formed. In JB architecture, once the
364 * group is formed, interface type of p2p0 is changed to P2P GO or
365 * Client.
366 * When supplicant remove the group, it first issue a set interface
367 * cmd to change the mode back to Station. In JB this works fine as
368 * we advertize two station type interface during driver init.
369 * Some vendors create separate interface for P2P GO/Client,
370 * after group formation(Third one). But while group remove
371 * supplicant first tries to change the mode(3rd interface) to STATION
372 * But as we advertized only two sta type interfaces nl80211 was
373 * returning error for the third one which was leading to failure in
374 * delete interface. Ideally while removing the group, supplicant
375 * should not try to change the 3rd interface mode to Station type.
376 * Till we get a fix in wpa_supplicant, we advertize max STA
377 * interface type to 3
378 */
379 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800380 .types = BIT(NL80211_IFTYPE_STATION),
381 },
382 {
383 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700384 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800385 },
386 {
387 .max = 1,
388 .types = BIT(NL80211_IFTYPE_P2P_GO) |
389 BIT(NL80211_IFTYPE_P2P_CLIENT),
390 },
391};
392
393/* By default, only single channel concurrency is allowed */
394static struct ieee80211_iface_combination
395wlan_hdd_iface_combination = {
396 .limits = wlan_hdd_iface_limit,
397 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800398 /*
399 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
400 * and p2p0 interfaces during driver init
401 * Some vendors create separate interface for P2P operations.
402 * wlan0: STA interface
403 * p2p0: P2P Device interface, action frames goes
404 * through this interface.
405 * p2p-xx: P2P interface, After GO negotiation this interface is
406 * created for p2p operations(GO/CLIENT interface).
407 */
408 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800409 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
410 .beacon_int_infra_match = false,
411};
412#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800413
Jeff Johnson295189b2012-06-20 16:38:30 -0700414static struct cfg80211_ops wlan_hdd_cfg80211_ops;
415
416/* Data rate 100KBPS based on IE Index */
417struct index_data_rate_type
418{
419 v_U8_t beacon_rate_index;
420 v_U16_t supported_rate[4];
421};
422
423/* 11B, 11G Rate table include Basic rate and Extended rate
424 The IDX field is the rate index
425 The HI field is the rate when RSSI is strong or being ignored
426 (in this case we report actual rate)
427 The MID field is the rate when RSSI is moderate
428 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
429 The LO field is the rate when RSSI is low
430 (in this case we don't report rates, actual current rate used)
431 */
432static const struct
433{
434 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700435 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700436} supported_data_rate[] =
437{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700438/* IDX HI HM LM LO (RSSI-based index */
439 {2, { 10, 10, 10, 0}},
440 {4, { 20, 20, 10, 0}},
441 {11, { 55, 20, 10, 0}},
442 {12, { 60, 55, 20, 0}},
443 {18, { 90, 55, 20, 0}},
444 {22, {110, 55, 20, 0}},
445 {24, {120, 90, 60, 0}},
446 {36, {180, 120, 60, 0}},
447 {44, {220, 180, 60, 0}},
448 {48, {240, 180, 90, 0}},
449 {66, {330, 180, 90, 0}},
450 {72, {360, 240, 90, 0}},
451 {96, {480, 240, 120, 0}},
452 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700453};
454
455/* MCS Based rate table */
456static struct index_data_rate_type supported_mcs_rate[] =
457{
458/* MCS L20 L40 S20 S40 */
459 {0, {65, 135, 72, 150}},
460 {1, {130, 270, 144, 300}},
461 {2, {195, 405, 217, 450}},
462 {3, {260, 540, 289, 600}},
463 {4, {390, 810, 433, 900}},
464 {5, {520, 1080, 578, 1200}},
465 {6, {585, 1215, 650, 1350}},
466 {7, {650, 1350, 722, 1500}}
467};
468
Leo Chang6f8870f2013-03-26 18:11:36 -0700469#ifdef WLAN_FEATURE_11AC
470
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530471#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700472
473struct index_vht_data_rate_type
474{
475 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530476 v_U16_t supported_VHT80_rate[2];
477 v_U16_t supported_VHT40_rate[2];
478 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700479};
480
481typedef enum
482{
483 DATA_RATE_11AC_MAX_MCS_7,
484 DATA_RATE_11AC_MAX_MCS_8,
485 DATA_RATE_11AC_MAX_MCS_9,
486 DATA_RATE_11AC_MAX_MCS_NA
487} eDataRate11ACMaxMcs;
488
489/* MCS Based VHT rate table */
490static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
491{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530492/* MCS L80 S80 L40 S40 L20 S40*/
493 {0, {293, 325}, {135, 150}, {65, 72}},
494 {1, {585, 650}, {270, 300}, {130, 144}},
495 {2, {878, 975}, {405, 450}, {195, 217}},
496 {3, {1170, 1300}, {540, 600}, {260, 289}},
497 {4, {1755, 1950}, {810, 900}, {390, 433}},
498 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
499 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
500 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
501 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
502 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700503};
504#endif /* WLAN_FEATURE_11AC */
505
Jeff Johnson295189b2012-06-20 16:38:30 -0700506extern struct net_device_ops net_ops_struct;
507
Leo Chang9056f462013-08-01 19:21:11 -0700508#ifdef WLAN_NL80211_TESTMODE
509enum wlan_hdd_tm_attr
510{
511 WLAN_HDD_TM_ATTR_INVALID = 0,
512 WLAN_HDD_TM_ATTR_CMD = 1,
513 WLAN_HDD_TM_ATTR_DATA = 2,
514 WLAN_HDD_TM_ATTR_TYPE = 3,
515 /* keep last */
516 WLAN_HDD_TM_ATTR_AFTER_LAST,
517 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
518};
519
520enum wlan_hdd_tm_cmd
521{
522 WLAN_HDD_TM_CMD_WLAN_HB = 1,
523};
524
525#define WLAN_HDD_TM_DATA_MAX_LEN 5000
526
527static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
528{
529 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
530 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
531 .len = WLAN_HDD_TM_DATA_MAX_LEN },
532};
533#endif /* WLAN_NL80211_TESTMODE */
534
Jeff Johnson295189b2012-06-20 16:38:30 -0700535/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530536 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530537 * This function is called by hdd_wlan_startup()
538 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530539 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -0700540 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530541struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -0700542{
543 struct wiphy *wiphy;
544 ENTER();
545
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530546 /*
547 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -0700548 */
549 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
550
551 if (!wiphy)
552 {
553 /* Print error and jump into err label and free the memory */
554 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
555 return NULL;
556 }
557
558 return wiphy;
559}
560
561/*
562 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530563 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -0700564 * private ioctl to change the band value
565 */
566int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
567{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530568 int i, j;
569 eNVChannelEnabledType channelEnabledState;
570
Jeff Johnsone7245742012-09-05 17:12:55 -0700571 ENTER();
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530572 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700573 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530574
575 if (NULL == wiphy->bands[i])
576 {
577 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
578 __func__, i);
579 continue;
580 }
581
582 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
583 {
584 struct ieee80211_supported_band *band = wiphy->bands[i];
585
586 channelEnabledState = vos_nv_getChannelEnabledState(
587 band->channels[j].hw_value);
588
589 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
590 {
591 // Enable Social channels for P2P
592 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq) &&
593 NV_CHANNEL_ENABLE == channelEnabledState)
594 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
595 else
596 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
597 continue;
598 }
599 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
600 {
601 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
602 continue;
603 }
604
605 if (NV_CHANNEL_DISABLE == channelEnabledState ||
606 NV_CHANNEL_INVALID == channelEnabledState)
607 {
608 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
609 }
610 else if (NV_CHANNEL_DFS == channelEnabledState)
611 {
612 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
613 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
614 }
615 else
616 {
617 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
618 |IEEE80211_CHAN_RADAR);
619 }
620 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700621 }
622 return 0;
623}
624/*
625 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530626 * This function is called by hdd_wlan_startup()
627 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 * This function is used to initialize and register wiphy structure.
629 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530630int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -0700631 struct wiphy *wiphy,
632 hdd_config_t *pCfg
633 )
634{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530635 int i, j;
Jeff Johnsone7245742012-09-05 17:12:55 -0700636 ENTER();
637
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 /* Now bind the underlying wlan device with wiphy */
639 set_wiphy_dev(wiphy, dev);
640
641 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -0700642
Kiet Lam6c583332013-10-14 05:37:09 +0530643#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -0700644 /* the flag for the other case would be initialzed in
645 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -0700646 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +0530647#endif
Amar Singhala49cbc52013-10-08 18:37:44 -0700648
Amar Singhalfddc28c2013-09-05 13:03:40 -0700649 /* This will disable updating of NL channels from passive to
650 * active if a beacon is received on passive channel. */
651 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Amar Singhalf0073192013-09-20 12:34:56 -0700652
Amar Singhalfddc28c2013-09-05 13:03:40 -0700653
Amar Singhala49cbc52013-10-08 18:37:44 -0700654
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700655#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -0700656 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
657 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
658 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -0700659 | WIPHY_FLAG_OFFCHAN_TX;
Kiet Lam6c583332013-10-14 05:37:09 +0530660 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700661#endif
Amar Singhala49cbc52013-10-08 18:37:44 -0700662
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700663#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
664 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -0800665#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700666 || pCfg->isFastRoamIniFeatureEnabled
667#endif
668#ifdef FEATURE_WLAN_CCX
669 || pCfg->isCcxIniFeatureEnabled
670#endif
671 )
672 {
673 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
674 }
James Zmuda77fb5ae2013-01-29 08:00:17 -0800675#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800676#ifdef FEATURE_WLAN_TDLS
677 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
678 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
679#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530680#ifdef FEATURE_WLAN_SCAN_PNO
681 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
Madan Mohan Koyyalamudi75de0102013-09-17 14:56:29 +0530682 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530683 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +0530684 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530685#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800686
Amar Singhalfddc28c2013-09-05 13:03:40 -0700687#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700688 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
689 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -0700690 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700691 driver need to determine what to do with both
692 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -0700693
694 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -0700695#else
696 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -0700697#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700698
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530699 wiphy->max_scan_ssids = MAX_SCAN_SSID;
700
Madan Mohan Koyyalamudi6815b162013-07-19 17:17:46 +0530701 wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700702
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +0530703 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
704
Jeff Johnson295189b2012-06-20 16:38:30 -0700705 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530706 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -0700707 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -0700708 | BIT(NL80211_IFTYPE_P2P_CLIENT)
709 | BIT(NL80211_IFTYPE_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 | BIT(NL80211_IFTYPE_AP);
711
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800712#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800713 if( pCfg->enableMCC )
714 {
715 /* Currently, supports up to two channels */
716 wlan_hdd_iface_combination.num_different_channels = 2;
717
718 if( !pCfg->allowMCCGODiffBI )
719 wlan_hdd_iface_combination.beacon_int_infra_match = true;
720
721 }
722 wiphy->iface_combinations = &wlan_hdd_iface_combination;
723 wiphy->n_iface_combinations = 1;
724#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800725
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 /* Before registering we need to update the ht capabilitied based
727 * on ini values*/
728 if( !pCfg->ShortGI20MhzEnable )
729 {
730 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
731 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
732 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
733 }
734
735 if( !pCfg->ShortGI40MhzEnable )
736 {
737 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
738 }
739
740 if( !pCfg->nChannelBondingMode5GHz )
741 {
742 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
743 }
744
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530745 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
746 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
747
748 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
749 {
750
751 if (NULL == wiphy->bands[i])
752 {
753 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
754 __func__, i);
755 continue;
756 }
757
758 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
759 {
760 struct ieee80211_supported_band *band = wiphy->bands[i];
761
762 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
763 {
764 // Enable social channels for P2P
765 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
766 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
767 else
768 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
769 continue;
770 }
771 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
772 {
773 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
774 continue;
775 }
776 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700777 }
778 /*Initialise the supported cipher suite details*/
779 wiphy->cipher_suites = hdd_cipher_suites;
780 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
781
782 /*signal strength in mBm (100*dBm) */
783 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
784
785#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnson295189b2012-06-20 16:38:30 -0700786 wiphy->max_remain_on_channel_duration = 1000;
787#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700788
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530789 EXIT();
790 return 0;
791}
792
793/* In this function we are registering wiphy. */
794int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
795{
796 ENTER();
797 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700798 if (0 > wiphy_register(wiphy))
799 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530800 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -0700801 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
802 return -EIO;
803 }
804
805 EXIT();
806 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530807}
Jeff Johnson295189b2012-06-20 16:38:30 -0700808
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530809/* In this function we are updating channel list when,
810 regulatory domain is FCC and country code is US.
811 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
812 As per FCC smart phone is not a indoor device.
813 GO should not opeate on indoor channels */
814void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
815{
816 int j;
817 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
818 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
819 //Default counrtycode from NV at the time of wiphy initialization.
820 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
821 &defaultCountryCode[0]))
822 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700823 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530824 }
825 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
826 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530827 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
828 {
829 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
830 return;
831 }
832 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
833 {
834 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
835 // Mark UNII -1 band channel as passive
836 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
837 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
838 }
839 }
840}
841
Jeff Johnson295189b2012-06-20 16:38:30 -0700842/* In this function we will do all post VOS start initialization.
843 In this function we will register for all frame in which supplicant
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530844 is interested.
Jeff Johnson295189b2012-06-20 16:38:30 -0700845*/
846void wlan_hdd_cfg80211_post_voss_start(hdd_adapter_t* pAdapter)
847{
Jeff Johnson295189b2012-06-20 16:38:30 -0700848 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
849 /* Register for all P2P action, public action etc frames */
850 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
851
Jeff Johnsone7245742012-09-05 17:12:55 -0700852 ENTER();
853
Jeff Johnson295189b2012-06-20 16:38:30 -0700854 /* Right now we are registering these frame when driver is getting
855 initialized. Once we will move to 2.6.37 kernel, in which we have
856 frame register ops, we will move this code as a part of that */
857 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530858 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
860
861 /* GAS Initial Response */
862 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
863 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530864
Jeff Johnson295189b2012-06-20 16:38:30 -0700865 /* GAS Comeback Request */
866 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
867 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
868
869 /* GAS Comeback Response */
870 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
871 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
872
873 /* P2P Public Action */
874 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530875 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700876 P2P_PUBLIC_ACTION_FRAME_SIZE );
877
878 /* P2P Action */
879 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
880 (v_U8_t*)P2P_ACTION_FRAME,
881 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700882
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +0530883 /* WNM BSS Transition Request frame */
884 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
885 (v_U8_t*)WNM_BSS_ACTION_FRAME,
886 WNM_BSS_ACTION_FRAME_SIZE );
887
Chet Lanctot186b5732013-03-18 10:26:30 -0700888#ifdef WLAN_FEATURE_11W
889 /* SA Query Response Action Frame */
890 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
891 (v_U8_t*)SA_QUERY_FRAME_RSP,
892 SA_QUERY_FRAME_RSP_SIZE );
893#endif /* WLAN_FEATURE_11W */
Jeff Johnson295189b2012-06-20 16:38:30 -0700894}
895
896void wlan_hdd_cfg80211_pre_voss_stop(hdd_adapter_t* pAdapter)
897{
Jeff Johnson295189b2012-06-20 16:38:30 -0700898 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
899 /* Register for all P2P action, public action etc frames */
900 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
901
Jeff Johnsone7245742012-09-05 17:12:55 -0700902 ENTER();
903
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 /* Right now we are registering these frame when driver is getting
905 initialized. Once we will move to 2.6.37 kernel, in which we have
906 frame register ops, we will move this code as a part of that */
907 /* GAS Initial Request */
908
909 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
910 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
911
912 /* GAS Initial Response */
913 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
914 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530915
Jeff Johnson295189b2012-06-20 16:38:30 -0700916 /* GAS Comeback Request */
917 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
918 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
919
920 /* GAS Comeback Response */
921 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
922 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
923
924 /* P2P Public Action */
925 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530926 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700927 P2P_PUBLIC_ACTION_FRAME_SIZE );
928
929 /* P2P Action */
930 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
931 (v_U8_t*)P2P_ACTION_FRAME,
932 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700933
934#ifdef WLAN_FEATURE_11W
935 /* SA Query Response Action Frame */
936 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
937 (v_U8_t*)SA_QUERY_FRAME_RSP,
938 SA_QUERY_FRAME_RSP_SIZE );
939#endif /* WLAN_FEATURE_11W */
Jeff Johnson295189b2012-06-20 16:38:30 -0700940}
941
942#ifdef FEATURE_WLAN_WAPI
943void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
944 const u8 *mac_addr, u8 *key , int key_Len)
945{
946 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
947 tCsrRoamSetKey setKey;
948 v_BOOL_t isConnected = TRUE;
949 int status = 0;
950 v_U32_t roamId= 0xFF;
951 tANI_U8 *pKeyPtr = NULL;
952 int n = 0;
953
954 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
955 __func__,pAdapter->device_mode);
956
Gopichand Nakkalae7480202013-02-11 15:24:22 +0530957 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -0700958 setKey.keyId = key_index; // Store Key ID
959 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
960 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
961 setKey.paeRole = 0 ; // the PAE role
962 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
963 {
964 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
965 }
966 else
967 {
968 isConnected = hdd_connIsConnected(pHddStaCtx);
969 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
970 }
971 setKey.keyLength = key_Len;
972 pKeyPtr = setKey.Key;
973 memcpy( pKeyPtr, key, key_Len);
974
975 hddLog(VOS_TRACE_LEVEL_INFO,"\n%s: WAPI KEY LENGTH:0x%04x",
976 __func__, key_Len);
977 for (n = 0 ; n < key_Len; n++)
978 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
979 __func__,n,setKey.Key[n]);
980
981 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
982 if ( isConnected )
983 {
984 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
985 pAdapter->sessionId, &setKey, &roamId );
986 }
987 if ( status != 0 )
988 {
989 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
990 "[%4d] sme_RoamSetKey returned ERROR status= %d",
991 __LINE__, status );
992 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
993 }
994}
995#endif /* FEATURE_WLAN_WAPI*/
996
997#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530998int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700999 beacon_data_t **ppBeacon,
1000 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001001#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301002int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001003 beacon_data_t **ppBeacon,
1004 struct cfg80211_beacon_data *params,
1005 int dtim_period)
1006#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301007{
Jeff Johnson295189b2012-06-20 16:38:30 -07001008 int size;
1009 beacon_data_t *beacon = NULL;
1010 beacon_data_t *old = NULL;
1011 int head_len,tail_len;
1012
Jeff Johnsone7245742012-09-05 17:12:55 -07001013 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001014 if (params->head && !params->head_len)
1015 return -EINVAL;
1016
1017 old = pAdapter->sessionCtx.ap.beacon;
1018
1019 if (!params->head && !old)
1020 return -EINVAL;
1021
Jeff Johnson295189b2012-06-20 16:38:30 -07001022#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
1023 /* Kernel 3.0 is not updating dtim_period for set beacon */
1024 if (!params->dtim_period)
1025 return -EINVAL;
1026#endif
1027
1028 if(params->head)
1029 head_len = params->head_len;
1030 else
1031 head_len = old->head_len;
1032
1033 if(params->tail || !old)
1034 tail_len = params->tail_len;
1035 else
1036 tail_len = old->tail_len;
1037
1038 size = sizeof(beacon_data_t) + head_len + tail_len;
1039
1040 beacon = kzalloc(size, GFP_KERNEL);
1041
1042 if( beacon == NULL )
1043 return -ENOMEM;
1044
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001045#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001046 if(params->dtim_period || !old )
1047 beacon->dtim_period = params->dtim_period;
1048 else
1049 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001050#else
1051 if(dtim_period || !old )
1052 beacon->dtim_period = dtim_period;
1053 else
1054 beacon->dtim_period = old->dtim_period;
1055#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301056
Jeff Johnson295189b2012-06-20 16:38:30 -07001057 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
1058 beacon->tail = beacon->head + head_len;
1059 beacon->head_len = head_len;
1060 beacon->tail_len = tail_len;
1061
1062 if(params->head) {
1063 memcpy (beacon->head,params->head,beacon->head_len);
1064 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301065 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001066 if(old)
1067 memcpy (beacon->head,old->head,beacon->head_len);
1068 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301069
Jeff Johnson295189b2012-06-20 16:38:30 -07001070 if(params->tail) {
1071 memcpy (beacon->tail,params->tail,beacon->tail_len);
1072 }
1073 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301074 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07001075 memcpy (beacon->tail,old->tail,beacon->tail_len);
1076 }
1077
1078 *ppBeacon = beacon;
1079
1080 kfree(old);
1081
1082 return 0;
1083
1084}
Jeff Johnson295189b2012-06-20 16:38:30 -07001085
1086v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
1087{
1088 int left = length;
1089 v_U8_t *ptr = pIes;
1090 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301091
Jeff Johnson295189b2012-06-20 16:38:30 -07001092 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301093 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001094 elem_id = ptr[0];
1095 elem_len = ptr[1];
1096 left -= 2;
1097 if(elem_len > left)
1098 {
1099 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001100 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001101 eid,elem_len,left);
1102 return NULL;
1103 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301104 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07001105 {
1106 return ptr;
1107 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301108
Jeff Johnson295189b2012-06-20 16:38:30 -07001109 left -= elem_len;
1110 ptr += (elem_len + 2);
1111 }
1112 return NULL;
1113}
1114
Jeff Johnson295189b2012-06-20 16:38:30 -07001115/* Check if rate is 11g rate or not */
1116static int wlan_hdd_rate_is_11g(u8 rate)
1117{
Sanjay Devnani28322e22013-06-21 16:13:40 -07001118 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 u8 i;
1120 for (i = 0; i < 8; i++)
1121 {
1122 if(rate == gRateArray[i])
1123 return TRUE;
1124 }
1125 return FALSE;
1126}
1127
1128/* Check for 11g rate and set proper 11g only mode */
1129static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
1130 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
1131{
1132 u8 i, num_rates = pIe[0];
1133
1134 pIe += 1;
1135 for ( i = 0; i < num_rates; i++)
1136 {
1137 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
1138 {
1139 /* If rate set have 11g rate than change the mode to 11G */
1140 *pSapHw_mode = eSAP_DOT11_MODE_11g;
1141 if (pIe[i] & BASIC_RATE_MASK)
1142 {
1143 /* If we have 11g rate as basic rate, it means mode
1144 is 11g only mode.
1145 */
1146 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
1147 *pCheckRatesfor11g = FALSE;
1148 }
1149 }
1150 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
1151 {
1152 *require_ht = TRUE;
1153 }
1154 }
1155 return;
1156}
1157
1158static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
1159{
1160 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1161 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1162 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1163 u8 checkRatesfor11g = TRUE;
1164 u8 require_ht = FALSE;
1165 u8 *pIe=NULL;
1166
1167 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
1168
1169 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
1170 pBeacon->head_len, WLAN_EID_SUPP_RATES);
1171 if (pIe != NULL)
1172 {
1173 pIe += 1;
1174 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1175 &pConfig->SapHw_mode);
1176 }
1177
1178 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1179 WLAN_EID_EXT_SUPP_RATES);
1180 if (pIe != NULL)
1181 {
1182
1183 pIe += 1;
1184 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1185 &pConfig->SapHw_mode);
1186 }
1187
1188 if( pConfig->channel > 14 )
1189 {
1190 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
1191 }
1192
1193 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1194 WLAN_EID_HT_CAPABILITY);
1195
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301196 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001197 {
1198 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
1199 if(require_ht)
1200 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
1201 }
1202}
1203
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301204static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
1205 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
1206{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001207 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301208 v_U8_t *pIe = NULL;
1209 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1210
1211 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
1212 pBeacon->tail, pBeacon->tail_len);
1213
1214 if (pIe)
1215 {
1216 ielen = pIe[1] + 2;
1217 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1218 {
1219 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
1220 }
1221 else
1222 {
1223 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
1224 return -EINVAL;
1225 }
1226 *total_ielen += ielen;
1227 }
1228 return 0;
1229}
1230
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001231static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
1232 v_U8_t *genie, v_U8_t *total_ielen)
1233{
1234 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1235 int left = pBeacon->tail_len;
1236 v_U8_t *ptr = pBeacon->tail;
1237 v_U8_t elem_id, elem_len;
1238 v_U16_t ielen = 0;
1239
1240 if ( NULL == ptr || 0 == left )
1241 return;
1242
1243 while (left >= 2)
1244 {
1245 elem_id = ptr[0];
1246 elem_len = ptr[1];
1247 left -= 2;
1248 if (elem_len > left)
1249 {
1250 hddLog( VOS_TRACE_LEVEL_ERROR,
1251 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
1252 elem_id, elem_len, left);
1253 return;
1254 }
1255 if (IE_EID_VENDOR == elem_id)
1256 {
1257 /* skipping the VSIE's which we don't want to include or
1258 * it will be included by existing code
1259 */
1260 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
1261#ifdef WLAN_FEATURE_WFD
1262 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
1263#endif
1264 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1265 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1266 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
1267 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1268 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
1269 {
1270 ielen = ptr[1] + 2;
1271 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1272 {
1273 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
1274 *total_ielen += ielen;
1275 }
1276 else
1277 {
1278 hddLog( VOS_TRACE_LEVEL_ERROR,
1279 "IE Length is too big "
1280 "IEs eid=%d elem_len=%d total_ie_lent=%d",
1281 elem_id, elem_len, *total_ielen);
1282 }
1283 }
1284 }
1285
1286 left -= elem_len;
1287 ptr += (elem_len + 2);
1288 }
1289 return;
1290}
1291
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001292#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001293static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1294 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001295#else
1296static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1297 struct cfg80211_beacon_data *params)
1298#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001299{
1300 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301301 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001302 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07001303 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001304
1305 genie = vos_mem_malloc(MAX_GENIE_LEN);
1306
1307 if(genie == NULL) {
1308
1309 return -ENOMEM;
1310 }
1311
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301312 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1313 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001314 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301315 ret = -EINVAL;
1316 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001317 }
1318
1319#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301320 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1321 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
1322 {
1323 ret = -EINVAL;
1324 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001325 }
1326#endif
1327
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301328 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1329 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301331 ret = -EINVAL;
1332 goto done;
1333 }
1334
1335 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
1336 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001337 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001338 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001339
1340 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1341 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
1342 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
1343 {
1344 hddLog(LOGE,
1345 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001346 ret = -EINVAL;
1347 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001348 }
1349
1350 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1351 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
1352 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1353 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1354 ==eHAL_STATUS_FAILURE)
1355 {
1356 hddLog(LOGE,
1357 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001358 ret = -EINVAL;
1359 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001360 }
1361
1362 // Added for ProResp IE
1363 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
1364 {
1365 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
1366 u8 probe_rsp_ie_len[3] = {0};
1367 u8 counter = 0;
1368 /* Check Probe Resp Length if it is greater then 255 then Store
1369 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
1370 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
1371 Store More then 255 bytes into One Variable.
1372 */
1373 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
1374 {
1375 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
1376 {
1377 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
1378 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
1379 }
1380 else
1381 {
1382 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
1383 rem_probe_resp_ie_len = 0;
1384 }
1385 }
1386
1387 rem_probe_resp_ie_len = 0;
1388
1389 if (probe_rsp_ie_len[0] > 0)
1390 {
1391 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1392 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
1393 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1394 probe_rsp_ie_len[0], NULL,
1395 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1396 {
1397 hddLog(LOGE,
1398 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001399 ret = -EINVAL;
1400 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001401 }
1402 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
1403 }
1404
1405 if (probe_rsp_ie_len[1] > 0)
1406 {
1407 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1408 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
1409 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1410 probe_rsp_ie_len[1], NULL,
1411 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1412 {
1413 hddLog(LOGE,
1414 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001415 ret = -EINVAL;
1416 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 }
1418 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
1419 }
1420
1421 if (probe_rsp_ie_len[2] > 0)
1422 {
1423 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1424 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
1425 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1426 probe_rsp_ie_len[2], NULL,
1427 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1428 {
1429 hddLog(LOGE,
1430 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001431 ret = -EINVAL;
1432 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001433 }
1434 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
1435 }
1436
1437 if (probe_rsp_ie_len[1] == 0 )
1438 {
1439 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1440 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
1441 eANI_BOOLEAN_FALSE) )
1442 {
1443 hddLog(LOGE,
1444 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM\n");
1445 }
1446 }
1447
1448 if (probe_rsp_ie_len[2] == 0 )
1449 {
1450 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1451 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
1452 eANI_BOOLEAN_FALSE) )
1453 {
1454 hddLog(LOGE,
1455 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM\n");
1456 }
1457 }
1458
1459 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1460 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
1461 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1462 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1463 == eHAL_STATUS_FAILURE)
1464 {
1465 hddLog(LOGE,
1466 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001467 ret = -EINVAL;
1468 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001469 }
1470 }
1471 else
1472 {
1473 // Reset WNI_CFG_PROBE_RSP Flags
1474 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
1475
1476 hddLog(VOS_TRACE_LEVEL_INFO,
1477 "%s: No Probe Response IE received in set beacon",
1478 __func__);
1479 }
1480
1481 // Added for AssocResp IE
1482 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
1483 {
1484 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1485 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
1486 params->assocresp_ies_len, NULL,
1487 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1488 {
1489 hddLog(LOGE,
1490 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001491 ret = -EINVAL;
1492 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001493 }
1494
1495 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1496 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
1497 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1498 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1499 == eHAL_STATUS_FAILURE)
1500 {
1501 hddLog(LOGE,
1502 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001503 ret = -EINVAL;
1504 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001505 }
1506 }
1507 else
1508 {
1509 hddLog(VOS_TRACE_LEVEL_INFO,
1510 "%s: No Assoc Response IE received in set beacon",
1511 __func__);
1512
1513 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1514 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
1515 eANI_BOOLEAN_FALSE) )
1516 {
1517 hddLog(LOGE,
1518 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
1519 }
1520 }
1521
Jeff Johnsone7245742012-09-05 17:12:55 -07001522done:
Jeff Johnson295189b2012-06-20 16:38:30 -07001523 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301524 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001525}
Jeff Johnson295189b2012-06-20 16:38:30 -07001526
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301527/*
Jeff Johnson295189b2012-06-20 16:38:30 -07001528 * FUNCTION: wlan_hdd_validate_operation_channel
1529 * called by wlan_hdd_cfg80211_start_bss() and
1530 * wlan_hdd_cfg80211_set_channel()
1531 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301532 * channel list.
1533 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001534VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001535{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301536
Jeff Johnson295189b2012-06-20 16:38:30 -07001537 v_U32_t num_ch = 0;
1538 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1539 u32 indx = 0;
1540 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301541 v_U8_t fValidChannel = FALSE, count = 0;
1542 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301543
Jeff Johnson295189b2012-06-20 16:38:30 -07001544 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1545
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301546 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001547 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301548 /* Validate the channel */
1549 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001550 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301551 if ( channel == rfChannels[count].channelNum )
1552 {
1553 fValidChannel = TRUE;
1554 break;
1555 }
1556 }
1557 if (fValidChannel != TRUE)
1558 {
1559 hddLog(VOS_TRACE_LEVEL_ERROR,
1560 "%s: Invalid Channel [%d]", __func__, channel);
1561 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001562 }
1563 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301564 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001565 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301566 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1567 valid_ch, &num_ch))
1568 {
1569 hddLog(VOS_TRACE_LEVEL_ERROR,
1570 "%s: failed to get valid channel list", __func__);
1571 return VOS_STATUS_E_FAILURE;
1572 }
1573 for (indx = 0; indx < num_ch; indx++)
1574 {
1575 if (channel == valid_ch[indx])
1576 {
1577 break;
1578 }
1579 }
1580
1581 if (indx >= num_ch)
1582 {
1583 hddLog(VOS_TRACE_LEVEL_ERROR,
1584 "%s: Invalid Channel [%d]", __func__, channel);
1585 return VOS_STATUS_E_FAILURE;
1586 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001587 }
1588 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301589
Jeff Johnson295189b2012-06-20 16:38:30 -07001590}
1591
Viral Modi3a32cc52013-02-08 11:14:52 -08001592/**
1593 * FUNCTION: wlan_hdd_cfg80211_set_channel
1594 * This function is used to set the channel number
1595 */
1596static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
1597 struct ieee80211_channel *chan,
1598 enum nl80211_channel_type channel_type
1599 )
1600{
1601 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07001602 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08001603 hdd_adapter_t *pAdapter = NULL;
1604 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301605 hdd_context_t *pHddCtx;
1606 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001607
1608 ENTER();
1609
1610 if( NULL == dev )
1611 {
1612 hddLog(VOS_TRACE_LEVEL_ERROR,
1613 "%s: Called with dev = NULL.\n", __func__);
1614 return -ENODEV;
1615 }
1616 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
1617
1618 hddLog(VOS_TRACE_LEVEL_INFO,
1619 "%s: device_mode = %d freq = %d \n",__func__,
1620 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301621
1622 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1623 status = wlan_hdd_validate_context(pHddCtx);
1624
1625 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08001626 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301627 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1628 "%s: HDD context is not valid", __func__);
1629 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001630 }
1631
1632 /*
1633 * Do freq to chan conversion
1634 * TODO: for 11a
1635 */
1636
1637 channel = ieee80211_frequency_to_channel(freq);
1638
1639 /* Check freq range */
1640 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
1641 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
1642 {
1643 hddLog(VOS_TRACE_LEVEL_ERROR,
1644 "%s: Channel [%d] is outside valid range from %d to %d\n",
1645 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
1646 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1647 return -EINVAL;
1648 }
1649
1650 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1651
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05301652 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
1653 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08001654 {
1655 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
1656 {
1657 hddLog(VOS_TRACE_LEVEL_ERROR,
1658 "%s: Invalid Channel [%d] \n", __func__, channel);
1659 return -EINVAL;
1660 }
1661 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1662 "%s: set channel to [%d] for device mode =%d",
1663 __func__, channel,pAdapter->device_mode);
1664 }
1665 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08001666 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08001667 )
1668 {
1669 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1670 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
1671 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1672
1673 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
1674 {
1675 /* Link is up then return cant set channel*/
1676 hddLog( VOS_TRACE_LEVEL_ERROR,
1677 "%s: IBSS Associated, can't set the channel\n", __func__);
1678 return -EINVAL;
1679 }
1680
1681 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
1682 pHddStaCtx->conn_info.operationChannel = channel;
1683 pRoamProfile->ChannelInfo.ChannelList =
1684 &pHddStaCtx->conn_info.operationChannel;
1685 }
1686 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08001687 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08001688 )
1689 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301690 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
1691 {
1692 if(VOS_STATUS_SUCCESS !=
1693 wlan_hdd_validate_operation_channel(pAdapter,channel))
1694 {
1695 hddLog(VOS_TRACE_LEVEL_ERROR,
1696 "%s: Invalid Channel [%d] \n", __func__, channel);
1697 return -EINVAL;
1698 }
1699 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1700 }
1701 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08001702 {
1703 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1704
1705 /* If auto channel selection is configured as enable/ 1 then ignore
1706 channel set by supplicant
1707 */
1708 if ( cfg_param->apAutoChannelSelection )
1709 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301710 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
1711 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08001712 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1713 "%s: set channel to auto channel (0) for device mode =%d",
1714 __func__, pAdapter->device_mode);
1715 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301716 else
1717 {
1718 if(VOS_STATUS_SUCCESS !=
1719 wlan_hdd_validate_operation_channel(pAdapter,channel))
1720 {
1721 hddLog(VOS_TRACE_LEVEL_ERROR,
1722 "%s: Invalid Channel [%d] \n", __func__, channel);
1723 return -EINVAL;
1724 }
1725 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1726 }
Viral Modi3a32cc52013-02-08 11:14:52 -08001727 }
1728 }
1729 else
1730 {
1731 hddLog(VOS_TRACE_LEVEL_FATAL,
1732 "%s: Invalid device mode failed to set valid channel", __func__);
1733 return -EINVAL;
1734 }
1735 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301736 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001737}
1738
Jeff Johnson295189b2012-06-20 16:38:30 -07001739#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
1740static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1741 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001742#else
1743static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1744 struct cfg80211_beacon_data *params,
1745 const u8 *ssid, size_t ssid_len,
1746 enum nl80211_hidden_ssid hidden_ssid)
1747#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001748{
1749 tsap_Config_t *pConfig;
1750 beacon_data_t *pBeacon = NULL;
1751 struct ieee80211_mgmt *pMgmt_frame;
1752 v_U8_t *pIe=NULL;
1753 v_U16_t capab_info;
1754 eCsrAuthType RSNAuthType;
1755 eCsrEncryptionType RSNEncryptType;
1756 eCsrEncryptionType mcRSNEncryptType;
1757 int status = VOS_STATUS_SUCCESS;
1758 tpWLAN_SAPEventCB pSapEventCallback;
1759 hdd_hostapd_state_t *pHostapdState;
1760 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
1761 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301762 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001763 struct qc_mac_acl_entry *acl_entry = NULL;
1764 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08001765 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001766
1767 ENTER();
1768
1769 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
1770
1771 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1772
1773 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1774
1775 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1776
1777 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
1778
1779 //channel is already set in the set_channel Call back
1780 //pConfig->channel = pCommitConfig->channel;
1781
1782 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301783 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07001784 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
1785
1786 pConfig->dtim_period = pBeacon->dtim_period;
1787
1788 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***\n",
1789 pConfig->dtim_period);
1790
1791
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08001792 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07001793 {
1794 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001795 WLAN_EID_COUNTRY);
Jeff Johnson32d95a32012-09-10 13:15:23 -07001796 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001797 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07001798 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07001799 pConfig->ieee80211d = 1;
1800 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
1801 sme_setRegInfo(hHal, pConfig->countryCode);
1802 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07001803 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001804 else
1805 {
1806 pConfig->ieee80211d = 0;
1807 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301808 /*
1809 * If auto channel is configured i.e. channel is 0,
1810 * so skip channel validation.
1811 */
1812 if( AUTO_CHANNEL_SELECT != pConfig->channel )
1813 {
1814 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
1815 {
1816 hddLog(VOS_TRACE_LEVEL_ERROR,
1817 "%s: Invalid Channel [%d] \n", __func__, pConfig->channel);
1818 return -EINVAL;
1819 }
1820 }
1821 else
1822 {
1823 if(1 != pHddCtx->is_dynamic_channel_range_set)
1824 {
1825 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
1826 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
1827 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
1828 }
1829 pHddCtx->is_dynamic_channel_range_set = 0;
1830 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001831 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001832 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001833 {
1834 pConfig->ieee80211d = 0;
1835 }
1836 pConfig->authType = eSAP_AUTO_SWITCH;
1837
1838 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301839
1840 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07001841 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
1842
1843 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
1844
1845 /*Set wps station to configured*/
1846 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
1847
1848 if(pIe)
1849 {
1850 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
1851 {
1852 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***\n");
1853 return -EINVAL;
1854 }
1855 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
1856 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001857 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07001858 /* Check 15 bit of WPS IE as it contain information for wps state
1859 * WPS state
1860 */
1861 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
1862 {
1863 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
1864 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
1865 {
1866 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
1867 }
1868 }
1869 }
1870 else
1871 {
1872 pConfig->wps_state = SAP_WPS_DISABLED;
1873 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301874 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07001875
1876 pConfig->RSNWPAReqIELength = 0;
1877 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301878 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001879 WLAN_EID_RSN);
1880 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301881 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001882 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1883 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1884 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301885 /* The actual processing may eventually be more extensive than
1886 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07001887 * by the app.
1888 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301889 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001890 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1891 &RSNEncryptType,
1892 &mcRSNEncryptType,
1893 &RSNAuthType,
1894 pConfig->pRSNWPAReqIE[1]+2,
1895 pConfig->pRSNWPAReqIE );
1896
1897 if( VOS_STATUS_SUCCESS == status )
1898 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301899 /* Now copy over all the security attributes you have
1900 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001901 * */
1902 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1903 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1904 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1905 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301906 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001907 "EncryptionType = %d mcEncryptionType = %d\n"),
1908 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1909 }
1910 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301911
Jeff Johnson295189b2012-06-20 16:38:30 -07001912 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1913 pBeacon->tail, pBeacon->tail_len);
1914
1915 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
1916 {
1917 if (pConfig->pRSNWPAReqIE)
1918 {
1919 /*Mixed mode WPA/WPA2*/
1920 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
1921 pConfig->RSNWPAReqIELength += pIe[1] + 2;
1922 }
1923 else
1924 {
1925 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1926 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1927 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301928 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001929 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1930 &RSNEncryptType,
1931 &mcRSNEncryptType,
1932 &RSNAuthType,
1933 pConfig->pRSNWPAReqIE[1]+2,
1934 pConfig->pRSNWPAReqIE );
1935
1936 if( VOS_STATUS_SUCCESS == status )
1937 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301938 /* Now copy over all the security attributes you have
1939 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001940 * */
1941 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1942 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1943 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1944 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301945 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001946 "EncryptionType = %d mcEncryptionType = %d\n"),
1947 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1948 }
1949 }
1950 }
1951
Jeff Johnson4416a782013-03-25 14:17:50 -07001952 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
1953 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
1954 return -EINVAL;
1955 }
1956
Jeff Johnson295189b2012-06-20 16:38:30 -07001957 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
1958
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001959#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001960 if (params->ssid != NULL)
1961 {
1962 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
1963 pConfig->SSIDinfo.ssid.length = params->ssid_len;
1964 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1965 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1966 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001967#else
1968 if (ssid != NULL)
1969 {
1970 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
1971 pConfig->SSIDinfo.ssid.length = ssid_len;
1972 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1973 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1974 }
1975#endif
1976
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301977 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07001978 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301979
Jeff Johnson295189b2012-06-20 16:38:30 -07001980 /* default value */
1981 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
1982 pConfig->num_accept_mac = 0;
1983 pConfig->num_deny_mac = 0;
1984
1985 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1986 pBeacon->tail, pBeacon->tail_len);
1987
1988 /* pIe for black list is following form:
1989 type : 1 byte
1990 length : 1 byte
1991 OUI : 4 bytes
1992 acl type : 1 byte
1993 no of mac addr in black list: 1 byte
1994 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301995 */
1996 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001997 {
1998 pConfig->SapMacaddr_acl = pIe[6];
1999 pConfig->num_deny_mac = pIe[7];
2000 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d\n",
2001 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302002 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
2003 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002004 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
2005 for (i = 0; i < pConfig->num_deny_mac; i++)
2006 {
2007 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
2008 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302009 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002010 }
2011 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
2012 pBeacon->tail, pBeacon->tail_len);
2013
2014 /* pIe for white list is following form:
2015 type : 1 byte
2016 length : 1 byte
2017 OUI : 4 bytes
2018 acl type : 1 byte
2019 no of mac addr in white list: 1 byte
2020 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302021 */
2022 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002023 {
2024 pConfig->SapMacaddr_acl = pIe[6];
2025 pConfig->num_accept_mac = pIe[7];
2026 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d\n",
2027 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302028 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
2029 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002030 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
2031 for (i = 0; i < pConfig->num_accept_mac; i++)
2032 {
2033 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
2034 acl_entry++;
2035 }
2036 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302037
Jeff Johnson295189b2012-06-20 16:38:30 -07002038 wlan_hdd_set_sapHwmode(pHostapdAdapter);
2039
Jeff Johnsone7245742012-09-05 17:12:55 -07002040#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002041 /* Overwrite the hostapd setting for HW mode only for 11ac.
2042 * This is valid only if mode is set to 11n in hostapd and either AUTO or 11ac in .ini .
2043 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode) */
2044 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
2045 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302046 (((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_AUTO) ||
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002047 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac) ||
2048 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07002049 {
2050 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07002051
2052 /* Disable VHT support in 2.4 GHz band */
2053 if (pConfig->channel <= 14 &&
2054 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->enableVhtFor24GHzBand == FALSE)
2055 {
2056 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
2057 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002058 }
2059#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302060
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07002061 if ( AUTO_CHANNEL_SELECT != pConfig->channel )
2062 {
2063 sme_SelectCBMode(hHal,
2064 sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode),
2065 pConfig->channel);
2066 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002067 // ht_capab is not what the name conveys,this is used for protection bitmap
2068 pConfig->ht_capab =
2069 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
2070
2071 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
2072 {
2073 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
2074 return -EINVAL;
2075 }
2076
2077 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302078 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07002079 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
2080 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302081 pConfig->obssProtEnabled =
2082 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07002083
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302084 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR"\n"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002085 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302086 hddLog(LOGW,FL("ssid =%s\n"), pConfig->SSIDinfo.ssid.ssId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002087 hddLog(LOGW,FL("beaconint=%d, channel=%d\n"), (int)pConfig->beacon_int,
2088 (int)pConfig->channel);
2089 hddLog(LOGW,FL("hw_mode=%x\n"), pConfig->SapHw_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302090 hddLog(LOGW,FL("privacy=%d, authType=%d\n"), pConfig->privacy,
2091 pConfig->authType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002092 hddLog(LOGW,FL("RSN/WPALen=%d, \n"),(int)pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302093 hddLog(LOGW,FL("Uapsd = %d\n"),pConfig->UapsdEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002094 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d\n"),
2095 pConfig->protEnabled, pConfig->obssProtEnabled);
2096
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302097 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07002098 {
2099 //Bss already started. just return.
2100 //TODO Probably it should update some beacon params.
2101 hddLog( LOGE, "Bss Already started...Ignore the request");
2102 EXIT();
2103 return 0;
2104 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302105
Jeff Johnson295189b2012-06-20 16:38:30 -07002106 pConfig->persona = pHostapdAdapter->device_mode;
2107
2108 pSapEventCallback = hdd_hostapd_SAPEventCB;
2109 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
2110 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
2111 {
2112 hddLog(LOGE,FL("SAP Start Bss fail\n"));
2113 return -EINVAL;
2114 }
2115
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302116 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002117 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
2118
2119 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302120
Jeff Johnson295189b2012-06-20 16:38:30 -07002121 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302122 {
2123 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07002124 ("ERROR: HDD vos wait for single_event failed!!\n"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07002125 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002126 VOS_ASSERT(0);
2127 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302128
Jeff Johnson295189b2012-06-20 16:38:30 -07002129 //Succesfully started Bss update the state bit.
2130 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
2131
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002132#ifdef WLAN_FEATURE_P2P_DEBUG
2133 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
2134 {
2135 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
2136 {
2137 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2138 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002139 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002140 }
2141 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
2142 {
2143 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2144 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002145 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002146 }
2147 }
2148#endif
2149
Jeff Johnson295189b2012-06-20 16:38:30 -07002150 pHostapdState->bCommit = TRUE;
2151 EXIT();
2152
2153 return 0;
2154}
2155
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002156#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302157static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
2158 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 struct beacon_parameters *params)
2160{
2161 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302162 hdd_context_t *pHddCtx;
2163 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002164
2165 ENTER();
2166
2167 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d\n",pAdapter->device_mode);
2168
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302169 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2170 status = wlan_hdd_validate_context(pHddCtx);
2171
2172 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002173 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302174 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2175 "%s: HDD context is not valid", __func__);
2176 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002177 }
2178
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302179 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002180 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002181 )
2182 {
2183 beacon_data_t *old,*new;
2184
2185 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302186
Jeff Johnson295189b2012-06-20 16:38:30 -07002187 if (old)
2188 return -EALREADY;
2189
2190 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2191
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302192 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002193 {
2194 hddLog(VOS_TRACE_LEVEL_FATAL,
2195 "%s:Error!!! Allocating the new beacon\n",__func__);
2196 return -EINVAL;
2197 }
2198
2199 pAdapter->sessionCtx.ap.beacon = new;
2200
2201 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2202 }
2203
2204 EXIT();
2205 return status;
2206}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302207
2208static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07002209 struct net_device *dev,
2210 struct beacon_parameters *params)
2211{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302212 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302213 hdd_context_t *pHddCtx;
2214 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002215
2216 ENTER();
2217
2218 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2219 __func__,pAdapter->device_mode);
2220
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302221 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2222 status = wlan_hdd_validate_context(pHddCtx);
2223
2224 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002225 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302226 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2227 "%s: HDD context is not valid", __func__);
2228 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002229 }
2230
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302231 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002232 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302233 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002234 {
2235 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302236
Jeff Johnson295189b2012-06-20 16:38:30 -07002237 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302238
Jeff Johnson295189b2012-06-20 16:38:30 -07002239 if (!old)
2240 return -ENOENT;
2241
2242 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2243
2244 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302245 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07002246 "%s: Error!!! Allocating the new beacon\n",__func__);
2247 return -EINVAL;
2248 }
2249
2250 pAdapter->sessionCtx.ap.beacon = new;
2251
2252 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2253 }
2254
2255 EXIT();
2256 return status;
2257}
2258
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002259#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
2260
2261#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002262static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
2263 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002264#else
2265static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
2266 struct net_device *dev)
2267#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002268{
2269 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07002270 hdd_context_t *pHddCtx = NULL;
2271 hdd_scaninfo_t *pScanInfo = NULL;
2272 hdd_adapter_t *staAdapter = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302273 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002274
2275 ENTER();
2276
2277 if (NULL == pAdapter)
2278 {
2279 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002280 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002281 return -ENODEV;
2282 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002283
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302284 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2285 status = wlan_hdd_validate_context(pHddCtx);
2286
2287 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002288 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302289 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2290 "%s: HDD context is not valid", __func__);
2291 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07002292 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002293
2294 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
2295 if (NULL == staAdapter)
2296 {
2297 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
2298 if (NULL == staAdapter)
2299 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002300 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2301 "%s: HDD adapter context for STA/P2P-CLI is Null",
2302 __func__);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002303 }
2304 }
2305
2306 pScanInfo = &pHddCtx->scan_info;
2307
Jeff Johnson295189b2012-06-20 16:38:30 -07002308 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2309 __func__,pAdapter->device_mode);
2310
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002311 if ((pScanInfo != NULL) && pScanInfo->mScanPending && staAdapter)
Jeff Johnsone7245742012-09-05 17:12:55 -07002312 {
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002313 INIT_COMPLETION(pScanInfo->abortscan_event_var);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05302314 hdd_abort_mac_scan(staAdapter->pHddCtx, pAdapter->sessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002315 status = wait_for_completion_interruptible_timeout(
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002316 &pScanInfo->abortscan_event_var,
Jeff Johnsone7245742012-09-05 17:12:55 -07002317 msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN));
2318 if (!status)
2319 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002320 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson902c9832012-12-10 14:28:09 -08002321 "%s: Timeout occurred while waiting for abortscan" ,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002322 __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07002323 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07002324 }
2325 }
2326
Jeff Johnson295189b2012-06-20 16:38:30 -07002327 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002328 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002329 )
2330 {
2331 beacon_data_t *old;
2332
2333 old = pAdapter->sessionCtx.ap.beacon;
2334
2335 if (!old)
2336 return -ENOENT;
2337
Jeff Johnson295189b2012-06-20 16:38:30 -07002338 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002339
2340 mutex_lock(&pHddCtx->sap_lock);
2341 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
2342 {
Jeff Johnson4416a782013-03-25 14:17:50 -07002343 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002344 {
2345 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
2346
2347 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
2348
2349 if (!VOS_IS_STATUS_SUCCESS(status))
2350 {
2351 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2352 ("ERROR: HDD vos wait for single_event failed!!\n"));
2353 VOS_ASSERT(0);
2354 }
2355 }
2356 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
2357 }
2358 mutex_unlock(&pHddCtx->sap_lock);
2359
2360 if(status != VOS_STATUS_SUCCESS)
2361 {
2362 hddLog(VOS_TRACE_LEVEL_FATAL,
2363 "%s:Error!!! Stopping the BSS\n",__func__);
2364 return -EINVAL;
2365 }
2366
Jeff Johnson4416a782013-03-25 14:17:50 -07002367 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002368 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
2369 ==eHAL_STATUS_FAILURE)
2370 {
2371 hddLog(LOGE,
2372 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM\n");
2373 }
2374
Jeff Johnson4416a782013-03-25 14:17:50 -07002375 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002376 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
2377 eANI_BOOLEAN_FALSE) )
2378 {
2379 hddLog(LOGE,
2380 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
2381 }
2382
2383 // Reset WNI_CFG_PROBE_RSP Flags
2384 wlan_hdd_reset_prob_rspies(pAdapter);
2385
2386 pAdapter->sessionCtx.ap.beacon = NULL;
2387 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002388#ifdef WLAN_FEATURE_P2P_DEBUG
2389 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
2390 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
2391 {
2392 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
2393 "GO got removed");
2394 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
2395 }
2396#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002397 }
2398 EXIT();
2399 return status;
2400}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002401
2402#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2403
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302404static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
2405 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002406 struct cfg80211_ap_settings *params)
2407{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302408 hdd_adapter_t *pAdapter;
2409 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302410 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002411
2412 ENTER();
2413
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302414 if (NULL == dev)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002415 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302416 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302417 "%s: Device is Null", __func__);
2418 return -ENODEV;
2419 }
2420
2421 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2422 if (NULL == pAdapter)
2423 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302424 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302425 "%s: HDD adapter is Null", __func__);
2426 return -ENODEV;
2427 }
2428
2429 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
2430 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302431 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302432 "%s: HDD adapter magic is invalid", __func__);
2433 return -ENODEV;
2434 }
2435
2436 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302437 status = wlan_hdd_validate_context(pHddCtx);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302438
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302439 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302440 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302441 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2442 "%s: HDD context is not valid", __func__);
2443 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302444 }
2445
2446 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %d",
2447 __func__, pAdapter->device_mode);
2448
2449 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002450 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002451 )
2452 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302453 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002454
2455 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302456
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002457 if (old)
2458 return -EALREADY;
2459
2460 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, &params->beacon, params->dtim_period);
2461
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302462 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002463 {
2464 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302465 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002466 return -EINVAL;
2467 }
2468 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08002469#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07002470 wlan_hdd_cfg80211_set_channel(wiphy, dev,
2471#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
2472 params->channel, params->channel_type);
2473#else
2474 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
2475#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08002476#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002477 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
2478 params->ssid_len, params->hidden_ssid);
2479 }
2480
2481 EXIT();
2482 return status;
2483}
2484
2485
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302486static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002487 struct net_device *dev,
2488 struct cfg80211_beacon_data *params)
2489{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302490 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302491 hdd_context_t *pHddCtx;
2492 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002493
2494 ENTER();
2495
2496 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2497 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302498
2499 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2500 status = wlan_hdd_validate_context(pHddCtx);
2501
2502 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002503 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302504 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2505 "%s: HDD context is not valid", __func__);
2506 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002507 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002508
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302509 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002510 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302511 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002512 {
2513 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302514
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002515 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302516
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002517 if (!old)
2518 return -ENOENT;
2519
2520 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
2521
2522 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302523 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002524 "%s: Error!!! Allocating the new beacon\n",__func__);
2525 return -EINVAL;
2526 }
2527
2528 pAdapter->sessionCtx.ap.beacon = new;
2529
2530 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
2531 }
2532
2533 EXIT();
2534 return status;
2535}
2536
2537#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2538
Jeff Johnson295189b2012-06-20 16:38:30 -07002539
2540static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
2541 struct net_device *dev,
2542 struct bss_parameters *params)
2543{
2544 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2545
2546 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302547
Jeff Johnson295189b2012-06-20 16:38:30 -07002548 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2549 __func__,pAdapter->device_mode);
2550
2551 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302553 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002554 {
2555 /* ap_isolate == -1 means that in change bss, upper layer doesn't
2556 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302557 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07002558 {
2559 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302560 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002561 }
2562
2563 EXIT();
2564 return 0;
2565}
2566
Kiet Lam10841362013-11-01 11:36:50 +05302567/* FUNCTION: wlan_hdd_change_country_code_cd
2568* to wait for contry code completion
2569*/
2570void* wlan_hdd_change_country_code_cb(void *pAdapter)
2571{
2572 hdd_adapter_t *call_back_pAdapter = pAdapter;
2573 complete(&call_back_pAdapter->change_country_code);
2574 return NULL;
2575}
2576
Jeff Johnson295189b2012-06-20 16:38:30 -07002577/*
2578 * FUNCTION: wlan_hdd_cfg80211_change_iface
2579 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
2580 */
2581int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
2582 struct net_device *ndev,
2583 enum nl80211_iftype type,
2584 u32 *flags,
2585 struct vif_params *params
2586 )
2587{
2588 struct wireless_dev *wdev;
2589 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
2590 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Mohit Khanna0f232092012-09-11 14:46:08 -07002591 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002592 tCsrRoamProfile *pRoamProfile = NULL;
2593 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302594 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002595 eMib_dot11DesiredBssType connectedBssType;
2596 VOS_STATUS status;
2597
2598 ENTER();
2599
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302600 status = wlan_hdd_validate_context(pHddCtx);
2601
2602 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002603 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302604 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2605 "%s: HDD context is not valid", __func__);
2606 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002607 }
2608
2609 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
2610 __func__, pAdapter->device_mode);
2611
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302612 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07002613 wdev = ndev->ieee80211_ptr;
2614
2615#ifdef WLAN_BTAMP_FEATURE
2616 if((NL80211_IFTYPE_P2P_CLIENT == type)||
2617 (NL80211_IFTYPE_ADHOC == type)||
2618 (NL80211_IFTYPE_AP == type)||
2619 (NL80211_IFTYPE_P2P_GO == type))
2620 {
2621 pHddCtx->isAmpAllowed = VOS_FALSE;
2622 // stop AMP traffic
2623 status = WLANBAP_StopAmp();
2624 if(VOS_STATUS_SUCCESS != status )
2625 {
2626 pHddCtx->isAmpAllowed = VOS_TRUE;
2627 hddLog(VOS_TRACE_LEVEL_FATAL,
2628 "%s: Failed to stop AMP", __func__);
2629 return -EINVAL;
2630 }
2631 }
2632#endif //WLAN_BTAMP_FEATURE
2633 /* Reset the current device mode bit mask*/
2634 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
2635
2636 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07002638 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002639 )
2640 {
2641 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2642 pRoamProfile = &pWextState->roamProfile;
2643 LastBSSType = pRoamProfile->BSSType;
2644
2645 switch (type)
2646 {
2647 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002648 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002649 hddLog(VOS_TRACE_LEVEL_INFO,
2650 "%s: setting interface Type to INFRASTRUCTURE", __func__);
2651 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002652#ifdef WLAN_FEATURE_11AC
2653 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
2654 {
2655 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
2656 }
2657#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302658 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07002659 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002660 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002661 //Check for sub-string p2p to confirm its a p2p interface
2662 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302663 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002664 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2665 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2666 }
2667 else
2668 {
2669 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002670 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002671 }
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05302672#ifdef FEATURE_WLAN_TDLS
2673 /* The open adapter for the p2p shall skip initializations in
2674 * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for
2675 * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke
2676 * tdls_init when the change_iface sets the device mode to
2677 * WLAN_HDD_P2P_CLIENT.
2678 */
2679
2680 if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2681 {
2682 if (0 != wlan_hdd_tdls_init (pAdapter))
2683 {
2684 return -EINVAL;
2685 }
2686 }
2687#endif
2688
Jeff Johnson295189b2012-06-20 16:38:30 -07002689 break;
2690 case NL80211_IFTYPE_ADHOC:
2691 hddLog(VOS_TRACE_LEVEL_INFO,
2692 "%s: setting interface Type to ADHOC", __func__);
2693 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2694 pRoamProfile->phyMode =
2695 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002696 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002697 wdev->iftype = type;
2698 break;
2699
2700 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002701 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002702 {
2703 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2704 "%s: setting interface Type to %s", __func__,
2705 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
2706
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002707 //Cancel any remain on channel for GO mode
2708 if (NL80211_IFTYPE_P2P_GO == type)
2709 {
2710 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
2711 }
Mohit Khanna0f232092012-09-11 14:46:08 -07002712 if (NL80211_IFTYPE_AP == type)
2713 {
2714 /* As Loading WLAN Driver one interface being created for p2p device
2715 * address. This will take one HW STA and the max number of clients
2716 * that can connect to softAP will be reduced by one. so while changing
2717 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
2718 * interface as it is not required in SoftAP mode.
2719 */
2720
2721 // Get P2P Adapter
2722 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
2723
2724 if (pP2pAdapter)
2725 {
2726 hdd_stop_adapter(pHddCtx, pP2pAdapter);
2727 hdd_deinit_adapter(pHddCtx, pP2pAdapter);
2728 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
2729 }
2730 }
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302731#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07002732
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302733 /* A Mutex Lock is introduced while changing the mode to
2734 * protect the concurrent access for the Adapters by TDLS
2735 * module.
2736 */
2737 if (mutex_lock_interruptible(&pHddCtx->tdls_lock))
2738 {
2739 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2740 "%s: unable to lock list", __func__);
2741 return -EINVAL;
2742 }
2743#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002744 //De-init the adapter.
2745 hdd_stop_adapter( pHddCtx, pAdapter );
2746 hdd_deinit_adapter( pHddCtx, pAdapter );
2747 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07002748 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2749 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302750#ifdef FEATURE_WLAN_TDLS
2751 mutex_unlock(&pHddCtx->tdls_lock);
2752#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07002753
2754 //Disable BMPS and IMPS if enabled
2755 //before starting Go
2756 if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
2757 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302758 if(VOS_STATUS_E_FAILURE ==
Jeff Johnson32d95a32012-09-10 13:15:23 -07002759 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
2760 {
2761 //Fail to Exit BMPS
2762 VOS_ASSERT(0);
2763 }
2764 }
2765
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07002766 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
2767 (pConfig->apRandomBssidEnabled))
2768 {
2769 /* To meet Android requirements create a randomized
2770 MAC address of the form 02:1A:11:Fx:xx:xx */
2771 get_random_bytes(&ndev->dev_addr[3], 3);
2772 ndev->dev_addr[0] = 0x02;
2773 ndev->dev_addr[1] = 0x1A;
2774 ndev->dev_addr[2] = 0x11;
2775 ndev->dev_addr[3] |= 0xF0;
2776 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
2777 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08002778 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
2779 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07002780 }
2781
Jeff Johnson295189b2012-06-20 16:38:30 -07002782 hdd_set_ap_ops( pAdapter->dev );
2783
Kiet Lam10841362013-11-01 11:36:50 +05302784 /* This is for only SAP mode where users can
2785 * control country through ini.
2786 * P2P GO follows station country code
2787 * acquired during the STA scanning. */
2788 if((NL80211_IFTYPE_AP == type) &&
2789 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
2790 {
2791 int status = 0;
2792 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
2793 "%s: setting country code from INI ", __func__);
2794 init_completion(&pAdapter->change_country_code);
2795 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
2796 (void *)(tSmeChangeCountryCallback)
2797 wlan_hdd_change_country_code_cb,
2798 pConfig->apCntryCode, pAdapter,
2799 pHddCtx->pvosContext,
2800 VOS_FALSE);
2801 if (eHAL_STATUS_SUCCESS == status)
2802 {
2803 /* Wait for completion */
2804 status = wait_for_completion_interruptible_timeout(
2805 &pAdapter->change_country_code,
2806 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
2807 if (status <= 0)
2808 {
2809 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2810 "%s: SME Timed out while setting country code ",
2811 __func__);
2812 }
2813 }
2814 else
2815 {
2816 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2817 "%s: SME Change Country code failed \n",__func__);
2818 return -EINVAL;
2819 }
2820 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002821 status = hdd_init_ap_mode(pAdapter);
2822 if(status != VOS_STATUS_SUCCESS)
2823 {
2824 hddLog(VOS_TRACE_LEVEL_FATAL,
2825 "%s: Error initializing the ap mode", __func__);
2826 return -EINVAL;
2827 }
2828 hdd_set_conparam(1);
2829
Jeff Johnson295189b2012-06-20 16:38:30 -07002830 /*interface type changed update in wiphy structure*/
2831 if(wdev)
2832 {
2833 wdev->iftype = type;
2834 pHddCtx->change_iface = type;
2835 }
2836 else
2837 {
2838 hddLog(VOS_TRACE_LEVEL_ERROR,
2839 "%s: ERROR !!!! Wireless dev is NULL", __func__);
2840 return -EINVAL;
2841 }
2842 goto done;
2843 }
2844
2845 default:
2846 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2847 __func__);
2848 return -EOPNOTSUPP;
2849 }
2850 }
2851 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002852 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002853 )
2854 {
2855 switch(type)
2856 {
2857 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002858 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002859 case NL80211_IFTYPE_ADHOC:
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302860#ifdef FEATURE_WLAN_TDLS
2861
2862 /* A Mutex Lock is introduced while changing the mode to
2863 * protect the concurrent access for the Adapters by TDLS
2864 * module.
2865 */
2866 if (mutex_lock_interruptible(&pHddCtx->tdls_lock))
2867 {
2868 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2869 "%s: unable to lock list", __func__);
2870 return -EINVAL;
2871 }
2872#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07002873 hdd_stop_adapter( pHddCtx, pAdapter );
2874 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07002875 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002876 //Check for sub-string p2p to confirm its a p2p interface
2877 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002878 {
2879 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2880 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2881 }
2882 else
2883 {
2884 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002885 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002886 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002887 hdd_set_conparam(0);
2888 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002889 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
2890 hdd_set_station_ops( pAdapter->dev );
2891 status = hdd_init_station_mode( pAdapter );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302892#ifdef FEATURE_WLAN_TDLS
2893 mutex_unlock(&pHddCtx->tdls_lock);
2894#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002895 if( VOS_STATUS_SUCCESS != status )
2896 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07002897 /* In case of JB, for P2P-GO, only change interface will be called,
2898 * This is the right place to enable back bmps_imps()
2899 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302900 if (pHddCtx->hdd_wlan_suspended)
2901 {
2902 hdd_set_pwrparams(pHddCtx);
2903 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002904 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07002905 goto done;
2906 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002908 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002909 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2910 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002911 goto done;
2912 default:
2913 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2914 __func__);
2915 return -EOPNOTSUPP;
2916
2917 }
2918
2919 }
2920 else
2921 {
2922 return -EOPNOTSUPP;
2923 }
2924
2925
2926 if(pRoamProfile)
2927 {
2928 if ( LastBSSType != pRoamProfile->BSSType )
2929 {
2930 /*interface type changed update in wiphy structure*/
2931 wdev->iftype = type;
2932
2933 /*the BSS mode changed, We need to issue disconnect
2934 if connected or in IBSS disconnect state*/
2935 if ( hdd_connGetConnectedBssType(
2936 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
2937 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
2938 {
2939 /*need to issue a disconnect to CSR.*/
2940 INIT_COMPLETION(pAdapter->disconnect_comp_var);
2941 if( eHAL_STATUS_SUCCESS ==
2942 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
2943 pAdapter->sessionId,
2944 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
2945 {
2946 wait_for_completion_interruptible_timeout(
2947 &pAdapter->disconnect_comp_var,
2948 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
2949 }
2950 }
2951 }
2952 }
2953
2954done:
2955 /*set bitmask based on updated value*/
2956 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07002957
2958 /* Only STA mode support TM now
2959 * all other mode, TM feature should be disabled */
2960 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
2961 (~VOS_STA & pHddCtx->concurrency_mode) )
2962 {
2963 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
2964 }
2965
Jeff Johnson295189b2012-06-20 16:38:30 -07002966#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302967 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002968 (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
2969 {
2970 //we are ok to do AMP
2971 pHddCtx->isAmpAllowed = VOS_TRUE;
2972 }
2973#endif //WLAN_BTAMP_FEATURE
2974 EXIT();
2975 return 0;
2976}
2977
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002978#ifdef FEATURE_WLAN_TDLS
2979static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
2980 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
2981{
2982 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2983 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2984 VOS_STATUS status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002985 hddTdlsPeer_t *pTdlsPeer;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002986
2987 ENTER();
2988
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05302989 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002990 {
2991 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2992 "Invalid arguments");
2993 return -EINVAL;
2994 }
Hoonki Lee27511902013-03-14 18:19:06 -07002995
2996 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
2997 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
2998 {
2999 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3000 "%s: TDLS mode is disabled OR not enabled in FW."
3001 MAC_ADDRESS_STR " Request declined.",
3002 __func__, MAC_ADDR_ARRAY(mac));
3003 return -ENOTSUPP;
3004 }
3005
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003006 if (pHddCtx->isLogpInProgress)
3007 {
3008 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3009 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07003010 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003011 return -EBUSY;
3012 }
3013
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303014 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003015
3016 if ( NULL == pTdlsPeer ) {
3017 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3018 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
3019 __func__, MAC_ADDR_ARRAY(mac), update);
3020 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003021 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003022
3023 /* in add station, we accept existing valid staId if there is */
3024 if ((0 == update) &&
3025 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
3026 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003027 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003028 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003029 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003030 " link_status %d. staId %d. add station ignored.",
3031 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
3032 return 0;
3033 }
3034 /* in change station, we accept only when staId is valid */
3035 if ((1 == update) &&
3036 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
3037 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
3038 {
3039 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3040 "%s: " MAC_ADDRESS_STR
3041 " link status %d. staId %d. change station %s.",
3042 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
3043 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
3044 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003045 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003046
3047 /* when others are on-going, we want to change link_status to idle */
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303048 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003049 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003050 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3051 "%s: " MAC_ADDRESS_STR
3052 " TDLS setup is ongoing. Request declined.",
3053 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07003054 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003055 }
3056
3057 /* first to check if we reached to maximum supported TDLS peer.
3058 TODO: for now, return -EPERM looks working fine,
3059 but need to check if any other errno fit into this category.*/
3060 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
3061 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003062 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3063 "%s: " MAC_ADDRESS_STR
3064 " TDLS Max peer already connected. Request declined.",
3065 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07003066 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003067 }
3068 else
3069 {
3070 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303071 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003072 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003073 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003074 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3075 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
3076 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003077 return -EPERM;
3078 }
3079 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003080 if (0 == update)
3081 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003082
Jeff Johnsond75fe012013-04-06 10:53:06 -07003083 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303084 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003085 {
3086 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3087 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003088 if(StaParams->htcap_present)
3089 {
3090 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3091 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
3092 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3093 "ht_capa->extended_capabilities: %0x",
3094 StaParams->HTCap.extendedHtCapInfo);
3095 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003096 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3097 "params->capability: %0x",StaParams->capability);
3098 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003099 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003100 if(StaParams->vhtcap_present)
3101 {
3102 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3103 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
3104 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
3105 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
3106 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003107 {
3108 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003109 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003110 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
3111 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3112 "[%d]: %x ", i, StaParams->supported_rates[i]);
3113 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07003114 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303115 else if ((1 == update) && (NULL == StaParams))
3116 {
3117 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3118 "%s : update is true, but staParams is NULL. Error!", __func__);
3119 return -EPERM;
3120 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003121
3122 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
3123
3124 if (!update)
3125 {
3126 status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3127 pAdapter->sessionId, mac);
3128 }
3129 else
3130 {
3131 status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3132 pAdapter->sessionId, mac, StaParams);
3133 }
3134
3135 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
3136 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
3137
3138 if (!status)
3139 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003140 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003141 "%s: timeout waiting for tdls add station indication",
3142 __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003143 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003144 }
3145 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
3146 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003147 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003148 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003149 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003150 }
3151
3152 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07003153
3154error:
3155 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
3156 return -EPERM;
3157
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003158}
3159#endif
3160
Jeff Johnson295189b2012-06-20 16:38:30 -07003161static int wlan_hdd_change_station(struct wiphy *wiphy,
3162 struct net_device *dev,
3163 u8 *mac,
3164 struct station_parameters *params)
3165{
3166 VOS_STATUS status = VOS_STATUS_SUCCESS;
3167 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkala29149562013-05-10 21:43:41 +05303168 hdd_context_t *pHddCtx;
3169 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003170 v_MACADDR_t STAMacAddress;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003171#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003172 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003173 tANI_U8 isBufSta = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003174#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003175 ENTER();
3176
Gopichand Nakkala29149562013-05-10 21:43:41 +05303177 if ((NULL == pAdapter))
3178 {
3179 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3180 "invalid adapter ");
3181 return -EINVAL;
3182 }
3183
3184 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3185 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3186
3187 if ((NULL == pHddCtx) || (NULL == pHddStaCtx))
3188 {
3189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3190 "invalid HDD state or HDD station context");
3191 return -EINVAL;
3192 }
3193
3194 if (pHddCtx->isLogpInProgress)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003195 {
3196 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3197 "%s:LOGP in Progress. Ignore!!!", __func__);
3198 return -EAGAIN;
3199 }
3200
Jeff Johnson295189b2012-06-20 16:38:30 -07003201 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
3202
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003203 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
3204 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07003205 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003206 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07003207 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303208 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07003209 WLANTL_STA_AUTHENTICATED);
3210
Gopichand Nakkala29149562013-05-10 21:43:41 +05303211 if (status != VOS_STATUS_SUCCESS)
3212 {
3213 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3214 "%s: Not able to change TL state to AUTHENTICATED", __func__);
3215 return -EINVAL;
3216 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003217 }
3218 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07003219 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
3220 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303221#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003222 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
3223 StaParams.capability = params->capability;
3224 StaParams.uapsd_queues = params->uapsd_queues;
3225 StaParams.max_sp = params->max_sp;
3226
3227 if (0 != params->ext_capab_len)
3228 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
3229 sizeof(StaParams.extn_capability));
3230
3231 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003232 {
3233 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003234 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003235 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003236
3237 StaParams.supported_rates_len = params->supported_rates_len;
3238
3239 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
3240 * The supported_rates array , for all the structures propogating till Add Sta
3241 * to the firmware has to be modified , if the supplicant (ieee80211) is
3242 * modified to send more rates.
3243 */
3244
3245 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
3246 */
3247 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
3248 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
3249
3250 if (0 != StaParams.supported_rates_len) {
3251 int i = 0;
3252 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
3253 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003254 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003255 "Supported Rates with Length %d", StaParams.supported_rates_len);
3256 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003257 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003258 "[%d]: %0x", i, StaParams.supported_rates[i]);
3259 }
3260
3261 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003262 {
3263 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003264 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003265 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003266
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003267 if (0 != params->ext_capab_len ) {
3268 /*Define A Macro : TODO Sunil*/
3269 if ((1<<4) & StaParams.extn_capability[3]) {
3270 isBufSta = 1;
3271 }
3272 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303273 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac, params->uapsd_queues,
3274 params->max_sp, isBufSta);
3275 if (VOS_STATUS_SUCCESS != status) {
3276 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3277 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
3278 return -EINVAL;
3279 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003280 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
3281
3282 if (VOS_STATUS_SUCCESS != status) {
3283 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3284 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
3285 return -EINVAL;
3286 }
3287 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003288#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05303289 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003290 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003291 return status;
3292}
3293
3294/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003295 * FUNCTION: wlan_hdd_cfg80211_add_key
3296 * This function is used to initialize the key information
3297 */
3298#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003299static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 struct net_device *ndev,
3301 u8 key_index, bool pairwise,
3302 const u8 *mac_addr,
3303 struct key_params *params
3304 )
3305#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003306static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003307 struct net_device *ndev,
3308 u8 key_index, const u8 *mac_addr,
3309 struct key_params *params
3310 )
3311#endif
3312{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003313 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003314 tCsrRoamSetKey setKey;
3315 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303316 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003317 v_U32_t roamId= 0xFF;
3318 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003319 hdd_hostapd_state_t *pHostapdState;
3320 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003321 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303322 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003323
3324 ENTER();
3325
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303326 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3327 status = wlan_hdd_validate_context(pHddCtx);
3328
3329 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003330 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303331 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3332 "%s: HDD context is not valid", __func__);
3333 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003334 }
3335
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003336 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
3337 __func__, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003338
3339 if (CSR_MAX_NUM_KEY <= key_index)
3340 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003341 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003342 key_index);
3343
3344 return -EINVAL;
3345 }
3346
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003347 if (CSR_MAX_KEY_LEN < params->key_len)
3348 {
3349 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
3350 params->key_len);
3351
3352 return -EINVAL;
3353 }
3354
3355 hddLog(VOS_TRACE_LEVEL_INFO,
3356 "%s: called with key index = %d & key length %d",
3357 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003358
3359 /*extract key idx, key len and key*/
3360 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3361 setKey.keyId = key_index;
3362 setKey.keyLength = params->key_len;
3363 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
3364
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003365 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07003366 {
3367 case WLAN_CIPHER_SUITE_WEP40:
3368 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3369 break;
3370
3371 case WLAN_CIPHER_SUITE_WEP104:
3372 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3373 break;
3374
3375 case WLAN_CIPHER_SUITE_TKIP:
3376 {
3377 u8 *pKey = &setKey.Key[0];
3378 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3379
3380 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3381
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003382 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07003383
3384 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003385 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003386 |--------------|----------|----------|
3387 <---16bytes---><--8bytes--><--8bytes-->
3388
3389 */
3390 /*Sme expects the 32 bytes key to be in the below order
3391
3392 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003393 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003394 |--------------|----------|----------|
3395 <---16bytes---><--8bytes--><--8bytes-->
3396 */
3397 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003398 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07003399
3400 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003401 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003402
3403 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003404 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003405
3406
3407 break;
3408 }
3409
3410 case WLAN_CIPHER_SUITE_CCMP:
3411 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3412 break;
3413
3414#ifdef FEATURE_WLAN_WAPI
3415 case WLAN_CIPHER_SUITE_SMS4:
3416 {
3417 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3418 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
3419 params->key, params->key_len);
3420 return 0;
3421 }
3422#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003423
Jeff Johnson295189b2012-06-20 16:38:30 -07003424#ifdef FEATURE_WLAN_CCX
3425 case WLAN_CIPHER_SUITE_KRK:
3426 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3427 break;
3428#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003429
3430#ifdef WLAN_FEATURE_11W
3431 case WLAN_CIPHER_SUITE_AES_CMAC:
3432 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07003433 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07003434#endif
3435
Jeff Johnson295189b2012-06-20 16:38:30 -07003436 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003437 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07003438 __func__, params->cipher);
3439 return -EOPNOTSUPP;
3440 }
3441
3442 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
3443 __func__, setKey.encType);
3444
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003445 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07003446#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3447 (!pairwise)
3448#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003449 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07003450#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003451 )
3452 {
3453 /* set group key*/
3454 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3455 "%s- %d: setting Broadcast key",
3456 __func__, __LINE__);
3457 setKey.keyDirection = eSIR_RX_ONLY;
3458 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3459 }
3460 else
3461 {
3462 /* set pairwise key*/
3463 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3464 "%s- %d: setting pairwise key",
3465 __func__, __LINE__);
3466 setKey.keyDirection = eSIR_TX_RX;
3467 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3468 }
3469 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
3470 {
3471 setKey.keyDirection = eSIR_TX_RX;
3472 /*Set the group key*/
3473 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3474 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003475
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003476 if ( 0 != status )
3477 {
3478 hddLog(VOS_TRACE_LEVEL_ERROR,
3479 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3480 return -EINVAL;
3481 }
3482 /*Save the keys here and call sme_RoamSetKey for setting
3483 the PTK after peer joins the IBSS network*/
3484 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
3485 &setKey, sizeof(tCsrRoamSetKey));
3486 return status;
3487 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05303488 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
3489 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
3490 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003491 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003492 if( pHostapdState->bssState == BSS_START )
3493 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003494 status = WLANSAP_SetKeySta( pVosContext, &setKey);
3495
3496 if ( status != eHAL_STATUS_SUCCESS )
3497 {
3498 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3499 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3500 __LINE__, status );
3501 }
3502 }
3503
3504 /* Saving WEP keys */
3505 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
3506 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
3507 {
3508 //Save the wep key in ap context. Issue setkey after the BSS is started.
3509 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3510 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
3511 }
3512 else
3513 {
3514 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003515 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003516 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
3517 }
3518 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003519 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
3520 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 {
3522 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3523 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3524
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303525#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3526 if (!pairwise)
3527#else
3528 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
3529#endif
3530 {
3531 /* set group key*/
3532 if (pHddStaCtx->roam_info.deferKeyComplete)
3533 {
3534 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3535 "%s- %d: Perform Set key Complete",
3536 __func__, __LINE__);
3537 hdd_PerformRoamSetKeyComplete(pAdapter);
3538 }
3539 }
3540
Jeff Johnson295189b2012-06-20 16:38:30 -07003541 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
3542
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08003543 pWextState->roamProfile.Keys.defaultIndex = key_index;
3544
3545
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003546 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003547 params->key, params->key_len);
3548
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303549
Jeff Johnson295189b2012-06-20 16:38:30 -07003550 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3551
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303552 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003553 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303554 __func__, setKey.peerMac[0], setKey.peerMac[1],
3555 setKey.peerMac[2], setKey.peerMac[3],
3556 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003557 setKey.keyDirection);
3558
3559 vos_status = wlan_hdd_check_ula_done(pAdapter);
3560
3561 if ( vos_status != VOS_STATUS_SUCCESS )
3562 {
3563 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3564 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3565 __LINE__, vos_status );
3566
3567 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3568
3569 return -EINVAL;
3570
3571 }
3572
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003573#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303574 /* The supplicant may attempt to set the PTK once pre-authentication
3575 is done. Save the key in the UMAC and include it in the ADD BSS
3576 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003577 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303578 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003579 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303580 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3581 "%s: Update PreAuth Key success", __func__);
3582 return 0;
3583 }
3584 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3585 {
3586 hddLog(VOS_TRACE_LEVEL_ERROR,
3587 "%s: Update PreAuth Key failed", __func__);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05303588 return -EINVAL;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003589 }
3590#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07003591
3592 /* issue set key request to SME*/
3593 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3594 pAdapter->sessionId, &setKey, &roamId );
3595
3596 if ( 0 != status )
3597 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303598 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003599 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3600 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3601 return -EINVAL;
3602 }
3603
3604
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303605 /* in case of IBSS as there was no information available about WEP keys during
3606 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07003607 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303608 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
3609 !( ( IW_AUTH_KEY_MGMT_802_1X
3610 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003611 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
3612 )
3613 &&
3614 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
3615 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
3616 )
3617 )
3618 {
3619 setKey.keyDirection = eSIR_RX_ONLY;
3620 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3621
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303622 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003623 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303624 __func__, setKey.peerMac[0], setKey.peerMac[1],
3625 setKey.peerMac[2], setKey.peerMac[3],
3626 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003627 setKey.keyDirection);
3628
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303629 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003630 pAdapter->sessionId, &setKey, &roamId );
3631
3632 if ( 0 != status )
3633 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303634 hddLog(VOS_TRACE_LEVEL_ERROR,
3635 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003636 __func__, status);
3637 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3638 return -EINVAL;
3639 }
3640 }
3641 }
3642
3643 return 0;
3644}
3645
3646/*
3647 * FUNCTION: wlan_hdd_cfg80211_get_key
3648 * This function is used to get the key information
3649 */
3650#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303651static int wlan_hdd_cfg80211_get_key(
3652 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003653 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303654 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003655 const u8 *mac_addr, void *cookie,
3656 void (*callback)(void *cookie, struct key_params*)
3657 )
3658#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303659static int wlan_hdd_cfg80211_get_key(
3660 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003661 struct net_device *ndev,
3662 u8 key_index, const u8 *mac_addr, void *cookie,
3663 void (*callback)(void *cookie, struct key_params*)
3664 )
3665#endif
3666{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303667 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003668 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3669 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3670 struct key_params params;
3671
3672 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303673
Jeff Johnson295189b2012-06-20 16:38:30 -07003674 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
3675 __func__,pAdapter->device_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303676
Jeff Johnson295189b2012-06-20 16:38:30 -07003677 memset(&params, 0, sizeof(params));
3678
3679 if (CSR_MAX_NUM_KEY <= key_index)
3680 {
3681 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303682 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003683
3684 switch(pRoamProfile->EncryptionType.encryptionType[0])
3685 {
3686 case eCSR_ENCRYPT_TYPE_NONE:
3687 params.cipher = IW_AUTH_CIPHER_NONE;
3688 break;
3689
3690 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3691 case eCSR_ENCRYPT_TYPE_WEP40:
3692 params.cipher = WLAN_CIPHER_SUITE_WEP40;
3693 break;
3694
3695 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3696 case eCSR_ENCRYPT_TYPE_WEP104:
3697 params.cipher = WLAN_CIPHER_SUITE_WEP104;
3698 break;
3699
3700 case eCSR_ENCRYPT_TYPE_TKIP:
3701 params.cipher = WLAN_CIPHER_SUITE_TKIP;
3702 break;
3703
3704 case eCSR_ENCRYPT_TYPE_AES:
3705 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
3706 break;
3707
3708 default:
3709 params.cipher = IW_AUTH_CIPHER_NONE;
3710 break;
3711 }
3712
3713 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
3714 params.seq_len = 0;
3715 params.seq = NULL;
3716 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
3717 callback(cookie, &params);
3718 return 0;
3719}
3720
3721/*
3722 * FUNCTION: wlan_hdd_cfg80211_del_key
3723 * This function is used to delete the key information
3724 */
3725#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303726static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003727 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303728 u8 key_index,
3729 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003730 const u8 *mac_addr
3731 )
3732#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303733static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003734 struct net_device *ndev,
3735 u8 key_index,
3736 const u8 *mac_addr
3737 )
3738#endif
3739{
3740 int status = 0;
3741
3742 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303743 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07003744 //it is observed that this is invalidating peer
3745 //key index whenever re-key is done. This is affecting data link.
3746 //It should be ok to ignore del_key.
3747#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303748 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
3749 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003750 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3751 tCsrRoamSetKey setKey;
3752 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303753
Jeff Johnson295189b2012-06-20 16:38:30 -07003754 ENTER();
3755
3756 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
3757 __func__,pAdapter->device_mode);
3758
3759 if (CSR_MAX_NUM_KEY <= key_index)
3760 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303761 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003762 key_index);
3763
3764 return -EINVAL;
3765 }
3766
3767 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3768 setKey.keyId = key_index;
3769
3770 if (mac_addr)
3771 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3772 else
3773 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
3774
3775 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3776
3777 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07003778 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303779 )
3780 {
3781
3782 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07003783 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
3784 if( pHostapdState->bssState == BSS_START)
3785 {
3786 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303787
Jeff Johnson295189b2012-06-20 16:38:30 -07003788 if ( status != eHAL_STATUS_SUCCESS )
3789 {
3790 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3791 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3792 __LINE__, status );
3793 }
3794 }
3795 }
3796 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303797 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07003798 )
3799 {
3800 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3801
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303802 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3803
3804 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003805 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303806 __func__, setKey.peerMac[0], setKey.peerMac[1],
3807 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07003808 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303809 if(pAdapter->sessionCtx.station.conn_info.connState ==
3810 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07003811 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303812 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003813 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303814
Jeff Johnson295189b2012-06-20 16:38:30 -07003815 if ( 0 != status )
3816 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303817 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003818 "%s: sme_RoamSetKey failure, returned %d",
3819 __func__, status);
3820 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3821 return -EINVAL;
3822 }
3823 }
3824 }
3825#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003826 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 return status;
3828}
3829
3830/*
3831 * FUNCTION: wlan_hdd_cfg80211_set_default_key
3832 * This function is used to set the default tx key index
3833 */
3834#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3835static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3836 struct net_device *ndev,
3837 u8 key_index,
3838 bool unicast, bool multicast)
3839#else
3840static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3841 struct net_device *ndev,
3842 u8 key_index)
3843#endif
3844{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303845 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303846 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05303847 hdd_wext_state_t *pWextState;
3848 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303849 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003850
3851 ENTER();
3852
Gopichand Nakkala29149562013-05-10 21:43:41 +05303853 if ((NULL == pAdapter))
3854 {
3855 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3856 "invalid adapter");
3857 return -EINVAL;
3858 }
3859
3860 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3861 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3862
3863 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3864 {
3865 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3866 "invalid Wext state or HDD context");
3867 return -EINVAL;
3868 }
3869
Jeff Johnson295189b2012-06-20 16:38:30 -07003870 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d \n",
3871 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303872
Jeff Johnson295189b2012-06-20 16:38:30 -07003873 if (CSR_MAX_NUM_KEY <= key_index)
3874 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303875 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003876 key_index);
3877
3878 return -EINVAL;
3879 }
3880
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303881 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3882 status = wlan_hdd_validate_context(pHddCtx);
3883
3884 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003885 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303886 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3887 "%s: HDD context is not valid", __func__);
3888 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003889 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303890
Jeff Johnson295189b2012-06-20 16:38:30 -07003891 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07003892 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303893 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003894 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303895 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08003896 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303897 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08003898 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07003899 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303900 {
3901 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07003902 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303903
Jeff Johnson295189b2012-06-20 16:38:30 -07003904 tCsrRoamSetKey setKey;
3905 v_U32_t roamId= 0xFF;
3906 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303907
3908 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003909 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303910
Jeff Johnson295189b2012-06-20 16:38:30 -07003911 Keys->defaultIndex = (u8)key_index;
3912 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3913 setKey.keyId = key_index;
3914 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303915
3916 vos_mem_copy(&setKey.Key[0],
3917 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003918 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303919
Gopichand Nakkala29149562013-05-10 21:43:41 +05303920 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303921
3922 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07003923 &pHddStaCtx->conn_info.bssId[0],
3924 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303925
Gopichand Nakkala29149562013-05-10 21:43:41 +05303926 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
3927 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
3928 eCSR_ENCRYPT_TYPE_WEP104)
3929 {
3930 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
3931 even though ap is configured for WEP-40 encryption. In this canse the key length
3932 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
3933 type(104) and switching encryption type to 40*/
3934 pWextState->roamProfile.EncryptionType.encryptionType[0] =
3935 eCSR_ENCRYPT_TYPE_WEP40;
3936 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
3937 eCSR_ENCRYPT_TYPE_WEP40;
3938 }
3939
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303940 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07003941 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303942
Jeff Johnson295189b2012-06-20 16:38:30 -07003943 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303944 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003945 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303946
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 if ( 0 != status )
3948 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303949 hddLog(VOS_TRACE_LEVEL_ERROR,
3950 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003951 status);
3952 return -EINVAL;
3953 }
3954 }
3955 }
3956
3957 /* In SoftAp mode setting key direction for default mode */
3958 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
3959 {
3960 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
3961 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
3962 (eCSR_ENCRYPT_TYPE_AES !=
3963 pWextState->roamProfile.EncryptionType.encryptionType[0])
3964 )
3965 {
3966 /* Saving key direction for default key index to TX default */
3967 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3968 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
3969 }
3970 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303971
Jeff Johnson295189b2012-06-20 16:38:30 -07003972 return status;
3973}
3974
Jeff Johnson295189b2012-06-20 16:38:30 -07003975/*
3976 * FUNCTION: wlan_hdd_cfg80211_inform_bss
3977 * This function is used to inform the BSS details to nl80211 interface.
3978 */
3979static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
3980 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
3981{
3982 struct net_device *dev = pAdapter->dev;
3983 struct wireless_dev *wdev = dev->ieee80211_ptr;
3984 struct wiphy *wiphy = wdev->wiphy;
3985 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
3986 int chan_no;
3987 int ie_length;
3988 const char *ie;
3989 unsigned int freq;
3990 struct ieee80211_channel *chan;
3991 int rssi = 0;
3992 struct cfg80211_bss *bss = NULL;
3993
3994 ENTER();
3995
3996 if( NULL == pBssDesc )
3997 {
3998 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL\n", __func__);
3999 return bss;
4000 }
4001
4002 chan_no = pBssDesc->channelId;
4003 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
4004 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
4005
4006 if( NULL == ie )
4007 {
4008 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL\n", __func__);
4009 return bss;
4010 }
4011
4012#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
4013 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
4014 {
4015 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4016 }
4017 else
4018 {
4019 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4020 }
4021#else
4022 freq = ieee80211_channel_to_frequency(chan_no);
4023#endif
4024
4025 chan = __ieee80211_get_channel(wiphy, freq);
4026
4027 bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId,
4028 &roamProfile->SSID.ssId[0], roamProfile->SSID.length,
4029 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
4030 if (bss == NULL)
4031 {
4032 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
4033
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304034 return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
4035 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07004036 pBssDesc->capabilityInfo,
4037 pBssDesc->beaconInterval, ie, ie_length,
4038 rssi, GFP_KERNEL ));
4039}
4040 else
4041 {
4042 return bss;
4043 }
4044}
4045
4046
4047
4048/*
4049 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
4050 * This function is used to inform the BSS details to nl80211 interface.
4051 */
4052struct cfg80211_bss*
4053wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
4054 tSirBssDescription *bss_desc
4055 )
4056{
4057 /*
4058 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
4059 already exists in bss data base of cfg80211 for that particular BSS ID.
4060 Using cfg80211_inform_bss_frame to update the bss entry instead of
4061 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
4062 now there is no possibility to get the mgmt(probe response) frame from PE,
4063 converting bss_desc to ieee80211_mgmt(probe response) and passing to
4064 cfg80211_inform_bss_frame.
4065 */
4066 struct net_device *dev = pAdapter->dev;
4067 struct wireless_dev *wdev = dev->ieee80211_ptr;
4068 struct wiphy *wiphy = wdev->wiphy;
4069 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004070#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4071 qcom_ie_age *qie_age = NULL;
4072 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
4073#else
Jeff Johnson295189b2012-06-20 16:38:30 -07004074 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004075#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004076 const char *ie =
4077 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
4078 unsigned int freq;
4079 struct ieee80211_channel *chan;
4080 struct ieee80211_mgmt *mgmt =
4081 kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
4082 struct cfg80211_bss *bss_status = NULL;
4083 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
4084 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07004085 hdd_context_t *pHddCtx;
4086 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07004087#ifdef WLAN_OPEN_SOURCE
4088 struct timespec ts;
4089#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004090
4091 ENTER();
4092
Wilson Yangf80a0542013-10-07 13:02:37 -07004093 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4094 status = wlan_hdd_validate_context(pHddCtx);
4095
4096 /*bss_update is not allowed during wlan driver loading or unloading*/
4097 if (pHddCtx->isLoadUnloadInProgress)
4098 {
4099 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4100 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
4101 return NULL;
4102 }
4103
4104
4105 if (0 != status)
4106 {
4107 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4108 "%s: HDD context is not valid", __func__);
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07004109 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07004110 }
4111
4112
4113 if (!mgmt)
4114 {
4115 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4116 "%s: memory allocation failed ", __func__);
4117 return NULL;
4118 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07004119
Jeff Johnson295189b2012-06-20 16:38:30 -07004120 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07004121
4122#ifdef WLAN_OPEN_SOURCE
4123 /* Android does not want the timestamp from the frame.
4124 Instead it wants a monotonic increasing value */
4125 get_monotonic_boottime(&ts);
4126 mgmt->u.probe_resp.timestamp =
4127 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
4128#else
4129 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07004130 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
4131 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07004132
4133#endif
4134
Jeff Johnson295189b2012-06-20 16:38:30 -07004135 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
4136 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004137
4138#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4139 /* GPS Requirement: need age ie per entry. Using vendor specific. */
4140 /* Assuming this is the last IE, copy at the end */
4141 ie_length -=sizeof(qcom_ie_age);
4142 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
4143 qie_age->element_id = QCOM_VENDOR_IE_ID;
4144 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
4145 qie_age->oui_1 = QCOM_OUI1;
4146 qie_age->oui_2 = QCOM_OUI2;
4147 qie_age->oui_3 = QCOM_OUI3;
4148 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
4149 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
4150#endif
4151
Jeff Johnson295189b2012-06-20 16:38:30 -07004152 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05304153 if (bss_desc->fProbeRsp)
4154 {
4155 mgmt->frame_control |=
4156 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
4157 }
4158 else
4159 {
4160 mgmt->frame_control |=
4161 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
4162 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004163
4164#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304165 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004166 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
4167 {
4168 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4169 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304170 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004171 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
4172
4173 {
4174 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4175 }
4176 else
4177 {
4178 kfree(mgmt);
4179 return NULL;
4180 }
4181#else
4182 freq = ieee80211_channel_to_frequency(chan_no);
4183#endif
4184 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004185 /*when the band is changed on the fly using the GUI, three things are done
4186 * 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)
4187 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
4188 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
4189 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
4190 * and discards the channels correponding to previous band and calls back with zero bss results.
4191 * 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
4192 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
4193 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
4194 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
4195 * So drop the bss and continue to next bss.
4196 */
4197 if(chan == NULL)
4198 {
4199 hddLog(VOS_TRACE_LEVEL_INFO, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07004200 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004201 return NULL;
4202 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004203 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304204 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07004205 * */
4206 if (( eConnectionState_Associated ==
4207 pAdapter->sessionCtx.station.conn_info.connState ) &&
4208 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
4209 pAdapter->sessionCtx.station.conn_info.bssId,
4210 WNI_CFG_BSSID_LEN)))
4211 {
4212 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
4213 rssi = (pAdapter->rssi * 100);
4214 }
4215 else
4216 {
4217 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
4218 }
4219
4220 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
4221 frame_len, rssi, GFP_KERNEL);
4222 kfree(mgmt);
4223 return bss_status;
4224}
4225
4226/*
4227 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
4228 * This function is used to update the BSS data base of CFG8011
4229 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304230struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004231 tCsrRoamInfo *pRoamInfo
4232 )
4233{
4234 tCsrRoamConnectedProfile roamProfile;
4235 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4236 struct cfg80211_bss *bss = NULL;
4237
4238 ENTER();
4239
4240 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
4241 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
4242
4243 if (NULL != roamProfile.pBssDesc)
4244 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304245 bss = wlan_hdd_cfg80211_inform_bss(pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004246 &roamProfile);
4247
4248 if (NULL == bss)
4249 {
4250 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
4251 __func__);
4252 }
4253
4254 sme_RoamFreeConnectProfile(hHal, &roamProfile);
4255 }
4256 else
4257 {
4258 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
4259 __func__);
4260 }
4261 return bss;
4262}
4263
4264/*
4265 * FUNCTION: wlan_hdd_cfg80211_update_bss
4266 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304267static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
4268 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07004269 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304270{
Jeff Johnson295189b2012-06-20 16:38:30 -07004271 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4272 tCsrScanResultInfo *pScanResult;
4273 eHalStatus status = 0;
4274 tScanResultHandle pResult;
4275 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07004276 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004277
4278 ENTER();
4279
Wilson Yangf80a0542013-10-07 13:02:37 -07004280 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4281
4282 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -07004283 {
Wilson Yangf80a0542013-10-07 13:02:37 -07004284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4285 "%s:LOGP in Progress. Ignore!!!",__func__);
4286 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004287 }
4288
Wilson Yangf80a0542013-10-07 13:02:37 -07004289
4290 /*bss_update is not allowed during wlan driver loading or unloading*/
4291 if (pHddCtx->isLoadUnloadInProgress)
4292 {
4293 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4294 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
4295 return VOS_STATUS_E_PERM;
4296 }
4297
4298
Jeff Johnson295189b2012-06-20 16:38:30 -07004299 /*
4300 * start getting scan results and populate cgf80211 BSS database
4301 */
4302 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
4303
4304 /* no scan results */
4305 if (NULL == pResult)
4306 {
4307 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result\n", __func__);
4308 return status;
4309 }
4310
4311 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
4312
4313 while (pScanResult)
4314 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304315 /*
4316 * cfg80211_inform_bss() is not updating ie field of bss entry, if
4317 * entry already exists in bss data base of cfg80211 for that
4318 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
4319 * bss entry instead of cfg80211_inform_bss, But this call expects
4320 * mgmt packet as input. As of now there is no possibility to get
4321 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07004322 * ieee80211_mgmt(probe response) and passing to c
4323 * fg80211_inform_bss_frame.
4324 * */
4325
4326 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
4327 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304328
Jeff Johnson295189b2012-06-20 16:38:30 -07004329
4330 if (NULL == bss_status)
4331 {
4332 hddLog(VOS_TRACE_LEVEL_INFO,
4333 "%s: NULL returned by cfg80211_inform_bss\n", __func__);
4334 }
4335 else
4336 {
Yue Maf49ba872013-08-19 12:04:25 -07004337 cfg80211_put_bss(
4338#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
4339 wiphy,
4340#endif
4341 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004342 }
4343
4344 pScanResult = sme_ScanResultGetNext(hHal, pResult);
4345 }
4346
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304347 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07004348
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304349 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004350}
4351
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004352void
4353hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
4354{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304355 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004356 "%02X:%02X:%02X:%02X:%02X:%02X\n",
4357 macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4],
4358 macAddr[5]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004359} /****** end hddPrintMacAddr() ******/
4360
4361void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004362hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004363{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304364 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004365 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
4366 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
4367 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
4368 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004369} /****** end hddPrintPmkId() ******/
4370
4371//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
4372//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
4373
4374//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
4375//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
4376
4377#define dump_bssid(bssid) \
4378 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004379 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
4380 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
4381 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004382 }
4383
4384#define dump_pmkid(pMac, pmkid) \
4385 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004386 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
4387 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
4388 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004389 }
4390
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004391#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004392/*
4393 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
4394 * This function is used to notify the supplicant of a new PMKSA candidate.
4395 */
4396int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304397 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004398 int index, bool preauth )
4399{
Jeff Johnsone7245742012-09-05 17:12:55 -07004400#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004401 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004402 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004403
4404 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07004405 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004406
4407 if( NULL == pRoamInfo )
4408 {
4409 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL\n", __func__);
4410 return -EINVAL;
4411 }
4412
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004413 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
4414 {
4415 dump_bssid(pRoamInfo->bssid);
4416 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004417 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004418 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004419#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304420 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004421}
4422#endif //FEATURE_WLAN_LFR
4423
Yue Maef608272013-04-08 23:09:17 -07004424#ifdef FEATURE_WLAN_LFR_METRICS
4425/*
4426 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
4427 * 802.11r/LFR metrics reporting function to report preauth initiation
4428 *
4429 */
4430#define MAX_LFR_METRICS_EVENT_LENGTH 100
4431VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
4432 tCsrRoamInfo *pRoamInfo)
4433{
4434 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4435 union iwreq_data wrqu;
4436
4437 ENTER();
4438
4439 if (NULL == pAdapter)
4440 {
4441 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4442 return VOS_STATUS_E_FAILURE;
4443 }
4444
4445 /* create the event */
4446 memset(&wrqu, 0, sizeof(wrqu));
4447 memset(metrics_notification, 0, sizeof(metrics_notification));
4448
4449 wrqu.data.pointer = metrics_notification;
4450 wrqu.data.length = scnprintf(metrics_notification,
4451 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
4452 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
4453
4454 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4455
4456 EXIT();
4457
4458 return VOS_STATUS_SUCCESS;
4459}
4460
4461/*
4462 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
4463 * 802.11r/LFR metrics reporting function to report preauth completion
4464 * or failure
4465 */
4466VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
4467 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
4468{
4469 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4470 union iwreq_data wrqu;
4471
4472 ENTER();
4473
4474 if (NULL == pAdapter)
4475 {
4476 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4477 return VOS_STATUS_E_FAILURE;
4478 }
4479
4480 /* create the event */
4481 memset(&wrqu, 0, sizeof(wrqu));
4482 memset(metrics_notification, 0, sizeof(metrics_notification));
4483
4484 scnprintf(metrics_notification, sizeof(metrics_notification),
4485 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
4486 MAC_ADDR_ARRAY(pRoamInfo->bssid));
4487
4488 if (1 == preauth_status)
4489 strncat(metrics_notification, " TRUE", 5);
4490 else
4491 strncat(metrics_notification, " FALSE", 6);
4492
4493 wrqu.data.pointer = metrics_notification;
4494 wrqu.data.length = strlen(metrics_notification);
4495
4496 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4497
4498 EXIT();
4499
4500 return VOS_STATUS_SUCCESS;
4501}
4502
4503/*
4504 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
4505 * 802.11r/LFR metrics reporting function to report handover initiation
4506 *
4507 */
4508VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
4509 tCsrRoamInfo *pRoamInfo)
4510{
4511 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4512 union iwreq_data wrqu;
4513
4514 ENTER();
4515
4516 if (NULL == pAdapter)
4517 {
4518 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4519 return VOS_STATUS_E_FAILURE;
4520 }
4521
4522 /* create the event */
4523 memset(&wrqu, 0, sizeof(wrqu));
4524 memset(metrics_notification, 0, sizeof(metrics_notification));
4525
4526 wrqu.data.pointer = metrics_notification;
4527 wrqu.data.length = scnprintf(metrics_notification,
4528 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
4529 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
4530
4531 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4532
4533 EXIT();
4534
4535 return VOS_STATUS_SUCCESS;
4536}
4537#endif
4538
Jeff Johnson295189b2012-06-20 16:38:30 -07004539/*
4540 * FUNCTION: hdd_cfg80211_scan_done_callback
4541 * scanning callback function, called after finishing scan
4542 *
4543 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304544static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -07004545 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
4546{
4547 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304548 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004549 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004550 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4551 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07004552 struct cfg80211_scan_request *req = NULL;
4553 int ret = 0;
4554
4555 ENTER();
4556
4557 hddLog(VOS_TRACE_LEVEL_INFO,
4558 "%s called with halHandle = %p, pContext = %p,"
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304559 "scanID = %d, returned status = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 __func__, halHandle, pContext, (int) scanId, (int) status);
4561
Kiet Lamac06e2c2013-10-23 16:25:07 +05304562 pScanInfo->mScanPendingCounter = 0;
4563
Jeff Johnson295189b2012-06-20 16:38:30 -07004564 //Block on scan req completion variable. Can't wait forever though.
4565 ret = wait_for_completion_interruptible_timeout(
4566 &pScanInfo->scan_req_completion_event,
4567 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
4568 if (!ret)
4569 {
4570 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004571 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004572 }
4573
Yue Maef608272013-04-08 23:09:17 -07004574 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004575 {
4576 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004577 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004578 }
4579
4580 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304581 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -07004582 {
4583 hddLog(VOS_TRACE_LEVEL_INFO,
4584 "%s called with mismatched scanId pScanInfo->scanId = %d "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304585 "scanId = %d \n", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004586 (int) scanId);
4587 }
4588
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304589 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004590 pAdapter);
4591
4592 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304593 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004594
4595
4596 /* If any client wait scan result through WEXT
4597 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004598 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07004599 {
4600 /* The other scan request waiting for current scan finish
4601 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004602 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004603 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004604 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07004605 }
4606 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004607 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004608 {
4609 struct net_device *dev = pAdapter->dev;
4610 union iwreq_data wrqu;
4611 int we_event;
4612 char *msg;
4613
4614 memset(&wrqu, '\0', sizeof(wrqu));
4615 we_event = SIOCGIWSCAN;
4616 msg = NULL;
4617 wireless_send_event(dev, we_event, &wrqu, msg);
4618 }
4619 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004620 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004621
4622 /* Get the Scan Req */
4623 req = pAdapter->request;
4624
4625 if (!req)
4626 {
4627 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL\n");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004628 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004629 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004630 }
4631
4632 /*
4633 * setting up 0, just in case.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304634 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004635 req->n_ssids = 0;
4636 req->n_channels = 0;
4637 req->ie = 0;
4638
Jeff Johnson295189b2012-06-20 16:38:30 -07004639 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07004640 /* Scan is no longer pending */
4641 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004642
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -07004643 /*
4644 * cfg80211_scan_done informing NL80211 about completion
4645 * of scanning
4646 */
4647 cfg80211_scan_done(req, false);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08004648 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07004649
Jeff Johnsone7245742012-09-05 17:12:55 -07004650allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004651 /* release the wake lock at the end of the scan*/
4652 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07004653
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004654 /* Acquire wakelock to handle the case where APP's tries to suspend
4655 * immediatly after the driver gets connect request(i.e after scan)
4656 * from supplicant, this result in app's is suspending and not able
4657 * to process the connect request to AP */
Amar Singhal6144c002013-05-03 16:11:42 -07004658 hdd_allow_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004659
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004660#ifdef FEATURE_WLAN_TDLS
4661 wlan_hdd_tdls_scan_done_callback(pAdapter);
4662#endif
4663
Jeff Johnson295189b2012-06-20 16:38:30 -07004664 EXIT();
4665 return 0;
4666}
4667
4668/*
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004669 * FUNCTION: hdd_isScanAllowed
4670 * Go through each adapter and check if scan allowed
4671 *
4672 */
4673v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx )
4674{
4675 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
4676 hdd_station_ctx_t *pHddStaCtx = NULL;
4677 hdd_adapter_t *pAdapter = NULL;
4678 VOS_STATUS status = 0;
4679 v_U8_t staId = 0;
4680 v_U8_t *staMac = NULL;
4681
4682 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
4683
4684 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
4685 {
4686 pAdapter = pAdapterNode->pAdapter;
4687
4688 if( pAdapter )
4689 {
4690 hddLog(VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304691 "%s: Adapter with device mode %d exists",
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004692 __func__, pAdapter->device_mode);
4693 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
4694 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4695 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
4696 {
4697 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4698 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
4699 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
4700 {
4701 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
4702 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08004703 "%s: client " MAC_ADDRESS_STR
4704 " is in the middle of WPS/EAPOL exchange.", __func__,
4705 MAC_ADDR_ARRAY(staMac));
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004706 return VOS_FALSE;
4707 }
4708 }
4709 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
4710 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
4711 {
4712 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
4713 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304714 if ((pAdapter->aStaInfo[staId].isUsed) &&
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004715 (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState))
4716 {
4717 staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
4718
4719 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08004720 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
4721 "middle of WPS/EAPOL exchange.", __func__,
4722 MAC_ADDR_ARRAY(staMac));
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004723 return VOS_FALSE;
4724 }
4725 }
4726 }
4727 }
4728 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
4729 pAdapterNode = pNext;
4730 }
4731 hddLog(VOS_TRACE_LEVEL_INFO,
4732 "%s: Scan allowed", __func__);
4733 return VOS_TRUE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304734}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004735
4736/*
Jeff Johnson295189b2012-06-20 16:38:30 -07004737 * FUNCTION: wlan_hdd_cfg80211_scan
4738 * this scan respond to scan trigger and update cfg80211 scan database
4739 * later, scan dump command can be used to recieve scan results
4740 */
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08004741int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
4742#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4743 struct net_device *dev,
4744#endif
4745 struct cfg80211_scan_request *request)
4746{
4747#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
4748 struct net_device *dev = request->wdev->netdev;
4749#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304750 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07004751 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4752 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304753 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004754 tCsrScanRequest scanRequest;
4755 tANI_U8 *channelList = NULL, i;
4756 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304757 int status;
4758 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004759 v_U8_t* pP2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004760
4761 ENTER();
4762
4763 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
4764 __func__,pAdapter->device_mode);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004765
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304766 status = wlan_hdd_validate_context(pHddCtx);
4767
4768 if (0 != status)
4769 {
4770 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4771 "%s: HDD context is not valid", __func__);
4772 return status;
4773 }
4774
4775 cfg_param = pHddCtx->cfg_ini;
4776 pScanInfo = &pHddCtx->scan_info;
4777
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004778 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004779 (eConnectionState_Connecting ==
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004780 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004781 {
4782 hddLog(VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08004783 "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \
4784 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004785 return -EBUSY;
4786 }
4787
Jeff Johnson295189b2012-06-20 16:38:30 -07004788#ifdef WLAN_BTAMP_FEATURE
4789 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004790 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -07004791 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004792 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004793 "%s: No scanning when AMP is on", __func__);
4794 return -EOPNOTSUPP;
4795 }
4796#endif
4797 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004798 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07004799 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004800 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004801 "%s: Not scanning on device_mode = %d",
4802 __func__, pAdapter->device_mode);
4803 return -EOPNOTSUPP;
4804 }
4805
4806 if (TRUE == pScanInfo->mScanPending)
4807 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05304808 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
4809 {
4810 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
4811 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004812 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004813 }
4814
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304815 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -07004816 //Channel and action frame is pending
4817 //Otherwise Cancel Remain On Channel and allow Scan
4818 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004819 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -07004820 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05304821 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -07004822 return -EBUSY;
4823 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004824#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004825 /* if tdls disagree scan right now, return immediately.
4826 tdls will schedule the scan when scan is allowed. (return SUCCESS)
4827 or will reject the scan if any TDLS is in progress. (return -EBUSY)
4828 */
4829 status = wlan_hdd_tdls_scan_callback (pAdapter,
4830 wiphy,
4831#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4832 dev,
Gopichand Nakkalac3c42b92013-03-20 19:42:34 -07004833#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004834 request);
4835 if(status <= 0)
4836 {
4837 hddLog(VOS_TRACE_LEVEL_INFO, "%s: TDLS Pending %d", __func__, status);
4838 return status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004839 }
4840#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07004841
Jeff Johnson295189b2012-06-20 16:38:30 -07004842 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
4843 {
4844 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -08004845 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004846 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304847 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004848 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
4849 {
4850 hddLog(VOS_TRACE_LEVEL_WARN,
4851 "%s: MAX TM Level Scan not allowed", __func__);
4852 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304853 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004854 }
4855 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
4856
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004857 /* Check if scan is allowed at this point of time.
4858 */
4859 if (!hdd_isScanAllowed(pHddCtx))
4860 {
4861 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
4862 return -EBUSY;
4863 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304864
Jeff Johnson295189b2012-06-20 16:38:30 -07004865 vos_mem_zero( &scanRequest, sizeof(scanRequest));
4866
4867 if (NULL != request)
4868 {
4869 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304870 (int)request->n_ssids);
Jeff Johnson295189b2012-06-20 16:38:30 -07004871
4872 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
4873 * Becasue of this, driver is assuming that this is not wildcard scan and so
4874 * is not aging out the scan results.
4875 */
Jeff Johnson32d95a32012-09-10 13:15:23 -07004876 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004877 {
4878 request->n_ssids = 0;
4879 }
4880
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004881 if ((request->ssids) && (0 < request->n_ssids))
Jeff Johnson295189b2012-06-20 16:38:30 -07004882 {
4883 tCsrSSIDInfo *SsidInfo;
4884 int j;
4885 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
4886 /* Allocate num_ssid tCsrSSIDInfo structure */
4887 SsidInfo = scanRequest.SSIDs.SSIDList =
4888 ( tCsrSSIDInfo *)vos_mem_malloc(
4889 request->n_ssids*sizeof(tCsrSSIDInfo));
4890
4891 if(NULL == scanRequest.SSIDs.SSIDList)
4892 {
4893 hddLog(VOS_TRACE_LEVEL_ERROR,
4894 "memory alloc failed SSIDInfo buffer");
4895 return -ENOMEM;
4896 }
4897
4898 /* copy all the ssid's and their length */
4899 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
4900 {
4901 /* get the ssid length */
4902 SsidInfo->SSID.length = request->ssids[j].ssid_len;
4903 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
4904 SsidInfo->SSID.length);
4905 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
4906 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "SSID number %d: %s",
4907 j, SsidInfo->SSID.ssId);
4908 }
4909 /* set the scan type to active */
4910 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4911 }
4912 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
4913 {
4914 /* set the scan type to active */
4915 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4916 }
4917 else
4918 {
4919 /*Set the scan type to default type, in this case it is ACTIVE*/
4920 scanRequest.scanType = pScanInfo->scan_mode;
4921 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304922 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07004923 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
4924 }
4925 else
4926 {
4927 /* set the scan type to active */
4928 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4929 vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff );
4930
4931 /* set min and max channel time to zero */
4932 scanRequest.minChnTime = 0;
4933 scanRequest.maxChnTime = 0;
4934 }
4935
4936 /* set BSSType to default type */
4937 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
4938
4939 /*TODO: scan the requested channels only*/
4940
4941 /*Right now scanning all the channels */
4942 if( request )
4943 {
4944 if( request->n_channels )
4945 {
4946 channelList = vos_mem_malloc( request->n_channels );
4947 if( NULL == channelList )
4948 {
4949 status = -ENOMEM;
4950 goto free_mem;
4951 }
4952
4953 for( i = 0 ; i < request->n_channels ; i++ )
4954 channelList[i] = request->channels[i]->hw_value;
4955 }
4956
4957 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
4958 scanRequest.ChannelInfo.ChannelList = channelList;
4959
4960 /* set requestType to full scan */
4961 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304962
4963 /* Flush the scan results(only p2p beacons) for STA scan and P2P
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004964 * search (Flush on both full scan and social scan but not on single
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304965 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004966 */
4967
4968 /* Supplicant does single channel scan after 8-way handshake
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304969 * and in that case driver shoudnt flush scan results. If
4970 * driver flushes the scan results here and unfortunately if
4971 * the AP doesnt respond to our probe req then association
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004972 * fails which is not desired
4973 */
4974
4975 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
4976 {
4977 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
4978 pAdapter->sessionId );
4979 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004980
4981 if( request->ie_len )
4982 {
4983 /* save this for future association (join requires this) */
4984 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
4985 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
4986 pScanInfo->scanAddIE.length = request->ie_len;
4987
4988 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07004989 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4990 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07004991 )
4992 {
4993 pwextBuf->roamProfile.pAddIEScan = pScanInfo->scanAddIE.addIEdata;
4994 pwextBuf->roamProfile.nAddIEScanLength = pScanInfo->scanAddIE.length;
4995 }
4996
4997 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
4998 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
4999
Jeff Johnson295189b2012-06-20 16:38:30 -07005000 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
5001 request->ie_len);
5002 if (pP2pIe != NULL)
5003 {
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07005004#ifdef WLAN_FEATURE_P2P_DEBUG
5005 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
5006 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
5007 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5008 {
5009 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
5010 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
5011 "Go nego completed to Connection is started");
5012 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
5013 "for 8way Handshake");
5014 }
5015 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
5016 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5017 {
5018 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
5019 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
5020 "Disconnected state to Connection is started");
5021 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
5022 "for 4way Handshake");
5023 }
5024#endif
5025
Jeff Johnsone7245742012-09-05 17:12:55 -07005026 /* no_cck will be set during p2p find to disable 11b rates */
5027 if(TRUE == request->no_cck)
Jeff Johnson295189b2012-06-20 16:38:30 -07005028 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005029 hddLog(VOS_TRACE_LEVEL_INFO,
5030 "%s: This is a P2P Search", __func__);
5031 scanRequest.p2pSearch = 1;
Jeff Johnsone7245742012-09-05 17:12:55 -07005032
Jeff Johnsone7245742012-09-05 17:12:55 -07005033 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
5034 {
Madan Mohan Koyyalamudi1b1d9e82012-10-21 11:38:33 -07005035 /* set requestType to P2P Discovery */
5036 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
Jeff Johnsone7245742012-09-05 17:12:55 -07005037 }
5038
5039 /*
5040 Skip Dfs Channel in case of P2P Search
5041 if it is set in ini file
5042 */
5043 if(cfg_param->skipDfsChnlInP2pSearch)
5044 {
5045 scanRequest.skipDfsChnlInP2pSearch = 1;
5046 }
5047 else
5048 {
5049 scanRequest.skipDfsChnlInP2pSearch = 0;
5050 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005051
Jeff Johnson295189b2012-06-20 16:38:30 -07005052 }
5053 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005054 }
5055 }
5056
5057 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
5058
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07005059 /* acquire the wakelock to avoid the apps suspend during the scan. To
5060 * address the following issues.
5061 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
5062 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
5063 * for long time, this result in apps running at full power for long time.
5064 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
5065 * be stuck in full power because of resume BMPS
5066 */
5067 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07005068
5069 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005070 pAdapter->sessionId, &scanRequest, &scanId,
5071 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -07005072
Jeff Johnson295189b2012-06-20 16:38:30 -07005073 if (eHAL_STATUS_SUCCESS != status)
5074 {
5075 hddLog(VOS_TRACE_LEVEL_ERROR,
5076 "%s: sme_ScanRequest returned error %d", __func__, status);
5077 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07005078 if(eHAL_STATUS_RESOURCES == status)
5079 {
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07005080 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 -07005081 status = -EBUSY;
5082 } else {
5083 status = -EIO;
5084 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07005085 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07005086 goto free_mem;
5087 }
5088
5089 pScanInfo->mScanPending = TRUE;
5090 pAdapter->request = request;
5091 pScanInfo->scanId = scanId;
5092
5093 complete(&pScanInfo->scan_req_completion_event);
5094
5095free_mem:
5096 if( scanRequest.SSIDs.SSIDList )
5097 {
5098 vos_mem_free(scanRequest.SSIDs.SSIDList);
5099 }
5100
5101 if( channelList )
5102 vos_mem_free( channelList );
5103
5104 EXIT();
5105
5106 return status;
5107}
5108
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005109
5110void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
5111{
5112 v_U8_t iniDot11Mode =
5113 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
5114 eHddDot11Mode hddDot11Mode = iniDot11Mode;
5115
5116 switch ( iniDot11Mode )
5117 {
5118 case eHDD_DOT11_MODE_AUTO:
5119 case eHDD_DOT11_MODE_11ac:
5120 case eHDD_DOT11_MODE_11ac_ONLY:
5121#ifdef WLAN_FEATURE_11AC
5122 hddDot11Mode = eHDD_DOT11_MODE_11ac;
5123#else
5124 hddDot11Mode = eHDD_DOT11_MODE_11n;
5125#endif
5126 break;
5127 case eHDD_DOT11_MODE_11n:
5128 case eHDD_DOT11_MODE_11n_ONLY:
5129 hddDot11Mode = eHDD_DOT11_MODE_11n;
5130 break;
5131 default:
5132 hddDot11Mode = iniDot11Mode;
5133 break;
5134 }
5135 /* This call decides required channel bonding mode */
5136 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
5137 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
5138 operationChannel);
5139}
5140
Jeff Johnson295189b2012-06-20 16:38:30 -07005141/*
5142 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305143 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -07005144 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305145int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -07005146 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07005147{
5148 int status = 0;
5149 hdd_wext_state_t *pWextState;
5150 v_U32_t roamId;
5151 tCsrRoamProfile *pRoamProfile;
5152 eMib_dot11DesiredBssType connectedBssType;
5153 eCsrAuthType RSNAuthType;
5154
5155 ENTER();
5156
5157 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305158
Jeff Johnson295189b2012-06-20 16:38:30 -07005159 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
5160 {
5161 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
5162 return -EINVAL;
5163 }
5164
5165 pRoamProfile = &pWextState->roamProfile;
5166
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305167 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07005168 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005169 int ret = 0;
5170 hdd_station_ctx_t *pHddStaCtx;
5171 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5172 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
5173
5174 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
5175 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
5176 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
Jeff Johnson295189b2012-06-20 16:38:30 -07005177 {
5178 /* Issue disconnect to CSR */
5179 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305180 if( eHAL_STATUS_SUCCESS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07005181 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
5182 pAdapter->sessionId,
5183 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
5184 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005185 ret = wait_for_completion_interruptible_timeout(
5186 &pAdapter->disconnect_comp_var,
5187 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5188 if (0 == ret)
5189 {
5190 VOS_ASSERT(0);
5191 }
5192 }
5193 }
5194 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
5195 {
5196 ret = wait_for_completion_interruptible_timeout(
5197 &pAdapter->disconnect_comp_var,
5198 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5199 if (0 == ret)
5200 {
5201 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005202 }
5203 }
5204
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305205 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07005206 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
5207 {
5208 /*QoS not enabled in cfg file*/
5209 pRoamProfile->uapsd_mask = 0;
5210 }
5211 else
5212 {
5213 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305214 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -07005215 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
5216 }
5217
5218 pRoamProfile->SSIDs.numOfSSIDs = 1;
5219 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
5220 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305221 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005222 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
5223 ssid, ssid_len);
5224
5225 if (bssid)
5226 {
5227 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
5228 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
5229 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305230 /* Save BSSID in seperate variable as well, as RoamProfile
5231 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -07005232 case of join failure we should send valid BSSID to supplicant
5233 */
5234 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
5235 WNI_CFG_BSSID_LEN);
5236 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07005237 else
5238 {
5239 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
5240 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005241
5242 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
5243 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305244 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005245 /*set gen ie*/
5246 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
5247 /*set auth*/
5248 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5249 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005250#ifdef FEATURE_WLAN_WAPI
5251 if (pAdapter->wapi_info.nWapiMode)
5252 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005253 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005254 switch (pAdapter->wapi_info.wapiAuthMode)
5255 {
5256 case WAPI_AUTH_MODE_PSK:
5257 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005258 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005259 pAdapter->wapi_info.wapiAuthMode);
5260 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5261 break;
5262 }
5263 case WAPI_AUTH_MODE_CERT:
5264 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005265 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005266 pAdapter->wapi_info.wapiAuthMode);
5267 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5268 break;
5269 }
5270 } // End of switch
5271 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5272 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
5273 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005274 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005275 pRoamProfile->AuthType.numEntries = 1;
5276 pRoamProfile->EncryptionType.numEntries = 1;
5277 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5278 pRoamProfile->mcEncryptionType.numEntries = 1;
5279 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5280 }
5281 }
5282#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305283#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305284 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305285 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
5286 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5287 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305288 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
5289 sizeof (tSirGtkOffloadParams));
5290 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305291 }
5292#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005293 pRoamProfile->csrPersona = pAdapter->device_mode;
5294
Jeff Johnson32d95a32012-09-10 13:15:23 -07005295 if( operatingChannel )
5296 {
5297 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
5298 pRoamProfile->ChannelInfo.numOfChannels = 1;
5299 }
Chet Lanctot186b5732013-03-18 10:26:30 -07005300 else
5301 {
5302 pRoamProfile->ChannelInfo.ChannelList = NULL;
5303 pRoamProfile->ChannelInfo.numOfChannels = 0;
5304 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005305 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
5306 {
5307 hdd_select_cbmode(pAdapter,operatingChannel);
5308 }
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005309 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
5310 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305311 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005312 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005313 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
5314 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305315 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5316 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005317 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5318 eConnectionState_Connecting);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305319
5320 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005321 pAdapter->sessionId, pRoamProfile, &roamId);
5322
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305323 if ((eHAL_STATUS_SUCCESS != status) &&
5324 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5325 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305326
5327 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005328 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
5329 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
5330 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305331 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005332 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305333 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005334
5335 pRoamProfile->ChannelInfo.ChannelList = NULL;
5336 pRoamProfile->ChannelInfo.numOfChannels = 0;
5337
Jeff Johnson295189b2012-06-20 16:38:30 -07005338 }
5339 else
5340 {
5341 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
5342 return -EINVAL;
5343 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005344 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005345 return status;
5346}
5347
5348/*
5349 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
5350 * This function is used to set the authentication type (OPEN/SHARED).
5351 *
5352 */
5353static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
5354 enum nl80211_auth_type auth_type)
5355{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305356 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005357 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5358
5359 ENTER();
5360
5361 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305362 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -07005363 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005364 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305365 hddLog(VOS_TRACE_LEVEL_INFO,
5366 "%s: set authentication type to AUTOSWITCH", __func__);
5367 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
5368 break;
5369
5370 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07005371#ifdef WLAN_FEATURE_VOWIFI_11R
5372 case NL80211_AUTHTYPE_FT:
5373#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305374 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005375 "%s: set authentication type to OPEN", __func__);
5376 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5377 break;
5378
5379 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305380 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005381 "%s: set authentication type to SHARED", __func__);
5382 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
5383 break;
5384#ifdef FEATURE_WLAN_CCX
5385 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305386 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005387 "%s: set authentication type to CCKM WPA", __func__);
5388 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
5389 break;
5390#endif
5391
5392
5393 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305394 hddLog(VOS_TRACE_LEVEL_ERROR,
5395 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005396 auth_type);
5397 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
5398 return -EINVAL;
5399 }
5400
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305401 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005402 pHddStaCtx->conn_info.authType;
5403 return 0;
5404}
5405
5406/*
5407 * FUNCTION: wlan_hdd_set_akm_suite
5408 * This function is used to set the key mgmt type(PSK/8021x).
5409 *
5410 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305411static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005412 u32 key_mgmt
5413 )
5414{
5415 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5416 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305417
Jeff Johnson295189b2012-06-20 16:38:30 -07005418 /*set key mgmt type*/
5419 switch(key_mgmt)
5420 {
5421 case WLAN_AKM_SUITE_PSK:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305422#ifdef WLAN_FEATURE_VOWIFI_11R
5423 case WLAN_AKM_SUITE_FT_PSK:
5424#endif
5425 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -07005426 __func__);
5427 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5428 break;
5429
5430 case WLAN_AKM_SUITE_8021X:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305431#ifdef WLAN_FEATURE_VOWIFI_11R
5432 case WLAN_AKM_SUITE_FT_8021X:
5433#endif
5434 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -07005435 __func__);
5436 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5437 break;
5438#ifdef FEATURE_WLAN_CCX
5439#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
5440#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5441 case WLAN_AKM_SUITE_CCKM:
5442 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
5443 __func__);
5444 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
5445 break;
5446#endif
5447
5448 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305449 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005450 __func__, key_mgmt);
5451 return -EINVAL;
5452
5453 }
5454 return 0;
5455}
5456
5457/*
5458 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305459 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -07005460 * (NONE/WEP40/WEP104/TKIP/CCMP).
5461 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305462static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
5463 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -07005464 bool ucast
5465 )
5466{
5467 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305468 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005469 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5470
5471 ENTER();
5472
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305473 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005474 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305475 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -07005476 __func__, cipher);
5477 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5478 }
5479 else
5480 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305481
Jeff Johnson295189b2012-06-20 16:38:30 -07005482 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305483 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005484 {
5485 case IW_AUTH_CIPHER_NONE:
5486 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5487 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305488
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305490 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07005491 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305492
Jeff Johnson295189b2012-06-20 16:38:30 -07005493 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305494 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -07005495 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305496
Jeff Johnson295189b2012-06-20 16:38:30 -07005497 case WLAN_CIPHER_SUITE_TKIP:
5498 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5499 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305500
Jeff Johnson295189b2012-06-20 16:38:30 -07005501 case WLAN_CIPHER_SUITE_CCMP:
5502 encryptionType = eCSR_ENCRYPT_TYPE_AES;
5503 break;
5504#ifdef FEATURE_WLAN_WAPI
5505 case WLAN_CIPHER_SUITE_SMS4:
5506 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
5507 break;
5508#endif
5509
5510#ifdef FEATURE_WLAN_CCX
5511 case WLAN_CIPHER_SUITE_KRK:
5512 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
5513 break;
5514#endif
5515 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305516 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005517 __func__, cipher);
5518 return -EOPNOTSUPP;
5519 }
5520 }
5521
5522 if (ucast)
5523 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305524 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005525 __func__, encryptionType);
5526 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
5527 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305528 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005529 encryptionType;
5530 }
5531 else
5532 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305533 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005534 __func__, encryptionType);
5535 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
5536 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5537 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
5538 }
5539
5540 return 0;
5541}
5542
5543
5544/*
5545 * FUNCTION: wlan_hdd_cfg80211_set_ie
5546 * This function is used to parse WPA/RSN IE's.
5547 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305548int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
5549 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -07005550 size_t ie_len
5551 )
5552{
5553 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5554 u8 *genie = ie;
5555 v_U16_t remLen = ie_len;
5556#ifdef FEATURE_WLAN_WAPI
5557 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
5558 u16 *tmp;
5559 v_U16_t akmsuiteCount;
5560 int *akmlist;
5561#endif
5562 ENTER();
5563
5564 /* clear previous assocAddIE */
5565 pWextState->assocAddIE.length = 0;
5566 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
5567
5568 while (remLen >= 2)
5569 {
5570 v_U16_t eLen = 0;
5571 v_U8_t elementId;
5572 elementId = *genie++;
5573 eLen = *genie++;
5574 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305575
5576 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005577 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305578
5579 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -07005580 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305581 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005582 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 -07005583 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305584 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005585 "%s: Invalid WPA IE", __func__);
5586 return -EINVAL;
5587 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305588 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -07005589 {
5590 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305591 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005592 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305593
Jeff Johnson295189b2012-06-20 16:38:30 -07005594 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5595 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005596 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
5597 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005598 VOS_ASSERT(0);
5599 return -ENOMEM;
5600 }
5601 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5602 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5603 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305604
Jeff Johnson295189b2012-06-20 16:38:30 -07005605 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
5606 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5607 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5608 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305609 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
5610 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005611 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
5612 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5613 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
5614 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
5615 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
5616 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305617 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
5618 P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005619 /*Consider P2P IE, only for P2P Client */
5620 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5621 {
5622 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305623 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005624 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305625
Jeff Johnson295189b2012-06-20 16:38:30 -07005626 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5627 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005628 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5629 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005630 VOS_ASSERT(0);
5631 return -ENOMEM;
5632 }
5633 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5634 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5635 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305636
Jeff Johnson295189b2012-06-20 16:38:30 -07005637 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5638 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5639 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005640#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305641 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
5642 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005643 /*Consider WFD IE, only for P2P Client */
5644 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5645 {
5646 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305647 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005648 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305649
Jeff Johnson295189b2012-06-20 16:38:30 -07005650 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5651 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005652 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5653 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005654 VOS_ASSERT(0);
5655 return -ENOMEM;
5656 }
5657 // WFD IE is saved to Additional IE ; it should be accumulated to handle
5658 // WPS IE + P2P IE + WFD IE
5659 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5660 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305661
Jeff Johnson295189b2012-06-20 16:38:30 -07005662 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5663 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5664 }
5665#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005666 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305667 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005668 HS20_OUI_TYPE_SIZE)) )
5669 {
5670 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305671 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005672 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005673
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005674 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5675 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005676 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5677 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005678 VOS_ASSERT(0);
5679 return -ENOMEM;
5680 }
5681 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5682 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005683
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005684 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5685 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5686 }
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005687
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -07005688 if (WLAN_HDD_IBSS == pAdapter->device_mode) {
5689
5690 /* populating as ADDIE in beacon frames */
5691 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5692 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
5693 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
5694 {
5695 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
5696 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
5697 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5698 {
5699 hddLog(LOGE,
5700 "Coldn't pass "
5701 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
5702 }
5703 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
5704 else
5705 hddLog(LOGE,
5706 "Could not pass on "
5707 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
5708
5709 /* IBSS mode doesn't contain params->proberesp_ies still
5710 beaconIE's need to be populated in probe response frames */
5711 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
5712 {
5713 u16 rem_probe_resp_ie_len = eLen + 2;
5714 u8 probe_rsp_ie_len[3] = {0};
5715 u8 counter = 0;
5716
5717 /* Check Probe Resp Length if it is greater then 255 then
5718 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
5719 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
5720 not able Store More then 255 bytes into One Variable */
5721
5722 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
5723 {
5724 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
5725 {
5726 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
5727 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
5728 }
5729 else
5730 {
5731 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
5732 rem_probe_resp_ie_len = 0;
5733 }
5734 }
5735
5736 rem_probe_resp_ie_len = 0;
5737
5738 if (probe_rsp_ie_len[0] > 0)
5739 {
5740 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5741 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
5742 (tANI_U8*)(genie - 2),
5743 probe_rsp_ie_len[0], NULL,
5744 eANI_BOOLEAN_FALSE)
5745 == eHAL_STATUS_FAILURE)
5746 {
5747 hddLog(LOGE,
5748 "Could not pass"
5749 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
5750 }
5751 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
5752 }
5753
5754 if (probe_rsp_ie_len[1] > 0)
5755 {
5756 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5757 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
5758 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
5759 probe_rsp_ie_len[1], NULL,
5760 eANI_BOOLEAN_FALSE)
5761 == eHAL_STATUS_FAILURE)
5762 {
5763 hddLog(LOGE,
5764 "Could not pass"
5765 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
5766 }
5767 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
5768 }
5769
5770 if (probe_rsp_ie_len[2] > 0)
5771 {
5772 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5773 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
5774 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
5775 probe_rsp_ie_len[2], NULL,
5776 eANI_BOOLEAN_FALSE)
5777 == eHAL_STATUS_FAILURE)
5778 {
5779 hddLog(LOGE,
5780 "Could not pass"
5781 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
5782 }
5783 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
5784 }
5785
5786 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
5787 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
5788 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5789 {
5790 hddLog(LOGE,
5791 "Could not pass"
5792 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
5793 }
5794 }
5795 else
5796 {
5797 // Reset WNI_CFG_PROBE_RSP Flags
5798 wlan_hdd_reset_prob_rspies(pAdapter);
5799
5800 hddLog(VOS_TRACE_LEVEL_INFO,
5801 "%s: No Probe Response IE received in set beacon",
5802 __func__);
5803 }
5804 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -07005805 break;
5806 case DOT11F_EID_RSN:
5807 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
5808 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5809 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
5810 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
5811 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
5812 break;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005813 /* Appending Extended Capabilities with Interworking bit set in Assoc Req */
5814 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305815 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005816 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305817 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005818 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305819
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005820 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5821 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005822 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5823 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005824 VOS_ASSERT(0);
5825 return -ENOMEM;
5826 }
5827 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5828 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305829
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005830 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5831 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5832 break;
5833 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005834#ifdef FEATURE_WLAN_WAPI
5835 case WLAN_EID_WAPI:
5836 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005837 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07005838 pAdapter->wapi_info.nWapiMode);
5839 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305840 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -07005841 akmsuiteCount = WPA_GET_LE16(tmp);
5842 tmp = tmp + 1;
5843 akmlist = (int *)(tmp);
5844 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
5845 {
5846 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
5847 }
5848 else
5849 {
5850 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count\n");
5851 VOS_ASSERT(0);
5852 return -EINVAL;
5853 }
5854
5855 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
5856 {
5857 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005858 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005859 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305860 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005861 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305862 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005863 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005864 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005865 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5866 }
5867 break;
5868#endif
5869 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305870 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005871 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005872 /* when Unknown IE is received we should break and continue
5873 * to the next IE in the buffer instead we were returning
5874 * so changing this to break */
5875 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005876 }
5877 genie += eLen;
5878 remLen -= eLen;
5879 }
5880 EXIT();
5881 return 0;
5882}
5883
5884/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +05305885 * FUNCTION: hdd_isWPAIEPresent
5886 * Parse the received IE to find the WPA IE
5887 *
5888 */
5889static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
5890{
5891 v_U8_t eLen = 0;
5892 v_U16_t remLen = ie_len;
5893 v_U8_t elementId = 0;
5894
5895 while (remLen >= 2)
5896 {
5897 elementId = *ie++;
5898 eLen = *ie++;
5899 remLen -= 2;
5900 if (eLen > remLen)
5901 {
5902 hddLog(VOS_TRACE_LEVEL_ERROR,
5903 "%s: IE length is wrong %d", __func__, eLen);
5904 return FALSE;
5905 }
5906 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
5907 {
5908 /* OUI - 0x00 0X50 0XF2
5909 WPA Information Element - 0x01
5910 WPA version - 0x01*/
5911 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
5912 return TRUE;
5913 }
5914 ie += eLen;
5915 remLen -= eLen;
5916 }
5917 return FALSE;
5918}
5919
5920/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005921 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305922 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005923 * parameters during connect operation.
5924 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305925int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005926 struct cfg80211_connect_params *req
5927 )
5928{
5929 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305930 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005931 ENTER();
5932
5933 /*set wpa version*/
5934 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
5935
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305936 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005937 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +05305938 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005939 {
5940 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
5941 }
5942 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
5943 {
5944 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
5945 }
5946 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305947
5948 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005949 pWextState->wpaVersion);
5950
5951 /*set authentication type*/
5952 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
5953
5954 if (0 > status)
5955 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305956 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005957 "%s: failed to set authentication type ", __func__);
5958 return status;
5959 }
5960
5961 /*set key mgmt type*/
5962 if (req->crypto.n_akm_suites)
5963 {
5964 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
5965 if (0 > status)
5966 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305967 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -07005968 __func__);
5969 return status;
5970 }
5971 }
5972
5973 /*set pairwise cipher type*/
5974 if (req->crypto.n_ciphers_pairwise)
5975 {
5976 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
5977 req->crypto.ciphers_pairwise[0], true);
5978 if (0 > status)
5979 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305980 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005981 "%s: failed to set unicast cipher type", __func__);
5982 return status;
5983 }
5984 }
5985 else
5986 {
5987 /*Reset previous cipher suite to none*/
5988 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
5989 if (0 > status)
5990 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305991 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005992 "%s: failed to set unicast cipher type", __func__);
5993 return status;
5994 }
5995 }
5996
5997 /*set group cipher type*/
5998 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
5999 false);
6000
6001 if (0 > status)
6002 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306003 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -07006004 __func__);
6005 return status;
6006 }
6007
Chet Lanctot186b5732013-03-18 10:26:30 -07006008#ifdef WLAN_FEATURE_11W
6009 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
6010#endif
6011
Jeff Johnson295189b2012-06-20 16:38:30 -07006012 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
6013 if (req->ie_len)
6014 {
6015 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
6016 if ( 0 > status)
6017 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306018 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006019 __func__);
6020 return status;
6021 }
6022 }
6023
6024 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306025 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006026 {
6027 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
6028 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
6029 )
6030 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306031 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -07006032 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
6033 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306034 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07006035 __func__);
6036 return -EOPNOTSUPP;
6037 }
6038 else
6039 {
6040 u8 key_len = req->key_len;
6041 u8 key_idx = req->key_idx;
6042
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306043 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006044 && (CSR_MAX_NUM_KEY > key_idx)
6045 )
6046 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306047 hddLog(VOS_TRACE_LEVEL_INFO,
6048 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006049 __func__, key_idx, key_len);
6050 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306051 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07006052 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306053 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -07006054 (u8)key_len;
6055 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
6056 }
6057 }
6058 }
6059 }
6060
6061 return status;
6062}
6063
6064/*
6065 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306066 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006067 * parameters during connect operation.
6068 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306069static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006070 struct net_device *ndev,
6071 struct cfg80211_connect_params *req
6072 )
6073{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306074 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306075 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006076 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
6077 hdd_context_t *pHddCtx = NULL;
6078
6079 ENTER();
6080
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306081 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006082 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6083
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306084 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6085 status = wlan_hdd_validate_context(pHddCtx);
6086
6087 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006088 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306089 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6090 "%s: HDD context is not valid", __func__);
6091 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006092 }
6093
6094#ifdef WLAN_BTAMP_FEATURE
6095 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306096 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -07006097 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306098 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006099 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08006100 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -07006101 }
6102#endif
6103 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306104 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -07006105
6106 if ( 0 > status)
6107 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306108 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -07006109 __func__);
6110 return status;
6111 }
6112
6113 //If Device Mode is Station Concurrent Sessions Exit BMps
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006114 //P2P Mode will be taken care in Open/close adapter
Jeff Johnson295189b2012-06-20 16:38:30 -07006115 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
6116 (vos_concurrent_sessions_running()))
6117 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306118 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
Jeff Johnson295189b2012-06-20 16:38:30 -07006119 }
6120
Mohit Khanna765234a2012-09-11 15:08:35 -07006121 if ( req->channel )
6122 {
6123 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
6124 req->ssid_len, req->bssid,
6125 req->channel->hw_value);
6126 }
6127 else
6128 {
6129 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306130 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -07006131 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006132
6133 if (0 > status)
6134 {
6135 //ReEnable BMPS if disabled
6136 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
6137 (NULL != pHddCtx))
6138 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306139 if (pHddCtx->hdd_wlan_suspended)
6140 {
6141 hdd_set_pwrparams(pHddCtx);
6142 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006143 //ReEnable Bmps and Imps back
6144 hdd_enable_bmps_imps(pHddCtx);
6145 }
6146
6147 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6148 return status;
6149 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306150 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006151 EXIT();
6152 return status;
6153}
6154
6155
6156/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306157 * FUNCTION: wlan_hdd_disconnect
6158 * This function is used to issue a disconnect request to SME
6159 */
6160int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
6161{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306162 int status;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306163 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306164 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6165
6166 status = wlan_hdd_validate_context(pHddCtx);
6167
6168 if (0 != status)
6169 {
6170 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6171 "%s: HDD context is not valid", __func__);
6172 return status;
6173 }
6174
6175 pHddCtx->isAmpAllowed = VOS_TRUE;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306176 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306177 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306178
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306179 /*issue disconnect*/
6180 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
6181 pAdapter->sessionId, reason);
6182
6183 if ( 0 != status )
6184 {
6185 hddLog(VOS_TRACE_LEVEL_ERROR,
6186 "%s csrRoamDisconnect failure, returned %d \n",
6187 __func__, (int)status );
6188 return -EINVAL;
6189 }
6190 wait_for_completion_interruptible_timeout(
6191 &pAdapter->disconnect_comp_var,
6192 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6193 /*stop tx queues*/
6194 netif_tx_disable(pAdapter->dev);
6195 netif_carrier_off(pAdapter->dev);
6196 return status;
6197}
6198
6199
6200/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006201 * FUNCTION: wlan_hdd_cfg80211_disconnect
6202 * This function is used to issue a disconnect request to SME
6203 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306204static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006205 struct net_device *dev,
6206 u16 reason
6207 )
6208{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306209 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6210 tCsrRoamProfile *pRoamProfile =
Jeff Johnson295189b2012-06-20 16:38:30 -07006211 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306212 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006213 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006214 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306215#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006216 tANI_U8 staIdx;
6217#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306218
Jeff Johnson295189b2012-06-20 16:38:30 -07006219 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306220
6221 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006222 __func__,pAdapter->device_mode);
6223
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306224 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
6225 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006226
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306227 status = wlan_hdd_validate_context(pHddCtx);
6228
6229 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006230 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306231 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6232 "%s: HDD context is not valid", __func__);
6233 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006234 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306235
Jeff Johnson295189b2012-06-20 16:38:30 -07006236 if (NULL != pRoamProfile)
6237 {
6238 /*issue disconnect request to SME, if station is in connected state*/
6239 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated)
6240 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306241 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07006242 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306243 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07006244 switch(reason)
6245 {
6246 case WLAN_REASON_MIC_FAILURE:
6247 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
6248 break;
6249
6250 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
6251 case WLAN_REASON_DISASSOC_AP_BUSY:
6252 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
6253 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
6254 break;
6255
6256 case WLAN_REASON_PREV_AUTH_NOT_VALID:
6257 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
6258 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
6259 break;
6260
6261 case WLAN_REASON_DEAUTH_LEAVING:
6262 default:
6263 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
6264 break;
6265 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306266 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
6267 pScanInfo = &pHddCtx->scan_info;
6268 if (pScanInfo->mScanPending)
6269 {
6270 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
6271 "Aborting Scan");
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306272 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306273 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006274
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006275#ifdef FEATURE_WLAN_TDLS
6276 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006277 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006278 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006279 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
6280 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006281 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006282 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006283 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006284 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006285 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006286 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006287 MAC_ADDR_ARRAY(mac));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006288 sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006289 pAdapter->sessionId,
6290 mac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006291 }
6292 }
6293#endif
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306294 status = wlan_hdd_disconnect(pAdapter, reasonCode);
6295 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -07006296 {
6297 hddLog(VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306298 "%s wlan_hdd_disconnect failure, returned %d \n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006299 __func__, (int)status );
6300 return -EINVAL;
6301 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006302 }
6303 }
6304 else
6305 {
6306 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
6307 }
6308
6309 return status;
6310}
6311
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306312
Jeff Johnson295189b2012-06-20 16:38:30 -07006313/*
6314 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306315 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006316 * settings in IBSS mode.
6317 */
6318static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306319 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006320 struct cfg80211_ibss_params *params
6321 )
6322{
6323 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306324 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006325 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6326 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306327
Jeff Johnson295189b2012-06-20 16:38:30 -07006328 ENTER();
6329
6330 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -07006331 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006332
6333 if (params->ie_len && ( NULL != params->ie) )
6334 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006335 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6336 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006337 {
6338 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
6339 encryptionType = eCSR_ENCRYPT_TYPE_AES;
6340 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006341 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006342 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006343 tDot11fIEWPA dot11WPAIE;
6344 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006345 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006346
Wilson Yang00256342013-10-10 23:13:38 -07006347 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006348 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6349 params->ie_len, DOT11F_EID_WPA);
6350 if ( NULL != ie )
6351 {
6352 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
6353 // Unpack the WPA IE
6354 //Skip past the EID byte and length byte - and four byte WiFi OUI
6355 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
6356 &ie[2+4],
6357 ie[1] - 4,
6358 &dot11WPAIE);
6359 /*Extract the multicast cipher, the encType for unicast
6360 cipher for wpa-none is none*/
6361 encryptionType =
6362 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
6363 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006364 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006365
Jeff Johnson295189b2012-06-20 16:38:30 -07006366 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
6367
6368 if (0 > status)
6369 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306370 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006371 __func__);
6372 return status;
6373 }
6374 }
6375
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306376 pWextState->roamProfile.AuthType.authType[0] =
6377 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -07006378 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6379
6380 if (params->privacy)
6381 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306382 /* Security enabled IBSS, At this time there is no information available
6383 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -07006384 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306385 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -07006386 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306387 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -07006388 *enable privacy bit in beacons */
6389
6390 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6391 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006392 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
6393 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07006394 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
6395 pWextState->roamProfile.EncryptionType.numEntries = 1;
6396 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07006397 return status;
6398}
6399
6400/*
6401 * FUNCTION: wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306402 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006403 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306404static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006405 struct net_device *dev,
6406 struct cfg80211_ibss_params *params
6407 )
6408{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306409 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006410 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6411 tCsrRoamProfile *pRoamProfile;
6412 int status;
6413 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306414 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006415
6416 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306417
6418 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006419 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6420
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306421 status = wlan_hdd_validate_context(pHddCtx);
6422
6423 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006424 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306425 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6426 "%s: HDD context is not valid", __func__);
6427 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006428 }
6429
6430 if (NULL == pWextState)
6431 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306432 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006433 __func__);
6434 return -EIO;
6435 }
6436
6437 pRoamProfile = &pWextState->roamProfile;
6438
6439 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
6440 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306441 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006442 "%s Interface type is not set to IBSS \n", __func__);
6443 return -EINVAL;
6444 }
6445
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -07006446 /* BSSID is provided by upper layers hence no need to AUTO generate */
6447 if (NULL != params->bssid) {
6448 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
6449 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
6450 hddLog (VOS_TRACE_LEVEL_ERROR,
6451 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
6452 return -EIO;
6453 }
6454 }
6455
Jeff Johnson295189b2012-06-20 16:38:30 -07006456 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -07006457 if (NULL !=
6458#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6459 params->chandef.chan)
6460#else
6461 params->channel)
6462#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006463 {
6464 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006465 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6466 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6467 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6468 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006469
6470 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306471 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -07006472 ieee80211_frequency_to_channel(
6473#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6474 params->chandef.chan->center_freq);
6475#else
6476 params->channel->center_freq);
6477#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006478
6479 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6480 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -07006481 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006482 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
6483 __func__);
6484 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -07006485 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006486
6487 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006488 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006489 if (channelNum == validChan[indx])
6490 {
6491 break;
6492 }
6493 }
6494 if (indx >= numChans)
6495 {
6496 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006497 __func__, channelNum);
6498 return -EINVAL;
6499 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006500 /* Set the Operational Channel */
6501 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
6502 channelNum);
6503 pRoamProfile->ChannelInfo.numOfChannels = 1;
6504 pHddStaCtx->conn_info.operationChannel = channelNum;
6505 pRoamProfile->ChannelInfo.ChannelList =
6506 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006507 }
6508
6509 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306510 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -07006511 if (status < 0)
6512 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306513 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -07006514 __func__);
6515 return status;
6516 }
6517
6518 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306519 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006520 params->ssid_len, params->bssid,
6521 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006522
6523 if (0 > status)
6524 {
6525 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6526 return status;
6527 }
6528
6529 return 0;
6530}
6531
6532/*
6533 * FUNCTION: wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306534 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006535 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306536static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006537 struct net_device *dev
6538 )
6539{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306540 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006541 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6542 tCsrRoamProfile *pRoamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306543 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6544 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006545
6546 ENTER();
6547
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306548 status = wlan_hdd_validate_context(pHddCtx);
6549
6550 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006551 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306552 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6553 "%s: HDD context is not valid", __func__);
6554 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006555 }
6556
Jeff Johnson295189b2012-06-20 16:38:30 -07006557 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6558 if (NULL == pWextState)
6559 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306560 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006561 __func__);
6562 return -EIO;
6563 }
6564
6565 pRoamProfile = &pWextState->roamProfile;
6566
6567 /* Issue disconnect only if interface type is set to IBSS */
6568 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
6569 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306570 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -07006571 __func__);
6572 return -EINVAL;
6573 }
6574
6575 /* Issue Disconnect request */
6576 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6577 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
6578 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
6579
6580 return 0;
6581}
6582
6583/*
6584 * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params
6585 * This function is used to set the phy parameters
6586 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
6587 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306588static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006589 u32 changed)
6590{
6591 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6592 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306593 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006594
6595 ENTER();
6596
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306597 status = wlan_hdd_validate_context(pHddCtx);
6598
6599 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006600 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306601 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6602 "%s: HDD context is not valid", __func__);
6603 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006604 }
6605
Jeff Johnson295189b2012-06-20 16:38:30 -07006606 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
6607 {
6608 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
6609 WNI_CFG_RTS_THRESHOLD_STAMAX :
6610 wiphy->rts_threshold;
6611
6612 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306613 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -07006614 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306615 hddLog(VOS_TRACE_LEVEL_ERROR,
6616 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006617 __func__, rts_threshold);
6618 return -EINVAL;
6619 }
6620
6621 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
6622 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306623 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006624 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306625 hddLog(VOS_TRACE_LEVEL_ERROR,
6626 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006627 __func__, rts_threshold);
6628 return -EIO;
6629 }
6630
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306631 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006632 rts_threshold);
6633 }
6634
6635 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
6636 {
6637 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
6638 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
6639 wiphy->frag_threshold;
6640
6641 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306642 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006643 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306644 hddLog(VOS_TRACE_LEVEL_ERROR,
6645 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006646 frag_threshold);
6647 return -EINVAL;
6648 }
6649
6650 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
6651 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306652 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006653 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306654 hddLog(VOS_TRACE_LEVEL_ERROR,
6655 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006656 __func__, frag_threshold);
6657 return -EIO;
6658 }
6659
6660 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
6661 frag_threshold);
6662 }
6663
6664 if ((changed & WIPHY_PARAM_RETRY_SHORT)
6665 || (changed & WIPHY_PARAM_RETRY_LONG))
6666 {
6667 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
6668 wiphy->retry_short :
6669 wiphy->retry_long;
6670
6671 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
6672 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
6673 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306674 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006675 __func__, retry_value);
6676 return -EINVAL;
6677 }
6678
6679 if (changed & WIPHY_PARAM_RETRY_SHORT)
6680 {
6681 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
6682 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306683 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006684 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306685 hddLog(VOS_TRACE_LEVEL_ERROR,
6686 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006687 __func__, retry_value);
6688 return -EIO;
6689 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306690 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006691 __func__, retry_value);
6692 }
6693 else if (changed & WIPHY_PARAM_RETRY_SHORT)
6694 {
6695 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
6696 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306697 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006698 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306699 hddLog(VOS_TRACE_LEVEL_ERROR,
6700 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006701 __func__, retry_value);
6702 return -EIO;
6703 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306704 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006705 __func__, retry_value);
6706 }
6707 }
6708
6709 return 0;
6710}
6711
6712/*
6713 * FUNCTION: wlan_hdd_cfg80211_set_txpower
6714 * This function is used to set the txpower
6715 */
6716static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07006717#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6718 struct wireless_dev *wdev,
6719#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006720#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306721 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006722#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306723 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006724#endif
6725 int dbm)
6726{
6727 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306728 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006729 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6730 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306731 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006732
6733 ENTER();
6734
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306735 status = wlan_hdd_validate_context(pHddCtx);
6736
6737 if (0 != status)
6738 {
6739 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6740 "%s: HDD context is not valid", __func__);
6741 return status;
6742 }
6743
6744 hHal = pHddCtx->hHal;
6745
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306746 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6747 dbm, ccmCfgSetCallback,
6748 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006749 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306750 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006751 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
6752 return -EIO;
6753 }
6754
6755 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
6756 dbm);
6757
6758 switch(type)
6759 {
6760 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
6761 /* Fall through */
6762 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
6763 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
6764 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306765 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
6766 __func__);
6767 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07006768 }
6769 break;
6770 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306771 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07006772 __func__);
6773 return -EOPNOTSUPP;
6774 break;
6775 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306776 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
6777 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006778 return -EIO;
6779 }
6780
6781 return 0;
6782}
6783
6784/*
6785 * FUNCTION: wlan_hdd_cfg80211_get_txpower
6786 * This function is used to read the txpower
6787 */
Yue Maf49ba872013-08-19 12:04:25 -07006788static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
6789#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6790 struct wireless_dev *wdev,
6791#endif
6792 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006793{
6794
6795 hdd_adapter_t *pAdapter;
6796 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306797 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006798
Jeff Johnsone7245742012-09-05 17:12:55 -07006799 ENTER();
6800
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306801 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07006802
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306803 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006804 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306805 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6806 "%s: HDD context is not valid", __func__);
6807 *dbm = 0;
6808 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006809 }
6810
Jeff Johnson295189b2012-06-20 16:38:30 -07006811 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
6812 if (NULL == pAdapter)
6813 {
6814 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
6815 return -ENOENT;
6816 }
6817
6818 wlan_hdd_get_classAstats(pAdapter);
6819 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
6820
Jeff Johnsone7245742012-09-05 17:12:55 -07006821 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006822 return 0;
6823}
6824
6825static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
6826 u8* mac, struct station_info *sinfo)
6827{
6828 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6829 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6830 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
6831 tANI_U8 rate_flags;
6832
6833 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
6834 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07006835
6836 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
6837 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
6838 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
6839 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
6840 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
6841 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
6842 tANI_U16 maxRate = 0;
6843 tANI_U16 myRate;
6844 tANI_U16 currentRate = 0;
6845 tANI_U8 maxSpeedMCS = 0;
6846 tANI_U8 maxMCSIdx = 0;
6847 tANI_U8 rateFlag = 1;
6848 tANI_U8 i, j, rssidx;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07006849 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306850 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006851
Leo Chang6f8870f2013-03-26 18:11:36 -07006852#ifdef WLAN_FEATURE_11AC
6853 tANI_U32 vht_mcs_map;
6854 eDataRate11ACMaxMcs vhtMaxMcs;
6855#endif /* WLAN_FEATURE_11AC */
6856
Jeff Johnsone7245742012-09-05 17:12:55 -07006857 ENTER();
6858
Jeff Johnson295189b2012-06-20 16:38:30 -07006859 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
6860 (0 == ssidlen))
6861 {
6862 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
6863 " Invalid ssidlen, %d", __func__, ssidlen);
6864 /*To keep GUI happy*/
6865 return 0;
6866 }
6867
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306868 status = wlan_hdd_validate_context(pHddCtx);
6869
6870 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006871 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306872 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6873 "%s: HDD context is not valid", __func__);
6874 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006875 }
6876
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07006877 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006878 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
6879
Kiet Lam3b17fc82013-09-27 05:24:08 +05306880 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
6881 sinfo->filled |= STATION_INFO_SIGNAL;
6882
Jeff Johnson295189b2012-06-20 16:38:30 -07006883 //convert to the UI units of 100kbps
6884 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
6885
6886#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -07006887 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 -07006888 sinfo->signal,
6889 pCfg->reportMaxLinkSpeed,
6890 myRate,
6891 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006892 (int) pCfg->linkSpeedRssiMid,
6893 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -07006894 (int) rate_flags,
6895 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07006896#endif //LINKSPEED_DEBUG_ENABLED
6897
6898 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
6899 {
6900 // we do not want to necessarily report the current speed
6901 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
6902 {
6903 // report the max possible speed
6904 rssidx = 0;
6905 }
6906 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
6907 {
6908 // report the max possible speed with RSSI scaling
6909 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
6910 {
6911 // report the max possible speed
6912 rssidx = 0;
6913 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006914 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006915 {
6916 // report middle speed
6917 rssidx = 1;
6918 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006919 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
6920 {
6921 // report middle speed
6922 rssidx = 2;
6923 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006924 else
6925 {
6926 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006927 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07006928 }
6929 }
6930 else
6931 {
6932 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
6933 hddLog(VOS_TRACE_LEVEL_ERROR,
6934 "%s: Invalid value for reportMaxLinkSpeed: %u",
6935 __func__, pCfg->reportMaxLinkSpeed);
6936 rssidx = 0;
6937 }
6938
6939 maxRate = 0;
6940
6941 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306942 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
6943 OperationalRates, &ORLeng))
6944 {
6945 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6946 /*To keep GUI happy*/
6947 return 0;
6948 }
6949
Jeff Johnson295189b2012-06-20 16:38:30 -07006950 for (i = 0; i < ORLeng; i++)
6951 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006952 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006953 {
6954 /* Validate Rate Set */
6955 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
6956 {
6957 currentRate = supported_data_rate[j].supported_rate[rssidx];
6958 break;
6959 }
6960 }
6961 /* Update MAX rate */
6962 maxRate = (currentRate > maxRate)?currentRate:maxRate;
6963 }
6964
6965 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306966 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
6967 ExtendedRates, &ERLeng))
6968 {
6969 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6970 /*To keep GUI happy*/
6971 return 0;
6972 }
6973
Jeff Johnson295189b2012-06-20 16:38:30 -07006974 for (i = 0; i < ERLeng; i++)
6975 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006976 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006977 {
6978 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
6979 {
6980 currentRate = supported_data_rate[j].supported_rate[rssidx];
6981 break;
6982 }
6983 }
6984 /* Update MAX rate */
6985 maxRate = (currentRate > maxRate)?currentRate:maxRate;
6986 }
Kiet Lamb69f8dc2013-11-15 15:34:27 +05306987 /* Get MCS Rate Set --
6988 only if we are connected at MCS rates (or)
6989 if we are always reporting max speed (or)
6990 if we have good rssi */
6991 if (((0 == rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY)) ||
6992 (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed))
Jeff Johnson295189b2012-06-20 16:38:30 -07006993 {
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306994 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
6995 MCSRates, &MCSLeng))
6996 {
6997 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6998 /*To keep GUI happy*/
6999 return 0;
7000 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007001 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -07007002#ifdef WLAN_FEATURE_11AC
7003 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307004 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -07007005 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007006 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307007 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -07007008 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -07007009 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007010 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007011 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007012 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -07007013 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007014 maxMCSIdx = 7;
7015 }
7016 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
7017 {
7018 maxMCSIdx = 8;
7019 }
7020 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
7021 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307022 //VHT20 is supporting 0~8
7023 if (rate_flags & eHAL_TX_RATE_VHT20)
7024 maxMCSIdx = 8;
7025 else
7026 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -07007027 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307028
7029 if (rate_flags & eHAL_TX_RATE_VHT80)
7030 {
7031 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
7032 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
7033 }
7034 else if (rate_flags & eHAL_TX_RATE_VHT40)
7035 {
7036 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
7037 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
7038 }
7039 else if (rate_flags & eHAL_TX_RATE_VHT20)
7040 {
7041 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
7042 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
7043 }
7044
Leo Chang6f8870f2013-03-26 18:11:36 -07007045 maxSpeedMCS = 1;
7046 if (currentRate > maxRate)
7047 {
7048 maxRate = currentRate;
7049 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307050
Leo Chang6f8870f2013-03-26 18:11:36 -07007051 }
7052 else
7053#endif /* WLAN_FEATURE_11AC */
7054 {
7055 if (rate_flags & eHAL_TX_RATE_HT40)
7056 {
7057 rateFlag |= 1;
7058 }
7059 if (rate_flags & eHAL_TX_RATE_SGI)
7060 {
7061 rateFlag |= 2;
7062 }
7063
7064 for (i = 0; i < MCSLeng; i++)
7065 {
7066 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
7067 for (j = 0; j < temp; j++)
7068 {
7069 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
7070 {
7071 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
7072 break;
7073 }
7074 }
7075 if ((j < temp) && (currentRate > maxRate))
7076 {
7077 maxRate = currentRate;
7078 maxSpeedMCS = 1;
7079 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
7080 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007081 }
7082 }
7083 }
7084
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307085 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
7086 {
7087 maxRate = myRate;
7088 maxSpeedMCS = 1;
7089 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
7090 }
7091
Jeff Johnson295189b2012-06-20 16:38:30 -07007092 // make sure we report a value at least as big as our current rate
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007093 if (((maxRate < myRate) && (0 == rssidx)) ||
7094 (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -07007095 {
7096 maxRate = myRate;
7097 if (rate_flags & eHAL_TX_RATE_LEGACY)
7098 {
7099 maxSpeedMCS = 0;
7100 }
7101 else
7102 {
7103 maxSpeedMCS = 1;
7104 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
7105 }
7106 }
7107
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307108 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -07007109 {
7110 sinfo->txrate.legacy = maxRate;
7111#ifdef LINKSPEED_DEBUG_ENABLED
7112 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
7113#endif //LINKSPEED_DEBUG_ENABLED
7114 }
7115 else
7116 {
7117 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -07007118#ifdef WLAN_FEATURE_11AC
7119 sinfo->txrate.nss = 1;
7120 if (rate_flags & eHAL_TX_RATE_VHT80)
7121 {
7122 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307123 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -07007124 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307125 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -07007126 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307127 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7128 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7129 }
7130 else if (rate_flags & eHAL_TX_RATE_VHT20)
7131 {
7132 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7133 }
7134#endif /* WLAN_FEATURE_11AC */
7135 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
7136 {
7137 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7138 if (rate_flags & eHAL_TX_RATE_HT40)
7139 {
7140 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7141 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007142 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007143 if (rate_flags & eHAL_TX_RATE_SGI)
7144 {
7145 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7146 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307147
Jeff Johnson295189b2012-06-20 16:38:30 -07007148#ifdef LINKSPEED_DEBUG_ENABLED
7149 pr_info("Reporting MCS rate %d flags %x\n",
7150 sinfo->txrate.mcs,
7151 sinfo->txrate.flags );
7152#endif //LINKSPEED_DEBUG_ENABLED
7153 }
7154 }
7155 else
7156 {
7157 // report current rate instead of max rate
7158
7159 if (rate_flags & eHAL_TX_RATE_LEGACY)
7160 {
7161 //provide to the UI in units of 100kbps
7162 sinfo->txrate.legacy = myRate;
7163#ifdef LINKSPEED_DEBUG_ENABLED
7164 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
7165#endif //LINKSPEED_DEBUG_ENABLED
7166 }
7167 else
7168 {
7169 //must be MCS
7170 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -07007171#ifdef WLAN_FEATURE_11AC
7172 sinfo->txrate.nss = 1;
7173 if (rate_flags & eHAL_TX_RATE_VHT80)
7174 {
7175 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7176 }
7177 else
7178#endif /* WLAN_FEATURE_11AC */
7179 {
7180 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7181 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007182 if (rate_flags & eHAL_TX_RATE_SGI)
7183 {
7184 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7185 }
7186 if (rate_flags & eHAL_TX_RATE_HT40)
7187 {
7188 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7189 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007190#ifdef WLAN_FEATURE_11AC
7191 else if (rate_flags & eHAL_TX_RATE_VHT80)
7192 {
7193 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
7194 }
7195#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -07007196#ifdef LINKSPEED_DEBUG_ENABLED
7197 pr_info("Reporting actual MCS rate %d flags %x\n",
7198 sinfo->txrate.mcs,
7199 sinfo->txrate.flags );
7200#endif //LINKSPEED_DEBUG_ENABLED
7201 }
7202 }
7203 sinfo->filled |= STATION_INFO_TX_BITRATE;
7204
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07007205 sinfo->tx_packets =
7206 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
7207 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
7208 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
7209 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
7210
7211 sinfo->tx_retries =
7212 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
7213 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
7214 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
7215 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
7216
7217 sinfo->tx_failed =
7218 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
7219 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
7220 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
7221 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
7222
7223 sinfo->filled |=
7224 STATION_INFO_TX_PACKETS |
7225 STATION_INFO_TX_RETRIES |
7226 STATION_INFO_TX_FAILED;
7227
7228 EXIT();
7229 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007230}
7231
7232static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -07007233 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -07007234{
7235 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307236 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007237 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307238 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007239
Jeff Johnsone7245742012-09-05 17:12:55 -07007240 ENTER();
7241
Jeff Johnson295189b2012-06-20 16:38:30 -07007242 if (NULL == pAdapter)
7243 {
7244 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
7245 return -ENODEV;
7246 }
7247
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307248 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307249 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307250
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307251 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307252 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307253 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7254 "%s: HDD context is not valid", __func__);
7255 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307256 }
7257
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307258 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
7259 (TRUE == pHddCtx->hdd_wlan_suspended) &&
7260 (pHddCtx->cfg_ini->fhostArpOffload) &&
7261 (eConnectionState_Associated ==
7262 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
7263 {
Amar Singhald53568e2013-09-26 11:03:45 -07007264
7265 hddLog(VOS_TRACE_LEVEL_INFO,
7266 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307267 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307268 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7269 {
7270 hddLog(VOS_TRACE_LEVEL_INFO,
7271 "%s:Failed to enable ARPOFFLOAD Feature %d\n",
7272 __func__, vos_status);
7273 }
7274 }
7275
Jeff Johnson295189b2012-06-20 16:38:30 -07007276 /**The get power cmd from the supplicant gets updated by the nl only
7277 *on successful execution of the function call
7278 *we are oppositely mapped w.r.t mode in the driver
7279 **/
7280 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
7281
Jeff Johnsone7245742012-09-05 17:12:55 -07007282 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007283 if (VOS_STATUS_E_FAILURE == vos_status)
7284 {
7285 return -EINVAL;
7286 }
7287 return 0;
7288}
7289
7290
7291#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7292static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
7293 struct net_device *netdev,
7294 u8 key_index)
7295{
Jeff Johnsone7245742012-09-05 17:12:55 -07007296 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007297 return 0;
7298}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307299#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -07007300
7301#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7302static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7303 struct net_device *dev,
7304 struct ieee80211_txq_params *params)
7305{
Jeff Johnsone7245742012-09-05 17:12:55 -07007306 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007307 return 0;
7308}
7309#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7310static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7311 struct ieee80211_txq_params *params)
7312{
Jeff Johnsone7245742012-09-05 17:12:55 -07007313 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007314 return 0;
7315}
7316#endif //LINUX_VERSION_CODE
7317
7318static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
7319 struct net_device *dev, u8 *mac)
7320{
7321 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307322 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007323 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307324 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007325 v_U8_t staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007326
Jeff Johnsone7245742012-09-05 17:12:55 -07007327 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307328 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -07007329 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307330 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007331 return -EINVAL;
7332 }
7333
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307334 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7335 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007336
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307337 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007338 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307339 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7340 "%s: HDD context is not valid", __func__);
7341 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007342 }
7343
Jeff Johnson295189b2012-06-20 16:38:30 -07007344 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007345 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007346 )
7347 {
7348 if( NULL == mac )
7349 {
7350 v_U16_t i;
7351 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
7352 {
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007353 if ((pAdapter->aStaInfo[i].isUsed) &&
7354 (!pAdapter->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -07007355 {
7356 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
7357 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007358 "%s: Delete STA with MAC::"
7359 MAC_ADDRESS_STR,
7360 __func__, MAC_ADDR_ARRAY(macAddr));
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007361 vos_status = hdd_softap_sta_deauth(pAdapter, macAddr);
7362 if (VOS_IS_STATUS_SUCCESS(vos_status))
7363 pAdapter->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007364 }
7365 }
7366 }
7367 else
7368 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007369
7370 vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId);
7371 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7372 {
7373 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007374 "%s: Skip this DEL STA as this is not used::"
7375 MAC_ADDRESS_STR,
7376 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007377 return -ENOENT;
7378 }
7379
7380 if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE)
7381 {
7382 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007383 "%s: Skip this DEL STA as deauth is in progress::"
7384 MAC_ADDRESS_STR,
7385 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007386 return -ENOENT;
7387 }
7388
7389 pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE;
7390
Jeff Johnson295189b2012-06-20 16:38:30 -07007391 hddLog(VOS_TRACE_LEVEL_INFO,
7392 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -08007393 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007394 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -08007395 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007396
7397 vos_status = hdd_softap_sta_deauth(pAdapter, mac);
7398 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7399 {
7400 pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE;
7401 hddLog(VOS_TRACE_LEVEL_INFO,
7402 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -08007403 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007404 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -08007405 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007406 return -ENOENT;
7407 }
7408
Jeff Johnson295189b2012-06-20 16:38:30 -07007409 }
7410 }
7411
7412 EXIT();
7413
7414 return 0;
7415}
7416
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007417static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
7418 struct net_device *dev, u8 *mac, struct station_parameters *params)
7419{
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007420 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007421#ifdef FEATURE_WLAN_TDLS
7422 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007423 ENTER();
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007424 mask = params->sta_flags_mask;
7425
7426 set = params->sta_flags_set;
7427
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007428#ifdef WLAN_FEATURE_TDLS_DEBUG
7429 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7430 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
7431 __func__, mask, set, MAC_ADDR_ARRAY(mac));
7432#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007433
7434 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
7435 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007436 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007437 }
7438 }
7439#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007440 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007441}
7442
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007443
7444#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -07007445#define MAX_PMKSAIDS_IN_CACHE 8
7446
7447static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD local cache
7448static tANI_U32 PMKIDCacheIndex; // HDD local Cache index
7449
7450
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007451static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07007452 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007453{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307454 tANI_U32 j=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007455 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7456 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307457 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307458 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007459 tANI_U8 BSSIDMatched = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307460 hdd_context_t *pHddCtx;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307461
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007462 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
7463 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07007464
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307465 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307466 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007467 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307468 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007469 return -EINVAL;
7470 }
7471
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307472 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7473 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007474
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307475 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007476 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307477 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7478 "%s: HDD context is not valid", __func__);
7479 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007480 }
7481
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307482 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007483 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7484
Wilson Yang6507c4e2013-10-01 20:11:19 -07007485 for (j = 0; j < PMKIDCacheIndex; j++)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007486 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307487 if(vos_mem_compare(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007488 pmksa->bssid, WNI_CFG_BSSID_LEN))
7489 {
7490 /* BSSID matched previous entry. Overwrite it. */
7491 BSSIDMatched = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307492 vos_mem_copy(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007493 pmksa->bssid, WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307494 vos_mem_copy(PMKIDCache[j].PMKID,
7495 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007496 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307497 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007498 __func__, j );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007499 dump_bssid(pmksa->bssid);
7500 dump_pmkid(halHandle, pmksa->pmkid);
7501 break;
7502 }
7503 }
7504
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007505 /* Check we compared all entries,if then take the first slot now */
Wilson Yang6507c4e2013-10-01 20:11:19 -07007506 if(j == MAX_PMKSAIDS_IN_CACHE) PMKIDCacheIndex=0;
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007507
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007508 if (!BSSIDMatched)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307509 {
7510 // Now, we DON'T have a BSSID match, so take a new entry in the cache.
Wilson Yang6507c4e2013-10-01 20:11:19 -07007511 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].BSSID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307512 pmksa->bssid, ETHER_ADDR_LEN);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007513 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].PMKID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307514 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007515 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307516 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Adding a new cache entry %d.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07007517 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007518 dump_bssid(pmksa->bssid);
7519 dump_pmkid(halHandle, pmksa->pmkid);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307520 // Increment the HDD Local Cache index
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007521 // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME
Wilson Yang6507c4e2013-10-01 20:11:19 -07007522 if (PMKIDCacheIndex <= (MAX_PMKSAIDS_IN_CACHE-1)) PMKIDCacheIndex++; else PMKIDCacheIndex = 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007523 }
7524
7525
7526 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307527 //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007528 // __func__, i );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307529 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07007530 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007531 // Finally set the PMKSA ID Cache in CSR
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307532 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
7533 PMKIDCache,
Wilson Yang6507c4e2013-10-01 20:11:19 -07007534 PMKIDCacheIndex);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007535 return 0;
7536}
7537
7538
Wilson Yang6507c4e2013-10-01 20:11:19 -07007539
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007540static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -07007541 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007542{
Wilson Yang6507c4e2013-10-01 20:11:19 -07007543 tANI_U32 j=0;
7544 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7545 tHalHandle halHandle;
7546 int status;
7547 tANI_U8 BSSIDMatched = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07007548 hdd_context_t *pHddCtx;
7549 int result = 0;
7550
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007551 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
7552 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -07007553
7554 /* Validate pAdapter */
7555 if (NULL == pAdapter)
7556 {
7557 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
7558 return -EINVAL;
7559 }
7560
7561 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7562 status = wlan_hdd_validate_context(pHddCtx);
7563
7564 if (0 != status)
7565 {
7566 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7567 "%s: HDD context is not valid", __func__);
7568 return status;
7569 }
7570
7571 /*Retrieve halHandle*/
7572 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7573
7574 /*in case index is 0,no entry to delete*/
7575 if (0 == PMKIDCacheIndex)
7576 {
7577 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" ,
7578 __func__);
7579 return -EINVAL;
7580 }
7581
7582 /*find the matching PMKSA entry from j=0 to (index-1),
7583 * and delete the matched one
7584 */
7585 for (j = 0; j<PMKIDCacheIndex; j++)
7586 {
7587 if (vos_mem_compare(PMKIDCache[j].BSSID,
7588 pmksa->bssid,
7589 WNI_CFG_BSSID_LEN))
7590 {
7591 /* BSSID matched entry */
7592 BSSIDMatched = 1;
7593
7594 if (j<PMKIDCacheIndex-1)
7595 {
7596 /*replace the matching entry with the last entry in HDD local cache*/
7597 vos_mem_copy(PMKIDCache[j].BSSID,
7598 PMKIDCache[PMKIDCacheIndex-1].BSSID,
7599 WNI_CFG_BSSID_LEN);
7600 vos_mem_copy(PMKIDCache[j].PMKID,
7601 PMKIDCache[PMKIDCacheIndex-1].PMKID,
7602 CSR_RSN_PMKID_SIZE);
7603 }
7604
7605 /*clear the last entry in HDD cache ---[index-1]*/
Wilson Yang6507c4e2013-10-01 20:11:19 -07007606 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].BSSID, WNI_CFG_BSSID_LEN);
7607 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].PMKID, CSR_RSN_PMKID_SIZE);
7608
7609 /*reduce the PMKID array index*/
7610 PMKIDCacheIndex--;
7611
7612 /*delete the last PMKID cache in CSR*/
Kiet Lam8d21d5b2013-10-31 17:18:29 +05307613 result = sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pmksa->bssid);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007614 if (0 != result)
7615 {
7616 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cannot delete PMKSA %d CONTENT.",
7617 __func__,PMKIDCacheIndex);
7618 }
7619
7620 dump_bssid(pmksa->bssid);
7621 dump_pmkid(halHandle,pmksa->pmkid);
7622
7623 break;
7624 }
7625 }
7626
7627 /* we compare all entries,but cannot find matching entry */
7628 if (j == MAX_PMKSAIDS_IN_CACHE && !BSSIDMatched)
7629 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007630 hddLog(VOS_TRACE_LEVEL_FATAL,
7631 "%s: No such PMKSA entry existed " MAC_ADDRESS_STR,
7632 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -07007633 dump_bssid(pmksa->bssid);
7634 dump_pmkid(halHandle, pmksa->pmkid);
7635 return -EINVAL;
7636 }
7637 return result;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007638}
7639
Wilson Yang6507c4e2013-10-01 20:11:19 -07007640
7641
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007642static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
7643{
Wilson Yang6507c4e2013-10-01 20:11:19 -07007644 tANI_U32 j=0;
7645 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7646 tHalHandle halHandle;
7647 hdd_context_t *pHddCtx;
7648 tANI_U8 *pBSSId;
7649 int status;
7650 int result;
7651
7652 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__);
7653
7654 /* Validate pAdapter */
7655 if (NULL == pAdapter)
7656 {
7657 hddLog(VOS_TRACE_LEVEL_ERROR,
7658 "%s: Invalid Adapter" ,__func__);
7659 return -EINVAL;
7660 }
7661
7662 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7663 status = wlan_hdd_validate_context(pHddCtx);
7664
7665 if (0 != status)
7666 {
7667 hddLog(VOS_TRACE_LEVEL_ERROR,
7668 "%s: HDD context is not valid", __func__);
7669 return status;
7670 }
7671
7672 /*Retrieve halHandle*/
7673 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7674
7675 /*in case index is 0,no entry to delete*/
7676 if (0 == PMKIDCacheIndex)
7677 {
7678 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" ,
7679 __func__);
7680 return -EINVAL;
7681 }
7682
7683 /*delete all the PMKSA one by one */
7684 for (j = 0; j<PMKIDCacheIndex; j++)
7685 {
Wilson Yang6507c4e2013-10-01 20:11:19 -07007686 pBSSId =(tANI_U8 *)(PMKIDCache[j].BSSID);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007687
7688 /*delete the PMKID in CSR*/
7689 result = sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId);
7690
7691 if (0!= result)
7692 {
7693 hddLog(VOS_TRACE_LEVEL_ERROR ,"%s cannot flush PMKIDCache %d.",
7694 __func__,j);
7695 }
Kiet Lam8d21d5b2013-10-31 17:18:29 +05307696 /*clear the entry in HDD cache 0--index-1 */
7697 vos_mem_zero(PMKIDCache[j].BSSID, WNI_CFG_BSSID_LEN);
7698 vos_mem_zero(PMKIDCache[j].PMKID, CSR_RSN_PMKID_SIZE);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007699 }
7700
7701 PMKIDCacheIndex = 0;
7702 return result;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007703}
7704#endif
7705
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007706#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307707static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007708 struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie)
7709{
7710 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7711 hdd_station_ctx_t *pHddStaCtx;
7712
7713 if (NULL == pAdapter)
7714 {
7715 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
7716 return -ENODEV;
7717 }
7718
7719 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7720
7721 // Added for debug on reception of Re-assoc Req.
7722 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7723 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307724 hddLog(LOGE, FL("Called with Ie of length = %d when not associated\n"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007725 ftie->ie_len);
7726 hddLog(LOGE, FL("Should be Re-assoc Req IEs\n"));
7727 }
7728
7729#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307730 hddLog(LOGE, FL("%s called with Ie of length = %d\n"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007731 ftie->ie_len);
7732#endif
7733
7734 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +05307735 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
7736 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007737 ftie->ie_len);
7738 return 0;
7739}
7740#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007741
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307742#ifdef FEATURE_WLAN_SCAN_PNO
7743
7744void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
7745 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
7746{
7747 int ret;
7748 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
7749 hdd_context_t *pHddCtx;
7750
7751 if (NULL == pAdapter)
7752 {
7753 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7754 "%s: HDD adapter is Null", __func__);
7755 return ;
7756 }
7757
7758 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7759 if (NULL == pHddCtx)
7760 {
7761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7762 "%s: HDD context is Null!!!", __func__);
7763 return ;
7764 }
7765
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307766 spin_lock(&pHddCtx->schedScan_lock);
7767 if (TRUE == pHddCtx->isWiphySuspended)
7768 {
7769 pHddCtx->isSchedScanUpdatePending = TRUE;
7770 spin_unlock(&pHddCtx->schedScan_lock);
7771 hddLog(VOS_TRACE_LEVEL_INFO,
7772 "%s: Update cfg80211 scan database after it resume", __func__);
7773 return ;
7774 }
7775 spin_unlock(&pHddCtx->schedScan_lock);
7776
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307777 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
7778
7779 if (0 > ret)
7780 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
7781
7782 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307783 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7784 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307785}
7786
7787/*
7788 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
7789 * NL interface to enable PNO
7790 */
7791static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
7792 struct net_device *dev, struct cfg80211_sched_scan_request *request)
7793{
7794 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7795 tpSirPNOScanReq pPnoRequest = NULL;
7796 hdd_context_t *pHddCtx;
7797 tHalHandle hHal;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05307798 v_U32_t i, indx, num_ch, tempInterval;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307799 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7800 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7801 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
7802 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307803 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307804
7805 if (NULL == pAdapter)
7806 {
7807 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7808 "%s: HDD adapter is Null", __func__);
7809 return -ENODEV;
7810 }
7811
7812 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307813 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307814
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307815 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307816 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307817 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7818 "%s: HDD context is not valid", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307819 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307820 }
7821
7822 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7823 if (NULL == hHal)
7824 {
7825 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7826 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307827 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307828 }
7829
7830 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
7831 if (NULL == pPnoRequest)
7832 {
7833 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7834 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307835 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307836 }
7837
Madan Mohan Koyyalamudic3f04352013-09-26 19:21:48 +05307838 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307839 pPnoRequest->enable = 1; /*Enable PNO */
7840 pPnoRequest->ucNetworksCount = request->n_match_sets;
7841
7842 if (( !pPnoRequest->ucNetworksCount ) ||
7843 ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
7844 {
7845 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7846 "Network input is not correct");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307847 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307848 goto error;
7849 }
7850
7851 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
7852 {
7853 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7854 "Incorrect number of channels");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307855 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307856 goto error;
7857 }
7858
7859 /* Framework provides one set of channels(all)
7860 * common for all saved profile */
7861 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
7862 channels_allowed, &num_channels_allowed))
7863 {
7864 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7865 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307866 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307867 goto error;
7868 }
7869 /* Checking each channel against allowed channel list */
7870 num_ch = 0;
7871 for (i = 0; i < request->n_channels; i++)
7872 {
7873 for (indx = 0; indx < num_channels_allowed; indx++)
7874 {
7875 if (request->channels[i]->hw_value == channels_allowed[indx])
7876 {
7877 valid_ch[num_ch++] = request->channels[i]->hw_value;
7878 break ;
7879 }
7880 }
7881 }
7882
7883 /* Filling per profile params */
7884 for (i = 0; i < pPnoRequest->ucNetworksCount; i++)
7885 {
7886 pPnoRequest->aNetworks[i].ssId.length =
7887 request->match_sets[i].ssid.ssid_len;
7888
7889 if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) ||
7890 ( pPnoRequest->aNetworks[i].ssId.length > 32 ) )
7891 {
7892 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7893 "SSID Len %d is not correct for network %d",
7894 pPnoRequest->aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307895 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307896 goto error;
7897 }
7898
7899 memcpy(pPnoRequest->aNetworks[i].ssId.ssId,
7900 request->match_sets[i].ssid.ssid,
7901 request->match_sets[i].ssid.ssid_len);
7902 pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
7903 pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/
7904 pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
7905
7906 /*Copying list of valid channel into request */
7907 memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch);
7908 pPnoRequest->aNetworks[i].ucChannelCount = num_ch;
7909
7910 pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value
7911 }
7912
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +05307913 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7914 "request->ie_len = %d", request->ie_len);
7915 if ((0 < request->ie_len) && (NULL != request->ie))
7916 {
7917 pPnoRequest->us24GProbeTemplateLen = request->ie_len;
7918 memcpy(&pPnoRequest->p24GProbeTemplate, request->ie,
7919 pPnoRequest->us24GProbeTemplateLen);
7920
7921 pPnoRequest->us5GProbeTemplateLen = request->ie_len;
7922 memcpy(&pPnoRequest->p5GProbeTemplate, request->ie,
7923 pPnoRequest->us5GProbeTemplateLen);
7924 }
7925
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05307926 /* Driver gets only one time interval which is hardcoded in
7927 * supplicant for 10000ms. Taking power consumption into account 6 timers
7928 * will be used, Timervalue is increased exponentially i.e 10,20,40,
7929 * 80,160,320 secs. And number of scan cycle for each timer
7930 * is configurable through INI param gPNOScanTimerRepeatValue.
7931 * If it is set to 0 only one timer will be used and PNO scan cycle
7932 * will be repeated after each interval specified by supplicant
7933 * till PNO is disabled.
7934 */
7935 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
7936 pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
7937 else
7938 pPnoRequest->scanTimers.ucScanTimersCount =
7939 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
7940
7941 tempInterval = (request->interval)/1000;
7942 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7943 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
7944 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
7945 for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++)
7946 {
7947 pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat =
7948 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
7949 pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval;
7950 tempInterval *= 2;
7951 }
7952 //Repeat last timer until pno disabled.
7953 pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
7954
Madan Mohan Koyyalamudid206c7b2013-09-26 22:54:51 +05307955 pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307956
7957 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
7958 pPnoRequest, pAdapter->sessionId,
7959 hdd_cfg80211_sched_scan_done_callback, pAdapter);
7960 if (eHAL_STATUS_SUCCESS != status)
7961 {
7962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7963 "Failed to enable PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307964 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307965 goto error;
7966 }
7967
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307968 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7969 "PNO scanRequest offloaded");
7970
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307971error:
7972 vos_mem_free(pPnoRequest);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307973 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307974}
7975
7976/*
7977 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
7978 * NL interface to disable PNO
7979 */
7980static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
7981 struct net_device *dev)
7982{
7983 eHalStatus status = eHAL_STATUS_FAILURE;
7984 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7985 hdd_context_t *pHddCtx;
7986 tHalHandle hHal;
7987 tpSirPNOScanReq pPnoRequest = NULL;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307988 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307989
7990 ENTER();
7991
7992 if (NULL == pAdapter)
7993 {
7994 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7995 "%s: HDD adapter is Null", __func__);
7996 return -ENODEV;
7997 }
7998
7999 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308000
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308001 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308002 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308003 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308004 "%s: HDD context is Null", __func__);
8005 return -ENODEV;
8006 }
8007
8008 /* The return 0 is intentional when isLogpInProgress and
8009 * isLoadUnloadInProgress. We did observe a crash due to a return of
8010 * failure in sched_scan_stop , especially for a case where the unload
8011 * of the happens at the same time. The function __cfg80211_stop_sched_scan
8012 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
8013 * success. If it returns a failure , then its next invocation due to the
8014 * clean up of the second interface will have the dev pointer corresponding
8015 * to the first one leading to a crash.
8016 */
8017 if (pHddCtx->isLogpInProgress)
8018 {
8019 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8020 "%s: LOGP in Progress. Ignore!!!", __func__);
8021 return ret;
8022 }
8023
8024 if (pHddCtx->isLoadUnloadInProgress)
8025 {
8026 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8027 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
8028 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308029 }
8030
8031 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8032 if (NULL == hHal)
8033 {
8034 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8035 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308036 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308037 }
8038
8039 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
8040 if (NULL == pPnoRequest)
8041 {
8042 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8043 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308044 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308045 }
8046
8047 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
8048 pPnoRequest->enable = 0; /* Disable PNO */
8049 pPnoRequest->ucNetworksCount = 0;
8050
8051 status = sme_SetPreferredNetworkList(hHal, pPnoRequest,
8052 pAdapter->sessionId,
8053 NULL, pAdapter);
8054 if (eHAL_STATUS_SUCCESS != status)
8055 {
8056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8057 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308058 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308059 }
8060
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308061 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8062 "%s: PNO scan disabled", __func__);
8063
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308064 vos_mem_free(pPnoRequest);
8065
8066 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308067 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308068}
8069
8070#endif /*FEATURE_WLAN_SCAN_PNO*/
8071
8072
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008073#ifdef FEATURE_WLAN_TDLS
8074static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
8075 u8 *peer, u8 action_code, u8 dialog_token,
8076 u16 status_code, const u8 *buf, size_t len)
8077{
8078
8079 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8080 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008081 u8 peerMac[6];
8082 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008083 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -08008084 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -07008085 long rc;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008086
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008087 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008088 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308089 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008090 "Invalid arguments");
8091 return -EINVAL;
8092 }
8093
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008094 if (pHddCtx->isLogpInProgress)
8095 {
8096 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8097 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008098 wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008099 return -EBUSY;
8100 }
8101
Hoonki Lee27511902013-03-14 18:19:06 -07008102 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008103 {
Hoonki Lee27511902013-03-14 18:19:06 -07008104 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8105 "%s: TDLS mode is disabled OR not enabled in FW."
8106 MAC_ADDRESS_STR " action %d declined.",
8107 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008108 return -ENOTSUPP;
8109 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008110
Hoonki Lee27511902013-03-14 18:19:06 -07008111 /* other than teardown frame, other mgmt frames are not sent if disabled */
8112 if (SIR_MAC_TDLS_TEARDOWN != action_code)
8113 {
8114 /* if tdls_mode is disabled to respond to peer's request */
8115 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
8116 {
8117 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8118 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008119 " TDLS mode is disabled. action %d declined.",
8120 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -07008121
8122 return -ENOTSUPP;
8123 }
8124 }
8125
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008126 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
8127 {
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308128 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008129 {
8130 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008131 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008132 " TDLS setup is ongoing. action %d declined.",
8133 __func__, MAC_ADDR_ARRAY(peer), action_code);
8134 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008135 }
8136 }
8137
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008138 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
8139 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -08008140 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008141 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
Lee Hoonkic1262f22013-01-24 21:59:00 -08008142 {
8143 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
8144 we return error code at 'add_station()'. Hence we have this
8145 check again in addtion to add_station().
8146 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008147 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -08008148 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008149 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8150 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008151 " TDLS Max peer already connected. action %d declined.",
8152 __func__, MAC_ADDR_ARRAY(peer), action_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008153 goto error;
Lee Hoonkic1262f22013-01-24 21:59:00 -08008154 }
8155 else
8156 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008157 /* maximum reached. tweak to send error code to peer and return
8158 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -08008159 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008160 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8161 "%s: " MAC_ADDRESS_STR
8162 " TDLS Max peer already connected send response status %d",
8163 __func__, MAC_ADDR_ARRAY(peer), status_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008164 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008165 /* fall through to send setup resp with failure status
8166 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -08008167 }
8168 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008169 else
8170 {
8171 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308172 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008173 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008174 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008175 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008176 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
8177 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008178 return -EPERM;
8179 }
8180 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008181 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008182 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008183
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008184#ifdef WLAN_FEATURE_TDLS_DEBUG
8185 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008186 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d",
8187 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
8188 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008189#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008190
Hoonki Leea34dd892013-02-05 22:56:02 -08008191 /*Except teardown responder will not be used so just make 0*/
8192 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008193 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -08008194 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008195
8196 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308197 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008198
8199 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
8200 responder = pTdlsPeer->is_responder;
8201 else
Hoonki Leea34dd892013-02-05 22:56:02 -08008202 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008203 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8204 "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d",
8205 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
8206 dialog_token, status_code, len);
8207 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -08008208 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008209 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008210
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308211 /* For explicit trigger of DIS_REQ come out of BMPS for
8212 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -07008213 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308214 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
8215 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -07008216 {
8217 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
8218 {
8219 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308220 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Hoonki Lee14621352013-04-16 17:51:19 -07008221 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
8222 }
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308223 if (SIR_MAC_TDLS_DIS_REQ != action_code)
8224 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
Hoonki Lee14621352013-04-16 17:51:19 -07008225 }
8226
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008227 /* make sure doesn't call send_mgmt() while it is pending */
8228 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
8229 {
8230 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8231 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY\n",
8232 __func__, MAC_ADDR_ARRAY(peer), action_code);
8233 return -EBUSY;
8234 }
8235
8236 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008237 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
8238
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008239 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Hoonki Leea34dd892013-02-05 22:56:02 -08008240 peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008241
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008242 if (VOS_STATUS_SUCCESS != status)
8243 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008244 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8245 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008246 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -07008247 wlan_hdd_tdls_check_bmps(pAdapter);
8248 goto error;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008249 }
8250
Hoonki Leed37cbb32013-04-20 00:31:14 -07008251 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
8252 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
8253
8254 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008255 {
Hoonki Leed37cbb32013-04-20 00:31:14 -07008256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008257 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -07008258 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008259 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Leed37cbb32013-04-20 00:31:14 -07008260 wlan_hdd_tdls_check_bmps(pAdapter);
8261 goto error;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008262 }
8263
Gopichand Nakkala05922802013-03-14 12:23:19 -07008264 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -07008265 {
8266 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008267 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -07008268 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008269
Hoonki Leea34dd892013-02-05 22:56:02 -08008270 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
8271 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008272 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -08008273 }
8274 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
8275 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008276 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -08008277 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008278
8279 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008280error:
8281 /* max_sta_failed ; we didn't set to CONNECTING for this case,
8282 because we already know that this transaction will be failed,
8283 but we weren't sure if supplicant call DISABLE_LINK or not. So,
8284 to be safe, do not change the state mahine.
8285 */
8286 if(max_sta_failed == 0 &&
8287 (WLAN_IS_TDLS_SETUP_ACTION(action_code)))
8288 wlan_hdd_tdls_set_link_status(pAdapter, peerMac, eTDLS_LINK_IDLE);
8289 return -EPERM;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008290}
8291
8292static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
8293 u8 *peer, enum nl80211_tdls_operation oper)
8294{
8295 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8296 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308297 int status;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008298#ifdef WLAN_FEATURE_TDLS_DEBUG
8299 const char *tdls_oper_str[]= {
8300 "NL80211_TDLS_DISCOVERY_REQ",
8301 "NL80211_TDLS_SETUP",
8302 "NL80211_TDLS_TEARDOWN",
8303 "NL80211_TDLS_ENABLE_LINK",
8304 "NL80211_TDLS_DISABLE_LINK",
Gopichand Nakkala29d00192013-06-20 19:03:52 +05308305 "NL80211_TDLS_UNKNOWN_OPER"};
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008306#endif
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008307 hddTdlsPeer_t *pTdlsPeer;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008308
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308309 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008310 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008311 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07008312 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008313 return -EINVAL;
8314 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008315
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308316 status = wlan_hdd_validate_context(pHddCtx);
8317
8318 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008319 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308320 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8321 "%s: HDD context is not valid", __func__);
8322 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008323 }
8324
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308325 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008326
8327 if ( NULL == pTdlsPeer ) {
8328 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR " (oper %d) not exsting. ignored",
8329 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
8330 return -EINVAL;
8331 }
8332
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008333#ifdef WLAN_FEATURE_TDLS_DEBUG
8334 if((int)oper > 4)
8335 oper = 5;
8336
8337 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008338 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
8339 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008340 tdls_oper_str[(int)oper]);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008341#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008342
8343 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008344 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008345 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008346 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07008347 "TDLS Disabled in INI OR not enabled in FW. "
8348 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008349 return -ENOTSUPP;
8350 }
8351
8352 switch (oper) {
8353 case NL80211_TDLS_ENABLE_LINK:
8354 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008355 VOS_STATUS status;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308356 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008357
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -07008358 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
8359 {
8360 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
8361 MAC_ADDRESS_STR " failed",
8362 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
8363 return -EINVAL;
8364 }
8365
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008366 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008367 {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05308368 long ret;
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308369 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05308370
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308371 if (0 != wlan_hdd_tdls_get_link_establish_params(
8372 pAdapter, peer,&tdlsLinkEstablishParams)) {
8373 return -EINVAL;
8374 }
8375 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308376
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308377 sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter),
8378 pAdapter->sessionId, peer, &tdlsLinkEstablishParams);
8379 /* Send TDLS peer UAPSD capabilities to the firmware and
8380 * register with the TL on after the response for this operation
8381 * is received .
8382 */
8383 ret = wait_for_completion_interruptible_timeout(
8384 &pAdapter->tdls_link_establish_req_comp,
8385 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
8386 if (ret <= 0)
8387 {
8388 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8389 "%s: Link Establish Request Faled Status %ld",
8390 __func__, ret);
8391 return -EINVAL;
8392 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308393 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008394 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED);
Gopichand Nakkala471708b2013-06-04 20:03:01 +05308395 /* Mark TDLS client Authenticated .*/
8396 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
8397 pTdlsPeer->staId,
8398 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008399 if (VOS_STATUS_SUCCESS == status)
8400 {
Hoonki Lee14621352013-04-16 17:51:19 -07008401 if (pTdlsPeer->is_responder == 0)
8402 {
8403 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
8404
8405 wlan_hdd_tdls_timer_restart(pAdapter,
8406 &pTdlsPeer->initiatorWaitTimeoutTimer,
8407 WAIT_TIME_TDLS_INITIATOR);
8408 /* suspend initiator TX until it receives direct packet from the
8409 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
8410 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
8411 &staId, NULL);
8412 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008413 wlan_hdd_tdls_increment_peer_count(pAdapter);
8414 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008415 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308416
8417 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308418 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
8419 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308420 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308421 int ac;
8422 uint8 ucAc[4] = { WLANTL_AC_VO,
8423 WLANTL_AC_VI,
8424 WLANTL_AC_BK,
8425 WLANTL_AC_BE };
8426 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
8427 for(ac=0; ac < 4; ac++)
8428 {
8429 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
8430 pTdlsPeer->staId, ucAc[ac],
8431 tlTid[ac], tlTid[ac], 0, 0,
8432 WLANTL_BI_DIR );
8433 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308434 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008435 }
8436
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008437 }
8438 break;
8439 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -08008440 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008441 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -08008442 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008443 long status;
8444
8445 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
8446
Lee Hoonkic1262f22013-01-24 21:59:00 -08008447 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
8448 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008449
8450 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
8451 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
8452 if (status <= 0)
8453 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008454 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008455 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8456 "%s: Del station failed status %ld",
8457 __func__, status);
8458 return -EPERM;
8459 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008460 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Lee Hoonkic1262f22013-01-24 21:59:00 -08008461 }
8462 else
8463 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008464 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8465 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -08008466 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008467 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008468 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008469 case NL80211_TDLS_TEARDOWN:
8470 case NL80211_TDLS_SETUP:
8471 case NL80211_TDLS_DISCOVERY_REQ:
8472 /* We don't support in-driver setup/teardown/discovery */
8473 return -ENOTSUPP;
8474 default:
8475 return -ENOTSUPP;
8476 }
8477 return 0;
8478}
Chilam NG571c65a2013-01-19 12:27:36 +05308479
8480int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
8481 struct net_device *dev, u8 *peer)
8482{
8483 hddLog(VOS_TRACE_LEVEL_INFO, "tdls send discover req: %x %x %x %x %x %x",
8484 peer[0], peer[1], peer[2], peer[3], peer[4], peer[5]);
8485
8486 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
8487 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
8488}
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008489#endif
8490
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308491#ifdef WLAN_FEATURE_GTK_OFFLOAD
8492/*
8493 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
8494 * Callback rountine called upon receiving response for
8495 * get offload info
8496 */
8497void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
8498 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
8499{
8500
8501 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308502 tANI_U8 tempReplayCounter[8];
8503 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308504
8505 ENTER();
8506
8507 if (NULL == pAdapter)
8508 {
8509 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8510 "%s: HDD adapter is Null", __func__);
8511 return ;
8512 }
8513
8514 if (NULL == pGtkOffloadGetInfoRsp)
8515 {
8516 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8517 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
8518 return ;
8519 }
8520
8521 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
8522 {
8523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8524 "%s: wlan Failed to get replay counter value",
8525 __func__);
8526 return ;
8527 }
8528
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308529 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8530 /* Update replay counter */
8531 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
8532 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
8533
8534 {
8535 /* changing from little to big endian since supplicant
8536 * works on big endian format
8537 */
8538 int i;
8539 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
8540
8541 for (i = 0; i < 8; i++)
8542 {
8543 tempReplayCounter[7-i] = (tANI_U8)p[i];
8544 }
8545 }
8546
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308547 /* Update replay counter to NL */
8548 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308549 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308550}
8551
8552/*
8553 * FUNCTION: wlan_hdd_cfg80211_set_rekey_data
8554 * This function is used to offload GTK rekeying job to the firmware.
8555 */
8556int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
8557 struct cfg80211_gtk_rekey_data *data)
8558{
8559 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8560 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8561 hdd_station_ctx_t *pHddStaCtx;
8562 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308563 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308564 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308565 eHalStatus status = eHAL_STATUS_FAILURE;
8566
8567 ENTER();
8568
8569 if (NULL == pAdapter)
8570 {
8571 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8572 "%s: HDD adapter is Null", __func__);
8573 return -ENODEV;
8574 }
8575
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308576 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308577
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308578 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308579 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308580 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8581 "%s: HDD context is not valid", __func__);
8582 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308583 }
8584
8585 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8586 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8587 if (NULL == hHal)
8588 {
8589 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8590 "%s: HAL context is Null!!!", __func__);
8591 return -EAGAIN;
8592 }
8593
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308594 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
8595 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
8596 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
8597 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308598 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308599 {
8600 /* changing from big to little endian since driver
8601 * works on little endian format
8602 */
8603 tANI_U8 *p =
8604 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
8605 int i;
8606
8607 for (i = 0; i < 8; i++)
8608 {
8609 p[7-i] = data->replay_ctr[i];
8610 }
8611 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308612
8613 if (TRUE == pHddCtx->hdd_wlan_suspended)
8614 {
8615 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308616 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
8617 sizeof (tSirGtkOffloadParams));
8618 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308619 pAdapter->sessionId);
8620
8621 if (eHAL_STATUS_SUCCESS != status)
8622 {
8623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8624 "%s: sme_SetGTKOffload failed, returned %d",
8625 __func__, status);
8626 return status;
8627 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8629 "%s: sme_SetGTKOffload successfull", __func__);
8630 }
8631 else
8632 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308633 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8634 "%s: wlan not suspended GTKOffload request is stored",
8635 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308636 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308637
8638 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308639}
8640#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
8641
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308642/*
8643 * FUNCTION: wlan_hdd_cfg80211_set_mac_acl
8644 * This function is used to set access control policy
8645 */
8646static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
8647 struct net_device *dev, const struct cfg80211_acl_data *params)
8648{
8649 int i;
8650 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8651 hdd_hostapd_state_t *pHostapdState;
8652 tsap_Config_t *pConfig;
8653 v_CONTEXT_t pVosContext = NULL;
8654 hdd_context_t *pHddCtx;
8655 int status;
8656
8657 ENTER();
8658
8659 if (NULL == pAdapter)
8660 {
8661 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8662 "%s: HDD adapter is Null", __func__);
8663 return -ENODEV;
8664 }
8665
8666 if (NULL == params)
8667 {
8668 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8669 "%s: params is Null", __func__);
8670 return -EINVAL;
8671 }
8672
8673 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8674 status = wlan_hdd_validate_context(pHddCtx);
8675
8676 if (0 != status)
8677 {
8678 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8679 "%s: HDD context is not valid", __func__);
8680 return status;
8681 }
8682
8683 pVosContext = pHddCtx->pvosContext;
8684 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
8685
8686 if (NULL == pHostapdState)
8687 {
8688 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8689 "%s: pHostapdState is Null", __func__);
8690 return -EINVAL;
8691 }
8692
8693 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
8694 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
8695
8696 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
8697 {
8698 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
8699
8700 /* default value */
8701 pConfig->num_accept_mac = 0;
8702 pConfig->num_deny_mac = 0;
8703
8704 /**
8705 * access control policy
8706 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
8707 * listed in hostapd.deny file.
8708 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
8709 * listed in hostapd.accept file.
8710 */
8711 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
8712 {
8713 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
8714 }
8715 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
8716 {
8717 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
8718 }
8719 else
8720 {
8721 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8722 "%s:Acl Policy : %d is not supported",
8723 __func__, params->acl_policy);
8724 return -ENOTSUPP;
8725 }
8726
8727 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
8728 {
8729 pConfig->num_accept_mac = params->n_acl_entries;
8730 for (i = 0; i < params->n_acl_entries; i++)
8731 {
8732 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8733 "** Add ACL MAC entry %i in WhiletList :"
8734 MAC_ADDRESS_STR, i,
8735 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8736
8737 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
8738 sizeof(qcmacaddr));
8739 }
8740 }
8741 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
8742 {
8743 pConfig->num_deny_mac = params->n_acl_entries;
8744 for (i = 0; i < params->n_acl_entries; i++)
8745 {
8746 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8747 "** Add ACL MAC entry %i in BlackList :"
8748 MAC_ADDRESS_STR, i,
8749 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8750
8751 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
8752 sizeof(qcmacaddr));
8753 }
8754 }
8755
8756 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
8757 {
8758 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8759 "%s: SAP Set Mac Acl fail", __func__);
8760 return -EINVAL;
8761 }
8762 }
8763 else
8764 {
8765 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8766 "%s: Invalid device_mode = %d",
8767 __func__, pAdapter->device_mode);
8768 return -EINVAL;
8769 }
8770
8771 return 0;
8772}
8773
Leo Chang9056f462013-08-01 19:21:11 -07008774#ifdef WLAN_NL80211_TESTMODE
8775#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -07008776void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -07008777(
8778 void *pAdapter,
8779 void *indCont
8780)
8781{
Leo Changd9df8aa2013-09-26 13:32:26 -07008782 tSirLPHBInd *lphbInd;
8783 struct sk_buff *skb;
Leo Chang9056f462013-08-01 19:21:11 -07008784
8785 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07008786 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -07008787
8788 if (NULL == indCont)
8789 {
8790 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07008791 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -07008792 return;
8793 }
8794
Leo Changd9df8aa2013-09-26 13:32:26 -07008795 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -07008796 skb = cfg80211_testmode_alloc_event_skb(
8797 ((hdd_adapter_t *)pAdapter)->wdev.wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -07008798 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -07008799 GFP_ATOMIC);
8800 if (!skb)
8801 {
8802 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8803 "LPHB timeout, NL buffer alloc fail");
8804 return;
8805 }
8806
Leo Changac3ba772013-10-07 09:47:04 -07008807 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -07008808 {
8809 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8810 "WLAN_HDD_TM_ATTR_CMD put fail");
8811 goto nla_put_failure;
8812 }
Leo Changac3ba772013-10-07 09:47:04 -07008813 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -07008814 {
8815 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8816 "WLAN_HDD_TM_ATTR_TYPE put fail");
8817 goto nla_put_failure;
8818 }
Leo Changac3ba772013-10-07 09:47:04 -07008819 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -07008820 sizeof(tSirLPHBInd), lphbInd))
8821 {
8822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8823 "WLAN_HDD_TM_ATTR_DATA put fail");
8824 goto nla_put_failure;
8825 }
Leo Chang9056f462013-08-01 19:21:11 -07008826 cfg80211_testmode_event(skb, GFP_ATOMIC);
8827 return;
8828
8829nla_put_failure:
8830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8831 "NLA Put fail");
8832 kfree_skb(skb);
8833
8834 return;
8835}
8836#endif /* FEATURE_WLAN_LPHB */
8837
8838static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
8839{
8840 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
8841 int err = 0;
8842#ifdef FEATURE_WLAN_LPHB
8843 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -07008844 eHalStatus smeStatus;
Leo Chang9056f462013-08-01 19:21:11 -07008845#endif /* FEATURE_WLAN_LPHB */
8846
8847 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
8848 if (err)
8849 {
8850 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8851 "%s Testmode INV ATTR", __func__);
8852 return err;
8853 }
8854
8855 if (!tb[WLAN_HDD_TM_ATTR_CMD])
8856 {
8857 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8858 "%s Testmode INV CMD", __func__);
8859 return -EINVAL;
8860 }
8861
8862 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
8863 {
8864#ifdef FEATURE_WLAN_LPHB
8865 /* Low Power Heartbeat configuration request */
8866 case WLAN_HDD_TM_CMD_WLAN_HB:
8867 {
8868 int buf_len;
8869 void *buf;
8870 tSirLPHBReq *hb_params = NULL;
8871
8872 if (!tb[WLAN_HDD_TM_ATTR_DATA])
8873 {
8874 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8875 "%s Testmode INV DATA", __func__);
8876 return -EINVAL;
8877 }
8878
8879 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
8880 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
8881 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
8882 if (NULL == hb_params)
8883 {
8884 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8885 "%s Request Buffer Alloc Fail", __func__);
8886 return -EINVAL;
8887 }
8888
8889 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -07008890 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
8891 hb_params,
8892 wlan_hdd_cfg80211_lphb_ind_handler);
8893 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -07008894 {
Leo Changd9df8aa2013-09-26 13:32:26 -07008895 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8896 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -07008897 vos_mem_free(hb_params);
8898 }
Leo Chang9056f462013-08-01 19:21:11 -07008899 return 0;
8900 }
8901#endif /* FEATURE_WLAN_LPHB */
8902 default:
8903 return -EOPNOTSUPP;
8904 }
8905
8906 return err;
8907}
8908#endif /* CONFIG_NL80211_TESTMODE */
8909
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308910static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
8911 struct net_device *dev,
8912 int idx, struct survey_info *survey)
8913{
8914 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8915 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +05308916 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308917 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +05308918 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308919 v_S7_t snr,rssi;
8920 int status, i, j, filled = 0;
8921
8922 ENTER();
8923
8924
8925 if (NULL == pAdapter)
8926 {
8927 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8928 "%s: HDD adapter is Null", __func__);
8929 return -ENODEV;
8930 }
8931
8932 if (NULL == wiphy)
8933 {
8934 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8935 "%s: wiphy is Null", __func__);
8936 return -ENODEV;
8937 }
8938
8939 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8940 status = wlan_hdd_validate_context(pHddCtx);
8941
8942 if (0 != status)
8943 {
8944 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8945 "%s: HDD context is not valid", __func__);
8946 return status;
8947 }
8948
Mihir Sheted9072e02013-08-21 17:02:29 +05308949 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8950
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308951 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +05308952 0 != pAdapter->survey_idx ||
8953 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308954 {
8955 /* The survey dump ops when implemented completely is expected to
8956 * return a survey of all channels and the ops is called by the
8957 * kernel with incremental values of the argument 'idx' till it
8958 * returns -ENONET. But we can only support the survey for the
8959 * operating channel for now. survey_idx is used to track
8960 * that the ops is called only once and then return -ENONET for
8961 * the next iteration
8962 */
8963 pAdapter->survey_idx = 0;
8964 return -ENONET;
8965 }
8966
8967 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
8968
8969 wlan_hdd_get_snr(pAdapter, &snr);
8970 wlan_hdd_get_rssi(pAdapter, &rssi);
8971
8972 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
8973 hdd_wlan_get_freq(channel, &freq);
8974
8975
8976 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
8977 {
8978 if (NULL == wiphy->bands[i])
8979 {
8980 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
8981 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
8982 continue;
8983 }
8984
8985 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
8986 {
8987 struct ieee80211_supported_band *band = wiphy->bands[i];
8988
8989 if (band->channels[j].center_freq == (v_U16_t)freq)
8990 {
8991 survey->channel = &band->channels[j];
8992 /* The Rx BDs contain SNR values in dB for the received frames
8993 * while the supplicant expects noise. So we calculate and
8994 * return the value of noise (dBm)
8995 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
8996 */
8997 survey->noise = rssi - snr;
8998 survey->filled = SURVEY_INFO_NOISE_DBM;
8999 filled = 1;
9000 }
9001 }
9002 }
9003
9004 if (filled)
9005 pAdapter->survey_idx = 1;
9006 else
9007 {
9008 pAdapter->survey_idx = 0;
9009 return -ENONET;
9010 }
9011
9012 return 0;
9013}
9014
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309015/*
9016 * FUNCTION: wlan_hdd_cfg80211_resume_wlan
9017 * this is called when cfg80211 driver resume
9018 * driver updates latest sched_scan scan result(if any) to cfg80211 database
9019 */
9020int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
9021{
9022 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9023 hdd_adapter_t *pAdapter;
9024 hdd_adapter_list_node_t *pAdapterNode, *pNext;
9025 VOS_STATUS status = VOS_STATUS_SUCCESS;
9026
9027 ENTER();
9028
9029 if ( NULL == pHddCtx )
9030 {
9031 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9032 "%s: HddCtx validation failed", __func__);
9033 return 0;
9034 }
9035
9036 if (pHddCtx->isLogpInProgress)
9037 {
9038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9039 "%s: LOGP in Progress. Ignore!!!", __func__);
9040 return 0;
9041 }
9042
9043 if (pHddCtx->isLoadUnloadInProgress)
9044 {
9045 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9046 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
9047 return 0;
9048 }
9049
9050 spin_lock(&pHddCtx->schedScan_lock);
9051 pHddCtx->isWiphySuspended = FALSE;
9052 if (TRUE != pHddCtx->isSchedScanUpdatePending)
9053 {
9054 spin_unlock(&pHddCtx->schedScan_lock);
9055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9056 "%s: Return resume is not due to PNO indication", __func__);
9057 return 0;
9058 }
9059 // Reset flag to avoid updatating cfg80211 data old results again
9060 pHddCtx->isSchedScanUpdatePending = FALSE;
9061 spin_unlock(&pHddCtx->schedScan_lock);
9062
9063 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
9064
9065 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
9066 {
9067 pAdapter = pAdapterNode->pAdapter;
9068 if ( (NULL != pAdapter) &&
9069 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
9070 {
9071 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
9072 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9073 "%s: NO SCAN result", __func__);
9074 else
9075 cfg80211_sched_scan_results(pHddCtx->wiphy);
9076
9077 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9078 "%s : cfg80211 scan result database updated", __func__);
9079
9080 return 0;
9081
9082 }
9083 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
9084 pAdapterNode = pNext;
9085 }
9086
9087 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9088 "%s: Failed to find Adapter", __func__);
9089 return 0;
9090}
9091
9092/*
9093 * FUNCTION: wlan_hdd_cfg80211_suspend_wlan
9094 * this is called when cfg80211 driver suspends
9095 */
9096int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
9097 struct cfg80211_wowlan *wow)
9098{
9099 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9100
9101 ENTER();
9102 if (NULL == pHddCtx)
9103 {
9104 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9105 "%s: HddCtx validation failed", __func__);
9106 return 0;
9107 }
9108
9109 pHddCtx->isWiphySuspended = TRUE;
9110
9111 EXIT();
9112
9113 return 0;
9114}
9115
Jeff Johnson295189b2012-06-20 16:38:30 -07009116/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309117static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -07009118{
9119 .add_virtual_intf = wlan_hdd_add_virtual_intf,
9120 .del_virtual_intf = wlan_hdd_del_virtual_intf,
9121 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
9122 .change_station = wlan_hdd_change_station,
9123#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9124 .add_beacon = wlan_hdd_cfg80211_add_beacon,
9125 .del_beacon = wlan_hdd_cfg80211_del_beacon,
9126 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009127#else
9128 .start_ap = wlan_hdd_cfg80211_start_ap,
9129 .change_beacon = wlan_hdd_cfg80211_change_beacon,
9130 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -07009131#endif
9132 .change_bss = wlan_hdd_cfg80211_change_bss,
9133 .add_key = wlan_hdd_cfg80211_add_key,
9134 .get_key = wlan_hdd_cfg80211_get_key,
9135 .del_key = wlan_hdd_cfg80211_del_key,
9136 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009137#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009138 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009139#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009140 .scan = wlan_hdd_cfg80211_scan,
9141 .connect = wlan_hdd_cfg80211_connect,
9142 .disconnect = wlan_hdd_cfg80211_disconnect,
9143 .join_ibss = wlan_hdd_cfg80211_join_ibss,
9144 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
9145 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
9146 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
9147 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -07009148 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
9149 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
9150 .mgmt_tx = wlan_hdd_action,
9151#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9152 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
9153 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
9154 .set_txq_params = wlan_hdd_set_txq_params,
9155#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009156 .get_station = wlan_hdd_cfg80211_get_station,
9157 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
9158 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009159 .add_station = wlan_hdd_cfg80211_add_station,
9160#ifdef FEATURE_WLAN_LFR
9161 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
9162 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
9163 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
9164#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009165#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
9166 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
9167#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009168#ifdef FEATURE_WLAN_TDLS
9169 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
9170 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
9171#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309172#ifdef WLAN_FEATURE_GTK_OFFLOAD
9173 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
9174#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309175#ifdef FEATURE_WLAN_SCAN_PNO
9176 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
9177 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
9178#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309179 .resume = wlan_hdd_cfg80211_resume_wlan,
9180 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309181 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -07009182#ifdef WLAN_NL80211_TESTMODE
9183 .testmode_cmd = wlan_hdd_cfg80211_testmode,
9184#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309185 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009186};
9187