blob: 1d68540a25e306da2696f969d5db811c6ff90cd7 [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
1022 if (params->tail && !params->tail_len)
1023 return -EINVAL;
1024
1025#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
1026 /* Kernel 3.0 is not updating dtim_period for set beacon */
1027 if (!params->dtim_period)
1028 return -EINVAL;
1029#endif
1030
1031 if(params->head)
1032 head_len = params->head_len;
1033 else
1034 head_len = old->head_len;
1035
1036 if(params->tail || !old)
1037 tail_len = params->tail_len;
1038 else
1039 tail_len = old->tail_len;
1040
1041 size = sizeof(beacon_data_t) + head_len + tail_len;
1042
1043 beacon = kzalloc(size, GFP_KERNEL);
1044
1045 if( beacon == NULL )
1046 return -ENOMEM;
1047
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001048#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001049 if(params->dtim_period || !old )
1050 beacon->dtim_period = params->dtim_period;
1051 else
1052 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001053#else
1054 if(dtim_period || !old )
1055 beacon->dtim_period = dtim_period;
1056 else
1057 beacon->dtim_period = old->dtim_period;
1058#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301059
Jeff Johnson295189b2012-06-20 16:38:30 -07001060 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
1061 beacon->tail = beacon->head + head_len;
1062 beacon->head_len = head_len;
1063 beacon->tail_len = tail_len;
1064
1065 if(params->head) {
1066 memcpy (beacon->head,params->head,beacon->head_len);
1067 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301068 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001069 if(old)
1070 memcpy (beacon->head,old->head,beacon->head_len);
1071 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301072
Jeff Johnson295189b2012-06-20 16:38:30 -07001073 if(params->tail) {
1074 memcpy (beacon->tail,params->tail,beacon->tail_len);
1075 }
1076 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301077 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07001078 memcpy (beacon->tail,old->tail,beacon->tail_len);
1079 }
1080
1081 *ppBeacon = beacon;
1082
1083 kfree(old);
1084
1085 return 0;
1086
1087}
Jeff Johnson295189b2012-06-20 16:38:30 -07001088
1089v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
1090{
1091 int left = length;
1092 v_U8_t *ptr = pIes;
1093 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301094
Jeff Johnson295189b2012-06-20 16:38:30 -07001095 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301096 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001097 elem_id = ptr[0];
1098 elem_len = ptr[1];
1099 left -= 2;
1100 if(elem_len > left)
1101 {
1102 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001103 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001104 eid,elem_len,left);
1105 return NULL;
1106 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301107 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07001108 {
1109 return ptr;
1110 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301111
Jeff Johnson295189b2012-06-20 16:38:30 -07001112 left -= elem_len;
1113 ptr += (elem_len + 2);
1114 }
1115 return NULL;
1116}
1117
Jeff Johnson295189b2012-06-20 16:38:30 -07001118/* Check if rate is 11g rate or not */
1119static int wlan_hdd_rate_is_11g(u8 rate)
1120{
Sanjay Devnani28322e22013-06-21 16:13:40 -07001121 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001122 u8 i;
1123 for (i = 0; i < 8; i++)
1124 {
1125 if(rate == gRateArray[i])
1126 return TRUE;
1127 }
1128 return FALSE;
1129}
1130
1131/* Check for 11g rate and set proper 11g only mode */
1132static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
1133 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
1134{
1135 u8 i, num_rates = pIe[0];
1136
1137 pIe += 1;
1138 for ( i = 0; i < num_rates; i++)
1139 {
1140 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
1141 {
1142 /* If rate set have 11g rate than change the mode to 11G */
1143 *pSapHw_mode = eSAP_DOT11_MODE_11g;
1144 if (pIe[i] & BASIC_RATE_MASK)
1145 {
1146 /* If we have 11g rate as basic rate, it means mode
1147 is 11g only mode.
1148 */
1149 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
1150 *pCheckRatesfor11g = FALSE;
1151 }
1152 }
1153 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
1154 {
1155 *require_ht = TRUE;
1156 }
1157 }
1158 return;
1159}
1160
1161static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
1162{
1163 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1164 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1165 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1166 u8 checkRatesfor11g = TRUE;
1167 u8 require_ht = FALSE;
1168 u8 *pIe=NULL;
1169
1170 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
1171
1172 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
1173 pBeacon->head_len, WLAN_EID_SUPP_RATES);
1174 if (pIe != NULL)
1175 {
1176 pIe += 1;
1177 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1178 &pConfig->SapHw_mode);
1179 }
1180
1181 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1182 WLAN_EID_EXT_SUPP_RATES);
1183 if (pIe != NULL)
1184 {
1185
1186 pIe += 1;
1187 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1188 &pConfig->SapHw_mode);
1189 }
1190
1191 if( pConfig->channel > 14 )
1192 {
1193 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
1194 }
1195
1196 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1197 WLAN_EID_HT_CAPABILITY);
1198
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301199 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001200 {
1201 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
1202 if(require_ht)
1203 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
1204 }
1205}
1206
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301207static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
1208 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
1209{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001210 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301211 v_U8_t *pIe = NULL;
1212 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1213
1214 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
1215 pBeacon->tail, pBeacon->tail_len);
1216
1217 if (pIe)
1218 {
1219 ielen = pIe[1] + 2;
1220 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1221 {
1222 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
1223 }
1224 else
1225 {
1226 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
1227 return -EINVAL;
1228 }
1229 *total_ielen += ielen;
1230 }
1231 return 0;
1232}
1233
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001234static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
1235 v_U8_t *genie, v_U8_t *total_ielen)
1236{
1237 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1238 int left = pBeacon->tail_len;
1239 v_U8_t *ptr = pBeacon->tail;
1240 v_U8_t elem_id, elem_len;
1241 v_U16_t ielen = 0;
1242
1243 if ( NULL == ptr || 0 == left )
1244 return;
1245
1246 while (left >= 2)
1247 {
1248 elem_id = ptr[0];
1249 elem_len = ptr[1];
1250 left -= 2;
1251 if (elem_len > left)
1252 {
1253 hddLog( VOS_TRACE_LEVEL_ERROR,
1254 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
1255 elem_id, elem_len, left);
1256 return;
1257 }
1258 if (IE_EID_VENDOR == elem_id)
1259 {
1260 /* skipping the VSIE's which we don't want to include or
1261 * it will be included by existing code
1262 */
1263 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
1264#ifdef WLAN_FEATURE_WFD
1265 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
1266#endif
1267 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1268 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1269 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
1270 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1271 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
1272 {
1273 ielen = ptr[1] + 2;
1274 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1275 {
1276 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
1277 *total_ielen += ielen;
1278 }
1279 else
1280 {
1281 hddLog( VOS_TRACE_LEVEL_ERROR,
1282 "IE Length is too big "
1283 "IEs eid=%d elem_len=%d total_ie_lent=%d",
1284 elem_id, elem_len, *total_ielen);
1285 }
1286 }
1287 }
1288
1289 left -= elem_len;
1290 ptr += (elem_len + 2);
1291 }
1292 return;
1293}
1294
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001295#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001296static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1297 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001298#else
1299static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1300 struct cfg80211_beacon_data *params)
1301#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001302{
1303 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301304 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001305 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07001306 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001307
1308 genie = vos_mem_malloc(MAX_GENIE_LEN);
1309
1310 if(genie == NULL) {
1311
1312 return -ENOMEM;
1313 }
1314
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301315 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1316 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001317 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301318 ret = -EINVAL;
1319 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001320 }
1321
1322#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301323 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1324 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
1325 {
1326 ret = -EINVAL;
1327 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001328 }
1329#endif
1330
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301331 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1332 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001333 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301334 ret = -EINVAL;
1335 goto done;
1336 }
1337
1338 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
1339 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001340 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001341 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001342
1343 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1344 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
1345 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
1346 {
1347 hddLog(LOGE,
1348 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001349 ret = -EINVAL;
1350 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001351 }
1352
1353 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1354 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
1355 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1356 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1357 ==eHAL_STATUS_FAILURE)
1358 {
1359 hddLog(LOGE,
1360 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001361 ret = -EINVAL;
1362 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001363 }
1364
1365 // Added for ProResp IE
1366 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
1367 {
1368 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
1369 u8 probe_rsp_ie_len[3] = {0};
1370 u8 counter = 0;
1371 /* Check Probe Resp Length if it is greater then 255 then Store
1372 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
1373 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
1374 Store More then 255 bytes into One Variable.
1375 */
1376 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
1377 {
1378 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
1379 {
1380 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
1381 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
1382 }
1383 else
1384 {
1385 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
1386 rem_probe_resp_ie_len = 0;
1387 }
1388 }
1389
1390 rem_probe_resp_ie_len = 0;
1391
1392 if (probe_rsp_ie_len[0] > 0)
1393 {
1394 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1395 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
1396 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1397 probe_rsp_ie_len[0], NULL,
1398 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1399 {
1400 hddLog(LOGE,
1401 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001402 ret = -EINVAL;
1403 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001404 }
1405 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
1406 }
1407
1408 if (probe_rsp_ie_len[1] > 0)
1409 {
1410 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1411 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
1412 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1413 probe_rsp_ie_len[1], NULL,
1414 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1415 {
1416 hddLog(LOGE,
1417 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001418 ret = -EINVAL;
1419 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001420 }
1421 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
1422 }
1423
1424 if (probe_rsp_ie_len[2] > 0)
1425 {
1426 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1427 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
1428 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1429 probe_rsp_ie_len[2], NULL,
1430 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1431 {
1432 hddLog(LOGE,
1433 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001434 ret = -EINVAL;
1435 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001436 }
1437 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
1438 }
1439
1440 if (probe_rsp_ie_len[1] == 0 )
1441 {
1442 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1443 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
1444 eANI_BOOLEAN_FALSE) )
1445 {
1446 hddLog(LOGE,
1447 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM\n");
1448 }
1449 }
1450
1451 if (probe_rsp_ie_len[2] == 0 )
1452 {
1453 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1454 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
1455 eANI_BOOLEAN_FALSE) )
1456 {
1457 hddLog(LOGE,
1458 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM\n");
1459 }
1460 }
1461
1462 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1463 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
1464 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1465 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1466 == eHAL_STATUS_FAILURE)
1467 {
1468 hddLog(LOGE,
1469 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001470 ret = -EINVAL;
1471 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001472 }
1473 }
1474 else
1475 {
1476 // Reset WNI_CFG_PROBE_RSP Flags
1477 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
1478
1479 hddLog(VOS_TRACE_LEVEL_INFO,
1480 "%s: No Probe Response IE received in set beacon",
1481 __func__);
1482 }
1483
1484 // Added for AssocResp IE
1485 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
1486 {
1487 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1488 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
1489 params->assocresp_ies_len, NULL,
1490 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1491 {
1492 hddLog(LOGE,
1493 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001494 ret = -EINVAL;
1495 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001496 }
1497
1498 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1499 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
1500 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1501 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1502 == eHAL_STATUS_FAILURE)
1503 {
1504 hddLog(LOGE,
1505 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001506 ret = -EINVAL;
1507 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001508 }
1509 }
1510 else
1511 {
1512 hddLog(VOS_TRACE_LEVEL_INFO,
1513 "%s: No Assoc Response IE received in set beacon",
1514 __func__);
1515
1516 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1517 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
1518 eANI_BOOLEAN_FALSE) )
1519 {
1520 hddLog(LOGE,
1521 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
1522 }
1523 }
1524
Jeff Johnsone7245742012-09-05 17:12:55 -07001525done:
Jeff Johnson295189b2012-06-20 16:38:30 -07001526 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301527 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001528}
Jeff Johnson295189b2012-06-20 16:38:30 -07001529
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301530/*
Jeff Johnson295189b2012-06-20 16:38:30 -07001531 * FUNCTION: wlan_hdd_validate_operation_channel
1532 * called by wlan_hdd_cfg80211_start_bss() and
1533 * wlan_hdd_cfg80211_set_channel()
1534 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301535 * channel list.
1536 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001537VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001538{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301539
Jeff Johnson295189b2012-06-20 16:38:30 -07001540 v_U32_t num_ch = 0;
1541 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1542 u32 indx = 0;
1543 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301544 v_U8_t fValidChannel = FALSE, count = 0;
1545 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301546
Jeff Johnson295189b2012-06-20 16:38:30 -07001547 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1548
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301549 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001550 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301551 /* Validate the channel */
1552 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001553 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301554 if ( channel == rfChannels[count].channelNum )
1555 {
1556 fValidChannel = TRUE;
1557 break;
1558 }
1559 }
1560 if (fValidChannel != TRUE)
1561 {
1562 hddLog(VOS_TRACE_LEVEL_ERROR,
1563 "%s: Invalid Channel [%d]", __func__, channel);
1564 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001565 }
1566 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301567 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001568 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301569 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1570 valid_ch, &num_ch))
1571 {
1572 hddLog(VOS_TRACE_LEVEL_ERROR,
1573 "%s: failed to get valid channel list", __func__);
1574 return VOS_STATUS_E_FAILURE;
1575 }
1576 for (indx = 0; indx < num_ch; indx++)
1577 {
1578 if (channel == valid_ch[indx])
1579 {
1580 break;
1581 }
1582 }
1583
1584 if (indx >= num_ch)
1585 {
1586 hddLog(VOS_TRACE_LEVEL_ERROR,
1587 "%s: Invalid Channel [%d]", __func__, channel);
1588 return VOS_STATUS_E_FAILURE;
1589 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001590 }
1591 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301592
Jeff Johnson295189b2012-06-20 16:38:30 -07001593}
1594
Viral Modi3a32cc52013-02-08 11:14:52 -08001595/**
1596 * FUNCTION: wlan_hdd_cfg80211_set_channel
1597 * This function is used to set the channel number
1598 */
1599static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
1600 struct ieee80211_channel *chan,
1601 enum nl80211_channel_type channel_type
1602 )
1603{
1604 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07001605 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08001606 hdd_adapter_t *pAdapter = NULL;
1607 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301608 hdd_context_t *pHddCtx;
1609 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001610
1611 ENTER();
1612
1613 if( NULL == dev )
1614 {
1615 hddLog(VOS_TRACE_LEVEL_ERROR,
1616 "%s: Called with dev = NULL.\n", __func__);
1617 return -ENODEV;
1618 }
1619 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
1620
1621 hddLog(VOS_TRACE_LEVEL_INFO,
1622 "%s: device_mode = %d freq = %d \n",__func__,
1623 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301624
1625 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1626 status = wlan_hdd_validate_context(pHddCtx);
1627
1628 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08001629 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301630 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1631 "%s: HDD context is not valid", __func__);
1632 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001633 }
1634
1635 /*
1636 * Do freq to chan conversion
1637 * TODO: for 11a
1638 */
1639
1640 channel = ieee80211_frequency_to_channel(freq);
1641
1642 /* Check freq range */
1643 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
1644 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
1645 {
1646 hddLog(VOS_TRACE_LEVEL_ERROR,
1647 "%s: Channel [%d] is outside valid range from %d to %d\n",
1648 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
1649 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1650 return -EINVAL;
1651 }
1652
1653 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1654
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05301655 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
1656 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08001657 {
1658 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
1659 {
1660 hddLog(VOS_TRACE_LEVEL_ERROR,
1661 "%s: Invalid Channel [%d] \n", __func__, channel);
1662 return -EINVAL;
1663 }
1664 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1665 "%s: set channel to [%d] for device mode =%d",
1666 __func__, channel,pAdapter->device_mode);
1667 }
1668 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08001669 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08001670 )
1671 {
1672 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1673 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
1674 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1675
1676 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
1677 {
1678 /* Link is up then return cant set channel*/
1679 hddLog( VOS_TRACE_LEVEL_ERROR,
1680 "%s: IBSS Associated, can't set the channel\n", __func__);
1681 return -EINVAL;
1682 }
1683
1684 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
1685 pHddStaCtx->conn_info.operationChannel = channel;
1686 pRoamProfile->ChannelInfo.ChannelList =
1687 &pHddStaCtx->conn_info.operationChannel;
1688 }
1689 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08001690 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08001691 )
1692 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301693 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
1694 {
1695 if(VOS_STATUS_SUCCESS !=
1696 wlan_hdd_validate_operation_channel(pAdapter,channel))
1697 {
1698 hddLog(VOS_TRACE_LEVEL_ERROR,
1699 "%s: Invalid Channel [%d] \n", __func__, channel);
1700 return -EINVAL;
1701 }
1702 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1703 }
1704 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08001705 {
1706 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1707
1708 /* If auto channel selection is configured as enable/ 1 then ignore
1709 channel set by supplicant
1710 */
1711 if ( cfg_param->apAutoChannelSelection )
1712 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301713 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
1714 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08001715 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1716 "%s: set channel to auto channel (0) for device mode =%d",
1717 __func__, pAdapter->device_mode);
1718 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301719 else
1720 {
1721 if(VOS_STATUS_SUCCESS !=
1722 wlan_hdd_validate_operation_channel(pAdapter,channel))
1723 {
1724 hddLog(VOS_TRACE_LEVEL_ERROR,
1725 "%s: Invalid Channel [%d] \n", __func__, channel);
1726 return -EINVAL;
1727 }
1728 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1729 }
Viral Modi3a32cc52013-02-08 11:14:52 -08001730 }
1731 }
1732 else
1733 {
1734 hddLog(VOS_TRACE_LEVEL_FATAL,
1735 "%s: Invalid device mode failed to set valid channel", __func__);
1736 return -EINVAL;
1737 }
1738 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301739 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001740}
1741
Jeff Johnson295189b2012-06-20 16:38:30 -07001742#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
1743static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1744 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001745#else
1746static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1747 struct cfg80211_beacon_data *params,
1748 const u8 *ssid, size_t ssid_len,
1749 enum nl80211_hidden_ssid hidden_ssid)
1750#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001751{
1752 tsap_Config_t *pConfig;
1753 beacon_data_t *pBeacon = NULL;
1754 struct ieee80211_mgmt *pMgmt_frame;
1755 v_U8_t *pIe=NULL;
1756 v_U16_t capab_info;
1757 eCsrAuthType RSNAuthType;
1758 eCsrEncryptionType RSNEncryptType;
1759 eCsrEncryptionType mcRSNEncryptType;
1760 int status = VOS_STATUS_SUCCESS;
1761 tpWLAN_SAPEventCB pSapEventCallback;
1762 hdd_hostapd_state_t *pHostapdState;
1763 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
1764 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301765 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001766 struct qc_mac_acl_entry *acl_entry = NULL;
1767 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08001768 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001769
1770 ENTER();
1771
1772 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
1773
1774 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1775
1776 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1777
1778 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1779
1780 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
1781
1782 //channel is already set in the set_channel Call back
1783 //pConfig->channel = pCommitConfig->channel;
1784
1785 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301786 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
1788
1789 pConfig->dtim_period = pBeacon->dtim_period;
1790
1791 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***\n",
1792 pConfig->dtim_period);
1793
1794
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08001795 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07001796 {
1797 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001798 WLAN_EID_COUNTRY);
Jeff Johnson32d95a32012-09-10 13:15:23 -07001799 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001800 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07001801 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07001802 pConfig->ieee80211d = 1;
1803 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
1804 sme_setRegInfo(hHal, pConfig->countryCode);
1805 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07001806 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001807 else
1808 {
1809 pConfig->ieee80211d = 0;
1810 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301811 /*
1812 * If auto channel is configured i.e. channel is 0,
1813 * so skip channel validation.
1814 */
1815 if( AUTO_CHANNEL_SELECT != pConfig->channel )
1816 {
1817 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
1818 {
1819 hddLog(VOS_TRACE_LEVEL_ERROR,
1820 "%s: Invalid Channel [%d] \n", __func__, pConfig->channel);
1821 return -EINVAL;
1822 }
1823 }
1824 else
1825 {
1826 if(1 != pHddCtx->is_dynamic_channel_range_set)
1827 {
1828 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
1829 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
1830 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
1831 }
1832 pHddCtx->is_dynamic_channel_range_set = 0;
1833 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001834 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001835 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001836 {
1837 pConfig->ieee80211d = 0;
1838 }
1839 pConfig->authType = eSAP_AUTO_SWITCH;
1840
1841 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301842
1843 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07001844 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
1845
1846 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
1847
1848 /*Set wps station to configured*/
1849 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
1850
1851 if(pIe)
1852 {
1853 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
1854 {
1855 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***\n");
1856 return -EINVAL;
1857 }
1858 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
1859 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001860 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07001861 /* Check 15 bit of WPS IE as it contain information for wps state
1862 * WPS state
1863 */
1864 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
1865 {
1866 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
1867 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
1868 {
1869 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
1870 }
1871 }
1872 }
1873 else
1874 {
1875 pConfig->wps_state = SAP_WPS_DISABLED;
1876 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301877 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07001878
1879 pConfig->RSNWPAReqIELength = 0;
1880 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301881 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001882 WLAN_EID_RSN);
1883 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301884 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001885 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1886 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1887 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301888 /* The actual processing may eventually be more extensive than
1889 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07001890 * by the app.
1891 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301892 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001893 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1894 &RSNEncryptType,
1895 &mcRSNEncryptType,
1896 &RSNAuthType,
1897 pConfig->pRSNWPAReqIE[1]+2,
1898 pConfig->pRSNWPAReqIE );
1899
1900 if( VOS_STATUS_SUCCESS == status )
1901 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301902 /* Now copy over all the security attributes you have
1903 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001904 * */
1905 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1906 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1907 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1908 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301909 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001910 "EncryptionType = %d mcEncryptionType = %d\n"),
1911 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1912 }
1913 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301914
Jeff Johnson295189b2012-06-20 16:38:30 -07001915 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1916 pBeacon->tail, pBeacon->tail_len);
1917
1918 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
1919 {
1920 if (pConfig->pRSNWPAReqIE)
1921 {
1922 /*Mixed mode WPA/WPA2*/
1923 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
1924 pConfig->RSNWPAReqIELength += pIe[1] + 2;
1925 }
1926 else
1927 {
1928 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1929 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1930 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301931 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001932 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1933 &RSNEncryptType,
1934 &mcRSNEncryptType,
1935 &RSNAuthType,
1936 pConfig->pRSNWPAReqIE[1]+2,
1937 pConfig->pRSNWPAReqIE );
1938
1939 if( VOS_STATUS_SUCCESS == status )
1940 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301941 /* Now copy over all the security attributes you have
1942 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001943 * */
1944 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1945 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1946 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1947 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301948 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001949 "EncryptionType = %d mcEncryptionType = %d\n"),
1950 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1951 }
1952 }
1953 }
1954
Jeff Johnson4416a782013-03-25 14:17:50 -07001955 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
1956 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
1957 return -EINVAL;
1958 }
1959
Jeff Johnson295189b2012-06-20 16:38:30 -07001960 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
1961
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001962#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001963 if (params->ssid != NULL)
1964 {
1965 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
1966 pConfig->SSIDinfo.ssid.length = params->ssid_len;
1967 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1968 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1969 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001970#else
1971 if (ssid != NULL)
1972 {
1973 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
1974 pConfig->SSIDinfo.ssid.length = ssid_len;
1975 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1976 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1977 }
1978#endif
1979
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301980 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07001981 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301982
Jeff Johnson295189b2012-06-20 16:38:30 -07001983 /* default value */
1984 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
1985 pConfig->num_accept_mac = 0;
1986 pConfig->num_deny_mac = 0;
1987
1988 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1989 pBeacon->tail, pBeacon->tail_len);
1990
1991 /* pIe for black list is following form:
1992 type : 1 byte
1993 length : 1 byte
1994 OUI : 4 bytes
1995 acl type : 1 byte
1996 no of mac addr in black list: 1 byte
1997 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301998 */
1999 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002000 {
2001 pConfig->SapMacaddr_acl = pIe[6];
2002 pConfig->num_deny_mac = pIe[7];
2003 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d\n",
2004 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302005 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
2006 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002007 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
2008 for (i = 0; i < pConfig->num_deny_mac; i++)
2009 {
2010 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
2011 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302012 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002013 }
2014 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
2015 pBeacon->tail, pBeacon->tail_len);
2016
2017 /* pIe for white list is following form:
2018 type : 1 byte
2019 length : 1 byte
2020 OUI : 4 bytes
2021 acl type : 1 byte
2022 no of mac addr in white list: 1 byte
2023 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302024 */
2025 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002026 {
2027 pConfig->SapMacaddr_acl = pIe[6];
2028 pConfig->num_accept_mac = pIe[7];
2029 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d\n",
2030 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302031 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
2032 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002033 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
2034 for (i = 0; i < pConfig->num_accept_mac; i++)
2035 {
2036 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
2037 acl_entry++;
2038 }
2039 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302040
Jeff Johnson295189b2012-06-20 16:38:30 -07002041 wlan_hdd_set_sapHwmode(pHostapdAdapter);
2042
Jeff Johnsone7245742012-09-05 17:12:55 -07002043#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002044 /* Overwrite the hostapd setting for HW mode only for 11ac.
2045 * This is valid only if mode is set to 11n in hostapd and either AUTO or 11ac in .ini .
2046 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode) */
2047 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
2048 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302049 (((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_AUTO) ||
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002050 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac) ||
2051 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07002052 {
2053 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07002054
2055 /* Disable VHT support in 2.4 GHz band */
2056 if (pConfig->channel <= 14 &&
2057 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->enableVhtFor24GHzBand == FALSE)
2058 {
2059 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
2060 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002061 }
2062#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302063
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07002064 if ( AUTO_CHANNEL_SELECT != pConfig->channel )
2065 {
2066 sme_SelectCBMode(hHal,
2067 sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode),
2068 pConfig->channel);
2069 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002070 // ht_capab is not what the name conveys,this is used for protection bitmap
2071 pConfig->ht_capab =
2072 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
2073
2074 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
2075 {
2076 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
2077 return -EINVAL;
2078 }
2079
2080 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302081 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07002082 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
2083 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302084 pConfig->obssProtEnabled =
2085 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07002086
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302087 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR"\n"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002088 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302089 hddLog(LOGW,FL("ssid =%s\n"), pConfig->SSIDinfo.ssid.ssId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002090 hddLog(LOGW,FL("beaconint=%d, channel=%d\n"), (int)pConfig->beacon_int,
2091 (int)pConfig->channel);
2092 hddLog(LOGW,FL("hw_mode=%x\n"), pConfig->SapHw_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302093 hddLog(LOGW,FL("privacy=%d, authType=%d\n"), pConfig->privacy,
2094 pConfig->authType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002095 hddLog(LOGW,FL("RSN/WPALen=%d, \n"),(int)pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302096 hddLog(LOGW,FL("Uapsd = %d\n"),pConfig->UapsdEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002097 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d\n"),
2098 pConfig->protEnabled, pConfig->obssProtEnabled);
2099
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302100 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07002101 {
2102 //Bss already started. just return.
2103 //TODO Probably it should update some beacon params.
2104 hddLog( LOGE, "Bss Already started...Ignore the request");
2105 EXIT();
2106 return 0;
2107 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302108
Jeff Johnson295189b2012-06-20 16:38:30 -07002109 pConfig->persona = pHostapdAdapter->device_mode;
2110
2111 pSapEventCallback = hdd_hostapd_SAPEventCB;
2112 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
2113 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
2114 {
2115 hddLog(LOGE,FL("SAP Start Bss fail\n"));
2116 return -EINVAL;
2117 }
2118
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302119 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002120 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
2121
2122 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302123
Jeff Johnson295189b2012-06-20 16:38:30 -07002124 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302125 {
2126 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07002127 ("ERROR: HDD vos wait for single_event failed!!\n"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07002128 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002129 VOS_ASSERT(0);
2130 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302131
Jeff Johnson295189b2012-06-20 16:38:30 -07002132 //Succesfully started Bss update the state bit.
2133 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
2134
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002135#ifdef WLAN_FEATURE_P2P_DEBUG
2136 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
2137 {
2138 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
2139 {
2140 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2141 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002142 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002143 }
2144 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
2145 {
2146 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2147 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002148 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002149 }
2150 }
2151#endif
2152
Jeff Johnson295189b2012-06-20 16:38:30 -07002153 pHostapdState->bCommit = TRUE;
2154 EXIT();
2155
2156 return 0;
2157}
2158
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002159#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302160static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
2161 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002162 struct beacon_parameters *params)
2163{
2164 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302165 hdd_context_t *pHddCtx;
2166 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002167
2168 ENTER();
2169
2170 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d\n",pAdapter->device_mode);
2171
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302172 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2173 status = wlan_hdd_validate_context(pHddCtx);
2174
2175 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002176 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302177 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2178 "%s: HDD context is not valid", __func__);
2179 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002180 }
2181
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302182 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002183 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 )
2185 {
2186 beacon_data_t *old,*new;
2187
2188 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302189
Jeff Johnson295189b2012-06-20 16:38:30 -07002190 if (old)
2191 return -EALREADY;
2192
2193 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2194
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302195 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002196 {
2197 hddLog(VOS_TRACE_LEVEL_FATAL,
2198 "%s:Error!!! Allocating the new beacon\n",__func__);
2199 return -EINVAL;
2200 }
2201
2202 pAdapter->sessionCtx.ap.beacon = new;
2203
2204 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2205 }
2206
2207 EXIT();
2208 return status;
2209}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302210
2211static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07002212 struct net_device *dev,
2213 struct beacon_parameters *params)
2214{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302215 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302216 hdd_context_t *pHddCtx;
2217 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002218
2219 ENTER();
2220
2221 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2222 __func__,pAdapter->device_mode);
2223
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302224 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2225 status = wlan_hdd_validate_context(pHddCtx);
2226
2227 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002228 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302229 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2230 "%s: HDD context is not valid", __func__);
2231 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002232 }
2233
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302234 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002235 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302236 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002237 {
2238 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302239
Jeff Johnson295189b2012-06-20 16:38:30 -07002240 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302241
Jeff Johnson295189b2012-06-20 16:38:30 -07002242 if (!old)
2243 return -ENOENT;
2244
2245 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2246
2247 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302248 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07002249 "%s: Error!!! Allocating the new beacon\n",__func__);
2250 return -EINVAL;
2251 }
2252
2253 pAdapter->sessionCtx.ap.beacon = new;
2254
2255 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2256 }
2257
2258 EXIT();
2259 return status;
2260}
2261
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002262#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
2263
2264#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002265static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
2266 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002267#else
2268static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
2269 struct net_device *dev)
2270#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002271{
2272 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07002273 hdd_context_t *pHddCtx = NULL;
2274 hdd_scaninfo_t *pScanInfo = NULL;
2275 hdd_adapter_t *staAdapter = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302276 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002277
2278 ENTER();
2279
2280 if (NULL == pAdapter)
2281 {
2282 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002283 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002284 return -ENODEV;
2285 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002286
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302287 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2288 status = wlan_hdd_validate_context(pHddCtx);
2289
2290 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002291 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302292 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2293 "%s: HDD context is not valid", __func__);
2294 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07002295 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002296
2297 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
2298 if (NULL == staAdapter)
2299 {
2300 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
2301 if (NULL == staAdapter)
2302 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002303 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2304 "%s: HDD adapter context for STA/P2P-CLI is Null",
2305 __func__);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002306 }
2307 }
2308
2309 pScanInfo = &pHddCtx->scan_info;
2310
Jeff Johnson295189b2012-06-20 16:38:30 -07002311 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2312 __func__,pAdapter->device_mode);
2313
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002314 if ((pScanInfo != NULL) && pScanInfo->mScanPending && staAdapter)
Jeff Johnsone7245742012-09-05 17:12:55 -07002315 {
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002316 INIT_COMPLETION(pScanInfo->abortscan_event_var);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05302317 hdd_abort_mac_scan(staAdapter->pHddCtx, pAdapter->sessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002318 status = wait_for_completion_interruptible_timeout(
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002319 &pScanInfo->abortscan_event_var,
Jeff Johnsone7245742012-09-05 17:12:55 -07002320 msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN));
2321 if (!status)
2322 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002323 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson902c9832012-12-10 14:28:09 -08002324 "%s: Timeout occurred while waiting for abortscan" ,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002325 __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07002326 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07002327 }
2328 }
2329
Jeff Johnson295189b2012-06-20 16:38:30 -07002330 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002331 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002332 )
2333 {
2334 beacon_data_t *old;
2335
2336 old = pAdapter->sessionCtx.ap.beacon;
2337
2338 if (!old)
2339 return -ENOENT;
2340
Jeff Johnson295189b2012-06-20 16:38:30 -07002341 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002342
2343 mutex_lock(&pHddCtx->sap_lock);
2344 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
2345 {
Jeff Johnson4416a782013-03-25 14:17:50 -07002346 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002347 {
2348 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
2349
2350 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
2351
2352 if (!VOS_IS_STATUS_SUCCESS(status))
2353 {
2354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2355 ("ERROR: HDD vos wait for single_event failed!!\n"));
2356 VOS_ASSERT(0);
2357 }
2358 }
2359 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
2360 }
2361 mutex_unlock(&pHddCtx->sap_lock);
2362
2363 if(status != VOS_STATUS_SUCCESS)
2364 {
2365 hddLog(VOS_TRACE_LEVEL_FATAL,
2366 "%s:Error!!! Stopping the BSS\n",__func__);
2367 return -EINVAL;
2368 }
2369
Jeff Johnson4416a782013-03-25 14:17:50 -07002370 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002371 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
2372 ==eHAL_STATUS_FAILURE)
2373 {
2374 hddLog(LOGE,
2375 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM\n");
2376 }
2377
Jeff Johnson4416a782013-03-25 14:17:50 -07002378 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002379 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
2380 eANI_BOOLEAN_FALSE) )
2381 {
2382 hddLog(LOGE,
2383 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
2384 }
2385
2386 // Reset WNI_CFG_PROBE_RSP Flags
2387 wlan_hdd_reset_prob_rspies(pAdapter);
2388
2389 pAdapter->sessionCtx.ap.beacon = NULL;
2390 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002391#ifdef WLAN_FEATURE_P2P_DEBUG
2392 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
2393 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
2394 {
2395 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
2396 "GO got removed");
2397 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
2398 }
2399#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002400 }
2401 EXIT();
2402 return status;
2403}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002404
2405#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2406
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302407static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
2408 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002409 struct cfg80211_ap_settings *params)
2410{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302411 hdd_adapter_t *pAdapter;
2412 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302413 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002414
2415 ENTER();
2416
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302417 if (NULL == dev)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002418 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302419 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302420 "%s: Device is Null", __func__);
2421 return -ENODEV;
2422 }
2423
2424 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2425 if (NULL == pAdapter)
2426 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302427 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302428 "%s: HDD adapter is Null", __func__);
2429 return -ENODEV;
2430 }
2431
2432 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
2433 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302434 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302435 "%s: HDD adapter magic is invalid", __func__);
2436 return -ENODEV;
2437 }
2438
2439 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302440 status = wlan_hdd_validate_context(pHddCtx);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302441
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302442 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302443 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302444 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2445 "%s: HDD context is not valid", __func__);
2446 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302447 }
2448
2449 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %d",
2450 __func__, pAdapter->device_mode);
2451
2452 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002453 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002454 )
2455 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302456 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002457
2458 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302459
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002460 if (old)
2461 return -EALREADY;
2462
2463 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, &params->beacon, params->dtim_period);
2464
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302465 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002466 {
2467 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302468 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002469 return -EINVAL;
2470 }
2471 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08002472#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07002473 wlan_hdd_cfg80211_set_channel(wiphy, dev,
2474#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
2475 params->channel, params->channel_type);
2476#else
2477 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
2478#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08002479#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002480 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
2481 params->ssid_len, params->hidden_ssid);
2482 }
2483
2484 EXIT();
2485 return status;
2486}
2487
2488
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302489static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002490 struct net_device *dev,
2491 struct cfg80211_beacon_data *params)
2492{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302493 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302494 hdd_context_t *pHddCtx;
2495 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002496
2497 ENTER();
2498
2499 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2500 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302501
2502 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2503 status = wlan_hdd_validate_context(pHddCtx);
2504
2505 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002506 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302507 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2508 "%s: HDD context is not valid", __func__);
2509 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002510 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002511
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302512 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002513 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302514 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002515 {
2516 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302517
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002518 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302519
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002520 if (!old)
2521 return -ENOENT;
2522
2523 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
2524
2525 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302526 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002527 "%s: Error!!! Allocating the new beacon\n",__func__);
2528 return -EINVAL;
2529 }
2530
2531 pAdapter->sessionCtx.ap.beacon = new;
2532
2533 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
2534 }
2535
2536 EXIT();
2537 return status;
2538}
2539
2540#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2541
Jeff Johnson295189b2012-06-20 16:38:30 -07002542
2543static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
2544 struct net_device *dev,
2545 struct bss_parameters *params)
2546{
2547 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2548
2549 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302550
Jeff Johnson295189b2012-06-20 16:38:30 -07002551 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2552 __func__,pAdapter->device_mode);
2553
2554 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002555 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302556 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002557 {
2558 /* ap_isolate == -1 means that in change bss, upper layer doesn't
2559 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302560 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07002561 {
2562 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302563 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002564 }
2565
2566 EXIT();
2567 return 0;
2568}
2569
Kiet Lam10841362013-11-01 11:36:50 +05302570/* FUNCTION: wlan_hdd_change_country_code_cd
2571* to wait for contry code completion
2572*/
2573void* wlan_hdd_change_country_code_cb(void *pAdapter)
2574{
2575 hdd_adapter_t *call_back_pAdapter = pAdapter;
2576 complete(&call_back_pAdapter->change_country_code);
2577 return NULL;
2578}
2579
Jeff Johnson295189b2012-06-20 16:38:30 -07002580/*
2581 * FUNCTION: wlan_hdd_cfg80211_change_iface
2582 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
2583 */
2584int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
2585 struct net_device *ndev,
2586 enum nl80211_iftype type,
2587 u32 *flags,
2588 struct vif_params *params
2589 )
2590{
2591 struct wireless_dev *wdev;
2592 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
2593 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Mohit Khanna0f232092012-09-11 14:46:08 -07002594 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002595 tCsrRoamProfile *pRoamProfile = NULL;
2596 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302597 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002598 eMib_dot11DesiredBssType connectedBssType;
2599 VOS_STATUS status;
2600
2601 ENTER();
2602
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302603 status = wlan_hdd_validate_context(pHddCtx);
2604
2605 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302607 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2608 "%s: HDD context is not valid", __func__);
2609 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002610 }
2611
2612 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
2613 __func__, pAdapter->device_mode);
2614
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302615 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07002616 wdev = ndev->ieee80211_ptr;
2617
2618#ifdef WLAN_BTAMP_FEATURE
2619 if((NL80211_IFTYPE_P2P_CLIENT == type)||
2620 (NL80211_IFTYPE_ADHOC == type)||
2621 (NL80211_IFTYPE_AP == type)||
2622 (NL80211_IFTYPE_P2P_GO == type))
2623 {
2624 pHddCtx->isAmpAllowed = VOS_FALSE;
2625 // stop AMP traffic
2626 status = WLANBAP_StopAmp();
2627 if(VOS_STATUS_SUCCESS != status )
2628 {
2629 pHddCtx->isAmpAllowed = VOS_TRUE;
2630 hddLog(VOS_TRACE_LEVEL_FATAL,
2631 "%s: Failed to stop AMP", __func__);
2632 return -EINVAL;
2633 }
2634 }
2635#endif //WLAN_BTAMP_FEATURE
2636 /* Reset the current device mode bit mask*/
2637 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
2638
2639 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07002640 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07002641 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002642 )
2643 {
2644 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2645 pRoamProfile = &pWextState->roamProfile;
2646 LastBSSType = pRoamProfile->BSSType;
2647
2648 switch (type)
2649 {
2650 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002651 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002652 hddLog(VOS_TRACE_LEVEL_INFO,
2653 "%s: setting interface Type to INFRASTRUCTURE", __func__);
2654 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002655#ifdef WLAN_FEATURE_11AC
2656 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
2657 {
2658 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
2659 }
2660#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302661 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07002662 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002663 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002664 //Check for sub-string p2p to confirm its a p2p interface
2665 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302666 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002667 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2668 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2669 }
2670 else
2671 {
2672 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002673 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002674 }
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05302675#ifdef FEATURE_WLAN_TDLS
2676 /* The open adapter for the p2p shall skip initializations in
2677 * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for
2678 * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke
2679 * tdls_init when the change_iface sets the device mode to
2680 * WLAN_HDD_P2P_CLIENT.
2681 */
2682
2683 if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2684 {
2685 if (0 != wlan_hdd_tdls_init (pAdapter))
2686 {
2687 return -EINVAL;
2688 }
2689 }
2690#endif
2691
Jeff Johnson295189b2012-06-20 16:38:30 -07002692 break;
2693 case NL80211_IFTYPE_ADHOC:
2694 hddLog(VOS_TRACE_LEVEL_INFO,
2695 "%s: setting interface Type to ADHOC", __func__);
2696 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2697 pRoamProfile->phyMode =
2698 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002699 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002700 wdev->iftype = type;
2701 break;
2702
2703 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002704 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002705 {
2706 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2707 "%s: setting interface Type to %s", __func__,
2708 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
2709
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002710 //Cancel any remain on channel for GO mode
2711 if (NL80211_IFTYPE_P2P_GO == type)
2712 {
2713 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
2714 }
Mohit Khanna0f232092012-09-11 14:46:08 -07002715 if (NL80211_IFTYPE_AP == type)
2716 {
2717 /* As Loading WLAN Driver one interface being created for p2p device
2718 * address. This will take one HW STA and the max number of clients
2719 * that can connect to softAP will be reduced by one. so while changing
2720 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
2721 * interface as it is not required in SoftAP mode.
2722 */
2723
2724 // Get P2P Adapter
2725 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
2726
2727 if (pP2pAdapter)
2728 {
2729 hdd_stop_adapter(pHddCtx, pP2pAdapter);
2730 hdd_deinit_adapter(pHddCtx, pP2pAdapter);
2731 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
2732 }
2733 }
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302734#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07002735
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302736 /* A Mutex Lock is introduced while changing the mode to
2737 * protect the concurrent access for the Adapters by TDLS
2738 * module.
2739 */
2740 if (mutex_lock_interruptible(&pHddCtx->tdls_lock))
2741 {
2742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2743 "%s: unable to lock list", __func__);
2744 return -EINVAL;
2745 }
2746#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002747 //De-init the adapter.
2748 hdd_stop_adapter( pHddCtx, pAdapter );
2749 hdd_deinit_adapter( pHddCtx, pAdapter );
2750 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07002751 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2752 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302753#ifdef FEATURE_WLAN_TDLS
2754 mutex_unlock(&pHddCtx->tdls_lock);
2755#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07002756
2757 //Disable BMPS and IMPS if enabled
2758 //before starting Go
2759 if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
2760 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302761 if(VOS_STATUS_E_FAILURE ==
Jeff Johnson32d95a32012-09-10 13:15:23 -07002762 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
2763 {
2764 //Fail to Exit BMPS
2765 VOS_ASSERT(0);
2766 }
2767 }
2768
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07002769 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
2770 (pConfig->apRandomBssidEnabled))
2771 {
2772 /* To meet Android requirements create a randomized
2773 MAC address of the form 02:1A:11:Fx:xx:xx */
2774 get_random_bytes(&ndev->dev_addr[3], 3);
2775 ndev->dev_addr[0] = 0x02;
2776 ndev->dev_addr[1] = 0x1A;
2777 ndev->dev_addr[2] = 0x11;
2778 ndev->dev_addr[3] |= 0xF0;
2779 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
2780 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08002781 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
2782 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07002783 }
2784
Jeff Johnson295189b2012-06-20 16:38:30 -07002785 hdd_set_ap_ops( pAdapter->dev );
2786
Kiet Lam10841362013-11-01 11:36:50 +05302787 /* This is for only SAP mode where users can
2788 * control country through ini.
2789 * P2P GO follows station country code
2790 * acquired during the STA scanning. */
2791 if((NL80211_IFTYPE_AP == type) &&
2792 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
2793 {
2794 int status = 0;
2795 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
2796 "%s: setting country code from INI ", __func__);
2797 init_completion(&pAdapter->change_country_code);
2798 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
2799 (void *)(tSmeChangeCountryCallback)
2800 wlan_hdd_change_country_code_cb,
2801 pConfig->apCntryCode, pAdapter,
2802 pHddCtx->pvosContext,
2803 VOS_FALSE);
2804 if (eHAL_STATUS_SUCCESS == status)
2805 {
2806 /* Wait for completion */
2807 status = wait_for_completion_interruptible_timeout(
2808 &pAdapter->change_country_code,
2809 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
2810 if (status <= 0)
2811 {
2812 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2813 "%s: SME Timed out while setting country code ",
2814 __func__);
2815 }
2816 }
2817 else
2818 {
2819 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2820 "%s: SME Change Country code failed \n",__func__);
2821 return -EINVAL;
2822 }
2823 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002824 status = hdd_init_ap_mode(pAdapter);
2825 if(status != VOS_STATUS_SUCCESS)
2826 {
2827 hddLog(VOS_TRACE_LEVEL_FATAL,
2828 "%s: Error initializing the ap mode", __func__);
2829 return -EINVAL;
2830 }
2831 hdd_set_conparam(1);
2832
Jeff Johnson295189b2012-06-20 16:38:30 -07002833 /*interface type changed update in wiphy structure*/
2834 if(wdev)
2835 {
2836 wdev->iftype = type;
2837 pHddCtx->change_iface = type;
2838 }
2839 else
2840 {
2841 hddLog(VOS_TRACE_LEVEL_ERROR,
2842 "%s: ERROR !!!! Wireless dev is NULL", __func__);
2843 return -EINVAL;
2844 }
2845 goto done;
2846 }
2847
2848 default:
2849 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2850 __func__);
2851 return -EOPNOTSUPP;
2852 }
2853 }
2854 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002855 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002856 )
2857 {
2858 switch(type)
2859 {
2860 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002861 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002862 case NL80211_IFTYPE_ADHOC:
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302863#ifdef FEATURE_WLAN_TDLS
2864
2865 /* A Mutex Lock is introduced while changing the mode to
2866 * protect the concurrent access for the Adapters by TDLS
2867 * module.
2868 */
2869 if (mutex_lock_interruptible(&pHddCtx->tdls_lock))
2870 {
2871 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2872 "%s: unable to lock list", __func__);
2873 return -EINVAL;
2874 }
2875#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07002876 hdd_stop_adapter( pHddCtx, pAdapter );
2877 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002879 //Check for sub-string p2p to confirm its a p2p interface
2880 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002881 {
2882 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2883 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2884 }
2885 else
2886 {
2887 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002889 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002890 hdd_set_conparam(0);
2891 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002892 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
2893 hdd_set_station_ops( pAdapter->dev );
2894 status = hdd_init_station_mode( pAdapter );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302895#ifdef FEATURE_WLAN_TDLS
2896 mutex_unlock(&pHddCtx->tdls_lock);
2897#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002898 if( VOS_STATUS_SUCCESS != status )
2899 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07002900 /* In case of JB, for P2P-GO, only change interface will be called,
2901 * This is the right place to enable back bmps_imps()
2902 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302903 if (pHddCtx->hdd_wlan_suspended)
2904 {
2905 hdd_set_pwrparams(pHddCtx);
2906 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002907 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07002908 goto done;
2909 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002910 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002911 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002912 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2913 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002914 goto done;
2915 default:
2916 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2917 __func__);
2918 return -EOPNOTSUPP;
2919
2920 }
2921
2922 }
2923 else
2924 {
2925 return -EOPNOTSUPP;
2926 }
2927
2928
2929 if(pRoamProfile)
2930 {
2931 if ( LastBSSType != pRoamProfile->BSSType )
2932 {
2933 /*interface type changed update in wiphy structure*/
2934 wdev->iftype = type;
2935
2936 /*the BSS mode changed, We need to issue disconnect
2937 if connected or in IBSS disconnect state*/
2938 if ( hdd_connGetConnectedBssType(
2939 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
2940 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
2941 {
2942 /*need to issue a disconnect to CSR.*/
2943 INIT_COMPLETION(pAdapter->disconnect_comp_var);
2944 if( eHAL_STATUS_SUCCESS ==
2945 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
2946 pAdapter->sessionId,
2947 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
2948 {
2949 wait_for_completion_interruptible_timeout(
2950 &pAdapter->disconnect_comp_var,
2951 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
2952 }
2953 }
2954 }
2955 }
2956
2957done:
2958 /*set bitmask based on updated value*/
2959 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07002960
2961 /* Only STA mode support TM now
2962 * all other mode, TM feature should be disabled */
2963 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
2964 (~VOS_STA & pHddCtx->concurrency_mode) )
2965 {
2966 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
2967 }
2968
Jeff Johnson295189b2012-06-20 16:38:30 -07002969#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302970 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002971 (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
2972 {
2973 //we are ok to do AMP
2974 pHddCtx->isAmpAllowed = VOS_TRUE;
2975 }
2976#endif //WLAN_BTAMP_FEATURE
2977 EXIT();
2978 return 0;
2979}
2980
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002981#ifdef FEATURE_WLAN_TDLS
2982static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
2983 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
2984{
2985 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2986 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2987 VOS_STATUS status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002988 hddTdlsPeer_t *pTdlsPeer;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002989
2990 ENTER();
2991
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05302992 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002993 {
2994 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2995 "Invalid arguments");
2996 return -EINVAL;
2997 }
Hoonki Lee27511902013-03-14 18:19:06 -07002998
2999 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
3000 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
3001 {
3002 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3003 "%s: TDLS mode is disabled OR not enabled in FW."
3004 MAC_ADDRESS_STR " Request declined.",
3005 __func__, MAC_ADDR_ARRAY(mac));
3006 return -ENOTSUPP;
3007 }
3008
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003009 if (pHddCtx->isLogpInProgress)
3010 {
3011 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3012 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07003013 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003014 return -EBUSY;
3015 }
3016
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303017 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003018
3019 if ( NULL == pTdlsPeer ) {
3020 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3021 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
3022 __func__, MAC_ADDR_ARRAY(mac), update);
3023 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003024 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003025
3026 /* in add station, we accept existing valid staId if there is */
3027 if ((0 == update) &&
3028 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
3029 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003030 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003031 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003032 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003033 " link_status %d. staId %d. add station ignored.",
3034 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
3035 return 0;
3036 }
3037 /* in change station, we accept only when staId is valid */
3038 if ((1 == update) &&
3039 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
3040 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
3041 {
3042 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3043 "%s: " MAC_ADDRESS_STR
3044 " link status %d. staId %d. change station %s.",
3045 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
3046 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
3047 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003048 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003049
3050 /* when others are on-going, we want to change link_status to idle */
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303051 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003052 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003053 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3054 "%s: " MAC_ADDRESS_STR
3055 " TDLS setup is ongoing. Request declined.",
3056 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07003057 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003058 }
3059
3060 /* first to check if we reached to maximum supported TDLS peer.
3061 TODO: for now, return -EPERM looks working fine,
3062 but need to check if any other errno fit into this category.*/
3063 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
3064 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003065 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3066 "%s: " MAC_ADDRESS_STR
3067 " TDLS Max peer already connected. Request declined.",
3068 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07003069 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003070 }
3071 else
3072 {
3073 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303074 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003075 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003076 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003077 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3078 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
3079 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003080 return -EPERM;
3081 }
3082 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003083 if (0 == update)
3084 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003085
Jeff Johnsond75fe012013-04-06 10:53:06 -07003086 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303087 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003088 {
3089 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3090 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003091 if(StaParams->htcap_present)
3092 {
3093 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3094 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
3095 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3096 "ht_capa->extended_capabilities: %0x",
3097 StaParams->HTCap.extendedHtCapInfo);
3098 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003099 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3100 "params->capability: %0x",StaParams->capability);
3101 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003102 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003103 if(StaParams->vhtcap_present)
3104 {
3105 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3106 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
3107 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
3108 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
3109 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003110 {
3111 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003112 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003113 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
3114 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3115 "[%d]: %x ", i, StaParams->supported_rates[i]);
3116 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07003117 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303118 else if ((1 == update) && (NULL == StaParams))
3119 {
3120 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3121 "%s : update is true, but staParams is NULL. Error!", __func__);
3122 return -EPERM;
3123 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003124
3125 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
3126
3127 if (!update)
3128 {
3129 status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3130 pAdapter->sessionId, mac);
3131 }
3132 else
3133 {
3134 status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3135 pAdapter->sessionId, mac, StaParams);
3136 }
3137
3138 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
3139 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
3140
3141 if (!status)
3142 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003143 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003144 "%s: timeout waiting for tdls add station indication",
3145 __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003146 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003147 }
3148 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
3149 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003150 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003151 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003152 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003153 }
3154
3155 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07003156
3157error:
3158 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
3159 return -EPERM;
3160
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003161}
3162#endif
3163
Jeff Johnson295189b2012-06-20 16:38:30 -07003164static int wlan_hdd_change_station(struct wiphy *wiphy,
3165 struct net_device *dev,
3166 u8 *mac,
3167 struct station_parameters *params)
3168{
3169 VOS_STATUS status = VOS_STATUS_SUCCESS;
3170 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkala29149562013-05-10 21:43:41 +05303171 hdd_context_t *pHddCtx;
3172 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003173 v_MACADDR_t STAMacAddress;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003174#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003175 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003176 tANI_U8 isBufSta = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003177#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003178 ENTER();
3179
Gopichand Nakkala29149562013-05-10 21:43:41 +05303180 if ((NULL == pAdapter))
3181 {
3182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3183 "invalid adapter ");
3184 return -EINVAL;
3185 }
3186
3187 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3188 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3189
3190 if ((NULL == pHddCtx) || (NULL == pHddStaCtx))
3191 {
3192 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3193 "invalid HDD state or HDD station context");
3194 return -EINVAL;
3195 }
3196
3197 if (pHddCtx->isLogpInProgress)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003198 {
3199 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3200 "%s:LOGP in Progress. Ignore!!!", __func__);
3201 return -EAGAIN;
3202 }
3203
Jeff Johnson295189b2012-06-20 16:38:30 -07003204 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
3205
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003206 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
3207 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07003208 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003209 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07003210 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303211 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07003212 WLANTL_STA_AUTHENTICATED);
3213
Gopichand Nakkala29149562013-05-10 21:43:41 +05303214 if (status != VOS_STATUS_SUCCESS)
3215 {
3216 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3217 "%s: Not able to change TL state to AUTHENTICATED", __func__);
3218 return -EINVAL;
3219 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003220 }
3221 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07003222 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
3223 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303224#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003225 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
3226 StaParams.capability = params->capability;
3227 StaParams.uapsd_queues = params->uapsd_queues;
3228 StaParams.max_sp = params->max_sp;
3229
3230 if (0 != params->ext_capab_len)
3231 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
3232 sizeof(StaParams.extn_capability));
3233
3234 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003235 {
3236 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003237 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003238 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003239
3240 StaParams.supported_rates_len = params->supported_rates_len;
3241
3242 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
3243 * The supported_rates array , for all the structures propogating till Add Sta
3244 * to the firmware has to be modified , if the supplicant (ieee80211) is
3245 * modified to send more rates.
3246 */
3247
3248 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
3249 */
3250 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
3251 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
3252
3253 if (0 != StaParams.supported_rates_len) {
3254 int i = 0;
3255 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
3256 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003257 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003258 "Supported Rates with Length %d", StaParams.supported_rates_len);
3259 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003260 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003261 "[%d]: %0x", i, StaParams.supported_rates[i]);
3262 }
3263
3264 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003265 {
3266 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003267 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003268 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003269
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003270 if (0 != params->ext_capab_len ) {
3271 /*Define A Macro : TODO Sunil*/
3272 if ((1<<4) & StaParams.extn_capability[3]) {
3273 isBufSta = 1;
3274 }
3275 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303276 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac, params->uapsd_queues,
3277 params->max_sp, isBufSta);
3278 if (VOS_STATUS_SUCCESS != status) {
3279 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3280 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
3281 return -EINVAL;
3282 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003283 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
3284
3285 if (VOS_STATUS_SUCCESS != status) {
3286 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3287 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
3288 return -EINVAL;
3289 }
3290 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003291#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05303292 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003293 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003294 return status;
3295}
3296
3297/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003298 * FUNCTION: wlan_hdd_cfg80211_add_key
3299 * This function is used to initialize the key information
3300 */
3301#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003302static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003303 struct net_device *ndev,
3304 u8 key_index, bool pairwise,
3305 const u8 *mac_addr,
3306 struct key_params *params
3307 )
3308#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003309static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003310 struct net_device *ndev,
3311 u8 key_index, const u8 *mac_addr,
3312 struct key_params *params
3313 )
3314#endif
3315{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003316 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003317 tCsrRoamSetKey setKey;
3318 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303319 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003320 v_U32_t roamId= 0xFF;
3321 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003322 hdd_hostapd_state_t *pHostapdState;
3323 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003324 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303325 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003326
3327 ENTER();
3328
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303329 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3330 status = wlan_hdd_validate_context(pHddCtx);
3331
3332 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003333 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303334 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3335 "%s: HDD context is not valid", __func__);
3336 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003337 }
3338
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003339 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
3340 __func__, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003341
3342 if (CSR_MAX_NUM_KEY <= key_index)
3343 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003344 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003345 key_index);
3346
3347 return -EINVAL;
3348 }
3349
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003350 if (CSR_MAX_KEY_LEN < params->key_len)
3351 {
3352 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
3353 params->key_len);
3354
3355 return -EINVAL;
3356 }
3357
3358 hddLog(VOS_TRACE_LEVEL_INFO,
3359 "%s: called with key index = %d & key length %d",
3360 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003361
3362 /*extract key idx, key len and key*/
3363 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3364 setKey.keyId = key_index;
3365 setKey.keyLength = params->key_len;
3366 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
3367
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003368 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07003369 {
3370 case WLAN_CIPHER_SUITE_WEP40:
3371 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3372 break;
3373
3374 case WLAN_CIPHER_SUITE_WEP104:
3375 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3376 break;
3377
3378 case WLAN_CIPHER_SUITE_TKIP:
3379 {
3380 u8 *pKey = &setKey.Key[0];
3381 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3382
3383 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3384
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003385 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07003386
3387 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003388 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003389 |--------------|----------|----------|
3390 <---16bytes---><--8bytes--><--8bytes-->
3391
3392 */
3393 /*Sme expects the 32 bytes key to be in the below order
3394
3395 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003396 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003397 |--------------|----------|----------|
3398 <---16bytes---><--8bytes--><--8bytes-->
3399 */
3400 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003401 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07003402
3403 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003404 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003405
3406 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003407 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003408
3409
3410 break;
3411 }
3412
3413 case WLAN_CIPHER_SUITE_CCMP:
3414 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3415 break;
3416
3417#ifdef FEATURE_WLAN_WAPI
3418 case WLAN_CIPHER_SUITE_SMS4:
3419 {
3420 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3421 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
3422 params->key, params->key_len);
3423 return 0;
3424 }
3425#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003426
Jeff Johnson295189b2012-06-20 16:38:30 -07003427#ifdef FEATURE_WLAN_CCX
3428 case WLAN_CIPHER_SUITE_KRK:
3429 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3430 break;
3431#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003432
3433#ifdef WLAN_FEATURE_11W
3434 case WLAN_CIPHER_SUITE_AES_CMAC:
3435 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07003436 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07003437#endif
3438
Jeff Johnson295189b2012-06-20 16:38:30 -07003439 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003440 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07003441 __func__, params->cipher);
3442 return -EOPNOTSUPP;
3443 }
3444
3445 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
3446 __func__, setKey.encType);
3447
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003448 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07003449#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3450 (!pairwise)
3451#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003452 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07003453#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003454 )
3455 {
3456 /* set group key*/
3457 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3458 "%s- %d: setting Broadcast key",
3459 __func__, __LINE__);
3460 setKey.keyDirection = eSIR_RX_ONLY;
3461 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3462 }
3463 else
3464 {
3465 /* set pairwise key*/
3466 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3467 "%s- %d: setting pairwise key",
3468 __func__, __LINE__);
3469 setKey.keyDirection = eSIR_TX_RX;
3470 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3471 }
3472 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
3473 {
3474 setKey.keyDirection = eSIR_TX_RX;
3475 /*Set the group key*/
3476 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3477 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003478
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003479 if ( 0 != status )
3480 {
3481 hddLog(VOS_TRACE_LEVEL_ERROR,
3482 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3483 return -EINVAL;
3484 }
3485 /*Save the keys here and call sme_RoamSetKey for setting
3486 the PTK after peer joins the IBSS network*/
3487 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
3488 &setKey, sizeof(tCsrRoamSetKey));
3489 return status;
3490 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05303491 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
3492 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
3493 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003494 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003495 if( pHostapdState->bssState == BSS_START )
3496 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003497 status = WLANSAP_SetKeySta( pVosContext, &setKey);
3498
3499 if ( status != eHAL_STATUS_SUCCESS )
3500 {
3501 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3502 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3503 __LINE__, status );
3504 }
3505 }
3506
3507 /* Saving WEP keys */
3508 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
3509 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
3510 {
3511 //Save the wep key in ap context. Issue setkey after the BSS is started.
3512 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3513 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
3514 }
3515 else
3516 {
3517 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003518 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003519 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
3520 }
3521 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003522 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
3523 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003524 {
3525 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3526 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3527
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303528#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3529 if (!pairwise)
3530#else
3531 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
3532#endif
3533 {
3534 /* set group key*/
3535 if (pHddStaCtx->roam_info.deferKeyComplete)
3536 {
3537 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3538 "%s- %d: Perform Set key Complete",
3539 __func__, __LINE__);
3540 hdd_PerformRoamSetKeyComplete(pAdapter);
3541 }
3542 }
3543
Jeff Johnson295189b2012-06-20 16:38:30 -07003544 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
3545
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08003546 pWextState->roamProfile.Keys.defaultIndex = key_index;
3547
3548
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003549 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003550 params->key, params->key_len);
3551
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303552
Jeff Johnson295189b2012-06-20 16:38:30 -07003553 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3554
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303555 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003556 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303557 __func__, setKey.peerMac[0], setKey.peerMac[1],
3558 setKey.peerMac[2], setKey.peerMac[3],
3559 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003560 setKey.keyDirection);
3561
3562 vos_status = wlan_hdd_check_ula_done(pAdapter);
3563
3564 if ( vos_status != VOS_STATUS_SUCCESS )
3565 {
3566 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3567 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3568 __LINE__, vos_status );
3569
3570 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3571
3572 return -EINVAL;
3573
3574 }
3575
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003576#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303577 /* The supplicant may attempt to set the PTK once pre-authentication
3578 is done. Save the key in the UMAC and include it in the ADD BSS
3579 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003580 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303581 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003582 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303583 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3584 "%s: Update PreAuth Key success", __func__);
3585 return 0;
3586 }
3587 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3588 {
3589 hddLog(VOS_TRACE_LEVEL_ERROR,
3590 "%s: Update PreAuth Key failed", __func__);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05303591 return -EINVAL;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003592 }
3593#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07003594
3595 /* issue set key request to SME*/
3596 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3597 pAdapter->sessionId, &setKey, &roamId );
3598
3599 if ( 0 != status )
3600 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303601 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003602 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3603 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3604 return -EINVAL;
3605 }
3606
3607
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303608 /* in case of IBSS as there was no information available about WEP keys during
3609 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07003610 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303611 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
3612 !( ( IW_AUTH_KEY_MGMT_802_1X
3613 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003614 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
3615 )
3616 &&
3617 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
3618 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
3619 )
3620 )
3621 {
3622 setKey.keyDirection = eSIR_RX_ONLY;
3623 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3624
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303625 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003626 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303627 __func__, setKey.peerMac[0], setKey.peerMac[1],
3628 setKey.peerMac[2], setKey.peerMac[3],
3629 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003630 setKey.keyDirection);
3631
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303632 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003633 pAdapter->sessionId, &setKey, &roamId );
3634
3635 if ( 0 != status )
3636 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303637 hddLog(VOS_TRACE_LEVEL_ERROR,
3638 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003639 __func__, status);
3640 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3641 return -EINVAL;
3642 }
3643 }
3644 }
3645
3646 return 0;
3647}
3648
3649/*
3650 * FUNCTION: wlan_hdd_cfg80211_get_key
3651 * This function is used to get the key information
3652 */
3653#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303654static int wlan_hdd_cfg80211_get_key(
3655 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003656 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303657 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003658 const u8 *mac_addr, void *cookie,
3659 void (*callback)(void *cookie, struct key_params*)
3660 )
3661#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303662static int wlan_hdd_cfg80211_get_key(
3663 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003664 struct net_device *ndev,
3665 u8 key_index, const u8 *mac_addr, void *cookie,
3666 void (*callback)(void *cookie, struct key_params*)
3667 )
3668#endif
3669{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303670 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003671 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3672 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3673 struct key_params params;
3674
3675 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303676
Jeff Johnson295189b2012-06-20 16:38:30 -07003677 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
3678 __func__,pAdapter->device_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303679
Jeff Johnson295189b2012-06-20 16:38:30 -07003680 memset(&params, 0, sizeof(params));
3681
3682 if (CSR_MAX_NUM_KEY <= key_index)
3683 {
3684 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303685 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003686
3687 switch(pRoamProfile->EncryptionType.encryptionType[0])
3688 {
3689 case eCSR_ENCRYPT_TYPE_NONE:
3690 params.cipher = IW_AUTH_CIPHER_NONE;
3691 break;
3692
3693 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3694 case eCSR_ENCRYPT_TYPE_WEP40:
3695 params.cipher = WLAN_CIPHER_SUITE_WEP40;
3696 break;
3697
3698 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3699 case eCSR_ENCRYPT_TYPE_WEP104:
3700 params.cipher = WLAN_CIPHER_SUITE_WEP104;
3701 break;
3702
3703 case eCSR_ENCRYPT_TYPE_TKIP:
3704 params.cipher = WLAN_CIPHER_SUITE_TKIP;
3705 break;
3706
3707 case eCSR_ENCRYPT_TYPE_AES:
3708 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
3709 break;
3710
3711 default:
3712 params.cipher = IW_AUTH_CIPHER_NONE;
3713 break;
3714 }
3715
3716 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
3717 params.seq_len = 0;
3718 params.seq = NULL;
3719 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
3720 callback(cookie, &params);
3721 return 0;
3722}
3723
3724/*
3725 * FUNCTION: wlan_hdd_cfg80211_del_key
3726 * This function is used to delete the key information
3727 */
3728#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303729static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003730 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303731 u8 key_index,
3732 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003733 const u8 *mac_addr
3734 )
3735#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303736static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003737 struct net_device *ndev,
3738 u8 key_index,
3739 const u8 *mac_addr
3740 )
3741#endif
3742{
3743 int status = 0;
3744
3745 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303746 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07003747 //it is observed that this is invalidating peer
3748 //key index whenever re-key is done. This is affecting data link.
3749 //It should be ok to ignore del_key.
3750#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303751 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
3752 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003753 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3754 tCsrRoamSetKey setKey;
3755 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303756
Jeff Johnson295189b2012-06-20 16:38:30 -07003757 ENTER();
3758
3759 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
3760 __func__,pAdapter->device_mode);
3761
3762 if (CSR_MAX_NUM_KEY <= key_index)
3763 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303764 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003765 key_index);
3766
3767 return -EINVAL;
3768 }
3769
3770 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3771 setKey.keyId = key_index;
3772
3773 if (mac_addr)
3774 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3775 else
3776 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
3777
3778 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3779
3780 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07003781 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303782 )
3783 {
3784
3785 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07003786 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
3787 if( pHostapdState->bssState == BSS_START)
3788 {
3789 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303790
Jeff Johnson295189b2012-06-20 16:38:30 -07003791 if ( status != eHAL_STATUS_SUCCESS )
3792 {
3793 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3794 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3795 __LINE__, status );
3796 }
3797 }
3798 }
3799 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303800 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07003801 )
3802 {
3803 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3804
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303805 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3806
3807 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003808 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303809 __func__, setKey.peerMac[0], setKey.peerMac[1],
3810 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07003811 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303812 if(pAdapter->sessionCtx.station.conn_info.connState ==
3813 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07003814 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303815 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003816 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303817
Jeff Johnson295189b2012-06-20 16:38:30 -07003818 if ( 0 != status )
3819 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303820 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003821 "%s: sme_RoamSetKey failure, returned %d",
3822 __func__, status);
3823 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3824 return -EINVAL;
3825 }
3826 }
3827 }
3828#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003829 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003830 return status;
3831}
3832
3833/*
3834 * FUNCTION: wlan_hdd_cfg80211_set_default_key
3835 * This function is used to set the default tx key index
3836 */
3837#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3838static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3839 struct net_device *ndev,
3840 u8 key_index,
3841 bool unicast, bool multicast)
3842#else
3843static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3844 struct net_device *ndev,
3845 u8 key_index)
3846#endif
3847{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303848 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303849 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05303850 hdd_wext_state_t *pWextState;
3851 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303852 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003853
3854 ENTER();
3855
Gopichand Nakkala29149562013-05-10 21:43:41 +05303856 if ((NULL == pAdapter))
3857 {
3858 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3859 "invalid adapter");
3860 return -EINVAL;
3861 }
3862
3863 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3864 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3865
3866 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3867 {
3868 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3869 "invalid Wext state or HDD context");
3870 return -EINVAL;
3871 }
3872
Jeff Johnson295189b2012-06-20 16:38:30 -07003873 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d \n",
3874 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303875
Jeff Johnson295189b2012-06-20 16:38:30 -07003876 if (CSR_MAX_NUM_KEY <= key_index)
3877 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303878 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003879 key_index);
3880
3881 return -EINVAL;
3882 }
3883
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303884 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3885 status = wlan_hdd_validate_context(pHddCtx);
3886
3887 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003888 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303889 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3890 "%s: HDD context is not valid", __func__);
3891 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003892 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303893
Jeff Johnson295189b2012-06-20 16:38:30 -07003894 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07003895 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303896 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003897 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303898 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08003899 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303900 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08003901 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07003902 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303903 {
3904 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07003905 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303906
Jeff Johnson295189b2012-06-20 16:38:30 -07003907 tCsrRoamSetKey setKey;
3908 v_U32_t roamId= 0xFF;
3909 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303910
3911 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003912 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303913
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 Keys->defaultIndex = (u8)key_index;
3915 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3916 setKey.keyId = key_index;
3917 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303918
3919 vos_mem_copy(&setKey.Key[0],
3920 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003921 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303922
Gopichand Nakkala29149562013-05-10 21:43:41 +05303923 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303924
3925 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 &pHddStaCtx->conn_info.bssId[0],
3927 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303928
Gopichand Nakkala29149562013-05-10 21:43:41 +05303929 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
3930 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
3931 eCSR_ENCRYPT_TYPE_WEP104)
3932 {
3933 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
3934 even though ap is configured for WEP-40 encryption. In this canse the key length
3935 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
3936 type(104) and switching encryption type to 40*/
3937 pWextState->roamProfile.EncryptionType.encryptionType[0] =
3938 eCSR_ENCRYPT_TYPE_WEP40;
3939 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
3940 eCSR_ENCRYPT_TYPE_WEP40;
3941 }
3942
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303943 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07003944 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303945
Jeff Johnson295189b2012-06-20 16:38:30 -07003946 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303947 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003948 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303949
Jeff Johnson295189b2012-06-20 16:38:30 -07003950 if ( 0 != status )
3951 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303952 hddLog(VOS_TRACE_LEVEL_ERROR,
3953 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003954 status);
3955 return -EINVAL;
3956 }
3957 }
3958 }
3959
3960 /* In SoftAp mode setting key direction for default mode */
3961 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
3962 {
3963 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
3964 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
3965 (eCSR_ENCRYPT_TYPE_AES !=
3966 pWextState->roamProfile.EncryptionType.encryptionType[0])
3967 )
3968 {
3969 /* Saving key direction for default key index to TX default */
3970 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3971 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
3972 }
3973 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303974
Jeff Johnson295189b2012-06-20 16:38:30 -07003975 return status;
3976}
3977
Jeff Johnson295189b2012-06-20 16:38:30 -07003978/*
3979 * FUNCTION: wlan_hdd_cfg80211_inform_bss
3980 * This function is used to inform the BSS details to nl80211 interface.
3981 */
3982static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
3983 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
3984{
3985 struct net_device *dev = pAdapter->dev;
3986 struct wireless_dev *wdev = dev->ieee80211_ptr;
3987 struct wiphy *wiphy = wdev->wiphy;
3988 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
3989 int chan_no;
3990 int ie_length;
3991 const char *ie;
3992 unsigned int freq;
3993 struct ieee80211_channel *chan;
3994 int rssi = 0;
3995 struct cfg80211_bss *bss = NULL;
3996
3997 ENTER();
3998
3999 if( NULL == pBssDesc )
4000 {
4001 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL\n", __func__);
4002 return bss;
4003 }
4004
4005 chan_no = pBssDesc->channelId;
4006 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
4007 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
4008
4009 if( NULL == ie )
4010 {
4011 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL\n", __func__);
4012 return bss;
4013 }
4014
4015#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
4016 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
4017 {
4018 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4019 }
4020 else
4021 {
4022 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4023 }
4024#else
4025 freq = ieee80211_channel_to_frequency(chan_no);
4026#endif
4027
4028 chan = __ieee80211_get_channel(wiphy, freq);
4029
4030 bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId,
4031 &roamProfile->SSID.ssId[0], roamProfile->SSID.length,
4032 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
4033 if (bss == NULL)
4034 {
4035 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
4036
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304037 return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
4038 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07004039 pBssDesc->capabilityInfo,
4040 pBssDesc->beaconInterval, ie, ie_length,
4041 rssi, GFP_KERNEL ));
4042}
4043 else
4044 {
4045 return bss;
4046 }
4047}
4048
4049
4050
4051/*
4052 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
4053 * This function is used to inform the BSS details to nl80211 interface.
4054 */
4055struct cfg80211_bss*
4056wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
4057 tSirBssDescription *bss_desc
4058 )
4059{
4060 /*
4061 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
4062 already exists in bss data base of cfg80211 for that particular BSS ID.
4063 Using cfg80211_inform_bss_frame to update the bss entry instead of
4064 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
4065 now there is no possibility to get the mgmt(probe response) frame from PE,
4066 converting bss_desc to ieee80211_mgmt(probe response) and passing to
4067 cfg80211_inform_bss_frame.
4068 */
4069 struct net_device *dev = pAdapter->dev;
4070 struct wireless_dev *wdev = dev->ieee80211_ptr;
4071 struct wiphy *wiphy = wdev->wiphy;
4072 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004073#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4074 qcom_ie_age *qie_age = NULL;
4075 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
4076#else
Jeff Johnson295189b2012-06-20 16:38:30 -07004077 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004078#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004079 const char *ie =
4080 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
4081 unsigned int freq;
4082 struct ieee80211_channel *chan;
4083 struct ieee80211_mgmt *mgmt =
4084 kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
4085 struct cfg80211_bss *bss_status = NULL;
4086 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
4087 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07004088 hdd_context_t *pHddCtx;
4089 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07004090#ifdef WLAN_OPEN_SOURCE
4091 struct timespec ts;
4092#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004093
4094 ENTER();
4095
Wilson Yangf80a0542013-10-07 13:02:37 -07004096 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4097 status = wlan_hdd_validate_context(pHddCtx);
4098
4099 /*bss_update is not allowed during wlan driver loading or unloading*/
4100 if (pHddCtx->isLoadUnloadInProgress)
4101 {
4102 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4103 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
4104 return NULL;
4105 }
4106
4107
4108 if (0 != status)
4109 {
4110 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4111 "%s: HDD context is not valid", __func__);
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07004112 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07004113 }
4114
4115
4116 if (!mgmt)
4117 {
4118 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4119 "%s: memory allocation failed ", __func__);
4120 return NULL;
4121 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07004122
Jeff Johnson295189b2012-06-20 16:38:30 -07004123 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07004124
4125#ifdef WLAN_OPEN_SOURCE
4126 /* Android does not want the timestamp from the frame.
4127 Instead it wants a monotonic increasing value */
4128 get_monotonic_boottime(&ts);
4129 mgmt->u.probe_resp.timestamp =
4130 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
4131#else
4132 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07004133 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
4134 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07004135
4136#endif
4137
Jeff Johnson295189b2012-06-20 16:38:30 -07004138 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
4139 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004140
4141#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4142 /* GPS Requirement: need age ie per entry. Using vendor specific. */
4143 /* Assuming this is the last IE, copy at the end */
4144 ie_length -=sizeof(qcom_ie_age);
4145 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
4146 qie_age->element_id = QCOM_VENDOR_IE_ID;
4147 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
4148 qie_age->oui_1 = QCOM_OUI1;
4149 qie_age->oui_2 = QCOM_OUI2;
4150 qie_age->oui_3 = QCOM_OUI3;
4151 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
4152 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
4153#endif
4154
Jeff Johnson295189b2012-06-20 16:38:30 -07004155 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05304156 if (bss_desc->fProbeRsp)
4157 {
4158 mgmt->frame_control |=
4159 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
4160 }
4161 else
4162 {
4163 mgmt->frame_control |=
4164 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
4165 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004166
4167#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304168 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004169 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
4170 {
4171 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4172 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304173 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004174 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
4175
4176 {
4177 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4178 }
4179 else
4180 {
4181 kfree(mgmt);
4182 return NULL;
4183 }
4184#else
4185 freq = ieee80211_channel_to_frequency(chan_no);
4186#endif
4187 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004188 /*when the band is changed on the fly using the GUI, three things are done
4189 * 1. scan abort 2.flush scan results from cache 3.update the band with the new band user specified(refer to the hdd_setBand_helper function)
4190 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
4191 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
4192 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
4193 * and discards the channels correponding to previous band and calls back with zero bss results.
4194 * but if the time between band update and scan done callback is very small then band change will not reflect in SME and SME reports to HDD
4195 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
4196 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
4197 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
4198 * So drop the bss and continue to next bss.
4199 */
4200 if(chan == NULL)
4201 {
4202 hddLog(VOS_TRACE_LEVEL_INFO, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07004203 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004204 return NULL;
4205 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004206 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304207 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07004208 * */
4209 if (( eConnectionState_Associated ==
4210 pAdapter->sessionCtx.station.conn_info.connState ) &&
4211 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
4212 pAdapter->sessionCtx.station.conn_info.bssId,
4213 WNI_CFG_BSSID_LEN)))
4214 {
4215 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
4216 rssi = (pAdapter->rssi * 100);
4217 }
4218 else
4219 {
4220 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
4221 }
4222
4223 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
4224 frame_len, rssi, GFP_KERNEL);
4225 kfree(mgmt);
4226 return bss_status;
4227}
4228
4229/*
4230 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
4231 * This function is used to update the BSS data base of CFG8011
4232 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304233struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004234 tCsrRoamInfo *pRoamInfo
4235 )
4236{
4237 tCsrRoamConnectedProfile roamProfile;
4238 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4239 struct cfg80211_bss *bss = NULL;
4240
4241 ENTER();
4242
4243 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
4244 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
4245
4246 if (NULL != roamProfile.pBssDesc)
4247 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304248 bss = wlan_hdd_cfg80211_inform_bss(pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004249 &roamProfile);
4250
4251 if (NULL == bss)
4252 {
4253 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
4254 __func__);
4255 }
4256
4257 sme_RoamFreeConnectProfile(hHal, &roamProfile);
4258 }
4259 else
4260 {
4261 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
4262 __func__);
4263 }
4264 return bss;
4265}
4266
4267/*
4268 * FUNCTION: wlan_hdd_cfg80211_update_bss
4269 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304270static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
4271 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07004272 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304273{
Jeff Johnson295189b2012-06-20 16:38:30 -07004274 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4275 tCsrScanResultInfo *pScanResult;
4276 eHalStatus status = 0;
4277 tScanResultHandle pResult;
4278 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07004279 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004280
4281 ENTER();
4282
Wilson Yangf80a0542013-10-07 13:02:37 -07004283 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4284
4285 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -07004286 {
Wilson Yangf80a0542013-10-07 13:02:37 -07004287 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4288 "%s:LOGP in Progress. Ignore!!!",__func__);
4289 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004290 }
4291
Wilson Yangf80a0542013-10-07 13:02:37 -07004292
4293 /*bss_update is not allowed during wlan driver loading or unloading*/
4294 if (pHddCtx->isLoadUnloadInProgress)
4295 {
4296 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4297 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
4298 return VOS_STATUS_E_PERM;
4299 }
4300
4301
Jeff Johnson295189b2012-06-20 16:38:30 -07004302 /*
4303 * start getting scan results and populate cgf80211 BSS database
4304 */
4305 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
4306
4307 /* no scan results */
4308 if (NULL == pResult)
4309 {
4310 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result\n", __func__);
4311 return status;
4312 }
4313
4314 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
4315
4316 while (pScanResult)
4317 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304318 /*
4319 * cfg80211_inform_bss() is not updating ie field of bss entry, if
4320 * entry already exists in bss data base of cfg80211 for that
4321 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
4322 * bss entry instead of cfg80211_inform_bss, But this call expects
4323 * mgmt packet as input. As of now there is no possibility to get
4324 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07004325 * ieee80211_mgmt(probe response) and passing to c
4326 * fg80211_inform_bss_frame.
4327 * */
4328
4329 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
4330 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304331
Jeff Johnson295189b2012-06-20 16:38:30 -07004332
4333 if (NULL == bss_status)
4334 {
4335 hddLog(VOS_TRACE_LEVEL_INFO,
4336 "%s: NULL returned by cfg80211_inform_bss\n", __func__);
4337 }
4338 else
4339 {
Yue Maf49ba872013-08-19 12:04:25 -07004340 cfg80211_put_bss(
4341#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
4342 wiphy,
4343#endif
4344 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004345 }
4346
4347 pScanResult = sme_ScanResultGetNext(hHal, pResult);
4348 }
4349
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304350 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07004351
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304352 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004353}
4354
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004355void
4356hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
4357{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304358 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004359 "%02X:%02X:%02X:%02X:%02X:%02X\n",
4360 macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4],
4361 macAddr[5]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004362} /****** end hddPrintMacAddr() ******/
4363
4364void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004365hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004366{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304367 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004368 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
4369 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
4370 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
4371 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004372} /****** end hddPrintPmkId() ******/
4373
4374//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
4375//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
4376
4377//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
4378//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
4379
4380#define dump_bssid(bssid) \
4381 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004382 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
4383 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
4384 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004385 }
4386
4387#define dump_pmkid(pMac, pmkid) \
4388 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004389 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
4390 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
4391 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004392 }
4393
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004394#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004395/*
4396 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
4397 * This function is used to notify the supplicant of a new PMKSA candidate.
4398 */
4399int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304400 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004401 int index, bool preauth )
4402{
Jeff Johnsone7245742012-09-05 17:12:55 -07004403#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004404 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004405 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004406
4407 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07004408 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004409
4410 if( NULL == pRoamInfo )
4411 {
4412 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL\n", __func__);
4413 return -EINVAL;
4414 }
4415
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004416 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
4417 {
4418 dump_bssid(pRoamInfo->bssid);
4419 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004420 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004421 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004422#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304423 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004424}
4425#endif //FEATURE_WLAN_LFR
4426
Yue Maef608272013-04-08 23:09:17 -07004427#ifdef FEATURE_WLAN_LFR_METRICS
4428/*
4429 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
4430 * 802.11r/LFR metrics reporting function to report preauth initiation
4431 *
4432 */
4433#define MAX_LFR_METRICS_EVENT_LENGTH 100
4434VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
4435 tCsrRoamInfo *pRoamInfo)
4436{
4437 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4438 union iwreq_data wrqu;
4439
4440 ENTER();
4441
4442 if (NULL == pAdapter)
4443 {
4444 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4445 return VOS_STATUS_E_FAILURE;
4446 }
4447
4448 /* create the event */
4449 memset(&wrqu, 0, sizeof(wrqu));
4450 memset(metrics_notification, 0, sizeof(metrics_notification));
4451
4452 wrqu.data.pointer = metrics_notification;
4453 wrqu.data.length = scnprintf(metrics_notification,
4454 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
4455 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
4456
4457 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4458
4459 EXIT();
4460
4461 return VOS_STATUS_SUCCESS;
4462}
4463
4464/*
4465 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
4466 * 802.11r/LFR metrics reporting function to report preauth completion
4467 * or failure
4468 */
4469VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
4470 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
4471{
4472 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4473 union iwreq_data wrqu;
4474
4475 ENTER();
4476
4477 if (NULL == pAdapter)
4478 {
4479 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4480 return VOS_STATUS_E_FAILURE;
4481 }
4482
4483 /* create the event */
4484 memset(&wrqu, 0, sizeof(wrqu));
4485 memset(metrics_notification, 0, sizeof(metrics_notification));
4486
4487 scnprintf(metrics_notification, sizeof(metrics_notification),
4488 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
4489 MAC_ADDR_ARRAY(pRoamInfo->bssid));
4490
4491 if (1 == preauth_status)
4492 strncat(metrics_notification, " TRUE", 5);
4493 else
4494 strncat(metrics_notification, " FALSE", 6);
4495
4496 wrqu.data.pointer = metrics_notification;
4497 wrqu.data.length = strlen(metrics_notification);
4498
4499 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4500
4501 EXIT();
4502
4503 return VOS_STATUS_SUCCESS;
4504}
4505
4506/*
4507 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
4508 * 802.11r/LFR metrics reporting function to report handover initiation
4509 *
4510 */
4511VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
4512 tCsrRoamInfo *pRoamInfo)
4513{
4514 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4515 union iwreq_data wrqu;
4516
4517 ENTER();
4518
4519 if (NULL == pAdapter)
4520 {
4521 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4522 return VOS_STATUS_E_FAILURE;
4523 }
4524
4525 /* create the event */
4526 memset(&wrqu, 0, sizeof(wrqu));
4527 memset(metrics_notification, 0, sizeof(metrics_notification));
4528
4529 wrqu.data.pointer = metrics_notification;
4530 wrqu.data.length = scnprintf(metrics_notification,
4531 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
4532 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
4533
4534 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4535
4536 EXIT();
4537
4538 return VOS_STATUS_SUCCESS;
4539}
4540#endif
4541
Jeff Johnson295189b2012-06-20 16:38:30 -07004542/*
4543 * FUNCTION: hdd_cfg80211_scan_done_callback
4544 * scanning callback function, called after finishing scan
4545 *
4546 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304547static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
4549{
4550 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304551 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004552 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004553 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4554 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07004555 struct cfg80211_scan_request *req = NULL;
4556 int ret = 0;
4557
4558 ENTER();
4559
4560 hddLog(VOS_TRACE_LEVEL_INFO,
4561 "%s called with halHandle = %p, pContext = %p,"
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304562 "scanID = %d, returned status = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07004563 __func__, halHandle, pContext, (int) scanId, (int) status);
4564
Kiet Lamac06e2c2013-10-23 16:25:07 +05304565 pScanInfo->mScanPendingCounter = 0;
4566
Jeff Johnson295189b2012-06-20 16:38:30 -07004567 //Block on scan req completion variable. Can't wait forever though.
4568 ret = wait_for_completion_interruptible_timeout(
4569 &pScanInfo->scan_req_completion_event,
4570 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
4571 if (!ret)
4572 {
4573 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004574 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004575 }
4576
Yue Maef608272013-04-08 23:09:17 -07004577 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004578 {
4579 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004580 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004581 }
4582
4583 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304584 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -07004585 {
4586 hddLog(VOS_TRACE_LEVEL_INFO,
4587 "%s called with mismatched scanId pScanInfo->scanId = %d "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304588 "scanId = %d \n", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004589 (int) scanId);
4590 }
4591
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304592 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004593 pAdapter);
4594
4595 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304596 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004597
4598
4599 /* If any client wait scan result through WEXT
4600 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004601 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07004602 {
4603 /* The other scan request waiting for current scan finish
4604 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004605 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004607 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07004608 }
4609 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004610 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004611 {
4612 struct net_device *dev = pAdapter->dev;
4613 union iwreq_data wrqu;
4614 int we_event;
4615 char *msg;
4616
4617 memset(&wrqu, '\0', sizeof(wrqu));
4618 we_event = SIOCGIWSCAN;
4619 msg = NULL;
4620 wireless_send_event(dev, we_event, &wrqu, msg);
4621 }
4622 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004623 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004624
4625 /* Get the Scan Req */
4626 req = pAdapter->request;
4627
4628 if (!req)
4629 {
4630 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL\n");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004631 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004632 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004633 }
4634
4635 /*
4636 * setting up 0, just in case.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304637 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004638 req->n_ssids = 0;
4639 req->n_channels = 0;
4640 req->ie = 0;
4641
Jeff Johnson295189b2012-06-20 16:38:30 -07004642 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07004643 /* Scan is no longer pending */
4644 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004645
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -07004646 /*
4647 * cfg80211_scan_done informing NL80211 about completion
4648 * of scanning
4649 */
4650 cfg80211_scan_done(req, false);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08004651 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07004652
Jeff Johnsone7245742012-09-05 17:12:55 -07004653allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004654 /* release the wake lock at the end of the scan*/
4655 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07004656
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004657 /* Acquire wakelock to handle the case where APP's tries to suspend
4658 * immediatly after the driver gets connect request(i.e after scan)
4659 * from supplicant, this result in app's is suspending and not able
4660 * to process the connect request to AP */
Amar Singhal6144c002013-05-03 16:11:42 -07004661 hdd_allow_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004662
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004663#ifdef FEATURE_WLAN_TDLS
4664 wlan_hdd_tdls_scan_done_callback(pAdapter);
4665#endif
4666
Jeff Johnson295189b2012-06-20 16:38:30 -07004667 EXIT();
4668 return 0;
4669}
4670
4671/*
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004672 * FUNCTION: hdd_isScanAllowed
4673 * Go through each adapter and check if scan allowed
4674 *
4675 */
4676v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx )
4677{
4678 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
4679 hdd_station_ctx_t *pHddStaCtx = NULL;
4680 hdd_adapter_t *pAdapter = NULL;
4681 VOS_STATUS status = 0;
4682 v_U8_t staId = 0;
4683 v_U8_t *staMac = NULL;
4684
4685 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
4686
4687 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
4688 {
4689 pAdapter = pAdapterNode->pAdapter;
4690
4691 if( pAdapter )
4692 {
4693 hddLog(VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304694 "%s: Adapter with device mode %d exists",
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004695 __func__, pAdapter->device_mode);
4696 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
4697 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4698 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
4699 {
4700 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4701 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
4702 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
4703 {
4704 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
4705 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08004706 "%s: client " MAC_ADDRESS_STR
4707 " is in the middle of WPS/EAPOL exchange.", __func__,
4708 MAC_ADDR_ARRAY(staMac));
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004709 return VOS_FALSE;
4710 }
4711 }
4712 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
4713 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
4714 {
4715 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
4716 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304717 if ((pAdapter->aStaInfo[staId].isUsed) &&
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004718 (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState))
4719 {
4720 staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
4721
4722 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08004723 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
4724 "middle of WPS/EAPOL exchange.", __func__,
4725 MAC_ADDR_ARRAY(staMac));
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004726 return VOS_FALSE;
4727 }
4728 }
4729 }
4730 }
4731 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
4732 pAdapterNode = pNext;
4733 }
4734 hddLog(VOS_TRACE_LEVEL_INFO,
4735 "%s: Scan allowed", __func__);
4736 return VOS_TRUE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304737}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004738
4739/*
Jeff Johnson295189b2012-06-20 16:38:30 -07004740 * FUNCTION: wlan_hdd_cfg80211_scan
4741 * this scan respond to scan trigger and update cfg80211 scan database
4742 * later, scan dump command can be used to recieve scan results
4743 */
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08004744int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
4745#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4746 struct net_device *dev,
4747#endif
4748 struct cfg80211_scan_request *request)
4749{
4750#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
4751 struct net_device *dev = request->wdev->netdev;
4752#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304753 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07004754 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4755 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304756 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004757 tCsrScanRequest scanRequest;
4758 tANI_U8 *channelList = NULL, i;
4759 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304760 int status;
4761 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004762 v_U8_t* pP2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004763
4764 ENTER();
4765
4766 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
4767 __func__,pAdapter->device_mode);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004768
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304769 status = wlan_hdd_validate_context(pHddCtx);
4770
4771 if (0 != status)
4772 {
4773 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4774 "%s: HDD context is not valid", __func__);
4775 return status;
4776 }
4777
4778 cfg_param = pHddCtx->cfg_ini;
4779 pScanInfo = &pHddCtx->scan_info;
4780
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004781 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004782 (eConnectionState_Connecting ==
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004783 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004784 {
4785 hddLog(VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08004786 "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \
4787 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004788 return -EBUSY;
4789 }
4790
Jeff Johnson295189b2012-06-20 16:38:30 -07004791#ifdef WLAN_BTAMP_FEATURE
4792 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004793 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -07004794 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004795 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004796 "%s: No scanning when AMP is on", __func__);
4797 return -EOPNOTSUPP;
4798 }
4799#endif
4800 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004801 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07004802 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004803 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004804 "%s: Not scanning on device_mode = %d",
4805 __func__, pAdapter->device_mode);
4806 return -EOPNOTSUPP;
4807 }
4808
4809 if (TRUE == pScanInfo->mScanPending)
4810 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05304811 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
4812 {
4813 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
4814 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004815 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004816 }
4817
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304818 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -07004819 //Channel and action frame is pending
4820 //Otherwise Cancel Remain On Channel and allow Scan
4821 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004822 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -07004823 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05304824 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -07004825 return -EBUSY;
4826 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004827#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004828 /* if tdls disagree scan right now, return immediately.
4829 tdls will schedule the scan when scan is allowed. (return SUCCESS)
4830 or will reject the scan if any TDLS is in progress. (return -EBUSY)
4831 */
4832 status = wlan_hdd_tdls_scan_callback (pAdapter,
4833 wiphy,
4834#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4835 dev,
Gopichand Nakkalac3c42b92013-03-20 19:42:34 -07004836#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004837 request);
4838 if(status <= 0)
4839 {
4840 hddLog(VOS_TRACE_LEVEL_INFO, "%s: TDLS Pending %d", __func__, status);
4841 return status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004842 }
4843#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07004844
Jeff Johnson295189b2012-06-20 16:38:30 -07004845 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
4846 {
4847 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -08004848 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004849 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304850 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004851 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
4852 {
4853 hddLog(VOS_TRACE_LEVEL_WARN,
4854 "%s: MAX TM Level Scan not allowed", __func__);
4855 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304856 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004857 }
4858 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
4859
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004860 /* Check if scan is allowed at this point of time.
4861 */
4862 if (!hdd_isScanAllowed(pHddCtx))
4863 {
4864 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
4865 return -EBUSY;
4866 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304867
Jeff Johnson295189b2012-06-20 16:38:30 -07004868 vos_mem_zero( &scanRequest, sizeof(scanRequest));
4869
4870 if (NULL != request)
4871 {
4872 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304873 (int)request->n_ssids);
Jeff Johnson295189b2012-06-20 16:38:30 -07004874
4875 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
4876 * Becasue of this, driver is assuming that this is not wildcard scan and so
4877 * is not aging out the scan results.
4878 */
Jeff Johnson32d95a32012-09-10 13:15:23 -07004879 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004880 {
4881 request->n_ssids = 0;
4882 }
4883
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004884 if ((request->ssids) && (0 < request->n_ssids))
Jeff Johnson295189b2012-06-20 16:38:30 -07004885 {
4886 tCsrSSIDInfo *SsidInfo;
4887 int j;
4888 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
4889 /* Allocate num_ssid tCsrSSIDInfo structure */
4890 SsidInfo = scanRequest.SSIDs.SSIDList =
4891 ( tCsrSSIDInfo *)vos_mem_malloc(
4892 request->n_ssids*sizeof(tCsrSSIDInfo));
4893
4894 if(NULL == scanRequest.SSIDs.SSIDList)
4895 {
4896 hddLog(VOS_TRACE_LEVEL_ERROR,
4897 "memory alloc failed SSIDInfo buffer");
4898 return -ENOMEM;
4899 }
4900
4901 /* copy all the ssid's and their length */
4902 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
4903 {
4904 /* get the ssid length */
4905 SsidInfo->SSID.length = request->ssids[j].ssid_len;
4906 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
4907 SsidInfo->SSID.length);
4908 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
4909 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "SSID number %d: %s",
4910 j, SsidInfo->SSID.ssId);
4911 }
4912 /* set the scan type to active */
4913 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4914 }
4915 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
4916 {
4917 /* set the scan type to active */
4918 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4919 }
4920 else
4921 {
4922 /*Set the scan type to default type, in this case it is ACTIVE*/
4923 scanRequest.scanType = pScanInfo->scan_mode;
4924 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304925 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07004926 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
4927 }
4928 else
4929 {
4930 /* set the scan type to active */
4931 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4932 vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff );
4933
4934 /* set min and max channel time to zero */
4935 scanRequest.minChnTime = 0;
4936 scanRequest.maxChnTime = 0;
4937 }
4938
4939 /* set BSSType to default type */
4940 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
4941
4942 /*TODO: scan the requested channels only*/
4943
4944 /*Right now scanning all the channels */
4945 if( request )
4946 {
4947 if( request->n_channels )
4948 {
4949 channelList = vos_mem_malloc( request->n_channels );
4950 if( NULL == channelList )
4951 {
4952 status = -ENOMEM;
4953 goto free_mem;
4954 }
4955
4956 for( i = 0 ; i < request->n_channels ; i++ )
4957 channelList[i] = request->channels[i]->hw_value;
4958 }
4959
4960 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
4961 scanRequest.ChannelInfo.ChannelList = channelList;
4962
4963 /* set requestType to full scan */
4964 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304965
4966 /* Flush the scan results(only p2p beacons) for STA scan and P2P
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004967 * search (Flush on both full scan and social scan but not on single
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304968 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004969 */
4970
4971 /* Supplicant does single channel scan after 8-way handshake
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304972 * and in that case driver shoudnt flush scan results. If
4973 * driver flushes the scan results here and unfortunately if
4974 * the AP doesnt respond to our probe req then association
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004975 * fails which is not desired
4976 */
4977
4978 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
4979 {
4980 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
4981 pAdapter->sessionId );
4982 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004983
4984 if( request->ie_len )
4985 {
4986 /* save this for future association (join requires this) */
4987 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
4988 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
4989 pScanInfo->scanAddIE.length = request->ie_len;
4990
4991 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07004992 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4993 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07004994 )
4995 {
4996 pwextBuf->roamProfile.pAddIEScan = pScanInfo->scanAddIE.addIEdata;
4997 pwextBuf->roamProfile.nAddIEScanLength = pScanInfo->scanAddIE.length;
4998 }
4999
5000 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
5001 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
5002
Jeff Johnson295189b2012-06-20 16:38:30 -07005003 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
5004 request->ie_len);
5005 if (pP2pIe != NULL)
5006 {
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07005007#ifdef WLAN_FEATURE_P2P_DEBUG
5008 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
5009 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
5010 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5011 {
5012 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
5013 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
5014 "Go nego completed to Connection is started");
5015 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
5016 "for 8way Handshake");
5017 }
5018 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
5019 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5020 {
5021 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
5022 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
5023 "Disconnected state to Connection is started");
5024 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
5025 "for 4way Handshake");
5026 }
5027#endif
5028
Jeff Johnsone7245742012-09-05 17:12:55 -07005029 /* no_cck will be set during p2p find to disable 11b rates */
5030 if(TRUE == request->no_cck)
Jeff Johnson295189b2012-06-20 16:38:30 -07005031 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005032 hddLog(VOS_TRACE_LEVEL_INFO,
5033 "%s: This is a P2P Search", __func__);
5034 scanRequest.p2pSearch = 1;
Jeff Johnsone7245742012-09-05 17:12:55 -07005035
Jeff Johnsone7245742012-09-05 17:12:55 -07005036 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
5037 {
Madan Mohan Koyyalamudi1b1d9e82012-10-21 11:38:33 -07005038 /* set requestType to P2P Discovery */
5039 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
Jeff Johnsone7245742012-09-05 17:12:55 -07005040 }
5041
5042 /*
5043 Skip Dfs Channel in case of P2P Search
5044 if it is set in ini file
5045 */
5046 if(cfg_param->skipDfsChnlInP2pSearch)
5047 {
5048 scanRequest.skipDfsChnlInP2pSearch = 1;
5049 }
5050 else
5051 {
5052 scanRequest.skipDfsChnlInP2pSearch = 0;
5053 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005054
Jeff Johnson295189b2012-06-20 16:38:30 -07005055 }
5056 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005057 }
5058 }
5059
5060 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
5061
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07005062 /* acquire the wakelock to avoid the apps suspend during the scan. To
5063 * address the following issues.
5064 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
5065 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
5066 * for long time, this result in apps running at full power for long time.
5067 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
5068 * be stuck in full power because of resume BMPS
5069 */
5070 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07005071
5072 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005073 pAdapter->sessionId, &scanRequest, &scanId,
5074 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -07005075
Jeff Johnson295189b2012-06-20 16:38:30 -07005076 if (eHAL_STATUS_SUCCESS != status)
5077 {
5078 hddLog(VOS_TRACE_LEVEL_ERROR,
5079 "%s: sme_ScanRequest returned error %d", __func__, status);
5080 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07005081 if(eHAL_STATUS_RESOURCES == status)
5082 {
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07005083 hddLog(VOS_TRACE_LEVEL_INFO, "%s: HO is in progress.So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07005084 status = -EBUSY;
5085 } else {
5086 status = -EIO;
5087 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07005088 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07005089 goto free_mem;
5090 }
5091
5092 pScanInfo->mScanPending = TRUE;
5093 pAdapter->request = request;
5094 pScanInfo->scanId = scanId;
5095
5096 complete(&pScanInfo->scan_req_completion_event);
5097
5098free_mem:
5099 if( scanRequest.SSIDs.SSIDList )
5100 {
5101 vos_mem_free(scanRequest.SSIDs.SSIDList);
5102 }
5103
5104 if( channelList )
5105 vos_mem_free( channelList );
5106
5107 EXIT();
5108
5109 return status;
5110}
5111
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005112
5113void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
5114{
5115 v_U8_t iniDot11Mode =
5116 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
5117 eHddDot11Mode hddDot11Mode = iniDot11Mode;
5118
5119 switch ( iniDot11Mode )
5120 {
5121 case eHDD_DOT11_MODE_AUTO:
5122 case eHDD_DOT11_MODE_11ac:
5123 case eHDD_DOT11_MODE_11ac_ONLY:
5124#ifdef WLAN_FEATURE_11AC
5125 hddDot11Mode = eHDD_DOT11_MODE_11ac;
5126#else
5127 hddDot11Mode = eHDD_DOT11_MODE_11n;
5128#endif
5129 break;
5130 case eHDD_DOT11_MODE_11n:
5131 case eHDD_DOT11_MODE_11n_ONLY:
5132 hddDot11Mode = eHDD_DOT11_MODE_11n;
5133 break;
5134 default:
5135 hddDot11Mode = iniDot11Mode;
5136 break;
5137 }
5138 /* This call decides required channel bonding mode */
5139 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
5140 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
5141 operationChannel);
5142}
5143
Jeff Johnson295189b2012-06-20 16:38:30 -07005144/*
5145 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305146 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -07005147 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305148int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -07005149 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07005150{
5151 int status = 0;
5152 hdd_wext_state_t *pWextState;
5153 v_U32_t roamId;
5154 tCsrRoamProfile *pRoamProfile;
5155 eMib_dot11DesiredBssType connectedBssType;
5156 eCsrAuthType RSNAuthType;
5157
5158 ENTER();
5159
5160 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305161
Jeff Johnson295189b2012-06-20 16:38:30 -07005162 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
5163 {
5164 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
5165 return -EINVAL;
5166 }
5167
5168 pRoamProfile = &pWextState->roamProfile;
5169
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305170 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07005171 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005172 int ret = 0;
5173 hdd_station_ctx_t *pHddStaCtx;
5174 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5175 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
5176
5177 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
5178 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
5179 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
Jeff Johnson295189b2012-06-20 16:38:30 -07005180 {
5181 /* Issue disconnect to CSR */
5182 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305183 if( eHAL_STATUS_SUCCESS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07005184 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
5185 pAdapter->sessionId,
5186 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
5187 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005188 ret = wait_for_completion_interruptible_timeout(
5189 &pAdapter->disconnect_comp_var,
5190 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5191 if (0 == ret)
5192 {
5193 VOS_ASSERT(0);
5194 }
5195 }
5196 }
5197 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
5198 {
5199 ret = wait_for_completion_interruptible_timeout(
5200 &pAdapter->disconnect_comp_var,
5201 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5202 if (0 == ret)
5203 {
5204 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005205 }
5206 }
5207
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305208 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07005209 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
5210 {
5211 /*QoS not enabled in cfg file*/
5212 pRoamProfile->uapsd_mask = 0;
5213 }
5214 else
5215 {
5216 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305217 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -07005218 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
5219 }
5220
5221 pRoamProfile->SSIDs.numOfSSIDs = 1;
5222 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
5223 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305224 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005225 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
5226 ssid, ssid_len);
5227
5228 if (bssid)
5229 {
5230 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
5231 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
5232 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305233 /* Save BSSID in seperate variable as well, as RoamProfile
5234 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -07005235 case of join failure we should send valid BSSID to supplicant
5236 */
5237 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
5238 WNI_CFG_BSSID_LEN);
5239 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07005240 else
5241 {
5242 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
5243 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005244
5245 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
5246 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305247 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005248 /*set gen ie*/
5249 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
5250 /*set auth*/
5251 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5252 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005253#ifdef FEATURE_WLAN_WAPI
5254 if (pAdapter->wapi_info.nWapiMode)
5255 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005256 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005257 switch (pAdapter->wapi_info.wapiAuthMode)
5258 {
5259 case WAPI_AUTH_MODE_PSK:
5260 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005261 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005262 pAdapter->wapi_info.wapiAuthMode);
5263 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5264 break;
5265 }
5266 case WAPI_AUTH_MODE_CERT:
5267 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005268 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005269 pAdapter->wapi_info.wapiAuthMode);
5270 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5271 break;
5272 }
5273 } // End of switch
5274 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5275 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
5276 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005277 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005278 pRoamProfile->AuthType.numEntries = 1;
5279 pRoamProfile->EncryptionType.numEntries = 1;
5280 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5281 pRoamProfile->mcEncryptionType.numEntries = 1;
5282 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5283 }
5284 }
5285#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305286#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305287 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305288 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
5289 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5290 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305291 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
5292 sizeof (tSirGtkOffloadParams));
5293 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305294 }
5295#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005296 pRoamProfile->csrPersona = pAdapter->device_mode;
5297
Jeff Johnson32d95a32012-09-10 13:15:23 -07005298 if( operatingChannel )
5299 {
5300 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
5301 pRoamProfile->ChannelInfo.numOfChannels = 1;
5302 }
Chet Lanctot186b5732013-03-18 10:26:30 -07005303 else
5304 {
5305 pRoamProfile->ChannelInfo.ChannelList = NULL;
5306 pRoamProfile->ChannelInfo.numOfChannels = 0;
5307 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005308 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
5309 {
5310 hdd_select_cbmode(pAdapter,operatingChannel);
5311 }
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005312 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
5313 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305314 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005315 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005316 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
5317 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305318 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5319 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005320 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5321 eConnectionState_Connecting);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305322
5323 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005324 pAdapter->sessionId, pRoamProfile, &roamId);
5325
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305326 if ((eHAL_STATUS_SUCCESS != status) &&
5327 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5328 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305329
5330 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005331 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
5332 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
5333 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305334 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005335 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305336 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005337
5338 pRoamProfile->ChannelInfo.ChannelList = NULL;
5339 pRoamProfile->ChannelInfo.numOfChannels = 0;
5340
Jeff Johnson295189b2012-06-20 16:38:30 -07005341 }
5342 else
5343 {
5344 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
5345 return -EINVAL;
5346 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005347 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005348 return status;
5349}
5350
5351/*
5352 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
5353 * This function is used to set the authentication type (OPEN/SHARED).
5354 *
5355 */
5356static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
5357 enum nl80211_auth_type auth_type)
5358{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305359 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005360 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5361
5362 ENTER();
5363
5364 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305365 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -07005366 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005367 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305368 hddLog(VOS_TRACE_LEVEL_INFO,
5369 "%s: set authentication type to AUTOSWITCH", __func__);
5370 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
5371 break;
5372
5373 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07005374#ifdef WLAN_FEATURE_VOWIFI_11R
5375 case NL80211_AUTHTYPE_FT:
5376#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305377 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005378 "%s: set authentication type to OPEN", __func__);
5379 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5380 break;
5381
5382 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305383 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005384 "%s: set authentication type to SHARED", __func__);
5385 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
5386 break;
5387#ifdef FEATURE_WLAN_CCX
5388 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305389 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005390 "%s: set authentication type to CCKM WPA", __func__);
5391 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
5392 break;
5393#endif
5394
5395
5396 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305397 hddLog(VOS_TRACE_LEVEL_ERROR,
5398 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005399 auth_type);
5400 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
5401 return -EINVAL;
5402 }
5403
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305404 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 pHddStaCtx->conn_info.authType;
5406 return 0;
5407}
5408
5409/*
5410 * FUNCTION: wlan_hdd_set_akm_suite
5411 * This function is used to set the key mgmt type(PSK/8021x).
5412 *
5413 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305414static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005415 u32 key_mgmt
5416 )
5417{
5418 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5419 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305420
Jeff Johnson295189b2012-06-20 16:38:30 -07005421 /*set key mgmt type*/
5422 switch(key_mgmt)
5423 {
5424 case WLAN_AKM_SUITE_PSK:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305425#ifdef WLAN_FEATURE_VOWIFI_11R
5426 case WLAN_AKM_SUITE_FT_PSK:
5427#endif
5428 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -07005429 __func__);
5430 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5431 break;
5432
5433 case WLAN_AKM_SUITE_8021X:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305434#ifdef WLAN_FEATURE_VOWIFI_11R
5435 case WLAN_AKM_SUITE_FT_8021X:
5436#endif
5437 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -07005438 __func__);
5439 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5440 break;
5441#ifdef FEATURE_WLAN_CCX
5442#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
5443#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5444 case WLAN_AKM_SUITE_CCKM:
5445 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
5446 __func__);
5447 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
5448 break;
5449#endif
5450
5451 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305452 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005453 __func__, key_mgmt);
5454 return -EINVAL;
5455
5456 }
5457 return 0;
5458}
5459
5460/*
5461 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305462 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -07005463 * (NONE/WEP40/WEP104/TKIP/CCMP).
5464 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305465static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
5466 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -07005467 bool ucast
5468 )
5469{
5470 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305471 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005472 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5473
5474 ENTER();
5475
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305476 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005477 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305478 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -07005479 __func__, cipher);
5480 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5481 }
5482 else
5483 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305484
Jeff Johnson295189b2012-06-20 16:38:30 -07005485 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305486 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005487 {
5488 case IW_AUTH_CIPHER_NONE:
5489 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5490 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305491
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305493 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07005494 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305495
Jeff Johnson295189b2012-06-20 16:38:30 -07005496 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305497 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -07005498 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305499
Jeff Johnson295189b2012-06-20 16:38:30 -07005500 case WLAN_CIPHER_SUITE_TKIP:
5501 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5502 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305503
Jeff Johnson295189b2012-06-20 16:38:30 -07005504 case WLAN_CIPHER_SUITE_CCMP:
5505 encryptionType = eCSR_ENCRYPT_TYPE_AES;
5506 break;
5507#ifdef FEATURE_WLAN_WAPI
5508 case WLAN_CIPHER_SUITE_SMS4:
5509 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
5510 break;
5511#endif
5512
5513#ifdef FEATURE_WLAN_CCX
5514 case WLAN_CIPHER_SUITE_KRK:
5515 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
5516 break;
5517#endif
5518 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305519 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005520 __func__, cipher);
5521 return -EOPNOTSUPP;
5522 }
5523 }
5524
5525 if (ucast)
5526 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305527 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005528 __func__, encryptionType);
5529 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
5530 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305531 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005532 encryptionType;
5533 }
5534 else
5535 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305536 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005537 __func__, encryptionType);
5538 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
5539 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5540 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
5541 }
5542
5543 return 0;
5544}
5545
5546
5547/*
5548 * FUNCTION: wlan_hdd_cfg80211_set_ie
5549 * This function is used to parse WPA/RSN IE's.
5550 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305551int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
5552 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -07005553 size_t ie_len
5554 )
5555{
5556 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5557 u8 *genie = ie;
5558 v_U16_t remLen = ie_len;
5559#ifdef FEATURE_WLAN_WAPI
5560 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
5561 u16 *tmp;
5562 v_U16_t akmsuiteCount;
5563 int *akmlist;
5564#endif
5565 ENTER();
5566
5567 /* clear previous assocAddIE */
5568 pWextState->assocAddIE.length = 0;
5569 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
5570
5571 while (remLen >= 2)
5572 {
5573 v_U16_t eLen = 0;
5574 v_U8_t elementId;
5575 elementId = *genie++;
5576 eLen = *genie++;
5577 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305578
5579 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005580 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305581
5582 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -07005583 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305584 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005585 if (4 > eLen) /* should have at least OUI which is 4 bytes so extra 2 bytes not needed */
Jeff Johnson295189b2012-06-20 16:38:30 -07005586 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305587 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005588 "%s: Invalid WPA IE", __func__);
5589 return -EINVAL;
5590 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305591 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -07005592 {
5593 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305594 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005595 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305596
Jeff Johnson295189b2012-06-20 16:38:30 -07005597 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5598 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005599 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
5600 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005601 VOS_ASSERT(0);
5602 return -ENOMEM;
5603 }
5604 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5605 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5606 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305607
Jeff Johnson295189b2012-06-20 16:38:30 -07005608 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
5609 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5610 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5611 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305612 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
5613 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005614 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
5615 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5616 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
5617 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
5618 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
5619 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305620 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
5621 P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005622 /*Consider P2P IE, only for P2P Client */
5623 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5624 {
5625 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305626 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005627 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305628
Jeff Johnson295189b2012-06-20 16:38:30 -07005629 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5630 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005631 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5632 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005633 VOS_ASSERT(0);
5634 return -ENOMEM;
5635 }
5636 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5637 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5638 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305639
Jeff Johnson295189b2012-06-20 16:38:30 -07005640 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5641 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5642 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005643#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305644 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
5645 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005646 /*Consider WFD IE, only for P2P Client */
5647 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5648 {
5649 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305650 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005651 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305652
Jeff Johnson295189b2012-06-20 16:38:30 -07005653 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5654 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005655 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5656 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005657 VOS_ASSERT(0);
5658 return -ENOMEM;
5659 }
5660 // WFD IE is saved to Additional IE ; it should be accumulated to handle
5661 // WPS IE + P2P IE + WFD IE
5662 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5663 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305664
Jeff Johnson295189b2012-06-20 16:38:30 -07005665 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5666 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5667 }
5668#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005669 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305670 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005671 HS20_OUI_TYPE_SIZE)) )
5672 {
5673 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305674 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005675 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005676
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005677 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5678 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005679 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5680 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005681 VOS_ASSERT(0);
5682 return -ENOMEM;
5683 }
5684 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5685 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005686
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005687 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5688 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5689 }
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005690
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -07005691 if (WLAN_HDD_IBSS == pAdapter->device_mode) {
5692
5693 /* populating as ADDIE in beacon frames */
5694 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5695 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
5696 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
5697 {
5698 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
5699 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
5700 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5701 {
5702 hddLog(LOGE,
5703 "Coldn't pass "
5704 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
5705 }
5706 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
5707 else
5708 hddLog(LOGE,
5709 "Could not pass on "
5710 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
5711
5712 /* IBSS mode doesn't contain params->proberesp_ies still
5713 beaconIE's need to be populated in probe response frames */
5714 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
5715 {
5716 u16 rem_probe_resp_ie_len = eLen + 2;
5717 u8 probe_rsp_ie_len[3] = {0};
5718 u8 counter = 0;
5719
5720 /* Check Probe Resp Length if it is greater then 255 then
5721 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
5722 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
5723 not able Store More then 255 bytes into One Variable */
5724
5725 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
5726 {
5727 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
5728 {
5729 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
5730 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
5731 }
5732 else
5733 {
5734 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
5735 rem_probe_resp_ie_len = 0;
5736 }
5737 }
5738
5739 rem_probe_resp_ie_len = 0;
5740
5741 if (probe_rsp_ie_len[0] > 0)
5742 {
5743 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5744 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
5745 (tANI_U8*)(genie - 2),
5746 probe_rsp_ie_len[0], NULL,
5747 eANI_BOOLEAN_FALSE)
5748 == eHAL_STATUS_FAILURE)
5749 {
5750 hddLog(LOGE,
5751 "Could not pass"
5752 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
5753 }
5754 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
5755 }
5756
5757 if (probe_rsp_ie_len[1] > 0)
5758 {
5759 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5760 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
5761 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
5762 probe_rsp_ie_len[1], NULL,
5763 eANI_BOOLEAN_FALSE)
5764 == eHAL_STATUS_FAILURE)
5765 {
5766 hddLog(LOGE,
5767 "Could not pass"
5768 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
5769 }
5770 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
5771 }
5772
5773 if (probe_rsp_ie_len[2] > 0)
5774 {
5775 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5776 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
5777 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
5778 probe_rsp_ie_len[2], NULL,
5779 eANI_BOOLEAN_FALSE)
5780 == eHAL_STATUS_FAILURE)
5781 {
5782 hddLog(LOGE,
5783 "Could not pass"
5784 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
5785 }
5786 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
5787 }
5788
5789 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
5790 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
5791 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5792 {
5793 hddLog(LOGE,
5794 "Could not pass"
5795 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
5796 }
5797 }
5798 else
5799 {
5800 // Reset WNI_CFG_PROBE_RSP Flags
5801 wlan_hdd_reset_prob_rspies(pAdapter);
5802
5803 hddLog(VOS_TRACE_LEVEL_INFO,
5804 "%s: No Probe Response IE received in set beacon",
5805 __func__);
5806 }
5807 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -07005808 break;
5809 case DOT11F_EID_RSN:
5810 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
5811 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5812 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
5813 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
5814 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
5815 break;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005816 /* Appending Extended Capabilities with Interworking bit set in Assoc Req */
5817 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305818 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005819 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305820 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005821 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305822
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005823 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5824 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005825 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5826 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005827 VOS_ASSERT(0);
5828 return -ENOMEM;
5829 }
5830 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5831 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305832
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005833 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5834 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5835 break;
5836 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005837#ifdef FEATURE_WLAN_WAPI
5838 case WLAN_EID_WAPI:
5839 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005840 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07005841 pAdapter->wapi_info.nWapiMode);
5842 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305843 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -07005844 akmsuiteCount = WPA_GET_LE16(tmp);
5845 tmp = tmp + 1;
5846 akmlist = (int *)(tmp);
5847 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
5848 {
5849 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
5850 }
5851 else
5852 {
5853 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count\n");
5854 VOS_ASSERT(0);
5855 return -EINVAL;
5856 }
5857
5858 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
5859 {
5860 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005861 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005862 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305863 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005864 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305865 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005866 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005867 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005868 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5869 }
5870 break;
5871#endif
5872 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305873 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005874 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005875 /* when Unknown IE is received we should break and continue
5876 * to the next IE in the buffer instead we were returning
5877 * so changing this to break */
5878 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005879 }
5880 genie += eLen;
5881 remLen -= eLen;
5882 }
5883 EXIT();
5884 return 0;
5885}
5886
5887/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +05305888 * FUNCTION: hdd_isWPAIEPresent
5889 * Parse the received IE to find the WPA IE
5890 *
5891 */
5892static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
5893{
5894 v_U8_t eLen = 0;
5895 v_U16_t remLen = ie_len;
5896 v_U8_t elementId = 0;
5897
5898 while (remLen >= 2)
5899 {
5900 elementId = *ie++;
5901 eLen = *ie++;
5902 remLen -= 2;
5903 if (eLen > remLen)
5904 {
5905 hddLog(VOS_TRACE_LEVEL_ERROR,
5906 "%s: IE length is wrong %d", __func__, eLen);
5907 return FALSE;
5908 }
5909 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
5910 {
5911 /* OUI - 0x00 0X50 0XF2
5912 WPA Information Element - 0x01
5913 WPA version - 0x01*/
5914 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
5915 return TRUE;
5916 }
5917 ie += eLen;
5918 remLen -= eLen;
5919 }
5920 return FALSE;
5921}
5922
5923/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005924 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305925 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005926 * parameters during connect operation.
5927 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305928int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005929 struct cfg80211_connect_params *req
5930 )
5931{
5932 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305933 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 ENTER();
5935
5936 /*set wpa version*/
5937 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
5938
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305939 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005940 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +05305941 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005942 {
5943 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
5944 }
5945 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
5946 {
5947 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
5948 }
5949 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305950
5951 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005952 pWextState->wpaVersion);
5953
5954 /*set authentication type*/
5955 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
5956
5957 if (0 > status)
5958 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305959 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005960 "%s: failed to set authentication type ", __func__);
5961 return status;
5962 }
5963
5964 /*set key mgmt type*/
5965 if (req->crypto.n_akm_suites)
5966 {
5967 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
5968 if (0 > status)
5969 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305970 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -07005971 __func__);
5972 return status;
5973 }
5974 }
5975
5976 /*set pairwise cipher type*/
5977 if (req->crypto.n_ciphers_pairwise)
5978 {
5979 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
5980 req->crypto.ciphers_pairwise[0], true);
5981 if (0 > status)
5982 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305983 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005984 "%s: failed to set unicast cipher type", __func__);
5985 return status;
5986 }
5987 }
5988 else
5989 {
5990 /*Reset previous cipher suite to none*/
5991 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
5992 if (0 > status)
5993 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305994 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005995 "%s: failed to set unicast cipher type", __func__);
5996 return status;
5997 }
5998 }
5999
6000 /*set group cipher type*/
6001 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
6002 false);
6003
6004 if (0 > status)
6005 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306006 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -07006007 __func__);
6008 return status;
6009 }
6010
Chet Lanctot186b5732013-03-18 10:26:30 -07006011#ifdef WLAN_FEATURE_11W
6012 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
6013#endif
6014
Jeff Johnson295189b2012-06-20 16:38:30 -07006015 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
6016 if (req->ie_len)
6017 {
6018 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
6019 if ( 0 > status)
6020 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306021 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006022 __func__);
6023 return status;
6024 }
6025 }
6026
6027 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306028 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006029 {
6030 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
6031 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
6032 )
6033 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306034 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -07006035 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
6036 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306037 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07006038 __func__);
6039 return -EOPNOTSUPP;
6040 }
6041 else
6042 {
6043 u8 key_len = req->key_len;
6044 u8 key_idx = req->key_idx;
6045
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306046 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006047 && (CSR_MAX_NUM_KEY > key_idx)
6048 )
6049 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306050 hddLog(VOS_TRACE_LEVEL_INFO,
6051 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006052 __func__, key_idx, key_len);
6053 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306054 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07006055 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306056 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -07006057 (u8)key_len;
6058 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
6059 }
6060 }
6061 }
6062 }
6063
6064 return status;
6065}
6066
6067/*
6068 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306069 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006070 * parameters during connect operation.
6071 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306072static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006073 struct net_device *ndev,
6074 struct cfg80211_connect_params *req
6075 )
6076{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306077 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306078 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006079 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
6080 hdd_context_t *pHddCtx = NULL;
6081
6082 ENTER();
6083
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306084 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006085 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6086
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306087 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6088 status = wlan_hdd_validate_context(pHddCtx);
6089
6090 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006091 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306092 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6093 "%s: HDD context is not valid", __func__);
6094 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006095 }
6096
6097#ifdef WLAN_BTAMP_FEATURE
6098 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306099 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -07006100 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306101 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006102 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08006103 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -07006104 }
6105#endif
6106 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306107 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -07006108
6109 if ( 0 > status)
6110 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306111 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -07006112 __func__);
6113 return status;
6114 }
6115
6116 //If Device Mode is Station Concurrent Sessions Exit BMps
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006117 //P2P Mode will be taken care in Open/close adapter
Jeff Johnson295189b2012-06-20 16:38:30 -07006118 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
6119 (vos_concurrent_sessions_running()))
6120 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306121 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
Jeff Johnson295189b2012-06-20 16:38:30 -07006122 }
6123
Mohit Khanna765234a2012-09-11 15:08:35 -07006124 if ( req->channel )
6125 {
6126 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
6127 req->ssid_len, req->bssid,
6128 req->channel->hw_value);
6129 }
6130 else
6131 {
6132 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306133 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -07006134 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006135
6136 if (0 > status)
6137 {
6138 //ReEnable BMPS if disabled
6139 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
6140 (NULL != pHddCtx))
6141 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306142 if (pHddCtx->hdd_wlan_suspended)
6143 {
6144 hdd_set_pwrparams(pHddCtx);
6145 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006146 //ReEnable Bmps and Imps back
6147 hdd_enable_bmps_imps(pHddCtx);
6148 }
6149
6150 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6151 return status;
6152 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306153 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006154 EXIT();
6155 return status;
6156}
6157
6158
6159/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306160 * FUNCTION: wlan_hdd_disconnect
6161 * This function is used to issue a disconnect request to SME
6162 */
6163int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
6164{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306165 int status;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306166 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306167 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6168
6169 status = wlan_hdd_validate_context(pHddCtx);
6170
6171 if (0 != status)
6172 {
6173 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6174 "%s: HDD context is not valid", __func__);
6175 return status;
6176 }
6177
6178 pHddCtx->isAmpAllowed = VOS_TRUE;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306179 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306180 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306181
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306182 /*issue disconnect*/
6183 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
6184 pAdapter->sessionId, reason);
6185
6186 if ( 0 != status )
6187 {
6188 hddLog(VOS_TRACE_LEVEL_ERROR,
6189 "%s csrRoamDisconnect failure, returned %d \n",
6190 __func__, (int)status );
6191 return -EINVAL;
6192 }
6193 wait_for_completion_interruptible_timeout(
6194 &pAdapter->disconnect_comp_var,
6195 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6196 /*stop tx queues*/
6197 netif_tx_disable(pAdapter->dev);
6198 netif_carrier_off(pAdapter->dev);
6199 return status;
6200}
6201
6202
6203/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006204 * FUNCTION: wlan_hdd_cfg80211_disconnect
6205 * This function is used to issue a disconnect request to SME
6206 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306207static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006208 struct net_device *dev,
6209 u16 reason
6210 )
6211{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306212 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6213 tCsrRoamProfile *pRoamProfile =
Jeff Johnson295189b2012-06-20 16:38:30 -07006214 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306215 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006216 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006217 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306218#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006219 tANI_U8 staIdx;
6220#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306221
Jeff Johnson295189b2012-06-20 16:38:30 -07006222 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306223
6224 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006225 __func__,pAdapter->device_mode);
6226
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306227 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
6228 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006229
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306230 status = wlan_hdd_validate_context(pHddCtx);
6231
6232 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006233 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306234 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6235 "%s: HDD context is not valid", __func__);
6236 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006237 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306238
Jeff Johnson295189b2012-06-20 16:38:30 -07006239 if (NULL != pRoamProfile)
6240 {
6241 /*issue disconnect request to SME, if station is in connected state*/
6242 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated)
6243 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306244 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07006245 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306246 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07006247 switch(reason)
6248 {
6249 case WLAN_REASON_MIC_FAILURE:
6250 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
6251 break;
6252
6253 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
6254 case WLAN_REASON_DISASSOC_AP_BUSY:
6255 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
6256 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
6257 break;
6258
6259 case WLAN_REASON_PREV_AUTH_NOT_VALID:
6260 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
6261 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
6262 break;
6263
6264 case WLAN_REASON_DEAUTH_LEAVING:
6265 default:
6266 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
6267 break;
6268 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306269 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
6270 pScanInfo = &pHddCtx->scan_info;
6271 if (pScanInfo->mScanPending)
6272 {
6273 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
6274 "Aborting Scan");
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306275 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306276 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006277
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006278#ifdef FEATURE_WLAN_TDLS
6279 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006280 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006281 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006282 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
6283 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006284 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006285 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006286 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006287 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006288 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006289 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006290 MAC_ADDR_ARRAY(mac));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006291 sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006292 pAdapter->sessionId,
6293 mac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006294 }
6295 }
6296#endif
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306297 status = wlan_hdd_disconnect(pAdapter, reasonCode);
6298 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -07006299 {
6300 hddLog(VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306301 "%s wlan_hdd_disconnect failure, returned %d \n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006302 __func__, (int)status );
6303 return -EINVAL;
6304 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006305 }
6306 }
6307 else
6308 {
6309 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
6310 }
6311
6312 return status;
6313}
6314
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306315
Jeff Johnson295189b2012-06-20 16:38:30 -07006316/*
6317 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306318 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006319 * settings in IBSS mode.
6320 */
6321static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306322 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006323 struct cfg80211_ibss_params *params
6324 )
6325{
6326 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306327 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006328 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6329 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306330
Jeff Johnson295189b2012-06-20 16:38:30 -07006331 ENTER();
6332
6333 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
6334
6335 if (params->ie_len && ( NULL != params->ie) )
6336 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006337 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6338 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006339 {
6340 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
6341 encryptionType = eCSR_ENCRYPT_TYPE_AES;
6342 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006343 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006344 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006345 tDot11fIEWPA dot11WPAIE;
6346 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006347 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006348
Wilson Yang00256342013-10-10 23:13:38 -07006349 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006350 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6351 params->ie_len, DOT11F_EID_WPA);
6352 if ( NULL != ie )
6353 {
6354 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
6355 // Unpack the WPA IE
6356 //Skip past the EID byte and length byte - and four byte WiFi OUI
6357 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
6358 &ie[2+4],
6359 ie[1] - 4,
6360 &dot11WPAIE);
6361 /*Extract the multicast cipher, the encType for unicast
6362 cipher for wpa-none is none*/
6363 encryptionType =
6364 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
6365 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006366 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006367
Jeff Johnson295189b2012-06-20 16:38:30 -07006368 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
6369
6370 if (0 > status)
6371 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306372 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006373 __func__);
6374 return status;
6375 }
6376 }
6377
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306378 pWextState->roamProfile.AuthType.authType[0] =
6379 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -07006380 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6381
6382 if (params->privacy)
6383 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306384 /* Security enabled IBSS, At this time there is no information available
6385 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -07006386 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306387 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -07006388 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306389 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -07006390 *enable privacy bit in beacons */
6391
6392 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6393 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006394 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
6395 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07006396 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
6397 pWextState->roamProfile.EncryptionType.numEntries = 1;
6398 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07006399 return status;
6400}
6401
6402/*
6403 * FUNCTION: wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306404 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006405 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306406static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006407 struct net_device *dev,
6408 struct cfg80211_ibss_params *params
6409 )
6410{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306411 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006412 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6413 tCsrRoamProfile *pRoamProfile;
6414 int status;
6415 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306416 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006417
6418 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306419
6420 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006421 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6422
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306423 status = wlan_hdd_validate_context(pHddCtx);
6424
6425 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006426 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306427 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6428 "%s: HDD context is not valid", __func__);
6429 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006430 }
6431
6432 if (NULL == pWextState)
6433 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306434 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006435 __func__);
6436 return -EIO;
6437 }
6438
6439 pRoamProfile = &pWextState->roamProfile;
6440
6441 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
6442 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306443 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006444 "%s Interface type is not set to IBSS \n", __func__);
6445 return -EINVAL;
6446 }
6447
6448 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -07006449 if (NULL !=
6450#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6451 params->chandef.chan)
6452#else
6453 params->channel)
6454#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006455 {
6456 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006457 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6458 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6459 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6460 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006461
6462 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306463 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -07006464 ieee80211_frequency_to_channel(
6465#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6466 params->chandef.chan->center_freq);
6467#else
6468 params->channel->center_freq);
6469#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006470
6471 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6472 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -07006473 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006474 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
6475 __func__);
6476 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -07006477 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006478
6479 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006480 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006481 if (channelNum == validChan[indx])
6482 {
6483 break;
6484 }
6485 }
6486 if (indx >= numChans)
6487 {
6488 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006489 __func__, channelNum);
6490 return -EINVAL;
6491 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006492 /* Set the Operational Channel */
6493 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
6494 channelNum);
6495 pRoamProfile->ChannelInfo.numOfChannels = 1;
6496 pHddStaCtx->conn_info.operationChannel = channelNum;
6497 pRoamProfile->ChannelInfo.ChannelList =
6498 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006499 }
6500
6501 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306502 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -07006503 if (status < 0)
6504 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306505 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -07006506 __func__);
6507 return status;
6508 }
6509
6510 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306511 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006512 params->ssid_len, params->bssid,
6513 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006514
6515 if (0 > status)
6516 {
6517 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6518 return status;
6519 }
6520
6521 return 0;
6522}
6523
6524/*
6525 * FUNCTION: wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306526 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006527 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306528static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006529 struct net_device *dev
6530 )
6531{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306532 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006533 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6534 tCsrRoamProfile *pRoamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306535 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6536 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006537
6538 ENTER();
6539
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306540 status = wlan_hdd_validate_context(pHddCtx);
6541
6542 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006543 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306544 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6545 "%s: HDD context is not valid", __func__);
6546 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006547 }
6548
Jeff Johnson295189b2012-06-20 16:38:30 -07006549 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6550 if (NULL == pWextState)
6551 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306552 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006553 __func__);
6554 return -EIO;
6555 }
6556
6557 pRoamProfile = &pWextState->roamProfile;
6558
6559 /* Issue disconnect only if interface type is set to IBSS */
6560 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
6561 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306562 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -07006563 __func__);
6564 return -EINVAL;
6565 }
6566
6567 /* Issue Disconnect request */
6568 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6569 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
6570 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
6571
6572 return 0;
6573}
6574
6575/*
6576 * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params
6577 * This function is used to set the phy parameters
6578 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
6579 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306580static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006581 u32 changed)
6582{
6583 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6584 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306585 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006586
6587 ENTER();
6588
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306589 status = wlan_hdd_validate_context(pHddCtx);
6590
6591 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006592 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306593 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6594 "%s: HDD context is not valid", __func__);
6595 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006596 }
6597
Jeff Johnson295189b2012-06-20 16:38:30 -07006598 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
6599 {
6600 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
6601 WNI_CFG_RTS_THRESHOLD_STAMAX :
6602 wiphy->rts_threshold;
6603
6604 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306605 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -07006606 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306607 hddLog(VOS_TRACE_LEVEL_ERROR,
6608 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006609 __func__, rts_threshold);
6610 return -EINVAL;
6611 }
6612
6613 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
6614 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306615 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006616 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306617 hddLog(VOS_TRACE_LEVEL_ERROR,
6618 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006619 __func__, rts_threshold);
6620 return -EIO;
6621 }
6622
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306623 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006624 rts_threshold);
6625 }
6626
6627 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
6628 {
6629 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
6630 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
6631 wiphy->frag_threshold;
6632
6633 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306634 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006635 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306636 hddLog(VOS_TRACE_LEVEL_ERROR,
6637 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006638 frag_threshold);
6639 return -EINVAL;
6640 }
6641
6642 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
6643 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306644 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006645 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306646 hddLog(VOS_TRACE_LEVEL_ERROR,
6647 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006648 __func__, frag_threshold);
6649 return -EIO;
6650 }
6651
6652 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
6653 frag_threshold);
6654 }
6655
6656 if ((changed & WIPHY_PARAM_RETRY_SHORT)
6657 || (changed & WIPHY_PARAM_RETRY_LONG))
6658 {
6659 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
6660 wiphy->retry_short :
6661 wiphy->retry_long;
6662
6663 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
6664 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
6665 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306666 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006667 __func__, retry_value);
6668 return -EINVAL;
6669 }
6670
6671 if (changed & WIPHY_PARAM_RETRY_SHORT)
6672 {
6673 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
6674 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306675 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006676 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306677 hddLog(VOS_TRACE_LEVEL_ERROR,
6678 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006679 __func__, retry_value);
6680 return -EIO;
6681 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306682 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006683 __func__, retry_value);
6684 }
6685 else if (changed & WIPHY_PARAM_RETRY_SHORT)
6686 {
6687 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
6688 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306689 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006690 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306691 hddLog(VOS_TRACE_LEVEL_ERROR,
6692 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006693 __func__, retry_value);
6694 return -EIO;
6695 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306696 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006697 __func__, retry_value);
6698 }
6699 }
6700
6701 return 0;
6702}
6703
6704/*
6705 * FUNCTION: wlan_hdd_cfg80211_set_txpower
6706 * This function is used to set the txpower
6707 */
6708static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07006709#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6710 struct wireless_dev *wdev,
6711#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006712#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306713 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006714#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306715 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006716#endif
6717 int dbm)
6718{
6719 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306720 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006721 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6722 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306723 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006724
6725 ENTER();
6726
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306727 status = wlan_hdd_validate_context(pHddCtx);
6728
6729 if (0 != status)
6730 {
6731 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6732 "%s: HDD context is not valid", __func__);
6733 return status;
6734 }
6735
6736 hHal = pHddCtx->hHal;
6737
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306738 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6739 dbm, ccmCfgSetCallback,
6740 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006741 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306742 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006743 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
6744 return -EIO;
6745 }
6746
6747 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
6748 dbm);
6749
6750 switch(type)
6751 {
6752 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
6753 /* Fall through */
6754 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
6755 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
6756 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306757 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
6758 __func__);
6759 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07006760 }
6761 break;
6762 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306763 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07006764 __func__);
6765 return -EOPNOTSUPP;
6766 break;
6767 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306768 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
6769 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006770 return -EIO;
6771 }
6772
6773 return 0;
6774}
6775
6776/*
6777 * FUNCTION: wlan_hdd_cfg80211_get_txpower
6778 * This function is used to read the txpower
6779 */
Yue Maf49ba872013-08-19 12:04:25 -07006780static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
6781#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6782 struct wireless_dev *wdev,
6783#endif
6784 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006785{
6786
6787 hdd_adapter_t *pAdapter;
6788 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306789 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006790
Jeff Johnsone7245742012-09-05 17:12:55 -07006791 ENTER();
6792
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306793 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07006794
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306795 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006796 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306797 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6798 "%s: HDD context is not valid", __func__);
6799 *dbm = 0;
6800 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006801 }
6802
Jeff Johnson295189b2012-06-20 16:38:30 -07006803 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
6804 if (NULL == pAdapter)
6805 {
6806 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
6807 return -ENOENT;
6808 }
6809
6810 wlan_hdd_get_classAstats(pAdapter);
6811 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
6812
Jeff Johnsone7245742012-09-05 17:12:55 -07006813 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006814 return 0;
6815}
6816
6817static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
6818 u8* mac, struct station_info *sinfo)
6819{
6820 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6821 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6822 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
6823 tANI_U8 rate_flags;
6824
6825 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
6826 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07006827
6828 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
6829 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
6830 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
6831 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
6832 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
6833 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
6834 tANI_U16 maxRate = 0;
6835 tANI_U16 myRate;
6836 tANI_U16 currentRate = 0;
6837 tANI_U8 maxSpeedMCS = 0;
6838 tANI_U8 maxMCSIdx = 0;
6839 tANI_U8 rateFlag = 1;
6840 tANI_U8 i, j, rssidx;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07006841 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306842 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006843
Leo Chang6f8870f2013-03-26 18:11:36 -07006844#ifdef WLAN_FEATURE_11AC
6845 tANI_U32 vht_mcs_map;
6846 eDataRate11ACMaxMcs vhtMaxMcs;
6847#endif /* WLAN_FEATURE_11AC */
6848
Jeff Johnsone7245742012-09-05 17:12:55 -07006849 ENTER();
6850
Jeff Johnson295189b2012-06-20 16:38:30 -07006851 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
6852 (0 == ssidlen))
6853 {
6854 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
6855 " Invalid ssidlen, %d", __func__, ssidlen);
6856 /*To keep GUI happy*/
6857 return 0;
6858 }
6859
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306860 status = wlan_hdd_validate_context(pHddCtx);
6861
6862 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006863 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306864 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6865 "%s: HDD context is not valid", __func__);
6866 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006867 }
6868
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07006869 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006870 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
6871
Kiet Lam3b17fc82013-09-27 05:24:08 +05306872 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
6873 sinfo->filled |= STATION_INFO_SIGNAL;
6874
Jeff Johnson295189b2012-06-20 16:38:30 -07006875 //convert to the UI units of 100kbps
6876 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
6877
6878#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -07006879 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 -07006880 sinfo->signal,
6881 pCfg->reportMaxLinkSpeed,
6882 myRate,
6883 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006884 (int) pCfg->linkSpeedRssiMid,
6885 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -07006886 (int) rate_flags,
6887 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07006888#endif //LINKSPEED_DEBUG_ENABLED
6889
6890 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
6891 {
6892 // we do not want to necessarily report the current speed
6893 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
6894 {
6895 // report the max possible speed
6896 rssidx = 0;
6897 }
6898 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
6899 {
6900 // report the max possible speed with RSSI scaling
6901 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
6902 {
6903 // report the max possible speed
6904 rssidx = 0;
6905 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006906 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006907 {
6908 // report middle speed
6909 rssidx = 1;
6910 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006911 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
6912 {
6913 // report middle speed
6914 rssidx = 2;
6915 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006916 else
6917 {
6918 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006919 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07006920 }
6921 }
6922 else
6923 {
6924 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
6925 hddLog(VOS_TRACE_LEVEL_ERROR,
6926 "%s: Invalid value for reportMaxLinkSpeed: %u",
6927 __func__, pCfg->reportMaxLinkSpeed);
6928 rssidx = 0;
6929 }
6930
6931 maxRate = 0;
6932
6933 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306934 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
6935 OperationalRates, &ORLeng))
6936 {
6937 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6938 /*To keep GUI happy*/
6939 return 0;
6940 }
6941
Jeff Johnson295189b2012-06-20 16:38:30 -07006942 for (i = 0; i < ORLeng; i++)
6943 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006944 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006945 {
6946 /* Validate Rate Set */
6947 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
6948 {
6949 currentRate = supported_data_rate[j].supported_rate[rssidx];
6950 break;
6951 }
6952 }
6953 /* Update MAX rate */
6954 maxRate = (currentRate > maxRate)?currentRate:maxRate;
6955 }
6956
6957 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306958 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
6959 ExtendedRates, &ERLeng))
6960 {
6961 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6962 /*To keep GUI happy*/
6963 return 0;
6964 }
6965
Jeff Johnson295189b2012-06-20 16:38:30 -07006966 for (i = 0; i < ERLeng; i++)
6967 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006968 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006969 {
6970 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
6971 {
6972 currentRate = supported_data_rate[j].supported_rate[rssidx];
6973 break;
6974 }
6975 }
6976 /* Update MAX rate */
6977 maxRate = (currentRate > maxRate)?currentRate:maxRate;
6978 }
Kiet Lamb69f8dc2013-11-15 15:34:27 +05306979 /* Get MCS Rate Set --
6980 only if we are connected at MCS rates (or)
6981 if we are always reporting max speed (or)
6982 if we have good rssi */
6983 if (((0 == rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY)) ||
6984 (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed))
Jeff Johnson295189b2012-06-20 16:38:30 -07006985 {
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306986 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
6987 MCSRates, &MCSLeng))
6988 {
6989 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6990 /*To keep GUI happy*/
6991 return 0;
6992 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006993 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -07006994#ifdef WLAN_FEATURE_11AC
6995 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306996 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -07006997 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006998 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306999 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -07007000 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -07007001 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007002 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007003 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007004 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -07007005 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007006 maxMCSIdx = 7;
7007 }
7008 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
7009 {
7010 maxMCSIdx = 8;
7011 }
7012 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
7013 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307014 //VHT20 is supporting 0~8
7015 if (rate_flags & eHAL_TX_RATE_VHT20)
7016 maxMCSIdx = 8;
7017 else
7018 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -07007019 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307020
7021 if (rate_flags & eHAL_TX_RATE_VHT80)
7022 {
7023 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
7024 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
7025 }
7026 else if (rate_flags & eHAL_TX_RATE_VHT40)
7027 {
7028 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
7029 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
7030 }
7031 else if (rate_flags & eHAL_TX_RATE_VHT20)
7032 {
7033 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
7034 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
7035 }
7036
Leo Chang6f8870f2013-03-26 18:11:36 -07007037 maxSpeedMCS = 1;
7038 if (currentRate > maxRate)
7039 {
7040 maxRate = currentRate;
7041 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307042
Leo Chang6f8870f2013-03-26 18:11:36 -07007043 }
7044 else
7045#endif /* WLAN_FEATURE_11AC */
7046 {
7047 if (rate_flags & eHAL_TX_RATE_HT40)
7048 {
7049 rateFlag |= 1;
7050 }
7051 if (rate_flags & eHAL_TX_RATE_SGI)
7052 {
7053 rateFlag |= 2;
7054 }
7055
7056 for (i = 0; i < MCSLeng; i++)
7057 {
7058 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
7059 for (j = 0; j < temp; j++)
7060 {
7061 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
7062 {
7063 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
7064 break;
7065 }
7066 }
7067 if ((j < temp) && (currentRate > maxRate))
7068 {
7069 maxRate = currentRate;
7070 maxSpeedMCS = 1;
7071 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
7072 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007073 }
7074 }
7075 }
7076
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307077 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
7078 {
7079 maxRate = myRate;
7080 maxSpeedMCS = 1;
7081 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
7082 }
7083
Jeff Johnson295189b2012-06-20 16:38:30 -07007084 // make sure we report a value at least as big as our current rate
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007085 if (((maxRate < myRate) && (0 == rssidx)) ||
7086 (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -07007087 {
7088 maxRate = myRate;
7089 if (rate_flags & eHAL_TX_RATE_LEGACY)
7090 {
7091 maxSpeedMCS = 0;
7092 }
7093 else
7094 {
7095 maxSpeedMCS = 1;
7096 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
7097 }
7098 }
7099
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307100 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -07007101 {
7102 sinfo->txrate.legacy = maxRate;
7103#ifdef LINKSPEED_DEBUG_ENABLED
7104 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
7105#endif //LINKSPEED_DEBUG_ENABLED
7106 }
7107 else
7108 {
7109 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -07007110#ifdef WLAN_FEATURE_11AC
7111 sinfo->txrate.nss = 1;
7112 if (rate_flags & eHAL_TX_RATE_VHT80)
7113 {
7114 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307115 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -07007116 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307117 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -07007118 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307119 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7120 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7121 }
7122 else if (rate_flags & eHAL_TX_RATE_VHT20)
7123 {
7124 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7125 }
7126#endif /* WLAN_FEATURE_11AC */
7127 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
7128 {
7129 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7130 if (rate_flags & eHAL_TX_RATE_HT40)
7131 {
7132 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7133 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007134 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007135 if (rate_flags & eHAL_TX_RATE_SGI)
7136 {
7137 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7138 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307139
Jeff Johnson295189b2012-06-20 16:38:30 -07007140#ifdef LINKSPEED_DEBUG_ENABLED
7141 pr_info("Reporting MCS rate %d flags %x\n",
7142 sinfo->txrate.mcs,
7143 sinfo->txrate.flags );
7144#endif //LINKSPEED_DEBUG_ENABLED
7145 }
7146 }
7147 else
7148 {
7149 // report current rate instead of max rate
7150
7151 if (rate_flags & eHAL_TX_RATE_LEGACY)
7152 {
7153 //provide to the UI in units of 100kbps
7154 sinfo->txrate.legacy = myRate;
7155#ifdef LINKSPEED_DEBUG_ENABLED
7156 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
7157#endif //LINKSPEED_DEBUG_ENABLED
7158 }
7159 else
7160 {
7161 //must be MCS
7162 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -07007163#ifdef WLAN_FEATURE_11AC
7164 sinfo->txrate.nss = 1;
7165 if (rate_flags & eHAL_TX_RATE_VHT80)
7166 {
7167 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7168 }
7169 else
7170#endif /* WLAN_FEATURE_11AC */
7171 {
7172 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7173 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007174 if (rate_flags & eHAL_TX_RATE_SGI)
7175 {
7176 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7177 }
7178 if (rate_flags & eHAL_TX_RATE_HT40)
7179 {
7180 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7181 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007182#ifdef WLAN_FEATURE_11AC
7183 else if (rate_flags & eHAL_TX_RATE_VHT80)
7184 {
7185 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
7186 }
7187#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -07007188#ifdef LINKSPEED_DEBUG_ENABLED
7189 pr_info("Reporting actual MCS rate %d flags %x\n",
7190 sinfo->txrate.mcs,
7191 sinfo->txrate.flags );
7192#endif //LINKSPEED_DEBUG_ENABLED
7193 }
7194 }
7195 sinfo->filled |= STATION_INFO_TX_BITRATE;
7196
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07007197 sinfo->tx_packets =
7198 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
7199 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
7200 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
7201 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
7202
7203 sinfo->tx_retries =
7204 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
7205 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
7206 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
7207 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
7208
7209 sinfo->tx_failed =
7210 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
7211 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
7212 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
7213 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
7214
7215 sinfo->filled |=
7216 STATION_INFO_TX_PACKETS |
7217 STATION_INFO_TX_RETRIES |
7218 STATION_INFO_TX_FAILED;
7219
7220 EXIT();
7221 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007222}
7223
7224static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -07007225 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -07007226{
7227 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307228 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007229 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307230 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007231
Jeff Johnsone7245742012-09-05 17:12:55 -07007232 ENTER();
7233
Jeff Johnson295189b2012-06-20 16:38:30 -07007234 if (NULL == pAdapter)
7235 {
7236 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
7237 return -ENODEV;
7238 }
7239
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307240 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307241 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307242
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307243 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307244 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307245 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7246 "%s: HDD context is not valid", __func__);
7247 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307248 }
7249
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307250 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
7251 (TRUE == pHddCtx->hdd_wlan_suspended) &&
7252 (pHddCtx->cfg_ini->fhostArpOffload) &&
7253 (eConnectionState_Associated ==
7254 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
7255 {
Amar Singhald53568e2013-09-26 11:03:45 -07007256
7257 hddLog(VOS_TRACE_LEVEL_INFO,
7258 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307259 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307260 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7261 {
7262 hddLog(VOS_TRACE_LEVEL_INFO,
7263 "%s:Failed to enable ARPOFFLOAD Feature %d\n",
7264 __func__, vos_status);
7265 }
7266 }
7267
Jeff Johnson295189b2012-06-20 16:38:30 -07007268 /**The get power cmd from the supplicant gets updated by the nl only
7269 *on successful execution of the function call
7270 *we are oppositely mapped w.r.t mode in the driver
7271 **/
7272 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
7273
Jeff Johnsone7245742012-09-05 17:12:55 -07007274 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007275 if (VOS_STATUS_E_FAILURE == vos_status)
7276 {
7277 return -EINVAL;
7278 }
7279 return 0;
7280}
7281
7282
7283#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7284static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
7285 struct net_device *netdev,
7286 u8 key_index)
7287{
Jeff Johnsone7245742012-09-05 17:12:55 -07007288 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007289 return 0;
7290}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307291#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -07007292
7293#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7294static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7295 struct net_device *dev,
7296 struct ieee80211_txq_params *params)
7297{
Jeff Johnsone7245742012-09-05 17:12:55 -07007298 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007299 return 0;
7300}
7301#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7302static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7303 struct ieee80211_txq_params *params)
7304{
Jeff Johnsone7245742012-09-05 17:12:55 -07007305 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007306 return 0;
7307}
7308#endif //LINUX_VERSION_CODE
7309
7310static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
7311 struct net_device *dev, u8 *mac)
7312{
7313 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307314 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007315 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307316 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007317 v_U8_t staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007318
Jeff Johnsone7245742012-09-05 17:12:55 -07007319 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307320 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -07007321 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307322 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007323 return -EINVAL;
7324 }
7325
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307326 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7327 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007328
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307329 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007330 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307331 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7332 "%s: HDD context is not valid", __func__);
7333 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007334 }
7335
Jeff Johnson295189b2012-06-20 16:38:30 -07007336 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007337 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007338 )
7339 {
7340 if( NULL == mac )
7341 {
7342 v_U16_t i;
7343 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
7344 {
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007345 if ((pAdapter->aStaInfo[i].isUsed) &&
7346 (!pAdapter->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -07007347 {
7348 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
7349 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007350 "%s: Delete STA with MAC::"
7351 MAC_ADDRESS_STR,
7352 __func__, MAC_ADDR_ARRAY(macAddr));
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007353 vos_status = hdd_softap_sta_deauth(pAdapter, macAddr);
7354 if (VOS_IS_STATUS_SUCCESS(vos_status))
7355 pAdapter->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007356 }
7357 }
7358 }
7359 else
7360 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007361
7362 vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId);
7363 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7364 {
7365 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007366 "%s: Skip this DEL STA as this is not used::"
7367 MAC_ADDRESS_STR,
7368 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007369 return -ENOENT;
7370 }
7371
7372 if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE)
7373 {
7374 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007375 "%s: Skip this DEL STA as deauth is in progress::"
7376 MAC_ADDRESS_STR,
7377 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007378 return -ENOENT;
7379 }
7380
7381 pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE;
7382
Jeff Johnson295189b2012-06-20 16:38:30 -07007383 hddLog(VOS_TRACE_LEVEL_INFO,
7384 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -08007385 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007386 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -08007387 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007388
7389 vos_status = hdd_softap_sta_deauth(pAdapter, mac);
7390 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7391 {
7392 pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE;
7393 hddLog(VOS_TRACE_LEVEL_INFO,
7394 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -08007395 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007396 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -08007397 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007398 return -ENOENT;
7399 }
7400
Jeff Johnson295189b2012-06-20 16:38:30 -07007401 }
7402 }
7403
7404 EXIT();
7405
7406 return 0;
7407}
7408
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007409static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
7410 struct net_device *dev, u8 *mac, struct station_parameters *params)
7411{
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007412 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007413#ifdef FEATURE_WLAN_TDLS
7414 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007415 ENTER();
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007416 mask = params->sta_flags_mask;
7417
7418 set = params->sta_flags_set;
7419
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007420#ifdef WLAN_FEATURE_TDLS_DEBUG
7421 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7422 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
7423 __func__, mask, set, MAC_ADDR_ARRAY(mac));
7424#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007425
7426 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
7427 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007428 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007429 }
7430 }
7431#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007432 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007433}
7434
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007435
7436#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -07007437#define MAX_PMKSAIDS_IN_CACHE 8
7438
7439static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD local cache
7440static tANI_U32 PMKIDCacheIndex; // HDD local Cache index
7441
7442
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007443static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07007444 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007445{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307446 tANI_U32 j=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007447 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7448 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307449 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307450 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007451 tANI_U8 BSSIDMatched = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307452 hdd_context_t *pHddCtx;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307453
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007454 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
7455 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07007456
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307457 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307458 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007459 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307460 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007461 return -EINVAL;
7462 }
7463
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307464 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7465 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007466
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307467 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007468 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307469 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7470 "%s: HDD context is not valid", __func__);
7471 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007472 }
7473
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307474 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007475 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7476
Wilson Yang6507c4e2013-10-01 20:11:19 -07007477 for (j = 0; j < PMKIDCacheIndex; j++)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007478 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307479 if(vos_mem_compare(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007480 pmksa->bssid, WNI_CFG_BSSID_LEN))
7481 {
7482 /* BSSID matched previous entry. Overwrite it. */
7483 BSSIDMatched = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307484 vos_mem_copy(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007485 pmksa->bssid, WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307486 vos_mem_copy(PMKIDCache[j].PMKID,
7487 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007488 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307489 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007490 __func__, j );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007491 dump_bssid(pmksa->bssid);
7492 dump_pmkid(halHandle, pmksa->pmkid);
7493 break;
7494 }
7495 }
7496
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007497 /* Check we compared all entries,if then take the first slot now */
Wilson Yang6507c4e2013-10-01 20:11:19 -07007498 if(j == MAX_PMKSAIDS_IN_CACHE) PMKIDCacheIndex=0;
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007499
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007500 if (!BSSIDMatched)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307501 {
7502 // Now, we DON'T have a BSSID match, so take a new entry in the cache.
Wilson Yang6507c4e2013-10-01 20:11:19 -07007503 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].BSSID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307504 pmksa->bssid, ETHER_ADDR_LEN);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007505 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].PMKID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307506 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007507 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307508 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Adding a new cache entry %d.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07007509 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007510 dump_bssid(pmksa->bssid);
7511 dump_pmkid(halHandle, pmksa->pmkid);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307512 // Increment the HDD Local Cache index
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007513 // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME
Wilson Yang6507c4e2013-10-01 20:11:19 -07007514 if (PMKIDCacheIndex <= (MAX_PMKSAIDS_IN_CACHE-1)) PMKIDCacheIndex++; else PMKIDCacheIndex = 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007515 }
7516
7517
7518 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307519 //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007520 // __func__, i );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307521 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07007522 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007523 // Finally set the PMKSA ID Cache in CSR
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307524 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
7525 PMKIDCache,
Wilson Yang6507c4e2013-10-01 20:11:19 -07007526 PMKIDCacheIndex);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007527 return 0;
7528}
7529
7530
Wilson Yang6507c4e2013-10-01 20:11:19 -07007531
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007532static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -07007533 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007534{
Wilson Yang6507c4e2013-10-01 20:11:19 -07007535 tANI_U32 j=0;
7536 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7537 tHalHandle halHandle;
7538 int status;
7539 tANI_U8 BSSIDMatched = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07007540 hdd_context_t *pHddCtx;
7541 int result = 0;
7542
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007543 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
7544 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -07007545
7546 /* Validate pAdapter */
7547 if (NULL == pAdapter)
7548 {
7549 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
7550 return -EINVAL;
7551 }
7552
7553 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7554 status = wlan_hdd_validate_context(pHddCtx);
7555
7556 if (0 != status)
7557 {
7558 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7559 "%s: HDD context is not valid", __func__);
7560 return status;
7561 }
7562
7563 /*Retrieve halHandle*/
7564 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7565
7566 /*in case index is 0,no entry to delete*/
7567 if (0 == PMKIDCacheIndex)
7568 {
7569 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" ,
7570 __func__);
7571 return -EINVAL;
7572 }
7573
7574 /*find the matching PMKSA entry from j=0 to (index-1),
7575 * and delete the matched one
7576 */
7577 for (j = 0; j<PMKIDCacheIndex; j++)
7578 {
7579 if (vos_mem_compare(PMKIDCache[j].BSSID,
7580 pmksa->bssid,
7581 WNI_CFG_BSSID_LEN))
7582 {
7583 /* BSSID matched entry */
7584 BSSIDMatched = 1;
7585
7586 if (j<PMKIDCacheIndex-1)
7587 {
7588 /*replace the matching entry with the last entry in HDD local cache*/
7589 vos_mem_copy(PMKIDCache[j].BSSID,
7590 PMKIDCache[PMKIDCacheIndex-1].BSSID,
7591 WNI_CFG_BSSID_LEN);
7592 vos_mem_copy(PMKIDCache[j].PMKID,
7593 PMKIDCache[PMKIDCacheIndex-1].PMKID,
7594 CSR_RSN_PMKID_SIZE);
7595 }
7596
7597 /*clear the last entry in HDD cache ---[index-1]*/
Wilson Yang6507c4e2013-10-01 20:11:19 -07007598 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].BSSID, WNI_CFG_BSSID_LEN);
7599 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].PMKID, CSR_RSN_PMKID_SIZE);
7600
7601 /*reduce the PMKID array index*/
7602 PMKIDCacheIndex--;
7603
7604 /*delete the last PMKID cache in CSR*/
Kiet Lam8d21d5b2013-10-31 17:18:29 +05307605 result = sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pmksa->bssid);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007606 if (0 != result)
7607 {
7608 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cannot delete PMKSA %d CONTENT.",
7609 __func__,PMKIDCacheIndex);
7610 }
7611
7612 dump_bssid(pmksa->bssid);
7613 dump_pmkid(halHandle,pmksa->pmkid);
7614
7615 break;
7616 }
7617 }
7618
7619 /* we compare all entries,but cannot find matching entry */
7620 if (j == MAX_PMKSAIDS_IN_CACHE && !BSSIDMatched)
7621 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007622 hddLog(VOS_TRACE_LEVEL_FATAL,
7623 "%s: No such PMKSA entry existed " MAC_ADDRESS_STR,
7624 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -07007625 dump_bssid(pmksa->bssid);
7626 dump_pmkid(halHandle, pmksa->pmkid);
7627 return -EINVAL;
7628 }
7629 return result;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007630}
7631
Wilson Yang6507c4e2013-10-01 20:11:19 -07007632
7633
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007634static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
7635{
Wilson Yang6507c4e2013-10-01 20:11:19 -07007636 tANI_U32 j=0;
7637 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7638 tHalHandle halHandle;
7639 hdd_context_t *pHddCtx;
7640 tANI_U8 *pBSSId;
7641 int status;
7642 int result;
7643
7644 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__);
7645
7646 /* Validate pAdapter */
7647 if (NULL == pAdapter)
7648 {
7649 hddLog(VOS_TRACE_LEVEL_ERROR,
7650 "%s: Invalid Adapter" ,__func__);
7651 return -EINVAL;
7652 }
7653
7654 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7655 status = wlan_hdd_validate_context(pHddCtx);
7656
7657 if (0 != status)
7658 {
7659 hddLog(VOS_TRACE_LEVEL_ERROR,
7660 "%s: HDD context is not valid", __func__);
7661 return status;
7662 }
7663
7664 /*Retrieve halHandle*/
7665 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7666
7667 /*in case index is 0,no entry to delete*/
7668 if (0 == PMKIDCacheIndex)
7669 {
7670 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" ,
7671 __func__);
7672 return -EINVAL;
7673 }
7674
7675 /*delete all the PMKSA one by one */
7676 for (j = 0; j<PMKIDCacheIndex; j++)
7677 {
Wilson Yang6507c4e2013-10-01 20:11:19 -07007678 pBSSId =(tANI_U8 *)(PMKIDCache[j].BSSID);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007679
7680 /*delete the PMKID in CSR*/
7681 result = sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId);
7682
7683 if (0!= result)
7684 {
7685 hddLog(VOS_TRACE_LEVEL_ERROR ,"%s cannot flush PMKIDCache %d.",
7686 __func__,j);
7687 }
Kiet Lam8d21d5b2013-10-31 17:18:29 +05307688 /*clear the entry in HDD cache 0--index-1 */
7689 vos_mem_zero(PMKIDCache[j].BSSID, WNI_CFG_BSSID_LEN);
7690 vos_mem_zero(PMKIDCache[j].PMKID, CSR_RSN_PMKID_SIZE);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007691 }
7692
7693 PMKIDCacheIndex = 0;
7694 return result;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007695}
7696#endif
7697
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007698#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307699static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007700 struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie)
7701{
7702 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7703 hdd_station_ctx_t *pHddStaCtx;
7704
7705 if (NULL == pAdapter)
7706 {
7707 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
7708 return -ENODEV;
7709 }
7710
7711 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7712
7713 // Added for debug on reception of Re-assoc Req.
7714 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7715 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307716 hddLog(LOGE, FL("Called with Ie of length = %d when not associated\n"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007717 ftie->ie_len);
7718 hddLog(LOGE, FL("Should be Re-assoc Req IEs\n"));
7719 }
7720
7721#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307722 hddLog(LOGE, FL("%s called with Ie of length = %d\n"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007723 ftie->ie_len);
7724#endif
7725
7726 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +05307727 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
7728 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007729 ftie->ie_len);
7730 return 0;
7731}
7732#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007733
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307734#ifdef FEATURE_WLAN_SCAN_PNO
7735
7736void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
7737 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
7738{
7739 int ret;
7740 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
7741 hdd_context_t *pHddCtx;
7742
7743 if (NULL == pAdapter)
7744 {
7745 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7746 "%s: HDD adapter is Null", __func__);
7747 return ;
7748 }
7749
7750 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7751 if (NULL == pHddCtx)
7752 {
7753 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7754 "%s: HDD context is Null!!!", __func__);
7755 return ;
7756 }
7757
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307758 spin_lock(&pHddCtx->schedScan_lock);
7759 if (TRUE == pHddCtx->isWiphySuspended)
7760 {
7761 pHddCtx->isSchedScanUpdatePending = TRUE;
7762 spin_unlock(&pHddCtx->schedScan_lock);
7763 hddLog(VOS_TRACE_LEVEL_INFO,
7764 "%s: Update cfg80211 scan database after it resume", __func__);
7765 return ;
7766 }
7767 spin_unlock(&pHddCtx->schedScan_lock);
7768
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307769 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
7770
7771 if (0 > ret)
7772 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
7773
7774 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7776 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307777}
7778
7779/*
7780 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
7781 * NL interface to enable PNO
7782 */
7783static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
7784 struct net_device *dev, struct cfg80211_sched_scan_request *request)
7785{
7786 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7787 tpSirPNOScanReq pPnoRequest = NULL;
7788 hdd_context_t *pHddCtx;
7789 tHalHandle hHal;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05307790 v_U32_t i, indx, num_ch, tempInterval;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307791 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7792 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7793 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
7794 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307795 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307796
7797 if (NULL == pAdapter)
7798 {
7799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7800 "%s: HDD adapter is Null", __func__);
7801 return -ENODEV;
7802 }
7803
7804 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307805 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307806
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307807 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307808 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307809 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7810 "%s: HDD context is not valid", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307811 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307812 }
7813
7814 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7815 if (NULL == hHal)
7816 {
7817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7818 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307819 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307820 }
7821
7822 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
7823 if (NULL == pPnoRequest)
7824 {
7825 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7826 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307827 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307828 }
7829
Madan Mohan Koyyalamudic3f04352013-09-26 19:21:48 +05307830 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307831 pPnoRequest->enable = 1; /*Enable PNO */
7832 pPnoRequest->ucNetworksCount = request->n_match_sets;
7833
7834 if (( !pPnoRequest->ucNetworksCount ) ||
7835 ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
7836 {
7837 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7838 "Network input is not correct");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307839 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307840 goto error;
7841 }
7842
7843 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
7844 {
7845 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7846 "Incorrect number of channels");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307847 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307848 goto error;
7849 }
7850
7851 /* Framework provides one set of channels(all)
7852 * common for all saved profile */
7853 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
7854 channels_allowed, &num_channels_allowed))
7855 {
7856 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7857 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307858 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307859 goto error;
7860 }
7861 /* Checking each channel against allowed channel list */
7862 num_ch = 0;
7863 for (i = 0; i < request->n_channels; i++)
7864 {
7865 for (indx = 0; indx < num_channels_allowed; indx++)
7866 {
7867 if (request->channels[i]->hw_value == channels_allowed[indx])
7868 {
7869 valid_ch[num_ch++] = request->channels[i]->hw_value;
7870 break ;
7871 }
7872 }
7873 }
7874
7875 /* Filling per profile params */
7876 for (i = 0; i < pPnoRequest->ucNetworksCount; i++)
7877 {
7878 pPnoRequest->aNetworks[i].ssId.length =
7879 request->match_sets[i].ssid.ssid_len;
7880
7881 if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) ||
7882 ( pPnoRequest->aNetworks[i].ssId.length > 32 ) )
7883 {
7884 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7885 "SSID Len %d is not correct for network %d",
7886 pPnoRequest->aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307887 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307888 goto error;
7889 }
7890
7891 memcpy(pPnoRequest->aNetworks[i].ssId.ssId,
7892 request->match_sets[i].ssid.ssid,
7893 request->match_sets[i].ssid.ssid_len);
7894 pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
7895 pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/
7896 pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
7897
7898 /*Copying list of valid channel into request */
7899 memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch);
7900 pPnoRequest->aNetworks[i].ucChannelCount = num_ch;
7901
7902 pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value
7903 }
7904
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +05307905 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7906 "request->ie_len = %d", request->ie_len);
7907 if ((0 < request->ie_len) && (NULL != request->ie))
7908 {
7909 pPnoRequest->us24GProbeTemplateLen = request->ie_len;
7910 memcpy(&pPnoRequest->p24GProbeTemplate, request->ie,
7911 pPnoRequest->us24GProbeTemplateLen);
7912
7913 pPnoRequest->us5GProbeTemplateLen = request->ie_len;
7914 memcpy(&pPnoRequest->p5GProbeTemplate, request->ie,
7915 pPnoRequest->us5GProbeTemplateLen);
7916 }
7917
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05307918 /* Driver gets only one time interval which is hardcoded in
7919 * supplicant for 10000ms. Taking power consumption into account 6 timers
7920 * will be used, Timervalue is increased exponentially i.e 10,20,40,
7921 * 80,160,320 secs. And number of scan cycle for each timer
7922 * is configurable through INI param gPNOScanTimerRepeatValue.
7923 * If it is set to 0 only one timer will be used and PNO scan cycle
7924 * will be repeated after each interval specified by supplicant
7925 * till PNO is disabled.
7926 */
7927 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
7928 pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
7929 else
7930 pPnoRequest->scanTimers.ucScanTimersCount =
7931 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
7932
7933 tempInterval = (request->interval)/1000;
7934 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7935 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
7936 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
7937 for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++)
7938 {
7939 pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat =
7940 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
7941 pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval;
7942 tempInterval *= 2;
7943 }
7944 //Repeat last timer until pno disabled.
7945 pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
7946
Madan Mohan Koyyalamudid206c7b2013-09-26 22:54:51 +05307947 pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307948
7949 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
7950 pPnoRequest, pAdapter->sessionId,
7951 hdd_cfg80211_sched_scan_done_callback, pAdapter);
7952 if (eHAL_STATUS_SUCCESS != status)
7953 {
7954 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7955 "Failed to enable PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307956 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307957 goto error;
7958 }
7959
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307960 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7961 "PNO scanRequest offloaded");
7962
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307963error:
7964 vos_mem_free(pPnoRequest);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307965 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307966}
7967
7968/*
7969 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
7970 * NL interface to disable PNO
7971 */
7972static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
7973 struct net_device *dev)
7974{
7975 eHalStatus status = eHAL_STATUS_FAILURE;
7976 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7977 hdd_context_t *pHddCtx;
7978 tHalHandle hHal;
7979 tpSirPNOScanReq pPnoRequest = NULL;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307980 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307981
7982 ENTER();
7983
7984 if (NULL == pAdapter)
7985 {
7986 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7987 "%s: HDD adapter is Null", __func__);
7988 return -ENODEV;
7989 }
7990
7991 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307992
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307993 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307994 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307995 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307996 "%s: HDD context is Null", __func__);
7997 return -ENODEV;
7998 }
7999
8000 /* The return 0 is intentional when isLogpInProgress and
8001 * isLoadUnloadInProgress. We did observe a crash due to a return of
8002 * failure in sched_scan_stop , especially for a case where the unload
8003 * of the happens at the same time. The function __cfg80211_stop_sched_scan
8004 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
8005 * success. If it returns a failure , then its next invocation due to the
8006 * clean up of the second interface will have the dev pointer corresponding
8007 * to the first one leading to a crash.
8008 */
8009 if (pHddCtx->isLogpInProgress)
8010 {
8011 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8012 "%s: LOGP in Progress. Ignore!!!", __func__);
8013 return ret;
8014 }
8015
8016 if (pHddCtx->isLoadUnloadInProgress)
8017 {
8018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8019 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
8020 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308021 }
8022
8023 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8024 if (NULL == hHal)
8025 {
8026 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8027 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308028 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308029 }
8030
8031 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
8032 if (NULL == pPnoRequest)
8033 {
8034 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8035 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308036 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308037 }
8038
8039 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
8040 pPnoRequest->enable = 0; /* Disable PNO */
8041 pPnoRequest->ucNetworksCount = 0;
8042
8043 status = sme_SetPreferredNetworkList(hHal, pPnoRequest,
8044 pAdapter->sessionId,
8045 NULL, pAdapter);
8046 if (eHAL_STATUS_SUCCESS != status)
8047 {
8048 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8049 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308050 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308051 }
8052
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308053 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8054 "%s: PNO scan disabled", __func__);
8055
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308056 vos_mem_free(pPnoRequest);
8057
8058 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308059 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308060}
8061
8062#endif /*FEATURE_WLAN_SCAN_PNO*/
8063
8064
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008065#ifdef FEATURE_WLAN_TDLS
8066static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
8067 u8 *peer, u8 action_code, u8 dialog_token,
8068 u16 status_code, const u8 *buf, size_t len)
8069{
8070
8071 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8072 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008073 u8 peerMac[6];
8074 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008075 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -08008076 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -07008077 long rc;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008078
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008079 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008080 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308081 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008082 "Invalid arguments");
8083 return -EINVAL;
8084 }
8085
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008086 if (pHddCtx->isLogpInProgress)
8087 {
8088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8089 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008090 wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008091 return -EBUSY;
8092 }
8093
Hoonki Lee27511902013-03-14 18:19:06 -07008094 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008095 {
Hoonki Lee27511902013-03-14 18:19:06 -07008096 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8097 "%s: TDLS mode is disabled OR not enabled in FW."
8098 MAC_ADDRESS_STR " action %d declined.",
8099 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008100 return -ENOTSUPP;
8101 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008102
Hoonki Lee27511902013-03-14 18:19:06 -07008103 /* other than teardown frame, other mgmt frames are not sent if disabled */
8104 if (SIR_MAC_TDLS_TEARDOWN != action_code)
8105 {
8106 /* if tdls_mode is disabled to respond to peer's request */
8107 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
8108 {
8109 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8110 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008111 " TDLS mode is disabled. action %d declined.",
8112 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -07008113
8114 return -ENOTSUPP;
8115 }
8116 }
8117
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008118 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
8119 {
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308120 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008121 {
8122 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008123 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008124 " TDLS setup is ongoing. action %d declined.",
8125 __func__, MAC_ADDR_ARRAY(peer), action_code);
8126 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008127 }
8128 }
8129
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008130 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
8131 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -08008132 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008133 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
Lee Hoonkic1262f22013-01-24 21:59:00 -08008134 {
8135 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
8136 we return error code at 'add_station()'. Hence we have this
8137 check again in addtion to add_station().
8138 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008139 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -08008140 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008141 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8142 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008143 " TDLS Max peer already connected. action %d declined.",
8144 __func__, MAC_ADDR_ARRAY(peer), action_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008145 goto error;
Lee Hoonkic1262f22013-01-24 21:59:00 -08008146 }
8147 else
8148 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008149 /* maximum reached. tweak to send error code to peer and return
8150 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -08008151 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008152 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8153 "%s: " MAC_ADDRESS_STR
8154 " TDLS Max peer already connected send response status %d",
8155 __func__, MAC_ADDR_ARRAY(peer), status_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008156 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008157 /* fall through to send setup resp with failure status
8158 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -08008159 }
8160 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008161 else
8162 {
8163 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308164 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008165 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008166 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008167 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008168 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
8169 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008170 return -EPERM;
8171 }
8172 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008173 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008174 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008175
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008176#ifdef WLAN_FEATURE_TDLS_DEBUG
8177 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008178 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d",
8179 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
8180 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008181#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008182
Hoonki Leea34dd892013-02-05 22:56:02 -08008183 /*Except teardown responder will not be used so just make 0*/
8184 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008185 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -08008186 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008187
8188 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308189 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008190
8191 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
8192 responder = pTdlsPeer->is_responder;
8193 else
Hoonki Leea34dd892013-02-05 22:56:02 -08008194 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008195 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8196 "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d",
8197 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
8198 dialog_token, status_code, len);
8199 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -08008200 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008201 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008202
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308203 /* For explicit trigger of DIS_REQ come out of BMPS for
8204 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -07008205 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308206 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
8207 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -07008208 {
8209 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
8210 {
8211 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308212 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Hoonki Lee14621352013-04-16 17:51:19 -07008213 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
8214 }
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308215 if (SIR_MAC_TDLS_DIS_REQ != action_code)
8216 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
Hoonki Lee14621352013-04-16 17:51:19 -07008217 }
8218
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008219 /* make sure doesn't call send_mgmt() while it is pending */
8220 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
8221 {
8222 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8223 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY\n",
8224 __func__, MAC_ADDR_ARRAY(peer), action_code);
8225 return -EBUSY;
8226 }
8227
8228 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008229 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
8230
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008231 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Hoonki Leea34dd892013-02-05 22:56:02 -08008232 peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008233
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008234 if (VOS_STATUS_SUCCESS != status)
8235 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008236 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8237 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008238 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -07008239 wlan_hdd_tdls_check_bmps(pAdapter);
8240 goto error;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008241 }
8242
Hoonki Leed37cbb32013-04-20 00:31:14 -07008243 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
8244 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
8245
8246 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008247 {
Hoonki Leed37cbb32013-04-20 00:31:14 -07008248 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008249 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -07008250 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008251 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Leed37cbb32013-04-20 00:31:14 -07008252 wlan_hdd_tdls_check_bmps(pAdapter);
8253 goto error;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008254 }
8255
Gopichand Nakkala05922802013-03-14 12:23:19 -07008256 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -07008257 {
8258 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008259 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -07008260 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008261
Hoonki Leea34dd892013-02-05 22:56:02 -08008262 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
8263 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008264 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -08008265 }
8266 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
8267 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008268 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -08008269 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008270
8271 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008272error:
8273 /* max_sta_failed ; we didn't set to CONNECTING for this case,
8274 because we already know that this transaction will be failed,
8275 but we weren't sure if supplicant call DISABLE_LINK or not. So,
8276 to be safe, do not change the state mahine.
8277 */
8278 if(max_sta_failed == 0 &&
8279 (WLAN_IS_TDLS_SETUP_ACTION(action_code)))
8280 wlan_hdd_tdls_set_link_status(pAdapter, peerMac, eTDLS_LINK_IDLE);
8281 return -EPERM;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008282}
8283
8284static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
8285 u8 *peer, enum nl80211_tdls_operation oper)
8286{
8287 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8288 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308289 int status;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008290#ifdef WLAN_FEATURE_TDLS_DEBUG
8291 const char *tdls_oper_str[]= {
8292 "NL80211_TDLS_DISCOVERY_REQ",
8293 "NL80211_TDLS_SETUP",
8294 "NL80211_TDLS_TEARDOWN",
8295 "NL80211_TDLS_ENABLE_LINK",
8296 "NL80211_TDLS_DISABLE_LINK",
Gopichand Nakkala29d00192013-06-20 19:03:52 +05308297 "NL80211_TDLS_UNKNOWN_OPER"};
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008298#endif
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008299 hddTdlsPeer_t *pTdlsPeer;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008300
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308301 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008302 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008303 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07008304 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008305 return -EINVAL;
8306 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008307
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308308 status = wlan_hdd_validate_context(pHddCtx);
8309
8310 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008311 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308312 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8313 "%s: HDD context is not valid", __func__);
8314 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008315 }
8316
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308317 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008318
8319 if ( NULL == pTdlsPeer ) {
8320 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR " (oper %d) not exsting. ignored",
8321 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
8322 return -EINVAL;
8323 }
8324
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008325#ifdef WLAN_FEATURE_TDLS_DEBUG
8326 if((int)oper > 4)
8327 oper = 5;
8328
8329 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008330 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
8331 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008332 tdls_oper_str[(int)oper]);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008333#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008334
8335 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008336 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008337 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008338 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07008339 "TDLS Disabled in INI OR not enabled in FW. "
8340 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008341 return -ENOTSUPP;
8342 }
8343
8344 switch (oper) {
8345 case NL80211_TDLS_ENABLE_LINK:
8346 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008347 VOS_STATUS status;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308348 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008349
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -07008350 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
8351 {
8352 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
8353 MAC_ADDRESS_STR " failed",
8354 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
8355 return -EINVAL;
8356 }
8357
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008358 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008359 {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05308360 long ret;
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308361 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05308362
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308363 if (0 != wlan_hdd_tdls_get_link_establish_params(
8364 pAdapter, peer,&tdlsLinkEstablishParams)) {
8365 return -EINVAL;
8366 }
8367 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308368
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308369 sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter),
8370 pAdapter->sessionId, peer, &tdlsLinkEstablishParams);
8371 /* Send TDLS peer UAPSD capabilities to the firmware and
8372 * register with the TL on after the response for this operation
8373 * is received .
8374 */
8375 ret = wait_for_completion_interruptible_timeout(
8376 &pAdapter->tdls_link_establish_req_comp,
8377 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
8378 if (ret <= 0)
8379 {
8380 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8381 "%s: Link Establish Request Faled Status %ld",
8382 __func__, ret);
8383 return -EINVAL;
8384 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308385 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008386 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED);
Gopichand Nakkala471708b2013-06-04 20:03:01 +05308387 /* Mark TDLS client Authenticated .*/
8388 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
8389 pTdlsPeer->staId,
8390 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008391 if (VOS_STATUS_SUCCESS == status)
8392 {
Hoonki Lee14621352013-04-16 17:51:19 -07008393 if (pTdlsPeer->is_responder == 0)
8394 {
8395 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
8396
8397 wlan_hdd_tdls_timer_restart(pAdapter,
8398 &pTdlsPeer->initiatorWaitTimeoutTimer,
8399 WAIT_TIME_TDLS_INITIATOR);
8400 /* suspend initiator TX until it receives direct packet from the
8401 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
8402 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
8403 &staId, NULL);
8404 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008405 wlan_hdd_tdls_increment_peer_count(pAdapter);
8406 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008407 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308408
8409 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308410 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
8411 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308412 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308413 int ac;
8414 uint8 ucAc[4] = { WLANTL_AC_VO,
8415 WLANTL_AC_VI,
8416 WLANTL_AC_BK,
8417 WLANTL_AC_BE };
8418 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
8419 for(ac=0; ac < 4; ac++)
8420 {
8421 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
8422 pTdlsPeer->staId, ucAc[ac],
8423 tlTid[ac], tlTid[ac], 0, 0,
8424 WLANTL_BI_DIR );
8425 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308426 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008427 }
8428
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008429 }
8430 break;
8431 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -08008432 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008433 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -08008434 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008435 long status;
8436
8437 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
8438
Lee Hoonkic1262f22013-01-24 21:59:00 -08008439 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
8440 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008441
8442 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
8443 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
8444 if (status <= 0)
8445 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008446 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008447 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8448 "%s: Del station failed status %ld",
8449 __func__, status);
8450 return -EPERM;
8451 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008452 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Lee Hoonkic1262f22013-01-24 21:59:00 -08008453 }
8454 else
8455 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008456 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8457 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -08008458 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008459 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008460 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008461 case NL80211_TDLS_TEARDOWN:
8462 case NL80211_TDLS_SETUP:
8463 case NL80211_TDLS_DISCOVERY_REQ:
8464 /* We don't support in-driver setup/teardown/discovery */
8465 return -ENOTSUPP;
8466 default:
8467 return -ENOTSUPP;
8468 }
8469 return 0;
8470}
Chilam NG571c65a2013-01-19 12:27:36 +05308471
8472int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
8473 struct net_device *dev, u8 *peer)
8474{
8475 hddLog(VOS_TRACE_LEVEL_INFO, "tdls send discover req: %x %x %x %x %x %x",
8476 peer[0], peer[1], peer[2], peer[3], peer[4], peer[5]);
8477
8478 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
8479 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
8480}
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008481#endif
8482
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308483#ifdef WLAN_FEATURE_GTK_OFFLOAD
8484/*
8485 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
8486 * Callback rountine called upon receiving response for
8487 * get offload info
8488 */
8489void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
8490 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
8491{
8492
8493 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308494 tANI_U8 tempReplayCounter[8];
8495 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308496
8497 ENTER();
8498
8499 if (NULL == pAdapter)
8500 {
8501 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8502 "%s: HDD adapter is Null", __func__);
8503 return ;
8504 }
8505
8506 if (NULL == pGtkOffloadGetInfoRsp)
8507 {
8508 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8509 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
8510 return ;
8511 }
8512
8513 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
8514 {
8515 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8516 "%s: wlan Failed to get replay counter value",
8517 __func__);
8518 return ;
8519 }
8520
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308521 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8522 /* Update replay counter */
8523 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
8524 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
8525
8526 {
8527 /* changing from little to big endian since supplicant
8528 * works on big endian format
8529 */
8530 int i;
8531 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
8532
8533 for (i = 0; i < 8; i++)
8534 {
8535 tempReplayCounter[7-i] = (tANI_U8)p[i];
8536 }
8537 }
8538
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308539 /* Update replay counter to NL */
8540 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308541 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308542}
8543
8544/*
8545 * FUNCTION: wlan_hdd_cfg80211_set_rekey_data
8546 * This function is used to offload GTK rekeying job to the firmware.
8547 */
8548int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
8549 struct cfg80211_gtk_rekey_data *data)
8550{
8551 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8552 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8553 hdd_station_ctx_t *pHddStaCtx;
8554 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308555 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308556 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308557 eHalStatus status = eHAL_STATUS_FAILURE;
8558
8559 ENTER();
8560
8561 if (NULL == pAdapter)
8562 {
8563 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8564 "%s: HDD adapter is Null", __func__);
8565 return -ENODEV;
8566 }
8567
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308568 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308569
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308570 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308571 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308572 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8573 "%s: HDD context is not valid", __func__);
8574 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308575 }
8576
8577 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8578 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8579 if (NULL == hHal)
8580 {
8581 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8582 "%s: HAL context is Null!!!", __func__);
8583 return -EAGAIN;
8584 }
8585
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308586 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
8587 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
8588 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
8589 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308590 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308591 {
8592 /* changing from big to little endian since driver
8593 * works on little endian format
8594 */
8595 tANI_U8 *p =
8596 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
8597 int i;
8598
8599 for (i = 0; i < 8; i++)
8600 {
8601 p[7-i] = data->replay_ctr[i];
8602 }
8603 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308604
8605 if (TRUE == pHddCtx->hdd_wlan_suspended)
8606 {
8607 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308608 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
8609 sizeof (tSirGtkOffloadParams));
8610 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308611 pAdapter->sessionId);
8612
8613 if (eHAL_STATUS_SUCCESS != status)
8614 {
8615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8616 "%s: sme_SetGTKOffload failed, returned %d",
8617 __func__, status);
8618 return status;
8619 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8621 "%s: sme_SetGTKOffload successfull", __func__);
8622 }
8623 else
8624 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308625 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8626 "%s: wlan not suspended GTKOffload request is stored",
8627 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308628 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308629
8630 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308631}
8632#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
8633
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308634/*
8635 * FUNCTION: wlan_hdd_cfg80211_set_mac_acl
8636 * This function is used to set access control policy
8637 */
8638static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
8639 struct net_device *dev, const struct cfg80211_acl_data *params)
8640{
8641 int i;
8642 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8643 hdd_hostapd_state_t *pHostapdState;
8644 tsap_Config_t *pConfig;
8645 v_CONTEXT_t pVosContext = NULL;
8646 hdd_context_t *pHddCtx;
8647 int status;
8648
8649 ENTER();
8650
8651 if (NULL == pAdapter)
8652 {
8653 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8654 "%s: HDD adapter is Null", __func__);
8655 return -ENODEV;
8656 }
8657
8658 if (NULL == params)
8659 {
8660 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8661 "%s: params is Null", __func__);
8662 return -EINVAL;
8663 }
8664
8665 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8666 status = wlan_hdd_validate_context(pHddCtx);
8667
8668 if (0 != status)
8669 {
8670 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8671 "%s: HDD context is not valid", __func__);
8672 return status;
8673 }
8674
8675 pVosContext = pHddCtx->pvosContext;
8676 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
8677
8678 if (NULL == pHostapdState)
8679 {
8680 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8681 "%s: pHostapdState is Null", __func__);
8682 return -EINVAL;
8683 }
8684
8685 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
8686 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
8687
8688 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
8689 {
8690 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
8691
8692 /* default value */
8693 pConfig->num_accept_mac = 0;
8694 pConfig->num_deny_mac = 0;
8695
8696 /**
8697 * access control policy
8698 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
8699 * listed in hostapd.deny file.
8700 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
8701 * listed in hostapd.accept file.
8702 */
8703 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
8704 {
8705 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
8706 }
8707 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
8708 {
8709 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
8710 }
8711 else
8712 {
8713 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8714 "%s:Acl Policy : %d is not supported",
8715 __func__, params->acl_policy);
8716 return -ENOTSUPP;
8717 }
8718
8719 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
8720 {
8721 pConfig->num_accept_mac = params->n_acl_entries;
8722 for (i = 0; i < params->n_acl_entries; i++)
8723 {
8724 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8725 "** Add ACL MAC entry %i in WhiletList :"
8726 MAC_ADDRESS_STR, i,
8727 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8728
8729 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
8730 sizeof(qcmacaddr));
8731 }
8732 }
8733 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
8734 {
8735 pConfig->num_deny_mac = params->n_acl_entries;
8736 for (i = 0; i < params->n_acl_entries; i++)
8737 {
8738 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8739 "** Add ACL MAC entry %i in BlackList :"
8740 MAC_ADDRESS_STR, i,
8741 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8742
8743 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
8744 sizeof(qcmacaddr));
8745 }
8746 }
8747
8748 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
8749 {
8750 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8751 "%s: SAP Set Mac Acl fail", __func__);
8752 return -EINVAL;
8753 }
8754 }
8755 else
8756 {
8757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8758 "%s: Invalid device_mode = %d",
8759 __func__, pAdapter->device_mode);
8760 return -EINVAL;
8761 }
8762
8763 return 0;
8764}
8765
Leo Chang9056f462013-08-01 19:21:11 -07008766#ifdef WLAN_NL80211_TESTMODE
8767#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -07008768void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -07008769(
8770 void *pAdapter,
8771 void *indCont
8772)
8773{
Leo Changd9df8aa2013-09-26 13:32:26 -07008774 tSirLPHBInd *lphbInd;
8775 struct sk_buff *skb;
Leo Chang9056f462013-08-01 19:21:11 -07008776
8777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07008778 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -07008779
8780 if (NULL == indCont)
8781 {
8782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07008783 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -07008784 return;
8785 }
8786
Leo Changd9df8aa2013-09-26 13:32:26 -07008787 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -07008788 skb = cfg80211_testmode_alloc_event_skb(
8789 ((hdd_adapter_t *)pAdapter)->wdev.wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -07008790 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -07008791 GFP_ATOMIC);
8792 if (!skb)
8793 {
8794 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8795 "LPHB timeout, NL buffer alloc fail");
8796 return;
8797 }
8798
Leo Changac3ba772013-10-07 09:47:04 -07008799 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -07008800 {
8801 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8802 "WLAN_HDD_TM_ATTR_CMD put fail");
8803 goto nla_put_failure;
8804 }
Leo Changac3ba772013-10-07 09:47:04 -07008805 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -07008806 {
8807 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8808 "WLAN_HDD_TM_ATTR_TYPE put fail");
8809 goto nla_put_failure;
8810 }
Leo Changac3ba772013-10-07 09:47:04 -07008811 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -07008812 sizeof(tSirLPHBInd), lphbInd))
8813 {
8814 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8815 "WLAN_HDD_TM_ATTR_DATA put fail");
8816 goto nla_put_failure;
8817 }
Leo Chang9056f462013-08-01 19:21:11 -07008818 cfg80211_testmode_event(skb, GFP_ATOMIC);
8819 return;
8820
8821nla_put_failure:
8822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8823 "NLA Put fail");
8824 kfree_skb(skb);
8825
8826 return;
8827}
8828#endif /* FEATURE_WLAN_LPHB */
8829
8830static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
8831{
8832 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
8833 int err = 0;
8834#ifdef FEATURE_WLAN_LPHB
8835 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -07008836 eHalStatus smeStatus;
Leo Chang9056f462013-08-01 19:21:11 -07008837#endif /* FEATURE_WLAN_LPHB */
8838
8839 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
8840 if (err)
8841 {
8842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8843 "%s Testmode INV ATTR", __func__);
8844 return err;
8845 }
8846
8847 if (!tb[WLAN_HDD_TM_ATTR_CMD])
8848 {
8849 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8850 "%s Testmode INV CMD", __func__);
8851 return -EINVAL;
8852 }
8853
8854 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
8855 {
8856#ifdef FEATURE_WLAN_LPHB
8857 /* Low Power Heartbeat configuration request */
8858 case WLAN_HDD_TM_CMD_WLAN_HB:
8859 {
8860 int buf_len;
8861 void *buf;
8862 tSirLPHBReq *hb_params = NULL;
8863
8864 if (!tb[WLAN_HDD_TM_ATTR_DATA])
8865 {
8866 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8867 "%s Testmode INV DATA", __func__);
8868 return -EINVAL;
8869 }
8870
8871 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
8872 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
8873 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
8874 if (NULL == hb_params)
8875 {
8876 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8877 "%s Request Buffer Alloc Fail", __func__);
8878 return -EINVAL;
8879 }
8880
8881 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -07008882 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
8883 hb_params,
8884 wlan_hdd_cfg80211_lphb_ind_handler);
8885 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -07008886 {
Leo Changd9df8aa2013-09-26 13:32:26 -07008887 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8888 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -07008889 vos_mem_free(hb_params);
8890 }
Leo Chang9056f462013-08-01 19:21:11 -07008891 return 0;
8892 }
8893#endif /* FEATURE_WLAN_LPHB */
8894 default:
8895 return -EOPNOTSUPP;
8896 }
8897
8898 return err;
8899}
8900#endif /* CONFIG_NL80211_TESTMODE */
8901
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308902static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
8903 struct net_device *dev,
8904 int idx, struct survey_info *survey)
8905{
8906 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8907 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +05308908 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308909 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +05308910 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308911 v_S7_t snr,rssi;
8912 int status, i, j, filled = 0;
8913
8914 ENTER();
8915
8916
8917 if (NULL == pAdapter)
8918 {
8919 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8920 "%s: HDD adapter is Null", __func__);
8921 return -ENODEV;
8922 }
8923
8924 if (NULL == wiphy)
8925 {
8926 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8927 "%s: wiphy is Null", __func__);
8928 return -ENODEV;
8929 }
8930
8931 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8932 status = wlan_hdd_validate_context(pHddCtx);
8933
8934 if (0 != status)
8935 {
8936 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8937 "%s: HDD context is not valid", __func__);
8938 return status;
8939 }
8940
Mihir Sheted9072e02013-08-21 17:02:29 +05308941 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8942
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308943 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +05308944 0 != pAdapter->survey_idx ||
8945 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308946 {
8947 /* The survey dump ops when implemented completely is expected to
8948 * return a survey of all channels and the ops is called by the
8949 * kernel with incremental values of the argument 'idx' till it
8950 * returns -ENONET. But we can only support the survey for the
8951 * operating channel for now. survey_idx is used to track
8952 * that the ops is called only once and then return -ENONET for
8953 * the next iteration
8954 */
8955 pAdapter->survey_idx = 0;
8956 return -ENONET;
8957 }
8958
8959 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
8960
8961 wlan_hdd_get_snr(pAdapter, &snr);
8962 wlan_hdd_get_rssi(pAdapter, &rssi);
8963
8964 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
8965 hdd_wlan_get_freq(channel, &freq);
8966
8967
8968 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
8969 {
8970 if (NULL == wiphy->bands[i])
8971 {
8972 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
8973 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
8974 continue;
8975 }
8976
8977 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
8978 {
8979 struct ieee80211_supported_band *band = wiphy->bands[i];
8980
8981 if (band->channels[j].center_freq == (v_U16_t)freq)
8982 {
8983 survey->channel = &band->channels[j];
8984 /* The Rx BDs contain SNR values in dB for the received frames
8985 * while the supplicant expects noise. So we calculate and
8986 * return the value of noise (dBm)
8987 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
8988 */
8989 survey->noise = rssi - snr;
8990 survey->filled = SURVEY_INFO_NOISE_DBM;
8991 filled = 1;
8992 }
8993 }
8994 }
8995
8996 if (filled)
8997 pAdapter->survey_idx = 1;
8998 else
8999 {
9000 pAdapter->survey_idx = 0;
9001 return -ENONET;
9002 }
9003
9004 return 0;
9005}
9006
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309007/*
9008 * FUNCTION: wlan_hdd_cfg80211_resume_wlan
9009 * this is called when cfg80211 driver resume
9010 * driver updates latest sched_scan scan result(if any) to cfg80211 database
9011 */
9012int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
9013{
9014 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9015 hdd_adapter_t *pAdapter;
9016 hdd_adapter_list_node_t *pAdapterNode, *pNext;
9017 VOS_STATUS status = VOS_STATUS_SUCCESS;
9018
9019 ENTER();
9020
9021 if ( NULL == pHddCtx )
9022 {
9023 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9024 "%s: HddCtx validation failed", __func__);
9025 return 0;
9026 }
9027
9028 if (pHddCtx->isLogpInProgress)
9029 {
9030 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9031 "%s: LOGP in Progress. Ignore!!!", __func__);
9032 return 0;
9033 }
9034
9035 if (pHddCtx->isLoadUnloadInProgress)
9036 {
9037 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9038 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
9039 return 0;
9040 }
9041
9042 spin_lock(&pHddCtx->schedScan_lock);
9043 pHddCtx->isWiphySuspended = FALSE;
9044 if (TRUE != pHddCtx->isSchedScanUpdatePending)
9045 {
9046 spin_unlock(&pHddCtx->schedScan_lock);
9047 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9048 "%s: Return resume is not due to PNO indication", __func__);
9049 return 0;
9050 }
9051 // Reset flag to avoid updatating cfg80211 data old results again
9052 pHddCtx->isSchedScanUpdatePending = FALSE;
9053 spin_unlock(&pHddCtx->schedScan_lock);
9054
9055 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
9056
9057 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
9058 {
9059 pAdapter = pAdapterNode->pAdapter;
9060 if ( (NULL != pAdapter) &&
9061 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
9062 {
9063 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
9064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9065 "%s: NO SCAN result", __func__);
9066 else
9067 cfg80211_sched_scan_results(pHddCtx->wiphy);
9068
9069 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9070 "%s : cfg80211 scan result database updated", __func__);
9071
9072 return 0;
9073
9074 }
9075 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
9076 pAdapterNode = pNext;
9077 }
9078
9079 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9080 "%s: Failed to find Adapter", __func__);
9081 return 0;
9082}
9083
9084/*
9085 * FUNCTION: wlan_hdd_cfg80211_suspend_wlan
9086 * this is called when cfg80211 driver suspends
9087 */
9088int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
9089 struct cfg80211_wowlan *wow)
9090{
9091 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9092
9093 ENTER();
9094 if (NULL == pHddCtx)
9095 {
9096 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9097 "%s: HddCtx validation failed", __func__);
9098 return 0;
9099 }
9100
9101 pHddCtx->isWiphySuspended = TRUE;
9102
9103 EXIT();
9104
9105 return 0;
9106}
9107
Jeff Johnson295189b2012-06-20 16:38:30 -07009108/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309109static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -07009110{
9111 .add_virtual_intf = wlan_hdd_add_virtual_intf,
9112 .del_virtual_intf = wlan_hdd_del_virtual_intf,
9113 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
9114 .change_station = wlan_hdd_change_station,
9115#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9116 .add_beacon = wlan_hdd_cfg80211_add_beacon,
9117 .del_beacon = wlan_hdd_cfg80211_del_beacon,
9118 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009119#else
9120 .start_ap = wlan_hdd_cfg80211_start_ap,
9121 .change_beacon = wlan_hdd_cfg80211_change_beacon,
9122 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -07009123#endif
9124 .change_bss = wlan_hdd_cfg80211_change_bss,
9125 .add_key = wlan_hdd_cfg80211_add_key,
9126 .get_key = wlan_hdd_cfg80211_get_key,
9127 .del_key = wlan_hdd_cfg80211_del_key,
9128 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009129#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009130 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009131#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009132 .scan = wlan_hdd_cfg80211_scan,
9133 .connect = wlan_hdd_cfg80211_connect,
9134 .disconnect = wlan_hdd_cfg80211_disconnect,
9135 .join_ibss = wlan_hdd_cfg80211_join_ibss,
9136 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
9137 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
9138 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
9139 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -07009140 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
9141 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
9142 .mgmt_tx = wlan_hdd_action,
9143#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9144 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
9145 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
9146 .set_txq_params = wlan_hdd_set_txq_params,
9147#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009148 .get_station = wlan_hdd_cfg80211_get_station,
9149 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
9150 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009151 .add_station = wlan_hdd_cfg80211_add_station,
9152#ifdef FEATURE_WLAN_LFR
9153 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
9154 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
9155 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
9156#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009157#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
9158 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
9159#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009160#ifdef FEATURE_WLAN_TDLS
9161 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
9162 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
9163#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309164#ifdef WLAN_FEATURE_GTK_OFFLOAD
9165 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
9166#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309167#ifdef FEATURE_WLAN_SCAN_PNO
9168 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
9169 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
9170#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309171 .resume = wlan_hdd_cfg80211_resume_wlan,
9172 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309173 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -07009174#ifdef WLAN_NL80211_TESTMODE
9175 .testmode_cmd = wlan_hdd_cfg80211_testmode,
9176#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309177 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009178};
9179