blob: 7931bad7a8f1a015dbc6a561817bbab38473a90c [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"
86#endif
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053087#include "wlan_nv.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070088
89#define g_mode_rates_size (12)
90#define a_mode_rates_size (8)
91#define FREQ_BASE_80211G (2407)
92#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070093#define MAX_SCAN_SSID 9
Jeff Johnson295189b2012-06-20 16:38:30 -070094#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
95 ((int) OFFSET_OF( tSirBssDescription, ieFields)))
96
97#define HDD2GHZCHAN(freq, chan, flag) { \
98 .band = IEEE80211_BAND_2GHZ, \
99 .center_freq = (freq), \
100 .hw_value = (chan),\
101 .flags = (flag), \
102 .max_antenna_gain = 0 ,\
103 .max_power = 30, \
104}
105
106#define HDD5GHZCHAN(freq, chan, flag) { \
107 .band = IEEE80211_BAND_5GHZ, \
108 .center_freq = (freq), \
109 .hw_value = (chan),\
110 .flags = (flag), \
111 .max_antenna_gain = 0 ,\
112 .max_power = 30, \
113}
114
115#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
116{\
117 .bitrate = rate, \
118 .hw_value = rate_id, \
119 .flags = flag, \
120}
121
Lee Hoonkic1262f22013-01-24 21:59:00 -0800122#ifndef WLAN_FEATURE_TDLS_DEBUG
123#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_INFO
124#else
125#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_ERROR
126#endif
127
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530128#ifdef WLAN_FEATURE_VOWIFI_11R
129#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
130#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
131#endif
132
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530133static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700134{
135 WLAN_CIPHER_SUITE_WEP40,
136 WLAN_CIPHER_SUITE_WEP104,
137 WLAN_CIPHER_SUITE_TKIP,
138#ifdef FEATURE_WLAN_CCX
139#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
140 WLAN_CIPHER_SUITE_KRK,
141 WLAN_CIPHER_SUITE_CCMP,
142#else
143 WLAN_CIPHER_SUITE_CCMP,
144#endif
145#ifdef FEATURE_WLAN_WAPI
146 WLAN_CIPHER_SUITE_SMS4,
147#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700148#ifdef WLAN_FEATURE_11W
149 WLAN_CIPHER_SUITE_AES_CMAC,
150#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700151};
152
153static inline int is_broadcast_ether_addr(const u8 *addr)
154{
155 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
156 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
157}
158
159static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530160{
Jeff Johnson295189b2012-06-20 16:38:30 -0700161 HDD2GHZCHAN(2412, 1, 0) ,
162 HDD2GHZCHAN(2417, 2, 0) ,
163 HDD2GHZCHAN(2422, 3, 0) ,
164 HDD2GHZCHAN(2427, 4, 0) ,
165 HDD2GHZCHAN(2432, 5, 0) ,
166 HDD2GHZCHAN(2437, 6, 0) ,
167 HDD2GHZCHAN(2442, 7, 0) ,
168 HDD2GHZCHAN(2447, 8, 0) ,
169 HDD2GHZCHAN(2452, 9, 0) ,
170 HDD2GHZCHAN(2457, 10, 0) ,
171 HDD2GHZCHAN(2462, 11, 0) ,
172 HDD2GHZCHAN(2467, 12, 0) ,
173 HDD2GHZCHAN(2472, 13, 0) ,
174 HDD2GHZCHAN(2484, 14, 0) ,
175};
176
Jeff Johnson295189b2012-06-20 16:38:30 -0700177static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
178{
179 HDD2GHZCHAN(2412, 1, 0) ,
180 HDD2GHZCHAN(2437, 6, 0) ,
181 HDD2GHZCHAN(2462, 11, 0) ,
182};
Jeff Johnson295189b2012-06-20 16:38:30 -0700183
184static struct ieee80211_channel hdd_channels_5_GHZ[] =
185{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700186 HDD5GHZCHAN(4920, 240, 0) ,
187 HDD5GHZCHAN(4940, 244, 0) ,
188 HDD5GHZCHAN(4960, 248, 0) ,
189 HDD5GHZCHAN(4980, 252, 0) ,
190 HDD5GHZCHAN(5040, 208, 0) ,
191 HDD5GHZCHAN(5060, 212, 0) ,
192 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700193 HDD5GHZCHAN(5180, 36, 0) ,
194 HDD5GHZCHAN(5200, 40, 0) ,
195 HDD5GHZCHAN(5220, 44, 0) ,
196 HDD5GHZCHAN(5240, 48, 0) ,
197 HDD5GHZCHAN(5260, 52, 0) ,
198 HDD5GHZCHAN(5280, 56, 0) ,
199 HDD5GHZCHAN(5300, 60, 0) ,
200 HDD5GHZCHAN(5320, 64, 0) ,
201 HDD5GHZCHAN(5500,100, 0) ,
202 HDD5GHZCHAN(5520,104, 0) ,
203 HDD5GHZCHAN(5540,108, 0) ,
204 HDD5GHZCHAN(5560,112, 0) ,
205 HDD5GHZCHAN(5580,116, 0) ,
206 HDD5GHZCHAN(5600,120, 0) ,
207 HDD5GHZCHAN(5620,124, 0) ,
208 HDD5GHZCHAN(5640,128, 0) ,
209 HDD5GHZCHAN(5660,132, 0) ,
210 HDD5GHZCHAN(5680,136, 0) ,
211 HDD5GHZCHAN(5700,140, 0) ,
212 HDD5GHZCHAN(5745,149, 0) ,
213 HDD5GHZCHAN(5765,153, 0) ,
214 HDD5GHZCHAN(5785,157, 0) ,
215 HDD5GHZCHAN(5805,161, 0) ,
216 HDD5GHZCHAN(5825,165, 0) ,
217};
218
219static struct ieee80211_rate g_mode_rates[] =
220{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530221 HDD_G_MODE_RATETAB(10, 0x1, 0),
222 HDD_G_MODE_RATETAB(20, 0x2, 0),
223 HDD_G_MODE_RATETAB(55, 0x4, 0),
224 HDD_G_MODE_RATETAB(110, 0x8, 0),
225 HDD_G_MODE_RATETAB(60, 0x10, 0),
226 HDD_G_MODE_RATETAB(90, 0x20, 0),
227 HDD_G_MODE_RATETAB(120, 0x40, 0),
228 HDD_G_MODE_RATETAB(180, 0x80, 0),
229 HDD_G_MODE_RATETAB(240, 0x100, 0),
230 HDD_G_MODE_RATETAB(360, 0x200, 0),
231 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700232 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530233};
Jeff Johnson295189b2012-06-20 16:38:30 -0700234
235static struct ieee80211_rate a_mode_rates[] =
236{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530237 HDD_G_MODE_RATETAB(60, 0x10, 0),
238 HDD_G_MODE_RATETAB(90, 0x20, 0),
239 HDD_G_MODE_RATETAB(120, 0x40, 0),
240 HDD_G_MODE_RATETAB(180, 0x80, 0),
241 HDD_G_MODE_RATETAB(240, 0x100, 0),
242 HDD_G_MODE_RATETAB(360, 0x200, 0),
243 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700244 HDD_G_MODE_RATETAB(540, 0x800, 0),
245};
246
247static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
248{
249 .channels = hdd_channels_2_4_GHZ,
250 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
251 .band = IEEE80211_BAND_2GHZ,
252 .bitrates = g_mode_rates,
253 .n_bitrates = g_mode_rates_size,
254 .ht_cap.ht_supported = 1,
255 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
256 | IEEE80211_HT_CAP_GRN_FLD
257 | IEEE80211_HT_CAP_DSSSCCK40
258 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
259 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
260 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
261 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
262 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
263 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
264};
265
Jeff Johnson295189b2012-06-20 16:38:30 -0700266static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
267{
268 .channels = hdd_social_channels_2_4_GHZ,
269 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
270 .band = IEEE80211_BAND_2GHZ,
271 .bitrates = g_mode_rates,
272 .n_bitrates = g_mode_rates_size,
273 .ht_cap.ht_supported = 1,
274 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
275 | IEEE80211_HT_CAP_GRN_FLD
276 | IEEE80211_HT_CAP_DSSSCCK40
277 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
278 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
279 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
280 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
281 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
282 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
283};
Jeff Johnson295189b2012-06-20 16:38:30 -0700284
285static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
286{
287 .channels = hdd_channels_5_GHZ,
288 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
289 .band = IEEE80211_BAND_5GHZ,
290 .bitrates = a_mode_rates,
291 .n_bitrates = a_mode_rates_size,
292 .ht_cap.ht_supported = 1,
293 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
294 | IEEE80211_HT_CAP_GRN_FLD
295 | IEEE80211_HT_CAP_DSSSCCK40
296 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
297 | IEEE80211_HT_CAP_SGI_40
298 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
299 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
300 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
301 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
302 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
303 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
304};
305
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530306/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700307 TX/RX direction for each kind of interface */
308static const struct ieee80211_txrx_stypes
309wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
310 [NL80211_IFTYPE_STATION] = {
311 .tx = 0xffff,
312 .rx = BIT(SIR_MAC_MGMT_ACTION) |
313 BIT(SIR_MAC_MGMT_PROBE_REQ),
314 },
315 [NL80211_IFTYPE_AP] = {
316 .tx = 0xffff,
317 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
318 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
319 BIT(SIR_MAC_MGMT_PROBE_REQ) |
320 BIT(SIR_MAC_MGMT_DISASSOC) |
321 BIT(SIR_MAC_MGMT_AUTH) |
322 BIT(SIR_MAC_MGMT_DEAUTH) |
323 BIT(SIR_MAC_MGMT_ACTION),
324 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700325 [NL80211_IFTYPE_ADHOC] = {
326 .tx = 0xffff,
327 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
328 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
329 BIT(SIR_MAC_MGMT_PROBE_REQ) |
330 BIT(SIR_MAC_MGMT_DISASSOC) |
331 BIT(SIR_MAC_MGMT_AUTH) |
332 BIT(SIR_MAC_MGMT_DEAUTH) |
333 BIT(SIR_MAC_MGMT_ACTION),
334 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700335 [NL80211_IFTYPE_P2P_CLIENT] = {
336 .tx = 0xffff,
337 .rx = BIT(SIR_MAC_MGMT_ACTION) |
338 BIT(SIR_MAC_MGMT_PROBE_REQ),
339 },
340 [NL80211_IFTYPE_P2P_GO] = {
341 /* This is also same as for SoftAP */
342 .tx = 0xffff,
343 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
344 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
345 BIT(SIR_MAC_MGMT_PROBE_REQ) |
346 BIT(SIR_MAC_MGMT_DISASSOC) |
347 BIT(SIR_MAC_MGMT_AUTH) |
348 BIT(SIR_MAC_MGMT_DEAUTH) |
349 BIT(SIR_MAC_MGMT_ACTION),
350 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700351};
352
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800353#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800354static const struct ieee80211_iface_limit
355wlan_hdd_iface_limit[] = {
356 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800357 /* max = 3 ; Our driver create two interfaces during driver init
358 * wlan0 and p2p0 interfaces. p2p0 is considered as station
359 * interface until a group is formed. In JB architecture, once the
360 * group is formed, interface type of p2p0 is changed to P2P GO or
361 * Client.
362 * When supplicant remove the group, it first issue a set interface
363 * cmd to change the mode back to Station. In JB this works fine as
364 * we advertize two station type interface during driver init.
365 * Some vendors create separate interface for P2P GO/Client,
366 * after group formation(Third one). But while group remove
367 * supplicant first tries to change the mode(3rd interface) to STATION
368 * But as we advertized only two sta type interfaces nl80211 was
369 * returning error for the third one which was leading to failure in
370 * delete interface. Ideally while removing the group, supplicant
371 * should not try to change the 3rd interface mode to Station type.
372 * Till we get a fix in wpa_supplicant, we advertize max STA
373 * interface type to 3
374 */
375 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800376 .types = BIT(NL80211_IFTYPE_STATION),
377 },
378 {
379 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700380 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800381 },
382 {
383 .max = 1,
384 .types = BIT(NL80211_IFTYPE_P2P_GO) |
385 BIT(NL80211_IFTYPE_P2P_CLIENT),
386 },
387};
388
389/* By default, only single channel concurrency is allowed */
390static struct ieee80211_iface_combination
391wlan_hdd_iface_combination = {
392 .limits = wlan_hdd_iface_limit,
393 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800394 /*
395 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
396 * and p2p0 interfaces during driver init
397 * Some vendors create separate interface for P2P operations.
398 * wlan0: STA interface
399 * p2p0: P2P Device interface, action frames goes
400 * through this interface.
401 * p2p-xx: P2P interface, After GO negotiation this interface is
402 * created for p2p operations(GO/CLIENT interface).
403 */
404 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800405 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
406 .beacon_int_infra_match = false,
407};
408#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800409
Jeff Johnson295189b2012-06-20 16:38:30 -0700410static struct cfg80211_ops wlan_hdd_cfg80211_ops;
411
412/* Data rate 100KBPS based on IE Index */
413struct index_data_rate_type
414{
415 v_U8_t beacon_rate_index;
416 v_U16_t supported_rate[4];
417};
418
419/* 11B, 11G Rate table include Basic rate and Extended rate
420 The IDX field is the rate index
421 The HI field is the rate when RSSI is strong or being ignored
422 (in this case we report actual rate)
423 The MID field is the rate when RSSI is moderate
424 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
425 The LO field is the rate when RSSI is low
426 (in this case we don't report rates, actual current rate used)
427 */
428static const struct
429{
430 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700431 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700432} supported_data_rate[] =
433{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700434/* IDX HI HM LM LO (RSSI-based index */
435 {2, { 10, 10, 10, 0}},
436 {4, { 20, 20, 10, 0}},
437 {11, { 55, 20, 10, 0}},
438 {12, { 60, 55, 20, 0}},
439 {18, { 90, 55, 20, 0}},
440 {22, {110, 55, 20, 0}},
441 {24, {120, 90, 60, 0}},
442 {36, {180, 120, 60, 0}},
443 {44, {220, 180, 60, 0}},
444 {48, {240, 180, 90, 0}},
445 {66, {330, 180, 90, 0}},
446 {72, {360, 240, 90, 0}},
447 {96, {480, 240, 120, 0}},
448 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700449};
450
451/* MCS Based rate table */
452static struct index_data_rate_type supported_mcs_rate[] =
453{
454/* MCS L20 L40 S20 S40 */
455 {0, {65, 135, 72, 150}},
456 {1, {130, 270, 144, 300}},
457 {2, {195, 405, 217, 450}},
458 {3, {260, 540, 289, 600}},
459 {4, {390, 810, 433, 900}},
460 {5, {520, 1080, 578, 1200}},
461 {6, {585, 1215, 650, 1350}},
462 {7, {650, 1350, 722, 1500}}
463};
464
Leo Chang6f8870f2013-03-26 18:11:36 -0700465#ifdef WLAN_FEATURE_11AC
466
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530467#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700468
469struct index_vht_data_rate_type
470{
471 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530472 v_U16_t supported_VHT80_rate[2];
473 v_U16_t supported_VHT40_rate[2];
474 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700475};
476
477typedef enum
478{
479 DATA_RATE_11AC_MAX_MCS_7,
480 DATA_RATE_11AC_MAX_MCS_8,
481 DATA_RATE_11AC_MAX_MCS_9,
482 DATA_RATE_11AC_MAX_MCS_NA
483} eDataRate11ACMaxMcs;
484
485/* MCS Based VHT rate table */
486static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
487{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530488/* MCS L80 S80 L40 S40 L20 S40*/
489 {0, {293, 325}, {135, 150}, {65, 72}},
490 {1, {585, 650}, {270, 300}, {130, 144}},
491 {2, {878, 975}, {405, 450}, {195, 217}},
492 {3, {1170, 1300}, {540, 600}, {260, 289}},
493 {4, {1755, 1950}, {810, 900}, {390, 433}},
494 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
495 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
496 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
497 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
498 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700499};
500#endif /* WLAN_FEATURE_11AC */
501
Jeff Johnson295189b2012-06-20 16:38:30 -0700502extern struct net_device_ops net_ops_struct;
503
504/*
505 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530506 * This function is called by hdd_wlan_startup()
507 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -0700508 * This function is used to initialize and register wiphy structure.
509 */
510struct wiphy *wlan_hdd_cfg80211_init(int priv_size)
511{
512 struct wiphy *wiphy;
513 ENTER();
514
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530515 /*
516 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -0700517 */
518 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
519
520 if (!wiphy)
521 {
522 /* Print error and jump into err label and free the memory */
523 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
524 return NULL;
525 }
526
527 return wiphy;
528}
529
530/*
531 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530532 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -0700533 * private ioctl to change the band value
534 */
535int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
536{
Jeff Johnsone7245742012-09-05 17:12:55 -0700537 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700538 switch(eBand)
539 {
540 case eCSR_BAND_24:
541 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
542 wiphy->bands[IEEE80211_BAND_5GHZ] = NULL;
543 break;
544 case eCSR_BAND_5G:
Madan Mohan Koyyalamudi6f6390c2012-09-24 13:57:46 -0700545 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_p2p_2_4_GHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -0700546 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
547 break;
548 case eCSR_BAND_ALL:
549 default:
550 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
551 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
552 }
553 return 0;
554}
555/*
556 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530557 * This function is called by hdd_wlan_startup()
558 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -0700559 * This function is used to initialize and register wiphy structure.
560 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530561int wlan_hdd_cfg80211_register(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -0700562 struct wiphy *wiphy,
563 hdd_config_t *pCfg
564 )
565{
Jeff Johnsone7245742012-09-05 17:12:55 -0700566 ENTER();
567
Jeff Johnson295189b2012-06-20 16:38:30 -0700568 /* Now bind the underlying wlan device with wiphy */
569 set_wiphy_dev(wiphy, dev);
570
571 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
572
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -0700573 wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY;
Jeff Johnson295189b2012-06-20 16:38:30 -0700574
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700575#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -0700576 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
577 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
578 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -0700579 | WIPHY_FLAG_OFFCHAN_TX;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700580#endif
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700581#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
582 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -0800583#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700584 || pCfg->isFastRoamIniFeatureEnabled
585#endif
586#ifdef FEATURE_WLAN_CCX
587 || pCfg->isCcxIniFeatureEnabled
588#endif
589 )
590 {
591 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
592 }
James Zmuda77fb5ae2013-01-29 08:00:17 -0800593#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800594#ifdef FEATURE_WLAN_TDLS
595 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
596 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
597#endif
598
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700599 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
600 driver can still register regulatory callback and
601 it will get CRDA setting in wiphy->band[], but
602 driver need to determine what to do with both
603 regulatory settings */
604 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700605
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530606 wiphy->max_scan_ssids = MAX_SCAN_SSID;
607
Jeff Johnson295189b2012-06-20 16:38:30 -0700608 wiphy->max_scan_ie_len = 200 ; //TODO: define a macro
609
610 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530611 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -0700612 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -0700613 | BIT(NL80211_IFTYPE_P2P_CLIENT)
614 | BIT(NL80211_IFTYPE_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -0700615 | BIT(NL80211_IFTYPE_AP);
616
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800617#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800618 if( pCfg->enableMCC )
619 {
620 /* Currently, supports up to two channels */
621 wlan_hdd_iface_combination.num_different_channels = 2;
622
623 if( !pCfg->allowMCCGODiffBI )
624 wlan_hdd_iface_combination.beacon_int_infra_match = true;
625
626 }
627 wiphy->iface_combinations = &wlan_hdd_iface_combination;
628 wiphy->n_iface_combinations = 1;
629#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800630
Jeff Johnson295189b2012-06-20 16:38:30 -0700631 /* Before registering we need to update the ht capabilitied based
632 * on ini values*/
633 if( !pCfg->ShortGI20MhzEnable )
634 {
635 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
636 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
637 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
638 }
639
640 if( !pCfg->ShortGI40MhzEnable )
641 {
642 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
643 }
644
645 if( !pCfg->nChannelBondingMode5GHz )
646 {
647 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
648 }
649
650 /*Initialize band capability*/
651 switch(pCfg->nBandCapability)
652 {
653 case eCSR_BAND_24:
654 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
655 break;
656 case eCSR_BAND_5G:
Jeff Johnson295189b2012-06-20 16:38:30 -0700657 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_p2p_2_4_GHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -0700658 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
659 break;
660 case eCSR_BAND_ALL:
661 default:
662 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
663 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
664 }
665 /*Initialise the supported cipher suite details*/
666 wiphy->cipher_suites = hdd_cipher_suites;
667 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
668
669 /*signal strength in mBm (100*dBm) */
670 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
671
672#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnson295189b2012-06-20 16:38:30 -0700673 wiphy->max_remain_on_channel_duration = 1000;
674#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700675
676 /* Register our wiphy dev with cfg80211 */
677 if (0 > wiphy_register(wiphy))
678 {
679 /* print eror */
680 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
681 return -EIO;
682 }
683
684 EXIT();
685 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530686}
Jeff Johnson295189b2012-06-20 16:38:30 -0700687
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700688/* In this function we will try to get default country code from crda.
689 If the gCrdaDefaultCountryCode is configured in ini file,
690 we will try to call user space crda to get the regulatory settings for
691 that country. We will timeout if we can't get it from crda.
692 It's called by hdd_wlan_startup() after wlan_hdd_cfg80211_register.
693*/
694int wlan_hdd_get_crda_regd_entry(struct wiphy *wiphy, hdd_config_t *pCfg)
695{
696 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
697 if (memcmp(pCfg->crdaDefaultCountryCode,
698 CFG_CRDA_DEFAULT_COUNTRY_CODE_DEFAULT , 2) != 0)
699 {
700 init_completion(&pHddCtx->driver_crda_req);
701 regulatory_hint(wiphy, pCfg->crdaDefaultCountryCode);
702 wait_for_completion_interruptible_timeout(&pHddCtx->driver_crda_req,
703 CRDA_WAIT_TIME);
Yunsen Wange3ba1fb2013-04-05 15:04:43 -0700704 /* if the country is not found from current regulatory.bin,
705 fall back to world domain */
706 if (is_crda_regulatory_entry_valid() == VOS_FALSE)
707 crda_regulatory_entry_default(pCfg->crdaDefaultCountryCode, NUM_REG_DOMAINS-1);
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700708 }
709 return 0;
710}
711
Jeff Johnson295189b2012-06-20 16:38:30 -0700712/* In this function we will do all post VOS start initialization.
713 In this function we will register for all frame in which supplicant
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530714 is interested.
Jeff Johnson295189b2012-06-20 16:38:30 -0700715*/
716void wlan_hdd_cfg80211_post_voss_start(hdd_adapter_t* pAdapter)
717{
Jeff Johnson295189b2012-06-20 16:38:30 -0700718 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
719 /* Register for all P2P action, public action etc frames */
720 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
721
Jeff Johnsone7245742012-09-05 17:12:55 -0700722 ENTER();
723
Jeff Johnson295189b2012-06-20 16:38:30 -0700724 /* Right now we are registering these frame when driver is getting
725 initialized. Once we will move to 2.6.37 kernel, in which we have
726 frame register ops, we will move this code as a part of that */
727 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530728 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -0700729 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
730
731 /* GAS Initial Response */
732 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
733 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530734
Jeff Johnson295189b2012-06-20 16:38:30 -0700735 /* GAS Comeback Request */
736 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
737 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
738
739 /* GAS Comeback Response */
740 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
741 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
742
743 /* P2P Public Action */
744 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530745 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700746 P2P_PUBLIC_ACTION_FRAME_SIZE );
747
748 /* P2P Action */
749 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
750 (v_U8_t*)P2P_ACTION_FRAME,
751 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700752
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +0530753 /* WNM BSS Transition Request frame */
754 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
755 (v_U8_t*)WNM_BSS_ACTION_FRAME,
756 WNM_BSS_ACTION_FRAME_SIZE );
757
Chet Lanctot186b5732013-03-18 10:26:30 -0700758#ifdef WLAN_FEATURE_11W
759 /* SA Query Response Action Frame */
760 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
761 (v_U8_t*)SA_QUERY_FRAME_RSP,
762 SA_QUERY_FRAME_RSP_SIZE );
763#endif /* WLAN_FEATURE_11W */
Jeff Johnson295189b2012-06-20 16:38:30 -0700764}
765
766void wlan_hdd_cfg80211_pre_voss_stop(hdd_adapter_t* pAdapter)
767{
Jeff Johnson295189b2012-06-20 16:38:30 -0700768 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
769 /* Register for all P2P action, public action etc frames */
770 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
771
Jeff Johnsone7245742012-09-05 17:12:55 -0700772 ENTER();
773
Jeff Johnson295189b2012-06-20 16:38:30 -0700774 /* Right now we are registering these frame when driver is getting
775 initialized. Once we will move to 2.6.37 kernel, in which we have
776 frame register ops, we will move this code as a part of that */
777 /* GAS Initial Request */
778
779 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
780 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
781
782 /* GAS Initial Response */
783 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
784 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530785
Jeff Johnson295189b2012-06-20 16:38:30 -0700786 /* GAS Comeback Request */
787 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
788 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
789
790 /* GAS Comeback Response */
791 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
792 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
793
794 /* P2P Public Action */
795 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530796 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700797 P2P_PUBLIC_ACTION_FRAME_SIZE );
798
799 /* P2P Action */
800 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
801 (v_U8_t*)P2P_ACTION_FRAME,
802 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700803
804#ifdef WLAN_FEATURE_11W
805 /* SA Query Response Action Frame */
806 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
807 (v_U8_t*)SA_QUERY_FRAME_RSP,
808 SA_QUERY_FRAME_RSP_SIZE );
809#endif /* WLAN_FEATURE_11W */
Jeff Johnson295189b2012-06-20 16:38:30 -0700810}
811
812#ifdef FEATURE_WLAN_WAPI
813void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
814 const u8 *mac_addr, u8 *key , int key_Len)
815{
816 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
817 tCsrRoamSetKey setKey;
818 v_BOOL_t isConnected = TRUE;
819 int status = 0;
820 v_U32_t roamId= 0xFF;
821 tANI_U8 *pKeyPtr = NULL;
822 int n = 0;
823
824 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
825 __func__,pAdapter->device_mode);
826
Gopichand Nakkalae7480202013-02-11 15:24:22 +0530827 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -0700828 setKey.keyId = key_index; // Store Key ID
829 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
830 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
831 setKey.paeRole = 0 ; // the PAE role
832 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
833 {
834 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
835 }
836 else
837 {
838 isConnected = hdd_connIsConnected(pHddStaCtx);
839 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
840 }
841 setKey.keyLength = key_Len;
842 pKeyPtr = setKey.Key;
843 memcpy( pKeyPtr, key, key_Len);
844
845 hddLog(VOS_TRACE_LEVEL_INFO,"\n%s: WAPI KEY LENGTH:0x%04x",
846 __func__, key_Len);
847 for (n = 0 ; n < key_Len; n++)
848 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
849 __func__,n,setKey.Key[n]);
850
851 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
852 if ( isConnected )
853 {
854 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
855 pAdapter->sessionId, &setKey, &roamId );
856 }
857 if ( status != 0 )
858 {
859 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
860 "[%4d] sme_RoamSetKey returned ERROR status= %d",
861 __LINE__, status );
862 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
863 }
864}
865#endif /* FEATURE_WLAN_WAPI*/
866
867#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530868int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700869 beacon_data_t **ppBeacon,
870 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700871#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530872int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700873 beacon_data_t **ppBeacon,
874 struct cfg80211_beacon_data *params,
875 int dtim_period)
876#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530877{
Jeff Johnson295189b2012-06-20 16:38:30 -0700878 int size;
879 beacon_data_t *beacon = NULL;
880 beacon_data_t *old = NULL;
881 int head_len,tail_len;
882
Jeff Johnsone7245742012-09-05 17:12:55 -0700883 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700884 if (params->head && !params->head_len)
885 return -EINVAL;
886
887 old = pAdapter->sessionCtx.ap.beacon;
888
889 if (!params->head && !old)
890 return -EINVAL;
891
892 if (params->tail && !params->tail_len)
893 return -EINVAL;
894
895#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
896 /* Kernel 3.0 is not updating dtim_period for set beacon */
897 if (!params->dtim_period)
898 return -EINVAL;
899#endif
900
901 if(params->head)
902 head_len = params->head_len;
903 else
904 head_len = old->head_len;
905
906 if(params->tail || !old)
907 tail_len = params->tail_len;
908 else
909 tail_len = old->tail_len;
910
911 size = sizeof(beacon_data_t) + head_len + tail_len;
912
913 beacon = kzalloc(size, GFP_KERNEL);
914
915 if( beacon == NULL )
916 return -ENOMEM;
917
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700918#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -0700919 if(params->dtim_period || !old )
920 beacon->dtim_period = params->dtim_period;
921 else
922 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700923#else
924 if(dtim_period || !old )
925 beacon->dtim_period = dtim_period;
926 else
927 beacon->dtim_period = old->dtim_period;
928#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530929
Jeff Johnson295189b2012-06-20 16:38:30 -0700930 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
931 beacon->tail = beacon->head + head_len;
932 beacon->head_len = head_len;
933 beacon->tail_len = tail_len;
934
935 if(params->head) {
936 memcpy (beacon->head,params->head,beacon->head_len);
937 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530938 else {
Jeff Johnson295189b2012-06-20 16:38:30 -0700939 if(old)
940 memcpy (beacon->head,old->head,beacon->head_len);
941 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530942
Jeff Johnson295189b2012-06-20 16:38:30 -0700943 if(params->tail) {
944 memcpy (beacon->tail,params->tail,beacon->tail_len);
945 }
946 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530947 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -0700948 memcpy (beacon->tail,old->tail,beacon->tail_len);
949 }
950
951 *ppBeacon = beacon;
952
953 kfree(old);
954
955 return 0;
956
957}
Jeff Johnson295189b2012-06-20 16:38:30 -0700958
959v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
960{
961 int left = length;
962 v_U8_t *ptr = pIes;
963 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530964
Jeff Johnson295189b2012-06-20 16:38:30 -0700965 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530966 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 elem_id = ptr[0];
968 elem_len = ptr[1];
969 left -= 2;
970 if(elem_len > left)
971 {
972 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700973 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700974 eid,elem_len,left);
975 return NULL;
976 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530977 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 {
979 return ptr;
980 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530981
Jeff Johnson295189b2012-06-20 16:38:30 -0700982 left -= elem_len;
983 ptr += (elem_len + 2);
984 }
985 return NULL;
986}
987
Jeff Johnson295189b2012-06-20 16:38:30 -0700988/* Check if rate is 11g rate or not */
989static int wlan_hdd_rate_is_11g(u8 rate)
990{
991 u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 104}; /* actual rate * 2 */
992 u8 i;
993 for (i = 0; i < 8; i++)
994 {
995 if(rate == gRateArray[i])
996 return TRUE;
997 }
998 return FALSE;
999}
1000
1001/* Check for 11g rate and set proper 11g only mode */
1002static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
1003 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
1004{
1005 u8 i, num_rates = pIe[0];
1006
1007 pIe += 1;
1008 for ( i = 0; i < num_rates; i++)
1009 {
1010 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
1011 {
1012 /* If rate set have 11g rate than change the mode to 11G */
1013 *pSapHw_mode = eSAP_DOT11_MODE_11g;
1014 if (pIe[i] & BASIC_RATE_MASK)
1015 {
1016 /* If we have 11g rate as basic rate, it means mode
1017 is 11g only mode.
1018 */
1019 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
1020 *pCheckRatesfor11g = FALSE;
1021 }
1022 }
1023 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
1024 {
1025 *require_ht = TRUE;
1026 }
1027 }
1028 return;
1029}
1030
1031static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
1032{
1033 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1034 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1035 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1036 u8 checkRatesfor11g = TRUE;
1037 u8 require_ht = FALSE;
1038 u8 *pIe=NULL;
1039
1040 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
1041
1042 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
1043 pBeacon->head_len, WLAN_EID_SUPP_RATES);
1044 if (pIe != NULL)
1045 {
1046 pIe += 1;
1047 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1048 &pConfig->SapHw_mode);
1049 }
1050
1051 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1052 WLAN_EID_EXT_SUPP_RATES);
1053 if (pIe != NULL)
1054 {
1055
1056 pIe += 1;
1057 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1058 &pConfig->SapHw_mode);
1059 }
1060
1061 if( pConfig->channel > 14 )
1062 {
1063 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
1064 }
1065
1066 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1067 WLAN_EID_HT_CAPABILITY);
1068
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301069 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001070 {
1071 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
1072 if(require_ht)
1073 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
1074 }
1075}
1076
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301077static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
1078 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
1079{
1080 v_U8_t ielen = 0;
1081 v_U8_t *pIe = NULL;
1082 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1083
1084 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
1085 pBeacon->tail, pBeacon->tail_len);
1086
1087 if (pIe)
1088 {
1089 ielen = pIe[1] + 2;
1090 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1091 {
1092 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
1093 }
1094 else
1095 {
1096 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
1097 return -EINVAL;
1098 }
1099 *total_ielen += ielen;
1100 }
1101 return 0;
1102}
1103
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001104#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001105static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1106 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001107#else
1108static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1109 struct cfg80211_beacon_data *params)
1110#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001111{
1112 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301113 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001114 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07001115 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001116
1117 genie = vos_mem_malloc(MAX_GENIE_LEN);
1118
1119 if(genie == NULL) {
1120
1121 return -ENOMEM;
1122 }
1123
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301124 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1125 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001126 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301127 ret = -EINVAL;
1128 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001129 }
1130
1131#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301132 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1133 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
1134 {
1135 ret = -EINVAL;
1136 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001137 }
1138#endif
1139
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301140 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1141 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001142 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301143 ret = -EINVAL;
1144 goto done;
1145 }
1146
1147 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
1148 {
1149 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1150 &total_ielen, SS_OUI_TYPE, SS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001151 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301152 ret = -EINVAL;
1153 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001154 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001155 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001156
1157 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1158 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
1159 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
1160 {
1161 hddLog(LOGE,
1162 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001163 ret = -EINVAL;
1164 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001165 }
1166
1167 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1168 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
1169 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1170 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1171 ==eHAL_STATUS_FAILURE)
1172 {
1173 hddLog(LOGE,
1174 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001175 ret = -EINVAL;
1176 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001177 }
1178
1179 // Added for ProResp IE
1180 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
1181 {
1182 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
1183 u8 probe_rsp_ie_len[3] = {0};
1184 u8 counter = 0;
1185 /* Check Probe Resp Length if it is greater then 255 then Store
1186 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
1187 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
1188 Store More then 255 bytes into One Variable.
1189 */
1190 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
1191 {
1192 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
1193 {
1194 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
1195 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
1196 }
1197 else
1198 {
1199 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
1200 rem_probe_resp_ie_len = 0;
1201 }
1202 }
1203
1204 rem_probe_resp_ie_len = 0;
1205
1206 if (probe_rsp_ie_len[0] > 0)
1207 {
1208 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1209 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
1210 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1211 probe_rsp_ie_len[0], NULL,
1212 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1213 {
1214 hddLog(LOGE,
1215 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001216 ret = -EINVAL;
1217 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001218 }
1219 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
1220 }
1221
1222 if (probe_rsp_ie_len[1] > 0)
1223 {
1224 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1225 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
1226 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1227 probe_rsp_ie_len[1], NULL,
1228 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1229 {
1230 hddLog(LOGE,
1231 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001232 ret = -EINVAL;
1233 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001234 }
1235 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
1236 }
1237
1238 if (probe_rsp_ie_len[2] > 0)
1239 {
1240 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1241 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
1242 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1243 probe_rsp_ie_len[2], NULL,
1244 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1245 {
1246 hddLog(LOGE,
1247 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001248 ret = -EINVAL;
1249 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001250 }
1251 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
1252 }
1253
1254 if (probe_rsp_ie_len[1] == 0 )
1255 {
1256 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1257 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
1258 eANI_BOOLEAN_FALSE) )
1259 {
1260 hddLog(LOGE,
1261 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM\n");
1262 }
1263 }
1264
1265 if (probe_rsp_ie_len[2] == 0 )
1266 {
1267 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1268 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
1269 eANI_BOOLEAN_FALSE) )
1270 {
1271 hddLog(LOGE,
1272 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM\n");
1273 }
1274 }
1275
1276 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1277 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
1278 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1279 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1280 == eHAL_STATUS_FAILURE)
1281 {
1282 hddLog(LOGE,
1283 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001284 ret = -EINVAL;
1285 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001286 }
1287 }
1288 else
1289 {
1290 // Reset WNI_CFG_PROBE_RSP Flags
1291 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
1292
1293 hddLog(VOS_TRACE_LEVEL_INFO,
1294 "%s: No Probe Response IE received in set beacon",
1295 __func__);
1296 }
1297
1298 // Added for AssocResp IE
1299 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
1300 {
1301 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1302 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
1303 params->assocresp_ies_len, NULL,
1304 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1305 {
1306 hddLog(LOGE,
1307 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001308 ret = -EINVAL;
1309 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001310 }
1311
1312 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1313 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
1314 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1315 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1316 == eHAL_STATUS_FAILURE)
1317 {
1318 hddLog(LOGE,
1319 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001320 ret = -EINVAL;
1321 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001322 }
1323 }
1324 else
1325 {
1326 hddLog(VOS_TRACE_LEVEL_INFO,
1327 "%s: No Assoc Response IE received in set beacon",
1328 __func__);
1329
1330 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1331 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
1332 eANI_BOOLEAN_FALSE) )
1333 {
1334 hddLog(LOGE,
1335 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
1336 }
1337 }
1338
Jeff Johnsone7245742012-09-05 17:12:55 -07001339done:
Jeff Johnson295189b2012-06-20 16:38:30 -07001340 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301341 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001342}
Jeff Johnson295189b2012-06-20 16:38:30 -07001343
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301344/*
Jeff Johnson295189b2012-06-20 16:38:30 -07001345 * FUNCTION: wlan_hdd_validate_operation_channel
1346 * called by wlan_hdd_cfg80211_start_bss() and
1347 * wlan_hdd_cfg80211_set_channel()
1348 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301349 * channel list.
1350 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001351static VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
1352{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301353
Jeff Johnson295189b2012-06-20 16:38:30 -07001354 v_U32_t num_ch = 0;
1355 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1356 u32 indx = 0;
1357 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301358 v_U8_t fValidChannel = FALSE, count = 0;
1359 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301360
Jeff Johnson295189b2012-06-20 16:38:30 -07001361 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1362
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301363 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001364 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301365 /* Validate the channel */
1366 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001367 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301368 if ( channel == rfChannels[count].channelNum )
1369 {
1370 fValidChannel = TRUE;
1371 break;
1372 }
1373 }
1374 if (fValidChannel != TRUE)
1375 {
1376 hddLog(VOS_TRACE_LEVEL_ERROR,
1377 "%s: Invalid Channel [%d]", __func__, channel);
1378 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001379 }
1380 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301381 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001382 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301383 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1384 valid_ch, &num_ch))
1385 {
1386 hddLog(VOS_TRACE_LEVEL_ERROR,
1387 "%s: failed to get valid channel list", __func__);
1388 return VOS_STATUS_E_FAILURE;
1389 }
1390 for (indx = 0; indx < num_ch; indx++)
1391 {
1392 if (channel == valid_ch[indx])
1393 {
1394 break;
1395 }
1396 }
1397
1398 if (indx >= num_ch)
1399 {
1400 hddLog(VOS_TRACE_LEVEL_ERROR,
1401 "%s: Invalid Channel [%d]", __func__, channel);
1402 return VOS_STATUS_E_FAILURE;
1403 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001404 }
1405 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301406
Jeff Johnson295189b2012-06-20 16:38:30 -07001407}
1408
Viral Modi3a32cc52013-02-08 11:14:52 -08001409/**
1410 * FUNCTION: wlan_hdd_cfg80211_set_channel
1411 * This function is used to set the channel number
1412 */
1413static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
1414 struct ieee80211_channel *chan,
1415 enum nl80211_channel_type channel_type
1416 )
1417{
1418 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07001419 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08001420 hdd_adapter_t *pAdapter = NULL;
1421 int freq = chan->center_freq; /* freq is in MHZ */
1422
1423 ENTER();
1424
1425 if( NULL == dev )
1426 {
1427 hddLog(VOS_TRACE_LEVEL_ERROR,
1428 "%s: Called with dev = NULL.\n", __func__);
1429 return -ENODEV;
1430 }
1431 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
1432
1433 hddLog(VOS_TRACE_LEVEL_INFO,
1434 "%s: device_mode = %d freq = %d \n",__func__,
1435 pAdapter->device_mode, chan->center_freq);
1436 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1437 {
1438 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1439 return -EAGAIN;
1440 }
1441
1442 /*
1443 * Do freq to chan conversion
1444 * TODO: for 11a
1445 */
1446
1447 channel = ieee80211_frequency_to_channel(freq);
1448
1449 /* Check freq range */
1450 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
1451 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
1452 {
1453 hddLog(VOS_TRACE_LEVEL_ERROR,
1454 "%s: Channel [%d] is outside valid range from %d to %d\n",
1455 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
1456 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1457 return -EINVAL;
1458 }
1459
1460 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1461
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05301462 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
1463 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08001464 {
1465 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
1466 {
1467 hddLog(VOS_TRACE_LEVEL_ERROR,
1468 "%s: Invalid Channel [%d] \n", __func__, channel);
1469 return -EINVAL;
1470 }
1471 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1472 "%s: set channel to [%d] for device mode =%d",
1473 __func__, channel,pAdapter->device_mode);
1474 }
1475 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08001476 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08001477 )
1478 {
1479 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1480 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
1481 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1482
1483 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
1484 {
1485 /* Link is up then return cant set channel*/
1486 hddLog( VOS_TRACE_LEVEL_ERROR,
1487 "%s: IBSS Associated, can't set the channel\n", __func__);
1488 return -EINVAL;
1489 }
1490
1491 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
1492 pHddStaCtx->conn_info.operationChannel = channel;
1493 pRoamProfile->ChannelInfo.ChannelList =
1494 &pHddStaCtx->conn_info.operationChannel;
1495 }
1496 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08001497 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08001498 )
1499 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301500 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
1501 {
1502 if(VOS_STATUS_SUCCESS !=
1503 wlan_hdd_validate_operation_channel(pAdapter,channel))
1504 {
1505 hddLog(VOS_TRACE_LEVEL_ERROR,
1506 "%s: Invalid Channel [%d] \n", __func__, channel);
1507 return -EINVAL;
1508 }
1509 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1510 }
1511 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08001512 {
1513 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1514
1515 /* If auto channel selection is configured as enable/ 1 then ignore
1516 channel set by supplicant
1517 */
1518 if ( cfg_param->apAutoChannelSelection )
1519 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301520 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
1521 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08001522 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1523 "%s: set channel to auto channel (0) for device mode =%d",
1524 __func__, pAdapter->device_mode);
1525 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301526 else
1527 {
1528 if(VOS_STATUS_SUCCESS !=
1529 wlan_hdd_validate_operation_channel(pAdapter,channel))
1530 {
1531 hddLog(VOS_TRACE_LEVEL_ERROR,
1532 "%s: Invalid Channel [%d] \n", __func__, channel);
1533 return -EINVAL;
1534 }
1535 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1536 }
Viral Modi3a32cc52013-02-08 11:14:52 -08001537 }
1538 }
1539 else
1540 {
1541 hddLog(VOS_TRACE_LEVEL_FATAL,
1542 "%s: Invalid device mode failed to set valid channel", __func__);
1543 return -EINVAL;
1544 }
1545 EXIT();
1546 return 0;
1547}
1548
Jeff Johnson295189b2012-06-20 16:38:30 -07001549#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
1550static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1551 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001552#else
1553static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1554 struct cfg80211_beacon_data *params,
1555 const u8 *ssid, size_t ssid_len,
1556 enum nl80211_hidden_ssid hidden_ssid)
1557#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001558{
1559 tsap_Config_t *pConfig;
1560 beacon_data_t *pBeacon = NULL;
1561 struct ieee80211_mgmt *pMgmt_frame;
1562 v_U8_t *pIe=NULL;
1563 v_U16_t capab_info;
1564 eCsrAuthType RSNAuthType;
1565 eCsrEncryptionType RSNEncryptType;
1566 eCsrEncryptionType mcRSNEncryptType;
1567 int status = VOS_STATUS_SUCCESS;
1568 tpWLAN_SAPEventCB pSapEventCallback;
1569 hdd_hostapd_state_t *pHostapdState;
1570 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
1571 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301572 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001573 struct qc_mac_acl_entry *acl_entry = NULL;
1574 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08001575 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001576
1577 ENTER();
1578
1579 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
1580
1581 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1582
1583 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1584
1585 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1586
1587 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
1588
1589 //channel is already set in the set_channel Call back
1590 //pConfig->channel = pCommitConfig->channel;
1591
1592 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301593 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07001594 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
1595
1596 pConfig->dtim_period = pBeacon->dtim_period;
1597
1598 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***\n",
1599 pConfig->dtim_period);
1600
1601
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08001602 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07001603 {
1604 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001605 WLAN_EID_COUNTRY);
Jeff Johnson32d95a32012-09-10 13:15:23 -07001606 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001607 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07001608 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07001609 pConfig->ieee80211d = 1;
1610 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
1611 sme_setRegInfo(hHal, pConfig->countryCode);
1612 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07001613 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001614 else
1615 {
1616 pConfig->ieee80211d = 0;
1617 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301618 /*
1619 * If auto channel is configured i.e. channel is 0,
1620 * so skip channel validation.
1621 */
1622 if( AUTO_CHANNEL_SELECT != pConfig->channel )
1623 {
1624 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
1625 {
1626 hddLog(VOS_TRACE_LEVEL_ERROR,
1627 "%s: Invalid Channel [%d] \n", __func__, pConfig->channel);
1628 return -EINVAL;
1629 }
1630 }
1631 else
1632 {
1633 if(1 != pHddCtx->is_dynamic_channel_range_set)
1634 {
1635 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
1636 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
1637 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
1638 }
1639 pHddCtx->is_dynamic_channel_range_set = 0;
1640 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001641 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001642 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001643 {
1644 pConfig->ieee80211d = 0;
1645 }
1646 pConfig->authType = eSAP_AUTO_SWITCH;
1647
1648 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301649
1650 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07001651 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
1652
1653 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
1654
1655 /*Set wps station to configured*/
1656 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
1657
1658 if(pIe)
1659 {
1660 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
1661 {
1662 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***\n");
1663 return -EINVAL;
1664 }
1665 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
1666 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001667 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07001668 /* Check 15 bit of WPS IE as it contain information for wps state
1669 * WPS state
1670 */
1671 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
1672 {
1673 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
1674 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
1675 {
1676 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
1677 }
1678 }
1679 }
1680 else
1681 {
1682 pConfig->wps_state = SAP_WPS_DISABLED;
1683 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301684 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07001685
1686 pConfig->RSNWPAReqIELength = 0;
1687 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301688 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001689 WLAN_EID_RSN);
1690 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301691 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1693 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1694 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301695 /* The actual processing may eventually be more extensive than
1696 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07001697 * by the app.
1698 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301699 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001700 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1701 &RSNEncryptType,
1702 &mcRSNEncryptType,
1703 &RSNAuthType,
1704 pConfig->pRSNWPAReqIE[1]+2,
1705 pConfig->pRSNWPAReqIE );
1706
1707 if( VOS_STATUS_SUCCESS == status )
1708 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301709 /* Now copy over all the security attributes you have
1710 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 * */
1712 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1713 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1714 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1715 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301716 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001717 "EncryptionType = %d mcEncryptionType = %d\n"),
1718 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1719 }
1720 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301721
Jeff Johnson295189b2012-06-20 16:38:30 -07001722 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1723 pBeacon->tail, pBeacon->tail_len);
1724
1725 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
1726 {
1727 if (pConfig->pRSNWPAReqIE)
1728 {
1729 /*Mixed mode WPA/WPA2*/
1730 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
1731 pConfig->RSNWPAReqIELength += pIe[1] + 2;
1732 }
1733 else
1734 {
1735 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1736 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1737 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301738 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001739 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1740 &RSNEncryptType,
1741 &mcRSNEncryptType,
1742 &RSNAuthType,
1743 pConfig->pRSNWPAReqIE[1]+2,
1744 pConfig->pRSNWPAReqIE );
1745
1746 if( VOS_STATUS_SUCCESS == status )
1747 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301748 /* Now copy over all the security attributes you have
1749 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001750 * */
1751 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1752 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1753 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1754 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301755 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001756 "EncryptionType = %d mcEncryptionType = %d\n"),
1757 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1758 }
1759 }
1760 }
1761
Jeff Johnson4416a782013-03-25 14:17:50 -07001762 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
1763 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
1764 return -EINVAL;
1765 }
1766
Jeff Johnson295189b2012-06-20 16:38:30 -07001767 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
1768
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001769#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001770 if (params->ssid != NULL)
1771 {
1772 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
1773 pConfig->SSIDinfo.ssid.length = params->ssid_len;
1774 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1775 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1776 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001777#else
1778 if (ssid != NULL)
1779 {
1780 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
1781 pConfig->SSIDinfo.ssid.length = ssid_len;
1782 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1783 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1784 }
1785#endif
1786
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301787 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07001788 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301789
Jeff Johnson295189b2012-06-20 16:38:30 -07001790 /* default value */
1791 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
1792 pConfig->num_accept_mac = 0;
1793 pConfig->num_deny_mac = 0;
1794
1795 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1796 pBeacon->tail, pBeacon->tail_len);
1797
1798 /* pIe for black list is following form:
1799 type : 1 byte
1800 length : 1 byte
1801 OUI : 4 bytes
1802 acl type : 1 byte
1803 no of mac addr in black list: 1 byte
1804 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301805 */
1806 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001807 {
1808 pConfig->SapMacaddr_acl = pIe[6];
1809 pConfig->num_deny_mac = pIe[7];
1810 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d\n",
1811 pIe[6], pIe[7]);
1812 if (pConfig->num_deny_mac > MAX_MAC_ADDRESS_DENIED)
1813 pConfig->num_deny_mac = MAX_MAC_ADDRESS_DENIED;
1814 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
1815 for (i = 0; i < pConfig->num_deny_mac; i++)
1816 {
1817 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
1818 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301819 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001820 }
1821 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1822 pBeacon->tail, pBeacon->tail_len);
1823
1824 /* pIe for white list is following form:
1825 type : 1 byte
1826 length : 1 byte
1827 OUI : 4 bytes
1828 acl type : 1 byte
1829 no of mac addr in white list: 1 byte
1830 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301831 */
1832 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001833 {
1834 pConfig->SapMacaddr_acl = pIe[6];
1835 pConfig->num_accept_mac = pIe[7];
1836 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d\n",
1837 pIe[6], pIe[7]);
1838 if (pConfig->num_accept_mac > MAX_MAC_ADDRESS_ACCEPTED)
1839 pConfig->num_accept_mac = MAX_MAC_ADDRESS_ACCEPTED;
1840 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
1841 for (i = 0; i < pConfig->num_accept_mac; i++)
1842 {
1843 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
1844 acl_entry++;
1845 }
1846 }
1847 wlan_hdd_set_sapHwmode(pHostapdAdapter);
1848
Jeff Johnsone7245742012-09-05 17:12:55 -07001849#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08001850 /* Overwrite the hostapd setting for HW mode only for 11ac.
1851 * This is valid only if mode is set to 11n in hostapd and either AUTO or 11ac in .ini .
1852 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode) */
1853 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
1854 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301855 (((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_AUTO) ||
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08001856 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac) ||
1857 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07001858 {
1859 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
1860 }
1861#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301862
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07001863 if ( AUTO_CHANNEL_SELECT != pConfig->channel )
1864 {
1865 sme_SelectCBMode(hHal,
1866 sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode),
1867 pConfig->channel);
1868 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001869 // ht_capab is not what the name conveys,this is used for protection bitmap
1870 pConfig->ht_capab =
1871 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
1872
1873 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
1874 {
1875 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
1876 return -EINVAL;
1877 }
1878
1879 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301880 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07001881 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
1882 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301883 pConfig->obssProtEnabled =
1884 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001885
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301886 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR"\n"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001887 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301888 hddLog(LOGW,FL("ssid =%s\n"), pConfig->SSIDinfo.ssid.ssId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001889 hddLog(LOGW,FL("beaconint=%d, channel=%d\n"), (int)pConfig->beacon_int,
1890 (int)pConfig->channel);
1891 hddLog(LOGW,FL("hw_mode=%x\n"), pConfig->SapHw_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301892 hddLog(LOGW,FL("privacy=%d, authType=%d\n"), pConfig->privacy,
1893 pConfig->authType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001894 hddLog(LOGW,FL("RSN/WPALen=%d, \n"),(int)pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301895 hddLog(LOGW,FL("Uapsd = %d\n"),pConfig->UapsdEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001896 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d\n"),
1897 pConfig->protEnabled, pConfig->obssProtEnabled);
1898
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301899 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07001900 {
1901 //Bss already started. just return.
1902 //TODO Probably it should update some beacon params.
1903 hddLog( LOGE, "Bss Already started...Ignore the request");
1904 EXIT();
1905 return 0;
1906 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301907
Jeff Johnson295189b2012-06-20 16:38:30 -07001908 pConfig->persona = pHostapdAdapter->device_mode;
1909
1910 pSapEventCallback = hdd_hostapd_SAPEventCB;
1911 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
1912 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
1913 {
1914 hddLog(LOGE,FL("SAP Start Bss fail\n"));
1915 return -EINVAL;
1916 }
1917
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301918 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001919 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
1920
1921 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301922
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301924 {
1925 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07001926 ("ERROR: HDD vos wait for single_event failed!!\n"));
1927 VOS_ASSERT(0);
1928 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301929
Jeff Johnson295189b2012-06-20 16:38:30 -07001930 //Succesfully started Bss update the state bit.
1931 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
1932
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07001933#ifdef WLAN_FEATURE_P2P_DEBUG
1934 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
1935 {
1936 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
1937 {
1938 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
1939 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08001940 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07001941 }
1942 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
1943 {
1944 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
1945 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08001946 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07001947 }
1948 }
1949#endif
1950
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 pHostapdState->bCommit = TRUE;
1952 EXIT();
1953
1954 return 0;
1955}
1956
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001957#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301958static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
1959 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001960 struct beacon_parameters *params)
1961{
1962 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301963 int status=VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001964
1965 ENTER();
1966
1967 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d\n",pAdapter->device_mode);
1968
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001969 if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress )
1970 {
1971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1972 "%s:LOGP in Progress. Ignore!!!", __func__);
1973 return -EAGAIN;
1974 }
1975
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301976 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07001977 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07001978 )
1979 {
1980 beacon_data_t *old,*new;
1981
1982 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301983
Jeff Johnson295189b2012-06-20 16:38:30 -07001984 if (old)
1985 return -EALREADY;
1986
1987 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
1988
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301989 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001990 {
1991 hddLog(VOS_TRACE_LEVEL_FATAL,
1992 "%s:Error!!! Allocating the new beacon\n",__func__);
1993 return -EINVAL;
1994 }
1995
1996 pAdapter->sessionCtx.ap.beacon = new;
1997
1998 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
1999 }
2000
2001 EXIT();
2002 return status;
2003}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302004
2005static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07002006 struct net_device *dev,
2007 struct beacon_parameters *params)
2008{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302009 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07002010 int status=VOS_STATUS_SUCCESS;
2011
2012 ENTER();
2013
2014 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2015 __func__,pAdapter->device_mode);
2016
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002017 if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress )
2018 {
2019 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2020 "%s:LOGP in Progress. Ignore!!!", __func__);
2021 return -EAGAIN;
2022 }
2023
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302024 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002025 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302026 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002027 {
2028 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302029
Jeff Johnson295189b2012-06-20 16:38:30 -07002030 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302031
Jeff Johnson295189b2012-06-20 16:38:30 -07002032 if (!old)
2033 return -ENOENT;
2034
2035 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2036
2037 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302038 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07002039 "%s: Error!!! Allocating the new beacon\n",__func__);
2040 return -EINVAL;
2041 }
2042
2043 pAdapter->sessionCtx.ap.beacon = new;
2044
2045 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2046 }
2047
2048 EXIT();
2049 return status;
2050}
2051
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002052#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
2053
2054#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002055static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
2056 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002057#else
2058static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
2059 struct net_device *dev)
2060#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002061{
2062 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07002063 hdd_context_t *pHddCtx = NULL;
2064 hdd_scaninfo_t *pScanInfo = NULL;
2065 hdd_adapter_t *staAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002066 VOS_STATUS status = 0;
2067
2068 ENTER();
2069
2070 if (NULL == pAdapter)
2071 {
2072 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002073 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002074 return -ENODEV;
2075 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002076
Jeff Johnson4416a782013-03-25 14:17:50 -07002077 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002078 if (NULL == pHddCtx)
2079 {
2080 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002081 "%s: HDD context is Null", __func__);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002082 return -ENODEV;
2083 }
Jeff Johnson4416a782013-03-25 14:17:50 -07002084 if (pHddCtx->isLogpInProgress)
2085 {
2086 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2087 "%s:LOGP in Progress. Ignore!!!", __func__);
2088 return -EAGAIN;
2089 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002090
2091 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
2092 if (NULL == staAdapter)
2093 {
2094 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
2095 if (NULL == staAdapter)
2096 {
2097 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002098 "%s: HDD adapter context is Null", __func__);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002099 return -ENODEV;
2100 }
2101 }
2102
2103 pScanInfo = &pHddCtx->scan_info;
2104
Jeff Johnson4416a782013-03-25 14:17:50 -07002105 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -07002106 {
2107 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
2108 return -EAGAIN;
2109 }
2110
2111 pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2112
2113 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2114 __func__,pAdapter->device_mode);
2115
Jeff Johnsone7245742012-09-05 17:12:55 -07002116 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
2117 {
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002118 INIT_COMPLETION(pScanInfo->abortscan_event_var);
Jeff Johnsone7245742012-09-05 17:12:55 -07002119 hdd_abort_mac_scan(staAdapter->pHddCtx);
2120 status = wait_for_completion_interruptible_timeout(
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002121 &pScanInfo->abortscan_event_var,
Jeff Johnsone7245742012-09-05 17:12:55 -07002122 msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN));
2123 if (!status)
2124 {
2125 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson902c9832012-12-10 14:28:09 -08002126 "%s: Timeout occurred while waiting for abortscan" ,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002127 __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07002128 VOS_ASSERT(pScanInfo->mScanPending);
2129 return 0;
2130 }
2131 }
2132
Jeff Johnson295189b2012-06-20 16:38:30 -07002133 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002134 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002135 )
2136 {
2137 beacon_data_t *old;
2138
2139 old = pAdapter->sessionCtx.ap.beacon;
2140
2141 if (!old)
2142 return -ENOENT;
2143
Jeff Johnson295189b2012-06-20 16:38:30 -07002144 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002145
2146 mutex_lock(&pHddCtx->sap_lock);
2147 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
2148 {
Jeff Johnson4416a782013-03-25 14:17:50 -07002149 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002150 {
2151 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
2152
2153 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
2154
2155 if (!VOS_IS_STATUS_SUCCESS(status))
2156 {
2157 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2158 ("ERROR: HDD vos wait for single_event failed!!\n"));
2159 VOS_ASSERT(0);
2160 }
2161 }
2162 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
2163 }
2164 mutex_unlock(&pHddCtx->sap_lock);
2165
2166 if(status != VOS_STATUS_SUCCESS)
2167 {
2168 hddLog(VOS_TRACE_LEVEL_FATAL,
2169 "%s:Error!!! Stopping the BSS\n",__func__);
2170 return -EINVAL;
2171 }
2172
Jeff Johnson4416a782013-03-25 14:17:50 -07002173 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002174 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
2175 ==eHAL_STATUS_FAILURE)
2176 {
2177 hddLog(LOGE,
2178 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM\n");
2179 }
2180
Jeff Johnson4416a782013-03-25 14:17:50 -07002181 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002182 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
2183 eANI_BOOLEAN_FALSE) )
2184 {
2185 hddLog(LOGE,
2186 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
2187 }
2188
2189 // Reset WNI_CFG_PROBE_RSP Flags
2190 wlan_hdd_reset_prob_rspies(pAdapter);
2191
2192 pAdapter->sessionCtx.ap.beacon = NULL;
2193 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002194#ifdef WLAN_FEATURE_P2P_DEBUG
2195 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
2196 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
2197 {
2198 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
2199 "GO got removed");
2200 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
2201 }
2202#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002203 }
2204 EXIT();
2205 return status;
2206}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002207
2208#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2209
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302210static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
2211 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002212 struct cfg80211_ap_settings *params)
2213{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302214 hdd_adapter_t *pAdapter;
2215 hdd_context_t *pHddCtx;
2216 int status = 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002217
2218 ENTER();
2219
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302220 if (NULL == dev)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002221 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302222 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2223 "%s: Device is Null", __func__);
2224 return -ENODEV;
2225 }
2226
2227 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2228 if (NULL == pAdapter)
2229 {
2230 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2231 "%s: HDD adapter is Null", __func__);
2232 return -ENODEV;
2233 }
2234
2235 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
2236 {
2237 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2238 "%s: HDD adapter magic is invalid", __func__);
2239 return -ENODEV;
2240 }
2241
2242 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2243 if (NULL == pHddCtx)
2244 {
2245 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2246 "%s: HDD context is Null", __func__);
2247 return -ENODEV;
2248 }
2249
2250 if (pHddCtx->isLogpInProgress)
2251 {
2252 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2253 "%s: LOGP in Progress. Ignore!!!", __func__);
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002254 return -EAGAIN;
2255 }
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302256
2257 if (pHddCtx->isLoadUnloadInProgress)
2258 {
2259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2260 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
2261 return -EAGAIN;
2262 }
2263
2264 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %d",
2265 __func__, pAdapter->device_mode);
2266
2267 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002268 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002269 )
2270 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302271 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002272
2273 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302274
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002275 if (old)
2276 return -EALREADY;
2277
2278 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, &params->beacon, params->dtim_period);
2279
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302280 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002281 {
2282 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302283 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002284 return -EINVAL;
2285 }
2286 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08002287#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
2288 wlan_hdd_cfg80211_set_channel(wiphy, dev, params->channel, params->channel_type);
2289#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002290 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
2291 params->ssid_len, params->hidden_ssid);
2292 }
2293
2294 EXIT();
2295 return status;
2296}
2297
2298
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302299static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002300 struct net_device *dev,
2301 struct cfg80211_beacon_data *params)
2302{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302303 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002304 int status=VOS_STATUS_SUCCESS;
2305
2306 ENTER();
2307
2308 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2309 __func__, pAdapter->device_mode);
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002310 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2311 {
2312 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
2313 return -EAGAIN;
2314 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002315
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302316 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002317 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302318 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002319 {
2320 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302321
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002322 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302323
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002324 if (!old)
2325 return -ENOENT;
2326
2327 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
2328
2329 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302330 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002331 "%s: Error!!! Allocating the new beacon\n",__func__);
2332 return -EINVAL;
2333 }
2334
2335 pAdapter->sessionCtx.ap.beacon = new;
2336
2337 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
2338 }
2339
2340 EXIT();
2341 return status;
2342}
2343
2344#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2345
Jeff Johnson295189b2012-06-20 16:38:30 -07002346
2347static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
2348 struct net_device *dev,
2349 struct bss_parameters *params)
2350{
2351 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2352
2353 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302354
Jeff Johnson295189b2012-06-20 16:38:30 -07002355 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2356 __func__,pAdapter->device_mode);
2357
2358 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002359 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302360 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002361 {
2362 /* ap_isolate == -1 means that in change bss, upper layer doesn't
2363 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302364 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07002365 {
2366 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302367 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002368 }
2369
2370 EXIT();
2371 return 0;
2372}
2373
2374/*
2375 * FUNCTION: wlan_hdd_cfg80211_change_iface
2376 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
2377 */
2378int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
2379 struct net_device *ndev,
2380 enum nl80211_iftype type,
2381 u32 *flags,
2382 struct vif_params *params
2383 )
2384{
2385 struct wireless_dev *wdev;
2386 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
2387 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Mohit Khanna0f232092012-09-11 14:46:08 -07002388 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002389 tCsrRoamProfile *pRoamProfile = NULL;
2390 eCsrRoamBssType LastBSSType;
2391 hdd_config_t *pConfig = pHddCtx->cfg_ini;
2392 eMib_dot11DesiredBssType connectedBssType;
2393 VOS_STATUS status;
2394
2395 ENTER();
2396
2397 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2398 {
2399 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
2400 return -EAGAIN;
2401 }
2402
2403 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
2404 __func__, pAdapter->device_mode);
2405
2406 wdev = ndev->ieee80211_ptr;
2407
2408#ifdef WLAN_BTAMP_FEATURE
2409 if((NL80211_IFTYPE_P2P_CLIENT == type)||
2410 (NL80211_IFTYPE_ADHOC == type)||
2411 (NL80211_IFTYPE_AP == type)||
2412 (NL80211_IFTYPE_P2P_GO == type))
2413 {
2414 pHddCtx->isAmpAllowed = VOS_FALSE;
2415 // stop AMP traffic
2416 status = WLANBAP_StopAmp();
2417 if(VOS_STATUS_SUCCESS != status )
2418 {
2419 pHddCtx->isAmpAllowed = VOS_TRUE;
2420 hddLog(VOS_TRACE_LEVEL_FATAL,
2421 "%s: Failed to stop AMP", __func__);
2422 return -EINVAL;
2423 }
2424 }
2425#endif //WLAN_BTAMP_FEATURE
2426 /* Reset the current device mode bit mask*/
2427 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
2428
2429 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07002430 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07002431 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002432 )
2433 {
2434 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2435 pRoamProfile = &pWextState->roamProfile;
2436 LastBSSType = pRoamProfile->BSSType;
2437
2438 switch (type)
2439 {
2440 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002441 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002442 hddLog(VOS_TRACE_LEVEL_INFO,
2443 "%s: setting interface Type to INFRASTRUCTURE", __func__);
2444 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002445#ifdef WLAN_FEATURE_11AC
2446 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
2447 {
2448 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
2449 }
2450#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302451 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07002452 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002453 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002454 //Check for sub-string p2p to confirm its a p2p interface
2455 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302456 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002457 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2458 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2459 }
2460 else
2461 {
2462 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002463 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002464 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002465 break;
2466 case NL80211_IFTYPE_ADHOC:
2467 hddLog(VOS_TRACE_LEVEL_INFO,
2468 "%s: setting interface Type to ADHOC", __func__);
2469 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2470 pRoamProfile->phyMode =
2471 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002472 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002473 wdev->iftype = type;
2474 break;
2475
2476 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002477 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002478 {
2479 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2480 "%s: setting interface Type to %s", __func__,
2481 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
2482
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002483 //Cancel any remain on channel for GO mode
2484 if (NL80211_IFTYPE_P2P_GO == type)
2485 {
2486 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
2487 }
Mohit Khanna0f232092012-09-11 14:46:08 -07002488 if (NL80211_IFTYPE_AP == type)
2489 {
2490 /* As Loading WLAN Driver one interface being created for p2p device
2491 * address. This will take one HW STA and the max number of clients
2492 * that can connect to softAP will be reduced by one. so while changing
2493 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
2494 * interface as it is not required in SoftAP mode.
2495 */
2496
2497 // Get P2P Adapter
2498 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
2499
2500 if (pP2pAdapter)
2501 {
2502 hdd_stop_adapter(pHddCtx, pP2pAdapter);
2503 hdd_deinit_adapter(pHddCtx, pP2pAdapter);
2504 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
2505 }
2506 }
2507
Jeff Johnson295189b2012-06-20 16:38:30 -07002508 //De-init the adapter.
2509 hdd_stop_adapter( pHddCtx, pAdapter );
2510 hdd_deinit_adapter( pHddCtx, pAdapter );
2511 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07002512 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2513 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002514
2515 //Disable BMPS and IMPS if enabled
2516 //before starting Go
2517 if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
2518 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302519 if(VOS_STATUS_E_FAILURE ==
Jeff Johnson32d95a32012-09-10 13:15:23 -07002520 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
2521 {
2522 //Fail to Exit BMPS
2523 VOS_ASSERT(0);
2524 }
2525 }
2526
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07002527 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
2528 (pConfig->apRandomBssidEnabled))
2529 {
2530 /* To meet Android requirements create a randomized
2531 MAC address of the form 02:1A:11:Fx:xx:xx */
2532 get_random_bytes(&ndev->dev_addr[3], 3);
2533 ndev->dev_addr[0] = 0x02;
2534 ndev->dev_addr[1] = 0x1A;
2535 ndev->dev_addr[2] = 0x11;
2536 ndev->dev_addr[3] |= 0xF0;
2537 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
2538 VOS_MAC_ADDR_SIZE);
2539 pr_info("wlan: Generated HotSpot BSSID "
2540 "%02x:%02x:%02x:%02x:%02x:%02x\n",
2541 ndev->dev_addr[0],
2542 ndev->dev_addr[1],
2543 ndev->dev_addr[2],
2544 ndev->dev_addr[3],
2545 ndev->dev_addr[4],
2546 ndev->dev_addr[5]);
2547 }
2548
Jeff Johnson295189b2012-06-20 16:38:30 -07002549 hdd_set_ap_ops( pAdapter->dev );
2550
2551 status = hdd_init_ap_mode(pAdapter);
2552 if(status != VOS_STATUS_SUCCESS)
2553 {
2554 hddLog(VOS_TRACE_LEVEL_FATAL,
2555 "%s: Error initializing the ap mode", __func__);
2556 return -EINVAL;
2557 }
2558 hdd_set_conparam(1);
2559
Jeff Johnson295189b2012-06-20 16:38:30 -07002560 /*interface type changed update in wiphy structure*/
2561 if(wdev)
2562 {
2563 wdev->iftype = type;
2564 pHddCtx->change_iface = type;
2565 }
2566 else
2567 {
2568 hddLog(VOS_TRACE_LEVEL_ERROR,
2569 "%s: ERROR !!!! Wireless dev is NULL", __func__);
2570 return -EINVAL;
2571 }
2572 goto done;
2573 }
2574
2575 default:
2576 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2577 __func__);
2578 return -EOPNOTSUPP;
2579 }
2580 }
2581 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002582 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002583 )
2584 {
2585 switch(type)
2586 {
2587 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002588 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002589 case NL80211_IFTYPE_ADHOC:
Jeff Johnson32d95a32012-09-10 13:15:23 -07002590 hdd_stop_adapter( pHddCtx, pAdapter );
2591 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07002592 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002593 //Check for sub-string p2p to confirm its a p2p interface
2594 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002595 {
2596 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2597 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2598 }
2599 else
2600 {
2601 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002602 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002603 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002604 hdd_set_conparam(0);
2605 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
2607 hdd_set_station_ops( pAdapter->dev );
2608 status = hdd_init_station_mode( pAdapter );
2609 if( VOS_STATUS_SUCCESS != status )
2610 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07002611 /* In case of JB, for P2P-GO, only change interface will be called,
2612 * This is the right place to enable back bmps_imps()
2613 */
2614 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07002615 goto done;
2616 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002618 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002619 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2620 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002621 goto done;
2622 default:
2623 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2624 __func__);
2625 return -EOPNOTSUPP;
2626
2627 }
2628
2629 }
2630 else
2631 {
2632 return -EOPNOTSUPP;
2633 }
2634
2635
2636 if(pRoamProfile)
2637 {
2638 if ( LastBSSType != pRoamProfile->BSSType )
2639 {
2640 /*interface type changed update in wiphy structure*/
2641 wdev->iftype = type;
2642
2643 /*the BSS mode changed, We need to issue disconnect
2644 if connected or in IBSS disconnect state*/
2645 if ( hdd_connGetConnectedBssType(
2646 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
2647 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
2648 {
2649 /*need to issue a disconnect to CSR.*/
2650 INIT_COMPLETION(pAdapter->disconnect_comp_var);
2651 if( eHAL_STATUS_SUCCESS ==
2652 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
2653 pAdapter->sessionId,
2654 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
2655 {
2656 wait_for_completion_interruptible_timeout(
2657 &pAdapter->disconnect_comp_var,
2658 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
2659 }
2660 }
2661 }
2662 }
2663
2664done:
2665 /*set bitmask based on updated value*/
2666 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
2667#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302668 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002669 (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
2670 {
2671 //we are ok to do AMP
2672 pHddCtx->isAmpAllowed = VOS_TRUE;
2673 }
2674#endif //WLAN_BTAMP_FEATURE
2675 EXIT();
2676 return 0;
2677}
2678
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002679#ifdef FEATURE_WLAN_TDLS
2680static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
2681 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
2682{
2683 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2684 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2685 VOS_STATUS status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002686 hddTdlsPeer_t *pTdlsPeer;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002687
2688 ENTER();
2689
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05302690 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002691 {
2692 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2693 "Invalid arguments");
2694 return -EINVAL;
2695 }
Hoonki Lee27511902013-03-14 18:19:06 -07002696
2697 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
2698 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
2699 {
2700 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2701 "%s: TDLS mode is disabled OR not enabled in FW."
2702 MAC_ADDRESS_STR " Request declined.",
2703 __func__, MAC_ADDR_ARRAY(mac));
2704 return -ENOTSUPP;
2705 }
2706
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002707 if (pHddCtx->isLogpInProgress)
2708 {
2709 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2710 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07002711 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002712 return -EBUSY;
2713 }
2714
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002715 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac);
2716
2717 if ( NULL == pTdlsPeer ) {
2718 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2719 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
2720 __func__, MAC_ADDR_ARRAY(mac), update);
2721 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002722 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002723
2724 /* in add station, we accept existing valid staId if there is */
2725 if ((0 == update) &&
2726 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
2727 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002728 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002729 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002730 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002731 " link_status %d. staId %d. add station ignored.",
2732 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
2733 return 0;
2734 }
2735 /* in change station, we accept only when staId is valid */
2736 if ((1 == update) &&
2737 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
2738 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
2739 {
2740 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2741 "%s: " MAC_ADDRESS_STR
2742 " link status %d. staId %d. change station %s.",
2743 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
2744 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
2745 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002746 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002747
2748 /* when others are on-going, we want to change link_status to idle */
Hoonki Leefb8df672013-04-10 18:20:34 -07002749 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002750 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07002751 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2752 "%s: " MAC_ADDRESS_STR
2753 " TDLS setup is ongoing. Request declined.",
2754 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07002755 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002756 }
2757
2758 /* first to check if we reached to maximum supported TDLS peer.
2759 TODO: for now, return -EPERM looks working fine,
2760 but need to check if any other errno fit into this category.*/
2761 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
2762 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07002763 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2764 "%s: " MAC_ADDRESS_STR
2765 " TDLS Max peer already connected. Request declined.",
2766 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07002767 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002768 }
2769 else
2770 {
2771 hddTdlsPeer_t *pTdlsPeer;
2772 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002773 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002774 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07002775 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2776 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
2777 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002778 return -EPERM;
2779 }
2780 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002781 if (0 == update)
2782 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002783
Jeff Johnsond75fe012013-04-06 10:53:06 -07002784 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05302785 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002786 {
2787 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2788 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07002789 if(StaParams->htcap_present)
2790 {
2791 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2792 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
2793 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2794 "ht_capa->extended_capabilities: %0x",
2795 StaParams->HTCap.extendedHtCapInfo);
2796 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002797 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2798 "params->capability: %0x",StaParams->capability);
2799 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2800 "params->ext_capab_len: %0x",StaParams->extn_capability);
Hoonki Lee66b75f32013-04-16 18:30:07 -07002801 if(StaParams->vhtcap_present)
2802 {
2803 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2804 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
2805 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
2806 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
2807 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002808 {
2809 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002810 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002811 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
2812 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2813 "[%d]: %x ", i, StaParams->supported_rates[i]);
2814 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07002815 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05302816 else if ((1 == update) && (NULL == StaParams))
2817 {
2818 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2819 "%s : update is true, but staParams is NULL. Error!", __func__);
2820 return -EPERM;
2821 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002822
2823 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
2824
2825 if (!update)
2826 {
2827 status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
2828 pAdapter->sessionId, mac);
2829 }
2830 else
2831 {
2832 status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
2833 pAdapter->sessionId, mac, StaParams);
2834 }
2835
2836 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
2837 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
2838
2839 if (!status)
2840 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07002841 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002842 "%s: timeout waiting for tdls add station indication",
2843 __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002844 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002845 }
2846 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
2847 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07002848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002849 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002850 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002851 }
2852
2853 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07002854
2855error:
2856 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
2857 return -EPERM;
2858
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002859}
2860#endif
2861
Jeff Johnson295189b2012-06-20 16:38:30 -07002862static int wlan_hdd_change_station(struct wiphy *wiphy,
2863 struct net_device *dev,
2864 u8 *mac,
2865 struct station_parameters *params)
2866{
2867 VOS_STATUS status = VOS_STATUS_SUCCESS;
2868 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkala29149562013-05-10 21:43:41 +05302869 hdd_context_t *pHddCtx;
2870 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002871 v_MACADDR_t STAMacAddress;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07002872#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002873 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002874 tANI_U8 isBufSta = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07002875#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002876 ENTER();
2877
Gopichand Nakkala29149562013-05-10 21:43:41 +05302878 if ((NULL == pAdapter))
2879 {
2880 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2881 "invalid adapter ");
2882 return -EINVAL;
2883 }
2884
2885 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2886 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2887
2888 if ((NULL == pHddCtx) || (NULL == pHddStaCtx))
2889 {
2890 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2891 "invalid HDD state or HDD station context");
2892 return -EINVAL;
2893 }
2894
2895 if (pHddCtx->isLogpInProgress)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002896 {
2897 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2898 "%s:LOGP in Progress. Ignore!!!", __func__);
2899 return -EAGAIN;
2900 }
2901
Jeff Johnson295189b2012-06-20 16:38:30 -07002902 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
2903
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002904 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
2905 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07002906 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002907 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07002908 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302909 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07002910 WLANTL_STA_AUTHENTICATED);
2911
Gopichand Nakkala29149562013-05-10 21:43:41 +05302912 if (status != VOS_STATUS_SUCCESS)
2913 {
2914 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2915 "%s: Not able to change TL state to AUTHENTICATED", __func__);
2916 return -EINVAL;
2917 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002918 }
2919 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07002920 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
2921 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05302922#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002923 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
2924 StaParams.capability = params->capability;
2925 StaParams.uapsd_queues = params->uapsd_queues;
2926 StaParams.max_sp = params->max_sp;
2927
2928 if (0 != params->ext_capab_len)
2929 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
2930 sizeof(StaParams.extn_capability));
2931
2932 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07002933 {
2934 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002935 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07002936 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002937
2938 StaParams.supported_rates_len = params->supported_rates_len;
2939
2940 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
2941 * The supported_rates array , for all the structures propogating till Add Sta
2942 * to the firmware has to be modified , if the supplicant (ieee80211) is
2943 * modified to send more rates.
2944 */
2945
2946 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
2947 */
2948 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
2949 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
2950
2951 if (0 != StaParams.supported_rates_len) {
2952 int i = 0;
2953 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
2954 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002955 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002956 "Supported Rates with Length %d", StaParams.supported_rates_len);
2957 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002958 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002959 "[%d]: %0x", i, StaParams.supported_rates[i]);
2960 }
2961
2962 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07002963 {
2964 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002965 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07002966 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002967
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002968 if (0 != params->ext_capab_len ) {
2969 /*Define A Macro : TODO Sunil*/
2970 if ((1<<4) & StaParams.extn_capability[3]) {
2971 isBufSta = 1;
2972 }
2973 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002974 //status = wlan_hdd_tdls_set_peer_caps( mac, params->uapsd_queues,
2975 // params->max_sp, isBufSta);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002976 //if (VOS_STATUS_SUCCESS != status) {
2977 // VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2978 // "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
2979 // return -EINVAL;
2980 //}
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002981 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
2982
2983 if (VOS_STATUS_SUCCESS != status) {
2984 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2985 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
2986 return -EINVAL;
2987 }
2988 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07002989#endif
Gopichand Nakkala29149562013-05-10 21:43:41 +05302990 if(params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
2991 {
2992 status = WLANTL_ChangeSTAState(pHddCtx->pvosContext, pHddStaCtx->conn_info.staId[ 0 ],
2993 WLANTL_STA_AUTHENTICATED);
2994 if (status != VOS_STATUS_SUCCESS)
2995 {
2996 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2997 "%s: Not able to change TL state to AUTHENTICATED", __func__);
2998 return -EINVAL;
2999 }
3000 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
3001 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3002 "%s: TL Moving to Authenticated state", __func__);
3003 }
3004 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303005
Jeff Johnsone7245742012-09-05 17:12:55 -07003006 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003007 return status;
3008}
3009
3010/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003011 * FUNCTION: wlan_hdd_cfg80211_add_key
3012 * This function is used to initialize the key information
3013 */
3014#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003015static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003016 struct net_device *ndev,
3017 u8 key_index, bool pairwise,
3018 const u8 *mac_addr,
3019 struct key_params *params
3020 )
3021#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003022static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003023 struct net_device *ndev,
3024 u8 key_index, const u8 *mac_addr,
3025 struct key_params *params
3026 )
3027#endif
3028{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003029 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003030 tCsrRoamSetKey setKey;
3031 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3032 int status = 0;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003033 v_U32_t roamId= 0xFF;
3034 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003035 hdd_hostapd_state_t *pHostapdState;
3036 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003037 eHalStatus halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07003038
3039 ENTER();
3040
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003041 if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress )
3042 {
3043 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3044 "%s:LOGP in Progress. Ignore!!!", __func__);
3045 return -EAGAIN;
3046 }
3047
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003048 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
3049 __func__, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003050
3051 if (CSR_MAX_NUM_KEY <= key_index)
3052 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003053 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003054 key_index);
3055
3056 return -EINVAL;
3057 }
3058
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003059 if (CSR_MAX_KEY_LEN < params->key_len)
3060 {
3061 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
3062 params->key_len);
3063
3064 return -EINVAL;
3065 }
3066
3067 hddLog(VOS_TRACE_LEVEL_INFO,
3068 "%s: called with key index = %d & key length %d",
3069 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003070
3071 /*extract key idx, key len and key*/
3072 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3073 setKey.keyId = key_index;
3074 setKey.keyLength = params->key_len;
3075 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
3076
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003077 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07003078 {
3079 case WLAN_CIPHER_SUITE_WEP40:
3080 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3081 break;
3082
3083 case WLAN_CIPHER_SUITE_WEP104:
3084 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3085 break;
3086
3087 case WLAN_CIPHER_SUITE_TKIP:
3088 {
3089 u8 *pKey = &setKey.Key[0];
3090 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3091
3092 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3093
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003094 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07003095
3096 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003097 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003098 |--------------|----------|----------|
3099 <---16bytes---><--8bytes--><--8bytes-->
3100
3101 */
3102 /*Sme expects the 32 bytes key to be in the below order
3103
3104 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003105 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003106 |--------------|----------|----------|
3107 <---16bytes---><--8bytes--><--8bytes-->
3108 */
3109 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003110 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07003111
3112 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003113 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003114
3115 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003116 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003117
3118
3119 break;
3120 }
3121
3122 case WLAN_CIPHER_SUITE_CCMP:
3123 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3124 break;
3125
3126#ifdef FEATURE_WLAN_WAPI
3127 case WLAN_CIPHER_SUITE_SMS4:
3128 {
3129 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3130 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
3131 params->key, params->key_len);
3132 return 0;
3133 }
3134#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003135
Jeff Johnson295189b2012-06-20 16:38:30 -07003136#ifdef FEATURE_WLAN_CCX
3137 case WLAN_CIPHER_SUITE_KRK:
3138 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3139 break;
3140#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003141
3142#ifdef WLAN_FEATURE_11W
3143 case WLAN_CIPHER_SUITE_AES_CMAC:
3144 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07003145 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07003146#endif
3147
Jeff Johnson295189b2012-06-20 16:38:30 -07003148 default:
3149 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %lu",
3150 __func__, params->cipher);
3151 return -EOPNOTSUPP;
3152 }
3153
3154 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
3155 __func__, setKey.encType);
3156
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003157 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07003158#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3159 (!pairwise)
3160#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003161 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07003162#endif
3163 )
3164 {
3165 /* set group key*/
3166 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson1250df42012-12-10 14:31:52 -08003167 "%s- %d: setting Broadcast key",
Jeff Johnson295189b2012-06-20 16:38:30 -07003168 __func__, __LINE__);
3169 setKey.keyDirection = eSIR_RX_ONLY;
3170 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3171 }
3172 else
3173 {
3174 /* set pairwise key*/
3175 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3176 "%s- %d: setting pairwise key",
3177 __func__, __LINE__);
3178 setKey.keyDirection = eSIR_TX_RX;
3179 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3180 }
3181
Gopichand Nakkala29149562013-05-10 21:43:41 +05303182 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
3183 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
3184 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003185 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003186 if( pHostapdState->bssState == BSS_START )
3187 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003188 status = WLANSAP_SetKeySta( pVosContext, &setKey);
3189
3190 if ( status != eHAL_STATUS_SUCCESS )
3191 {
3192 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3193 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3194 __LINE__, status );
3195 }
3196 }
3197
3198 /* Saving WEP keys */
3199 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
3200 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
3201 {
3202 //Save the wep key in ap context. Issue setkey after the BSS is started.
3203 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3204 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
3205 }
3206 else
3207 {
3208 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003209 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003210 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
3211 }
3212 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003213 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
3214 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003215 {
3216 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3217 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3218
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303219#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3220 if (!pairwise)
3221#else
3222 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
3223#endif
3224 {
3225 /* set group key*/
3226 if (pHddStaCtx->roam_info.deferKeyComplete)
3227 {
3228 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3229 "%s- %d: Perform Set key Complete",
3230 __func__, __LINE__);
3231 hdd_PerformRoamSetKeyComplete(pAdapter);
3232 }
3233 }
3234
Jeff Johnson295189b2012-06-20 16:38:30 -07003235 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
3236
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08003237 pWextState->roamProfile.Keys.defaultIndex = key_index;
3238
3239
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003240 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003241 params->key, params->key_len);
3242
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303243
Jeff Johnson295189b2012-06-20 16:38:30 -07003244 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3245
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303246 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003247 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303248 __func__, setKey.peerMac[0], setKey.peerMac[1],
3249 setKey.peerMac[2], setKey.peerMac[3],
3250 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003251 setKey.keyDirection);
3252
3253 vos_status = wlan_hdd_check_ula_done(pAdapter);
3254
3255 if ( vos_status != VOS_STATUS_SUCCESS )
3256 {
3257 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3258 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3259 __LINE__, vos_status );
3260
3261 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3262
3263 return -EINVAL;
3264
3265 }
3266
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003267#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303268 /* The supplicant may attempt to set the PTK once pre-authentication
3269 is done. Save the key in the UMAC and include it in the ADD BSS
3270 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003271 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303272 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003273 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303274 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3275 "%s: Update PreAuth Key success", __func__);
3276 return 0;
3277 }
3278 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3279 {
3280 hddLog(VOS_TRACE_LEVEL_ERROR,
3281 "%s: Update PreAuth Key failed", __func__);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05303282 return -EINVAL;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003283 }
3284#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07003285
3286 /* issue set key request to SME*/
3287 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3288 pAdapter->sessionId, &setKey, &roamId );
3289
3290 if ( 0 != status )
3291 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303292 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003293 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3294 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3295 return -EINVAL;
3296 }
3297
3298
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303299 /* in case of IBSS as there was no information available about WEP keys during
3300 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07003301 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303302 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
3303 !( ( IW_AUTH_KEY_MGMT_802_1X
3304 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003305 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
3306 )
3307 &&
3308 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
3309 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
3310 )
3311 )
3312 {
3313 setKey.keyDirection = eSIR_RX_ONLY;
3314 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3315
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303316 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003317 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303318 __func__, setKey.peerMac[0], setKey.peerMac[1],
3319 setKey.peerMac[2], setKey.peerMac[3],
3320 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003321 setKey.keyDirection);
3322
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303323 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003324 pAdapter->sessionId, &setKey, &roamId );
3325
3326 if ( 0 != status )
3327 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303328 hddLog(VOS_TRACE_LEVEL_ERROR,
3329 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003330 __func__, status);
3331 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3332 return -EINVAL;
3333 }
3334 }
3335 }
3336
3337 return 0;
3338}
3339
3340/*
3341 * FUNCTION: wlan_hdd_cfg80211_get_key
3342 * This function is used to get the key information
3343 */
3344#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303345static int wlan_hdd_cfg80211_get_key(
3346 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003347 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303348 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003349 const u8 *mac_addr, void *cookie,
3350 void (*callback)(void *cookie, struct key_params*)
3351 )
3352#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303353static int wlan_hdd_cfg80211_get_key(
3354 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003355 struct net_device *ndev,
3356 u8 key_index, const u8 *mac_addr, void *cookie,
3357 void (*callback)(void *cookie, struct key_params*)
3358 )
3359#endif
3360{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303361 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003362 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3363 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3364 struct key_params params;
3365
3366 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303367
Jeff Johnson295189b2012-06-20 16:38:30 -07003368 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
3369 __func__,pAdapter->device_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303370
Jeff Johnson295189b2012-06-20 16:38:30 -07003371 memset(&params, 0, sizeof(params));
3372
3373 if (CSR_MAX_NUM_KEY <= key_index)
3374 {
3375 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303376 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003377
3378 switch(pRoamProfile->EncryptionType.encryptionType[0])
3379 {
3380 case eCSR_ENCRYPT_TYPE_NONE:
3381 params.cipher = IW_AUTH_CIPHER_NONE;
3382 break;
3383
3384 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3385 case eCSR_ENCRYPT_TYPE_WEP40:
3386 params.cipher = WLAN_CIPHER_SUITE_WEP40;
3387 break;
3388
3389 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3390 case eCSR_ENCRYPT_TYPE_WEP104:
3391 params.cipher = WLAN_CIPHER_SUITE_WEP104;
3392 break;
3393
3394 case eCSR_ENCRYPT_TYPE_TKIP:
3395 params.cipher = WLAN_CIPHER_SUITE_TKIP;
3396 break;
3397
3398 case eCSR_ENCRYPT_TYPE_AES:
3399 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
3400 break;
3401
3402 default:
3403 params.cipher = IW_AUTH_CIPHER_NONE;
3404 break;
3405 }
3406
3407 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
3408 params.seq_len = 0;
3409 params.seq = NULL;
3410 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
3411 callback(cookie, &params);
3412 return 0;
3413}
3414
3415/*
3416 * FUNCTION: wlan_hdd_cfg80211_del_key
3417 * This function is used to delete the key information
3418 */
3419#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303420static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003421 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303422 u8 key_index,
3423 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003424 const u8 *mac_addr
3425 )
3426#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303427static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003428 struct net_device *ndev,
3429 u8 key_index,
3430 const u8 *mac_addr
3431 )
3432#endif
3433{
3434 int status = 0;
3435
3436 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303437 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07003438 //it is observed that this is invalidating peer
3439 //key index whenever re-key is done. This is affecting data link.
3440 //It should be ok to ignore del_key.
3441#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303442 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
3443 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003444 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3445 tCsrRoamSetKey setKey;
3446 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303447
Jeff Johnson295189b2012-06-20 16:38:30 -07003448 ENTER();
3449
3450 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
3451 __func__,pAdapter->device_mode);
3452
3453 if (CSR_MAX_NUM_KEY <= key_index)
3454 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303455 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003456 key_index);
3457
3458 return -EINVAL;
3459 }
3460
3461 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3462 setKey.keyId = key_index;
3463
3464 if (mac_addr)
3465 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3466 else
3467 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
3468
3469 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3470
3471 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07003472 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303473 )
3474 {
3475
3476 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07003477 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
3478 if( pHostapdState->bssState == BSS_START)
3479 {
3480 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303481
Jeff Johnson295189b2012-06-20 16:38:30 -07003482 if ( status != eHAL_STATUS_SUCCESS )
3483 {
3484 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3485 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3486 __LINE__, status );
3487 }
3488 }
3489 }
3490 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303491 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07003492 )
3493 {
3494 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3495
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303496 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3497
3498 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003499 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303500 __func__, setKey.peerMac[0], setKey.peerMac[1],
3501 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07003502 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303503 if(pAdapter->sessionCtx.station.conn_info.connState ==
3504 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07003505 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303506 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003507 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303508
Jeff Johnson295189b2012-06-20 16:38:30 -07003509 if ( 0 != status )
3510 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303511 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003512 "%s: sme_RoamSetKey failure, returned %d",
3513 __func__, status);
3514 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3515 return -EINVAL;
3516 }
3517 }
3518 }
3519#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003520 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 return status;
3522}
3523
3524/*
3525 * FUNCTION: wlan_hdd_cfg80211_set_default_key
3526 * This function is used to set the default tx key index
3527 */
3528#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3529static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3530 struct net_device *ndev,
3531 u8 key_index,
3532 bool unicast, bool multicast)
3533#else
3534static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3535 struct net_device *ndev,
3536 u8 key_index)
3537#endif
3538{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303539 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003540 int status = 0;
Gopichand Nakkala29149562013-05-10 21:43:41 +05303541 hdd_wext_state_t *pWextState;
3542 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003543
3544 ENTER();
3545
Gopichand Nakkala29149562013-05-10 21:43:41 +05303546 if ((NULL == pAdapter))
3547 {
3548 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3549 "invalid adapter");
3550 return -EINVAL;
3551 }
3552
3553 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3554 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3555
3556 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3557 {
3558 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3559 "invalid Wext state or HDD context");
3560 return -EINVAL;
3561 }
3562
Jeff Johnson295189b2012-06-20 16:38:30 -07003563 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d \n",
3564 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303565
Jeff Johnson295189b2012-06-20 16:38:30 -07003566 if (CSR_MAX_NUM_KEY <= key_index)
3567 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303568 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003569 key_index);
3570
3571 return -EINVAL;
3572 }
3573
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003574 if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress )
3575 {
3576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3577 "%s:LOGP in Progress. Ignore!!!", __func__);
3578 return -EAGAIN;
3579 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303580
Jeff Johnson295189b2012-06-20 16:38:30 -07003581 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07003582 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303583 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003584 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303585 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Jeff Johnson295189b2012-06-20 16:38:30 -07003586 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303587 (eCSR_ENCRYPT_TYPE_AES !=
Jeff Johnson295189b2012-06-20 16:38:30 -07003588 pWextState->roamProfile.EncryptionType.encryptionType[0])
3589 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303590 {
3591 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07003592 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303593
Jeff Johnson295189b2012-06-20 16:38:30 -07003594 tCsrRoamSetKey setKey;
3595 v_U32_t roamId= 0xFF;
3596 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303597
3598 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003599 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303600
Jeff Johnson295189b2012-06-20 16:38:30 -07003601 Keys->defaultIndex = (u8)key_index;
3602 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3603 setKey.keyId = key_index;
3604 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303605
3606 vos_mem_copy(&setKey.Key[0],
3607 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003608 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303609
Gopichand Nakkala29149562013-05-10 21:43:41 +05303610 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303611
3612 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07003613 &pHddStaCtx->conn_info.bssId[0],
3614 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303615
Gopichand Nakkala29149562013-05-10 21:43:41 +05303616 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
3617 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
3618 eCSR_ENCRYPT_TYPE_WEP104)
3619 {
3620 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
3621 even though ap is configured for WEP-40 encryption. In this canse the key length
3622 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
3623 type(104) and switching encryption type to 40*/
3624 pWextState->roamProfile.EncryptionType.encryptionType[0] =
3625 eCSR_ENCRYPT_TYPE_WEP40;
3626 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
3627 eCSR_ENCRYPT_TYPE_WEP40;
3628 }
3629
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303630 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07003631 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303632
Jeff Johnson295189b2012-06-20 16:38:30 -07003633 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303634 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003635 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303636
Jeff Johnson295189b2012-06-20 16:38:30 -07003637 if ( 0 != status )
3638 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303639 hddLog(VOS_TRACE_LEVEL_ERROR,
3640 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003641 status);
3642 return -EINVAL;
3643 }
3644 }
3645 }
3646
3647 /* In SoftAp mode setting key direction for default mode */
3648 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
3649 {
3650 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
3651 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
3652 (eCSR_ENCRYPT_TYPE_AES !=
3653 pWextState->roamProfile.EncryptionType.encryptionType[0])
3654 )
3655 {
3656 /* Saving key direction for default key index to TX default */
3657 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3658 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
3659 }
3660 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303661
Jeff Johnson295189b2012-06-20 16:38:30 -07003662 return status;
3663}
3664
Jeff Johnson295189b2012-06-20 16:38:30 -07003665/*
3666 * FUNCTION: wlan_hdd_cfg80211_inform_bss
3667 * This function is used to inform the BSS details to nl80211 interface.
3668 */
3669static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
3670 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
3671{
3672 struct net_device *dev = pAdapter->dev;
3673 struct wireless_dev *wdev = dev->ieee80211_ptr;
3674 struct wiphy *wiphy = wdev->wiphy;
3675 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
3676 int chan_no;
3677 int ie_length;
3678 const char *ie;
3679 unsigned int freq;
3680 struct ieee80211_channel *chan;
3681 int rssi = 0;
3682 struct cfg80211_bss *bss = NULL;
3683
3684 ENTER();
3685
3686 if( NULL == pBssDesc )
3687 {
3688 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL\n", __func__);
3689 return bss;
3690 }
3691
3692 chan_no = pBssDesc->channelId;
3693 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
3694 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
3695
3696 if( NULL == ie )
3697 {
3698 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL\n", __func__);
3699 return bss;
3700 }
3701
3702#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
3703 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
3704 {
3705 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
3706 }
3707 else
3708 {
3709 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
3710 }
3711#else
3712 freq = ieee80211_channel_to_frequency(chan_no);
3713#endif
3714
3715 chan = __ieee80211_get_channel(wiphy, freq);
3716
3717 bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId,
3718 &roamProfile->SSID.ssId[0], roamProfile->SSID.length,
3719 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
3720 if (bss == NULL)
3721 {
3722 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
3723
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303724 return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
3725 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07003726 pBssDesc->capabilityInfo,
3727 pBssDesc->beaconInterval, ie, ie_length,
3728 rssi, GFP_KERNEL ));
3729}
3730 else
3731 {
3732 return bss;
3733 }
3734}
3735
3736
3737
3738/*
3739 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
3740 * This function is used to inform the BSS details to nl80211 interface.
3741 */
3742struct cfg80211_bss*
3743wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
3744 tSirBssDescription *bss_desc
3745 )
3746{
3747 /*
3748 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
3749 already exists in bss data base of cfg80211 for that particular BSS ID.
3750 Using cfg80211_inform_bss_frame to update the bss entry instead of
3751 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
3752 now there is no possibility to get the mgmt(probe response) frame from PE,
3753 converting bss_desc to ieee80211_mgmt(probe response) and passing to
3754 cfg80211_inform_bss_frame.
3755 */
3756 struct net_device *dev = pAdapter->dev;
3757 struct wireless_dev *wdev = dev->ieee80211_ptr;
3758 struct wiphy *wiphy = wdev->wiphy;
3759 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08003760#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
3761 qcom_ie_age *qie_age = NULL;
3762 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
3763#else
Jeff Johnson295189b2012-06-20 16:38:30 -07003764 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08003765#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003766 const char *ie =
3767 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
3768 unsigned int freq;
3769 struct ieee80211_channel *chan;
3770 struct ieee80211_mgmt *mgmt =
3771 kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
3772 struct cfg80211_bss *bss_status = NULL;
3773 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
3774 int rssi = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07003775#ifdef WLAN_OPEN_SOURCE
3776 struct timespec ts;
3777#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003778
3779 ENTER();
3780
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07003781 if (!mgmt)
3782 return NULL;
3783
Jeff Johnson295189b2012-06-20 16:38:30 -07003784 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07003785
3786#ifdef WLAN_OPEN_SOURCE
3787 /* Android does not want the timestamp from the frame.
3788 Instead it wants a monotonic increasing value */
3789 get_monotonic_boottime(&ts);
3790 mgmt->u.probe_resp.timestamp =
3791 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
3792#else
3793 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07003794 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
3795 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07003796
3797#endif
3798
Jeff Johnson295189b2012-06-20 16:38:30 -07003799 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
3800 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08003801
3802#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
3803 /* GPS Requirement: need age ie per entry. Using vendor specific. */
3804 /* Assuming this is the last IE, copy at the end */
3805 ie_length -=sizeof(qcom_ie_age);
3806 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
3807 qie_age->element_id = QCOM_VENDOR_IE_ID;
3808 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
3809 qie_age->oui_1 = QCOM_OUI1;
3810 qie_age->oui_2 = QCOM_OUI2;
3811 qie_age->oui_3 = QCOM_OUI3;
3812 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
3813 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
3814#endif
3815
Jeff Johnson295189b2012-06-20 16:38:30 -07003816 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
3817
3818 mgmt->frame_control |=
3819 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
3820
3821#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303822 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003823 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
3824 {
3825 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
3826 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303827 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003828 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
3829
3830 {
3831 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
3832 }
3833 else
3834 {
3835 kfree(mgmt);
3836 return NULL;
3837 }
3838#else
3839 freq = ieee80211_channel_to_frequency(chan_no);
3840#endif
3841 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08003842 /*when the band is changed on the fly using the GUI, three things are done
3843 * 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)
3844 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
3845 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
3846 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
3847 * and discards the channels correponding to previous band and calls back with zero bss results.
3848 * 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
3849 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
3850 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
3851 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
3852 * So drop the bss and continue to next bss.
3853 */
3854 if(chan == NULL)
3855 {
3856 hddLog(VOS_TRACE_LEVEL_INFO, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07003857 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08003858 return NULL;
3859 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003860 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303861 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07003862 * */
3863 if (( eConnectionState_Associated ==
3864 pAdapter->sessionCtx.station.conn_info.connState ) &&
3865 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
3866 pAdapter->sessionCtx.station.conn_info.bssId,
3867 WNI_CFG_BSSID_LEN)))
3868 {
3869 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
3870 rssi = (pAdapter->rssi * 100);
3871 }
3872 else
3873 {
3874 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
3875 }
3876
3877 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
3878 frame_len, rssi, GFP_KERNEL);
3879 kfree(mgmt);
3880 return bss_status;
3881}
3882
3883/*
3884 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
3885 * This function is used to update the BSS data base of CFG8011
3886 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303887struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07003888 tCsrRoamInfo *pRoamInfo
3889 )
3890{
3891 tCsrRoamConnectedProfile roamProfile;
3892 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3893 struct cfg80211_bss *bss = NULL;
3894
3895 ENTER();
3896
3897 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
3898 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
3899
3900 if (NULL != roamProfile.pBssDesc)
3901 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303902 bss = wlan_hdd_cfg80211_inform_bss(pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07003903 &roamProfile);
3904
3905 if (NULL == bss)
3906 {
3907 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
3908 __func__);
3909 }
3910
3911 sme_RoamFreeConnectProfile(hHal, &roamProfile);
3912 }
3913 else
3914 {
3915 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
3916 __func__);
3917 }
3918 return bss;
3919}
3920
3921/*
3922 * FUNCTION: wlan_hdd_cfg80211_update_bss
3923 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303924static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
3925 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303927{
Jeff Johnson295189b2012-06-20 16:38:30 -07003928 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3929 tCsrScanResultInfo *pScanResult;
3930 eHalStatus status = 0;
3931 tScanResultHandle pResult;
3932 struct cfg80211_bss *bss_status = NULL;
3933
3934 ENTER();
3935
3936 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3937 {
3938 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
3939 return -EAGAIN;
3940 }
3941
3942 /*
3943 * start getting scan results and populate cgf80211 BSS database
3944 */
3945 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
3946
3947 /* no scan results */
3948 if (NULL == pResult)
3949 {
3950 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result\n", __func__);
3951 return status;
3952 }
3953
3954 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
3955
3956 while (pScanResult)
3957 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303958 /*
3959 * cfg80211_inform_bss() is not updating ie field of bss entry, if
3960 * entry already exists in bss data base of cfg80211 for that
3961 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
3962 * bss entry instead of cfg80211_inform_bss, But this call expects
3963 * mgmt packet as input. As of now there is no possibility to get
3964 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07003965 * ieee80211_mgmt(probe response) and passing to c
3966 * fg80211_inform_bss_frame.
3967 * */
3968
3969 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
3970 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303971
Jeff Johnson295189b2012-06-20 16:38:30 -07003972
3973 if (NULL == bss_status)
3974 {
3975 hddLog(VOS_TRACE_LEVEL_INFO,
3976 "%s: NULL returned by cfg80211_inform_bss\n", __func__);
3977 }
3978 else
3979 {
3980 cfg80211_put_bss(bss_status);
3981 }
3982
3983 pScanResult = sme_ScanResultGetNext(hHal, pResult);
3984 }
3985
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303986 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07003987
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303988 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003989}
3990
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003991void
3992hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
3993{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303994 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07003995 "%02X:%02X:%02X:%02X:%02X:%02X\n",
3996 macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4],
3997 macAddr[5]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003998} /****** end hddPrintMacAddr() ******/
3999
4000void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004001hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004002{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304003 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004004 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
4005 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
4006 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
4007 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004008} /****** end hddPrintPmkId() ******/
4009
4010//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
4011//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
4012
4013//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
4014//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
4015
4016#define dump_bssid(bssid) \
4017 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004018 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
4019 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
4020 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004021 }
4022
4023#define dump_pmkid(pMac, pmkid) \
4024 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004025 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
4026 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
4027 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004028 }
4029
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004030#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004031/*
4032 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
4033 * This function is used to notify the supplicant of a new PMKSA candidate.
4034 */
4035int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304036 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004037 int index, bool preauth )
4038{
Jeff Johnsone7245742012-09-05 17:12:55 -07004039#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004040 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004041 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004042
4043 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07004044 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004045
4046 if( NULL == pRoamInfo )
4047 {
4048 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL\n", __func__);
4049 return -EINVAL;
4050 }
4051
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004052 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
4053 {
4054 dump_bssid(pRoamInfo->bssid);
4055 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004056 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004057 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004058#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304059 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004060}
4061#endif //FEATURE_WLAN_LFR
4062
Jeff Johnson295189b2012-06-20 16:38:30 -07004063/*
4064 * FUNCTION: hdd_cfg80211_scan_done_callback
4065 * scanning callback function, called after finishing scan
4066 *
4067 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304068static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
4070{
4071 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304072 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004073 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004074 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4075 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07004076 struct cfg80211_scan_request *req = NULL;
4077 int ret = 0;
4078
4079 ENTER();
4080
4081 hddLog(VOS_TRACE_LEVEL_INFO,
4082 "%s called with halHandle = %p, pContext = %p,"
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304083 "scanID = %d, returned status = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07004084 __func__, halHandle, pContext, (int) scanId, (int) status);
4085
4086 //Block on scan req completion variable. Can't wait forever though.
4087 ret = wait_for_completion_interruptible_timeout(
4088 &pScanInfo->scan_req_completion_event,
4089 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
4090 if (!ret)
4091 {
4092 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004093 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004094 }
4095
4096 if(pScanInfo->mScanPending != VOS_TRUE)
4097 {
4098 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004099 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004100 }
4101
4102 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304103 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -07004104 {
4105 hddLog(VOS_TRACE_LEVEL_INFO,
4106 "%s called with mismatched scanId pScanInfo->scanId = %d "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304107 "scanId = %d \n", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004108 (int) scanId);
4109 }
4110
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304111 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004112 pAdapter);
4113
4114 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304115 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004116
4117
4118 /* If any client wait scan result through WEXT
4119 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004120 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07004121 {
4122 /* The other scan request waiting for current scan finish
4123 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004124 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004125 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004126 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07004127 }
4128 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004129 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004130 {
4131 struct net_device *dev = pAdapter->dev;
4132 union iwreq_data wrqu;
4133 int we_event;
4134 char *msg;
4135
4136 memset(&wrqu, '\0', sizeof(wrqu));
4137 we_event = SIOCGIWSCAN;
4138 msg = NULL;
4139 wireless_send_event(dev, we_event, &wrqu, msg);
4140 }
4141 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004142 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004143
4144 /* Get the Scan Req */
4145 req = pAdapter->request;
4146
4147 if (!req)
4148 {
4149 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL\n");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004150 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004151 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004152 }
4153
4154 /*
4155 * setting up 0, just in case.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304156 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004157 req->n_ssids = 0;
4158 req->n_channels = 0;
4159 req->ie = 0;
4160
Jeff Johnson295189b2012-06-20 16:38:30 -07004161 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07004162 /* Scan is no longer pending */
4163 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004164
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -07004165 /*
4166 * cfg80211_scan_done informing NL80211 about completion
4167 * of scanning
4168 */
4169 cfg80211_scan_done(req, false);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08004170 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07004171
Jeff Johnsone7245742012-09-05 17:12:55 -07004172allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004173 /* release the wake lock at the end of the scan*/
4174 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07004175
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004176 /* Acquire wakelock to handle the case where APP's tries to suspend
4177 * immediatly after the driver gets connect request(i.e after scan)
4178 * from supplicant, this result in app's is suspending and not able
4179 * to process the connect request to AP */
Amar Singhal6144c002013-05-03 16:11:42 -07004180 hdd_allow_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004181
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004182#ifdef FEATURE_WLAN_TDLS
4183 wlan_hdd_tdls_scan_done_callback(pAdapter);
4184#endif
4185
Jeff Johnson295189b2012-06-20 16:38:30 -07004186 EXIT();
4187 return 0;
4188}
4189
4190/*
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004191 * FUNCTION: hdd_isScanAllowed
4192 * Go through each adapter and check if scan allowed
4193 *
4194 */
4195v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx )
4196{
4197 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
4198 hdd_station_ctx_t *pHddStaCtx = NULL;
4199 hdd_adapter_t *pAdapter = NULL;
4200 VOS_STATUS status = 0;
4201 v_U8_t staId = 0;
4202 v_U8_t *staMac = NULL;
4203
4204 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
4205
4206 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
4207 {
4208 pAdapter = pAdapterNode->pAdapter;
4209
4210 if( pAdapter )
4211 {
4212 hddLog(VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304213 "%s: Adapter with device mode %d exists",
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004214 __func__, pAdapter->device_mode);
4215 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
4216 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4217 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
4218 {
4219 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4220 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
4221 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
4222 {
4223 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
4224 hddLog(VOS_TRACE_LEVEL_ERROR,
4225 "%s: client %02x:%02x:%02x:%02x:%02x:%02x is in the "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304226 "middle of WPS/EAPOL exchange.", __func__,
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004227 staMac[0], staMac[1], staMac[2],
4228 staMac[3], staMac[4], staMac[5]);
4229 return VOS_FALSE;
4230 }
4231 }
4232 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
4233 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
4234 {
4235 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
4236 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304237 if ((pAdapter->aStaInfo[staId].isUsed) &&
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004238 (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState))
4239 {
4240 staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
4241
4242 hddLog(VOS_TRACE_LEVEL_ERROR,
4243 "%s: client %02x:%02x:%02x:%02x:%02x:%02x of SoftAP/P2P-GO is in the "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304244 "middle of WPS/EAPOL exchange.", __func__,
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004245 staMac[0], staMac[1], staMac[2],
4246 staMac[3], staMac[4], staMac[5]);
4247 return VOS_FALSE;
4248 }
4249 }
4250 }
4251 }
4252 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
4253 pAdapterNode = pNext;
4254 }
4255 hddLog(VOS_TRACE_LEVEL_INFO,
4256 "%s: Scan allowed", __func__);
4257 return VOS_TRUE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304258}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004259
4260/*
Jeff Johnson295189b2012-06-20 16:38:30 -07004261 * FUNCTION: wlan_hdd_cfg80211_scan
4262 * this scan respond to scan trigger and update cfg80211 scan database
4263 * later, scan dump command can be used to recieve scan results
4264 */
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08004265int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
4266#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4267 struct net_device *dev,
4268#endif
4269 struct cfg80211_scan_request *request)
4270{
4271#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
4272 struct net_device *dev = request->wdev->netdev;
4273#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304274 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07004275 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4276 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4277 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
4278 tCsrScanRequest scanRequest;
4279 tANI_U8 *channelList = NULL, i;
4280 v_U32_t scanId = 0;
4281 int status = 0;
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004282 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07004283 v_U8_t* pP2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004284
4285 ENTER();
4286
4287 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
4288 __func__,pAdapter->device_mode);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004289
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004290 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004291 (eConnectionState_Connecting ==
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004292 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004293 {
4294 hddLog(VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08004295 "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \
4296 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004297 return -EBUSY;
4298 }
4299
Jeff Johnson295189b2012-06-20 16:38:30 -07004300#ifdef WLAN_BTAMP_FEATURE
4301 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004302 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -07004303 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004304 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004305 "%s: No scanning when AMP is on", __func__);
4306 return -EOPNOTSUPP;
4307 }
4308#endif
4309 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004310 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07004311 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004312 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004313 "%s: Not scanning on device_mode = %d",
4314 __func__, pAdapter->device_mode);
4315 return -EOPNOTSUPP;
4316 }
4317
4318 if (TRUE == pScanInfo->mScanPending)
4319 {
4320 hddLog(VOS_TRACE_LEVEL_INFO, "%s: mScanPending is TRUE", __func__);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004321 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004322 }
4323
4324 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4325 {
4326 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4327 "%s:LOGP in Progress. Ignore!!!", __func__);
4328 return -EAGAIN;
4329 }
4330
Mohit Khanna6c52bbf2012-09-11 15:10:12 -07004331 if ((WLAN_HDD_GET_CTX(pAdapter))->isLoadUnloadInProgress)
4332 {
4333 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4334 "%s:Unloading/Loading in Progress. Ignore!!!", __func__);
4335 return -EAGAIN;
4336 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304337 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -07004338 //Channel and action frame is pending
4339 //Otherwise Cancel Remain On Channel and allow Scan
4340 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004341 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -07004342 {
4343 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Remain On Channel Pending", __func__);
4344 return -EBUSY;
4345 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004346#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004347 /* if tdls disagree scan right now, return immediately.
4348 tdls will schedule the scan when scan is allowed. (return SUCCESS)
4349 or will reject the scan if any TDLS is in progress. (return -EBUSY)
4350 */
4351 status = wlan_hdd_tdls_scan_callback (pAdapter,
4352 wiphy,
4353#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4354 dev,
Gopichand Nakkalac3c42b92013-03-20 19:42:34 -07004355#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004356 request);
4357 if(status <= 0)
4358 {
4359 hddLog(VOS_TRACE_LEVEL_INFO, "%s: TDLS Pending %d", __func__, status);
4360 return status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004361 }
4362#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07004363
Jeff Johnson295189b2012-06-20 16:38:30 -07004364 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
4365 {
4366 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -08004367 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004368 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304369 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004370 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
4371 {
4372 hddLog(VOS_TRACE_LEVEL_WARN,
4373 "%s: MAX TM Level Scan not allowed", __func__);
4374 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304375 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004376 }
4377 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
4378
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004379 /* Check if scan is allowed at this point of time.
4380 */
4381 if (!hdd_isScanAllowed(pHddCtx))
4382 {
4383 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
4384 return -EBUSY;
4385 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304386
Jeff Johnson295189b2012-06-20 16:38:30 -07004387 vos_mem_zero( &scanRequest, sizeof(scanRequest));
4388
4389 if (NULL != request)
4390 {
4391 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304392 (int)request->n_ssids);
Jeff Johnson295189b2012-06-20 16:38:30 -07004393
4394 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
4395 * Becasue of this, driver is assuming that this is not wildcard scan and so
4396 * is not aging out the scan results.
4397 */
Jeff Johnson32d95a32012-09-10 13:15:23 -07004398 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004399 {
4400 request->n_ssids = 0;
4401 }
4402
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004403 if ((request->ssids) && (0 < request->n_ssids))
Jeff Johnson295189b2012-06-20 16:38:30 -07004404 {
4405 tCsrSSIDInfo *SsidInfo;
4406 int j;
4407 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
4408 /* Allocate num_ssid tCsrSSIDInfo structure */
4409 SsidInfo = scanRequest.SSIDs.SSIDList =
4410 ( tCsrSSIDInfo *)vos_mem_malloc(
4411 request->n_ssids*sizeof(tCsrSSIDInfo));
4412
4413 if(NULL == scanRequest.SSIDs.SSIDList)
4414 {
4415 hddLog(VOS_TRACE_LEVEL_ERROR,
4416 "memory alloc failed SSIDInfo buffer");
4417 return -ENOMEM;
4418 }
4419
4420 /* copy all the ssid's and their length */
4421 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
4422 {
4423 /* get the ssid length */
4424 SsidInfo->SSID.length = request->ssids[j].ssid_len;
4425 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
4426 SsidInfo->SSID.length);
4427 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
4428 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "SSID number %d: %s",
4429 j, SsidInfo->SSID.ssId);
4430 }
4431 /* set the scan type to active */
4432 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4433 }
4434 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
4435 {
4436 /* set the scan type to active */
4437 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4438 }
4439 else
4440 {
4441 /*Set the scan type to default type, in this case it is ACTIVE*/
4442 scanRequest.scanType = pScanInfo->scan_mode;
4443 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304444 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07004445 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
4446 }
4447 else
4448 {
4449 /* set the scan type to active */
4450 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4451 vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff );
4452
4453 /* set min and max channel time to zero */
4454 scanRequest.minChnTime = 0;
4455 scanRequest.maxChnTime = 0;
4456 }
4457
4458 /* set BSSType to default type */
4459 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
4460
4461 /*TODO: scan the requested channels only*/
4462
4463 /*Right now scanning all the channels */
4464 if( request )
4465 {
4466 if( request->n_channels )
4467 {
4468 channelList = vos_mem_malloc( request->n_channels );
4469 if( NULL == channelList )
4470 {
4471 status = -ENOMEM;
4472 goto free_mem;
4473 }
4474
4475 for( i = 0 ; i < request->n_channels ; i++ )
4476 channelList[i] = request->channels[i]->hw_value;
4477 }
4478
4479 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
4480 scanRequest.ChannelInfo.ChannelList = channelList;
4481
4482 /* set requestType to full scan */
4483 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304484
4485 /* Flush the scan results(only p2p beacons) for STA scan and P2P
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004486 * search (Flush on both full scan and social scan but not on single
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304487 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004488 */
4489
4490 /* Supplicant does single channel scan after 8-way handshake
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304491 * and in that case driver shoudnt flush scan results. If
4492 * driver flushes the scan results here and unfortunately if
4493 * the AP doesnt respond to our probe req then association
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004494 * fails which is not desired
4495 */
4496
4497 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
4498 {
4499 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
4500 pAdapter->sessionId );
4501 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004502
4503 if( request->ie_len )
4504 {
4505 /* save this for future association (join requires this) */
4506 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
4507 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
4508 pScanInfo->scanAddIE.length = request->ie_len;
4509
4510 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07004511 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4512 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07004513 )
4514 {
4515 pwextBuf->roamProfile.pAddIEScan = pScanInfo->scanAddIE.addIEdata;
4516 pwextBuf->roamProfile.nAddIEScanLength = pScanInfo->scanAddIE.length;
4517 }
4518
4519 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
4520 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
4521
Jeff Johnson295189b2012-06-20 16:38:30 -07004522 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
4523 request->ie_len);
4524 if (pP2pIe != NULL)
4525 {
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07004526#ifdef WLAN_FEATURE_P2P_DEBUG
4527 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
4528 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
4529 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
4530 {
4531 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
4532 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
4533 "Go nego completed to Connection is started");
4534 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
4535 "for 8way Handshake");
4536 }
4537 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
4538 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
4539 {
4540 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
4541 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
4542 "Disconnected state to Connection is started");
4543 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
4544 "for 4way Handshake");
4545 }
4546#endif
4547
Jeff Johnsone7245742012-09-05 17:12:55 -07004548 /* no_cck will be set during p2p find to disable 11b rates */
4549 if(TRUE == request->no_cck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004550 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004551 hddLog(VOS_TRACE_LEVEL_INFO,
4552 "%s: This is a P2P Search", __func__);
4553 scanRequest.p2pSearch = 1;
Jeff Johnsone7245742012-09-05 17:12:55 -07004554
Jeff Johnsone7245742012-09-05 17:12:55 -07004555 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
4556 {
Madan Mohan Koyyalamudi1b1d9e82012-10-21 11:38:33 -07004557 /* set requestType to P2P Discovery */
4558 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
Jeff Johnsone7245742012-09-05 17:12:55 -07004559 }
4560
4561 /*
4562 Skip Dfs Channel in case of P2P Search
4563 if it is set in ini file
4564 */
4565 if(cfg_param->skipDfsChnlInP2pSearch)
4566 {
4567 scanRequest.skipDfsChnlInP2pSearch = 1;
4568 }
4569 else
4570 {
4571 scanRequest.skipDfsChnlInP2pSearch = 0;
4572 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004573
Jeff Johnson295189b2012-06-20 16:38:30 -07004574 }
4575 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004576 }
4577 }
4578
4579 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
4580
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004581 /* acquire the wakelock to avoid the apps suspend during the scan. To
4582 * address the following issues.
4583 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
4584 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
4585 * for long time, this result in apps running at full power for long time.
4586 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
4587 * be stuck in full power because of resume BMPS
4588 */
4589 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07004590
4591 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07004592 pAdapter->sessionId, &scanRequest, &scanId,
4593 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -07004594
Jeff Johnson295189b2012-06-20 16:38:30 -07004595 if (eHAL_STATUS_SUCCESS != status)
4596 {
4597 hddLog(VOS_TRACE_LEVEL_ERROR,
4598 "%s: sme_ScanRequest returned error %d", __func__, status);
4599 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07004600 if(eHAL_STATUS_RESOURCES == status)
4601 {
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07004602 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 -07004603 status = -EBUSY;
4604 } else {
4605 status = -EIO;
4606 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004607 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07004608 goto free_mem;
4609 }
4610
4611 pScanInfo->mScanPending = TRUE;
4612 pAdapter->request = request;
4613 pScanInfo->scanId = scanId;
4614
4615 complete(&pScanInfo->scan_req_completion_event);
4616
4617free_mem:
4618 if( scanRequest.SSIDs.SSIDList )
4619 {
4620 vos_mem_free(scanRequest.SSIDs.SSIDList);
4621 }
4622
4623 if( channelList )
4624 vos_mem_free( channelList );
4625
4626 EXIT();
4627
4628 return status;
4629}
4630
4631/*
4632 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304633 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304635int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -07004636 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07004637{
4638 int status = 0;
4639 hdd_wext_state_t *pWextState;
4640 v_U32_t roamId;
4641 tCsrRoamProfile *pRoamProfile;
4642 eMib_dot11DesiredBssType connectedBssType;
4643 eCsrAuthType RSNAuthType;
4644
4645 ENTER();
4646
4647 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304648
Jeff Johnson295189b2012-06-20 16:38:30 -07004649 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
4650 {
4651 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
4652 return -EINVAL;
4653 }
4654
4655 pRoamProfile = &pWextState->roamProfile;
4656
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304657 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004658 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004659 int ret = 0;
4660 hdd_station_ctx_t *pHddStaCtx;
4661 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4662 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
4663
4664 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
4665 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
4666 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004667 {
4668 /* Issue disconnect to CSR */
4669 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304670 if( eHAL_STATUS_SUCCESS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07004671 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
4672 pAdapter->sessionId,
4673 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
4674 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004675 ret = wait_for_completion_interruptible_timeout(
4676 &pAdapter->disconnect_comp_var,
4677 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4678 if (0 == ret)
4679 {
4680 VOS_ASSERT(0);
4681 }
4682 }
4683 }
4684 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
4685 {
4686 ret = wait_for_completion_interruptible_timeout(
4687 &pAdapter->disconnect_comp_var,
4688 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4689 if (0 == ret)
4690 {
4691 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004692 }
4693 }
4694
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304695 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07004696 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
4697 {
4698 /*QoS not enabled in cfg file*/
4699 pRoamProfile->uapsd_mask = 0;
4700 }
4701 else
4702 {
4703 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304704 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -07004705 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
4706 }
4707
4708 pRoamProfile->SSIDs.numOfSSIDs = 1;
4709 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
4710 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304711 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004712 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
4713 ssid, ssid_len);
4714
4715 if (bssid)
4716 {
4717 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
4718 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
4719 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304720 /* Save BSSID in seperate variable as well, as RoamProfile
4721 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -07004722 case of join failure we should send valid BSSID to supplicant
4723 */
4724 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
4725 WNI_CFG_BSSID_LEN);
4726 }
4727
4728 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
4729 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304730 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004731 /*set gen ie*/
4732 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
4733 /*set auth*/
4734 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
4735 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004736#ifdef FEATURE_WLAN_WAPI
4737 if (pAdapter->wapi_info.nWapiMode)
4738 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004739 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004740 switch (pAdapter->wapi_info.wapiAuthMode)
4741 {
4742 case WAPI_AUTH_MODE_PSK:
4743 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004744 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004745 pAdapter->wapi_info.wapiAuthMode);
4746 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
4747 break;
4748 }
4749 case WAPI_AUTH_MODE_CERT:
4750 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004751 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004752 pAdapter->wapi_info.wapiAuthMode);
4753 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
4754 break;
4755 }
4756 } // End of switch
4757 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
4758 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
4759 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004760 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004761 pRoamProfile->AuthType.numEntries = 1;
4762 pRoamProfile->EncryptionType.numEntries = 1;
4763 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4764 pRoamProfile->mcEncryptionType.numEntries = 1;
4765 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4766 }
4767 }
4768#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05304769#ifdef WLAN_FEATURE_GTK_OFFLOAD
4770 /* Initializing gtkOffloadRequestParams */
4771 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
4772 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
4773 {
4774 pHddStaCtx->gtkOffloadRequestParams.requested = FALSE;
4775 memset(&pHddStaCtx->gtkOffloadRequestParams.gtkOffloadReqParams,
4776 0, sizeof (tSirGtkOffloadParams));
4777 }
4778#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004779 pRoamProfile->csrPersona = pAdapter->device_mode;
4780
Jeff Johnson32d95a32012-09-10 13:15:23 -07004781 if( operatingChannel )
4782 {
4783 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
4784 pRoamProfile->ChannelInfo.numOfChannels = 1;
4785 }
Chet Lanctot186b5732013-03-18 10:26:30 -07004786 else
4787 {
4788 pRoamProfile->ChannelInfo.ChannelList = NULL;
4789 pRoamProfile->ChannelInfo.numOfChannels = 0;
4790 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07004791
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08004792 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
4793 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304794 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08004795 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08004796 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
4797 */
4798 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode)
4799 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
4800 eConnectionState_Connecting);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304801
4802 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07004803 pAdapter->sessionId, pRoamProfile, &roamId);
4804
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08004805 if( (eHAL_STATUS_SUCCESS != status) &&
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05304806 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
4807
4808 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08004809 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
4810 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
4811 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05304812 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08004813 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05304814 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08004815
4816 pRoamProfile->ChannelInfo.ChannelList = NULL;
4817 pRoamProfile->ChannelInfo.numOfChannels = 0;
4818
Jeff Johnson295189b2012-06-20 16:38:30 -07004819 }
4820 else
4821 {
4822 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
4823 return -EINVAL;
4824 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004825 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004826 return status;
4827}
4828
4829/*
4830 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
4831 * This function is used to set the authentication type (OPEN/SHARED).
4832 *
4833 */
4834static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
4835 enum nl80211_auth_type auth_type)
4836{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304837 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004838 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4839
4840 ENTER();
4841
4842 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304843 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -07004844 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004845 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +05304846 hddLog(VOS_TRACE_LEVEL_INFO,
4847 "%s: set authentication type to AUTOSWITCH", __func__);
4848 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
4849 break;
4850
4851 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07004852#ifdef WLAN_FEATURE_VOWIFI_11R
4853 case NL80211_AUTHTYPE_FT:
4854#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304855 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07004856 "%s: set authentication type to OPEN", __func__);
4857 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4858 break;
4859
4860 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304861 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07004862 "%s: set authentication type to SHARED", __func__);
4863 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
4864 break;
4865#ifdef FEATURE_WLAN_CCX
4866 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304867 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07004868 "%s: set authentication type to CCKM WPA", __func__);
4869 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
4870 break;
4871#endif
4872
4873
4874 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304875 hddLog(VOS_TRACE_LEVEL_ERROR,
4876 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004877 auth_type);
4878 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
4879 return -EINVAL;
4880 }
4881
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304882 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07004883 pHddStaCtx->conn_info.authType;
4884 return 0;
4885}
4886
4887/*
4888 * FUNCTION: wlan_hdd_set_akm_suite
4889 * This function is used to set the key mgmt type(PSK/8021x).
4890 *
4891 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304892static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004893 u32 key_mgmt
4894 )
4895{
4896 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4897 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304898
Jeff Johnson295189b2012-06-20 16:38:30 -07004899 /*set key mgmt type*/
4900 switch(key_mgmt)
4901 {
4902 case WLAN_AKM_SUITE_PSK:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05304903#ifdef WLAN_FEATURE_VOWIFI_11R
4904 case WLAN_AKM_SUITE_FT_PSK:
4905#endif
4906 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -07004907 __func__);
4908 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
4909 break;
4910
4911 case WLAN_AKM_SUITE_8021X:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05304912#ifdef WLAN_FEATURE_VOWIFI_11R
4913 case WLAN_AKM_SUITE_FT_8021X:
4914#endif
4915 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -07004916 __func__);
4917 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
4918 break;
4919#ifdef FEATURE_WLAN_CCX
4920#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
4921#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
4922 case WLAN_AKM_SUITE_CCKM:
4923 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
4924 __func__);
4925 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
4926 break;
4927#endif
4928
4929 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304930 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004931 __func__, key_mgmt);
4932 return -EINVAL;
4933
4934 }
4935 return 0;
4936}
4937
4938/*
4939 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304940 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -07004941 * (NONE/WEP40/WEP104/TKIP/CCMP).
4942 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304943static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
4944 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -07004945 bool ucast
4946 )
4947{
4948 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304949 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4951
4952 ENTER();
4953
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304954 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07004955 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304956 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -07004957 __func__, cipher);
4958 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4959 }
4960 else
4961 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304962
Jeff Johnson295189b2012-06-20 16:38:30 -07004963 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304964 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07004965 {
4966 case IW_AUTH_CIPHER_NONE:
4967 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4968 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304969
Jeff Johnson295189b2012-06-20 16:38:30 -07004970 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +05304971 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07004972 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304973
Jeff Johnson295189b2012-06-20 16:38:30 -07004974 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +05304975 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -07004976 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304977
Jeff Johnson295189b2012-06-20 16:38:30 -07004978 case WLAN_CIPHER_SUITE_TKIP:
4979 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
4980 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304981
Jeff Johnson295189b2012-06-20 16:38:30 -07004982 case WLAN_CIPHER_SUITE_CCMP:
4983 encryptionType = eCSR_ENCRYPT_TYPE_AES;
4984 break;
4985#ifdef FEATURE_WLAN_WAPI
4986 case WLAN_CIPHER_SUITE_SMS4:
4987 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
4988 break;
4989#endif
4990
4991#ifdef FEATURE_WLAN_CCX
4992 case WLAN_CIPHER_SUITE_KRK:
4993 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
4994 break;
4995#endif
4996 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304997 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004998 __func__, cipher);
4999 return -EOPNOTSUPP;
5000 }
5001 }
5002
5003 if (ucast)
5004 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305005 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005006 __func__, encryptionType);
5007 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
5008 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305009 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005010 encryptionType;
5011 }
5012 else
5013 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305014 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005015 __func__, encryptionType);
5016 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
5017 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5018 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
5019 }
5020
5021 return 0;
5022}
5023
5024
5025/*
5026 * FUNCTION: wlan_hdd_cfg80211_set_ie
5027 * This function is used to parse WPA/RSN IE's.
5028 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305029int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
5030 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -07005031 size_t ie_len
5032 )
5033{
5034 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5035 u8 *genie = ie;
5036 v_U16_t remLen = ie_len;
5037#ifdef FEATURE_WLAN_WAPI
5038 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
5039 u16 *tmp;
5040 v_U16_t akmsuiteCount;
5041 int *akmlist;
5042#endif
5043 ENTER();
5044
5045 /* clear previous assocAddIE */
5046 pWextState->assocAddIE.length = 0;
5047 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
5048
5049 while (remLen >= 2)
5050 {
5051 v_U16_t eLen = 0;
5052 v_U8_t elementId;
5053 elementId = *genie++;
5054 eLen = *genie++;
5055 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305056
5057 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005058 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305059
5060 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -07005061 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305062 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005063 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 -07005064 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305065 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005066 "%s: Invalid WPA IE", __func__);
5067 return -EINVAL;
5068 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305069 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -07005070 {
5071 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305072 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005073 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305074
Jeff Johnson295189b2012-06-20 16:38:30 -07005075 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5076 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005077 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
5078 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005079 VOS_ASSERT(0);
5080 return -ENOMEM;
5081 }
5082 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5083 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5084 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305085
Jeff Johnson295189b2012-06-20 16:38:30 -07005086 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
5087 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5088 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5089 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305090 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
5091 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005092 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
5093 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5094 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
5095 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
5096 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
5097 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305098 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
5099 P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005100 /*Consider P2P IE, only for P2P Client */
5101 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5102 {
5103 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305104 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005105 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305106
Jeff Johnson295189b2012-06-20 16:38:30 -07005107 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5108 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005109 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5110 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005111 VOS_ASSERT(0);
5112 return -ENOMEM;
5113 }
5114 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5115 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5116 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305117
Jeff Johnson295189b2012-06-20 16:38:30 -07005118 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5119 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5120 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005121#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305122 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
5123 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005124 /*Consider WFD IE, only for P2P Client */
5125 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5126 {
5127 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305128 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005129 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305130
Jeff Johnson295189b2012-06-20 16:38:30 -07005131 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5132 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005133 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5134 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005135 VOS_ASSERT(0);
5136 return -ENOMEM;
5137 }
5138 // WFD IE is saved to Additional IE ; it should be accumulated to handle
5139 // WPS IE + P2P IE + WFD IE
5140 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5141 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305142
Jeff Johnson295189b2012-06-20 16:38:30 -07005143 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5144 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5145 }
5146#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005147 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305148 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005149 HS20_OUI_TYPE_SIZE)) )
5150 {
5151 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305152 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005153 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005154
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005155 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5156 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005157 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5158 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005159 VOS_ASSERT(0);
5160 return -ENOMEM;
5161 }
5162 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5163 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005164
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005165 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5166 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5167 }
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005168
Jeff Johnson295189b2012-06-20 16:38:30 -07005169 break;
5170 case DOT11F_EID_RSN:
5171 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
5172 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5173 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
5174 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
5175 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
5176 break;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005177 /* Appending Extended Capabilities with Interworking bit set in Assoc Req */
5178 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305179 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005180 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305181 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005182 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305183
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005184 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5185 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005186 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5187 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005188 VOS_ASSERT(0);
5189 return -ENOMEM;
5190 }
5191 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5192 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305193
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005194 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5195 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5196 break;
5197 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005198#ifdef FEATURE_WLAN_WAPI
5199 case WLAN_EID_WAPI:
5200 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
5201 hddLog(VOS_TRACE_LEVEL_INFO,"WAPI MODE IS %lu \n",
5202 pAdapter->wapi_info.nWapiMode);
5203 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305204 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -07005205 akmsuiteCount = WPA_GET_LE16(tmp);
5206 tmp = tmp + 1;
5207 akmlist = (int *)(tmp);
5208 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
5209 {
5210 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
5211 }
5212 else
5213 {
5214 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count\n");
5215 VOS_ASSERT(0);
5216 return -EINVAL;
5217 }
5218
5219 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
5220 {
5221 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005222 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005223 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305224 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005225 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305226 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005227 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005228 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005229 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5230 }
5231 break;
5232#endif
5233 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305234 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005235 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005236 /* when Unknown IE is received we should break and continue
5237 * to the next IE in the buffer instead we were returning
5238 * so changing this to break */
5239 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005240 }
5241 genie += eLen;
5242 remLen -= eLen;
5243 }
5244 EXIT();
5245 return 0;
5246}
5247
5248/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +05305249 * FUNCTION: hdd_isWPAIEPresent
5250 * Parse the received IE to find the WPA IE
5251 *
5252 */
5253static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
5254{
5255 v_U8_t eLen = 0;
5256 v_U16_t remLen = ie_len;
5257 v_U8_t elementId = 0;
5258
5259 while (remLen >= 2)
5260 {
5261 elementId = *ie++;
5262 eLen = *ie++;
5263 remLen -= 2;
5264 if (eLen > remLen)
5265 {
5266 hddLog(VOS_TRACE_LEVEL_ERROR,
5267 "%s: IE length is wrong %d", __func__, eLen);
5268 return FALSE;
5269 }
5270 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
5271 {
5272 /* OUI - 0x00 0X50 0XF2
5273 WPA Information Element - 0x01
5274 WPA version - 0x01*/
5275 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
5276 return TRUE;
5277 }
5278 ie += eLen;
5279 remLen -= eLen;
5280 }
5281 return FALSE;
5282}
5283
5284/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005285 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305286 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005287 * parameters during connect operation.
5288 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305289int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005290 struct cfg80211_connect_params *req
5291 )
5292{
5293 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305294 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005295 ENTER();
5296
5297 /*set wpa version*/
5298 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
5299
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305300 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005301 {
5302 if ( (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305303 && ( (req->ie_len)
Gopichand Nakkala18f0c262013-05-07 23:25:08 +05305304 && (hdd_isWPAIEPresent(req->ie, req->ie_len) ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005305 // Make sure that it is including a WPA IE.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305306 /* Currently NL is putting WPA version 1 even for open,
Jeff Johnson295189b2012-06-20 16:38:30 -07005307 * since p2p ie is also put in same buffer.
5308 * */
5309 {
5310 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
5311 }
5312 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
5313 {
5314 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
5315 }
5316 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305317
5318 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005319 pWextState->wpaVersion);
5320
5321 /*set authentication type*/
5322 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
5323
5324 if (0 > status)
5325 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305326 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005327 "%s: failed to set authentication type ", __func__);
5328 return status;
5329 }
5330
5331 /*set key mgmt type*/
5332 if (req->crypto.n_akm_suites)
5333 {
5334 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
5335 if (0 > status)
5336 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305337 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -07005338 __func__);
5339 return status;
5340 }
5341 }
5342
5343 /*set pairwise cipher type*/
5344 if (req->crypto.n_ciphers_pairwise)
5345 {
5346 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
5347 req->crypto.ciphers_pairwise[0], true);
5348 if (0 > status)
5349 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305350 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005351 "%s: failed to set unicast cipher type", __func__);
5352 return status;
5353 }
5354 }
5355 else
5356 {
5357 /*Reset previous cipher suite to none*/
5358 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
5359 if (0 > status)
5360 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305361 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005362 "%s: failed to set unicast cipher type", __func__);
5363 return status;
5364 }
5365 }
5366
5367 /*set group cipher type*/
5368 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
5369 false);
5370
5371 if (0 > status)
5372 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305373 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -07005374 __func__);
5375 return status;
5376 }
5377
Chet Lanctot186b5732013-03-18 10:26:30 -07005378#ifdef WLAN_FEATURE_11W
5379 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
5380#endif
5381
Jeff Johnson295189b2012-06-20 16:38:30 -07005382 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
5383 if (req->ie_len)
5384 {
5385 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
5386 if ( 0 > status)
5387 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305388 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07005389 __func__);
5390 return status;
5391 }
5392 }
5393
5394 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305395 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07005396 {
5397 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
5398 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
5399 )
5400 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305401 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -07005402 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
5403 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305404 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 __func__);
5406 return -EOPNOTSUPP;
5407 }
5408 else
5409 {
5410 u8 key_len = req->key_len;
5411 u8 key_idx = req->key_idx;
5412
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305413 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07005414 && (CSR_MAX_NUM_KEY > key_idx)
5415 )
5416 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305417 hddLog(VOS_TRACE_LEVEL_INFO,
5418 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07005419 __func__, key_idx, key_len);
5420 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305421 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07005422 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305423 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005424 (u8)key_len;
5425 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
5426 }
5427 }
5428 }
5429 }
5430
5431 return status;
5432}
5433
5434/*
5435 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305436 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005437 * parameters during connect operation.
5438 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305439static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005440 struct net_device *ndev,
5441 struct cfg80211_connect_params *req
5442 )
5443{
5444 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305445 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07005446 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
5447 hdd_context_t *pHddCtx = NULL;
5448
5449 ENTER();
5450
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305451 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005452 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
5453
5454 if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress )
5455 {
5456 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5457 "%s:LOGP in Progress. Ignore!!!", __func__);
5458 return -EAGAIN;
5459 }
5460
5461#ifdef WLAN_BTAMP_FEATURE
5462 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305463 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -07005464 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305465 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005466 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08005467 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -07005468 }
5469#endif
5470 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305471 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -07005472
5473 if ( 0 > status)
5474 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305475 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -07005476 __func__);
5477 return status;
5478 }
5479
5480 //If Device Mode is Station Concurrent Sessions Exit BMps
Jeff Johnsona8a1a482012-12-12 16:49:33 -08005481 //P2P Mode will be taken care in Open/close adapter
Jeff Johnson295189b2012-06-20 16:38:30 -07005482 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
5483 (vos_concurrent_sessions_running()))
5484 {
5485 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
5486
5487 if (NULL != pVosContext)
5488 {
5489 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
5490 if(NULL != pHddCtx)
5491 {
5492 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
5493 }
5494 }
5495 }
5496
Mohit Khanna765234a2012-09-11 15:08:35 -07005497 if ( req->channel )
5498 {
5499 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
5500 req->ssid_len, req->bssid,
5501 req->channel->hw_value);
5502 }
5503 else
5504 {
5505 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
5506 req->ssid_len, req->bssid,
5507 0);
5508 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005509
5510 if (0 > status)
5511 {
5512 //ReEnable BMPS if disabled
5513 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
5514 (NULL != pHddCtx))
5515 {
5516 //ReEnable Bmps and Imps back
5517 hdd_enable_bmps_imps(pHddCtx);
5518 }
5519
5520 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
5521 return status;
5522 }
5523 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
5524 EXIT();
5525 return status;
5526}
5527
5528
5529/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305530 * FUNCTION: wlan_hdd_disconnect
5531 * This function is used to issue a disconnect request to SME
5532 */
5533int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
5534{
5535 int status = 0;
5536 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5537 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
5538 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_TRUE;
5539 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5540 /*issue disconnect*/
5541 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
5542 pAdapter->sessionId, reason);
5543
5544 if ( 0 != status )
5545 {
5546 hddLog(VOS_TRACE_LEVEL_ERROR,
5547 "%s csrRoamDisconnect failure, returned %d \n",
5548 __func__, (int)status );
5549 return -EINVAL;
5550 }
5551 wait_for_completion_interruptible_timeout(
5552 &pAdapter->disconnect_comp_var,
5553 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5554 /*stop tx queues*/
5555 netif_tx_disable(pAdapter->dev);
5556 netif_carrier_off(pAdapter->dev);
5557 return status;
5558}
5559
5560
5561/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005562 * FUNCTION: wlan_hdd_cfg80211_disconnect
5563 * This function is used to issue a disconnect request to SME
5564 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305565static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005566 struct net_device *dev,
5567 u16 reason
5568 )
5569{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305570 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
5571 tCsrRoamProfile *pRoamProfile =
Jeff Johnson295189b2012-06-20 16:38:30 -07005572 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
5573 int status = 0;
5574 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005575#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005576 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005577 tANI_U8 staIdx;
5578#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305579
Jeff Johnson295189b2012-06-20 16:38:30 -07005580 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305581
5582 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005583 __func__,pAdapter->device_mode);
5584
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305585 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
5586 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005587
5588 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5589 {
5590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5591 "%s:LOGP in Progress. Ignore!!!",__func__);
5592 return -EAGAIN;
5593 }
5594 if (NULL != pRoamProfile)
5595 {
5596 /*issue disconnect request to SME, if station is in connected state*/
5597 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated)
5598 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305599 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07005600 eCSR_DISCONNECT_REASON_UNSPECIFIED;
5601 switch(reason)
5602 {
5603 case WLAN_REASON_MIC_FAILURE:
5604 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
5605 break;
5606
5607 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
5608 case WLAN_REASON_DISASSOC_AP_BUSY:
5609 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
5610 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
5611 break;
5612
5613 case WLAN_REASON_PREV_AUTH_NOT_VALID:
5614 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
5615 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
5616 break;
5617
5618 case WLAN_REASON_DEAUTH_LEAVING:
5619 default:
5620 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5621 break;
5622 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005623
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005624#ifdef FEATURE_WLAN_TDLS
5625 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005626 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005627 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005628 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
5629 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005630 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08005631 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005632 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08005633 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07005634 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005635 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07005636 MAC_ADDR_ARRAY(mac));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005637 sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005638 pAdapter->sessionId,
5639 mac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005640 }
5641 }
5642#endif
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305643 status = wlan_hdd_disconnect(pAdapter, reasonCode);
5644 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -07005645 {
5646 hddLog(VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305647 "%s wlan_hdd_disconnect failure, returned %d \n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005648 __func__, (int)status );
5649 return -EINVAL;
5650 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005651 }
5652 }
5653 else
5654 {
5655 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
5656 }
5657
5658 return status;
5659}
5660
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305661
Jeff Johnson295189b2012-06-20 16:38:30 -07005662/*
5663 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305664 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005665 * settings in IBSS mode.
5666 */
5667static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305668 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005669 struct cfg80211_ibss_params *params
5670 )
5671{
5672 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305673 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005674 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5675 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305676
Jeff Johnson295189b2012-06-20 16:38:30 -07005677 ENTER();
5678
5679 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
5680
5681 if (params->ie_len && ( NULL != params->ie) )
5682 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305683 if (WLAN_EID_RSN == params->ie[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07005684 {
5685 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
5686 encryptionType = eCSR_ENCRYPT_TYPE_AES;
5687 }
5688 else
5689 {
5690 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
5691 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5692 }
5693 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
5694
5695 if (0 > status)
5696 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305697 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07005698 __func__);
5699 return status;
5700 }
5701 }
5702
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305703 pWextState->roamProfile.AuthType.authType[0] =
5704 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -07005705 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5706
5707 if (params->privacy)
5708 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305709 /* Security enabled IBSS, At this time there is no information available
5710 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -07005711 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305712 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -07005713 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305714 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -07005715 *enable privacy bit in beacons */
5716
5717 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5718 }
5719
5720 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
5721 pWextState->roamProfile.EncryptionType.numEntries = 1;
5722 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
5723
5724 return status;
5725}
5726
5727/*
5728 * FUNCTION: wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305729 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07005730 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305731static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005732 struct net_device *dev,
5733 struct cfg80211_ibss_params *params
5734 )
5735{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305736 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07005737 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5738 tCsrRoamProfile *pRoamProfile;
5739 int status;
5740 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5741
5742 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305743
5744 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005745 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
5746
5747 if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress )
5748 {
5749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5750 "%s:LOGP in Progress. Ignore!!!", __func__);
5751 return -EAGAIN;
5752 }
5753
5754 if (NULL == pWextState)
5755 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305756 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005757 __func__);
5758 return -EIO;
5759 }
5760
5761 pRoamProfile = &pWextState->roamProfile;
5762
5763 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
5764 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305765 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005766 "%s Interface type is not set to IBSS \n", __func__);
5767 return -EINVAL;
5768 }
5769
5770 /* Set Channel */
5771 if (NULL != params->channel)
5772 {
5773 u8 channelNum;
5774 if (IEEE80211_BAND_5GHZ == params->channel->band)
5775 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305776 hddLog(VOS_TRACE_LEVEL_ERROR,
5777 "%s: IBSS join is called with unsupported band %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005778 __func__, params->channel->band);
5779 return -EOPNOTSUPP;
5780 }
5781
5782 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305783 channelNum =
Jeff Johnson295189b2012-06-20 16:38:30 -07005784 ieee80211_frequency_to_channel(params->channel->center_freq);
5785
5786 /*TODO: use macro*/
5787 if (14 >= channelNum)
5788 {
5789 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
5790 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
5791 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5792 int indx;
5793
5794 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
5795 validChan, &numChans))
5796 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305797 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
Jeff Johnson295189b2012-06-20 16:38:30 -07005798 __func__);
5799 return -EOPNOTSUPP;
5800 }
5801
5802 for (indx = 0; indx < numChans; indx++)
5803 {
5804 if (channelNum == validChan[indx])
5805 {
5806 break;
5807 }
5808 }
5809 if (indx >= numChans)
5810 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305811 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005812 __func__, channelNum);
5813 return -EINVAL;
5814 }
5815 /* Set the Operational Channel */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305816 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005817 channelNum);
5818 pRoamProfile->ChannelInfo.numOfChannels = 1;
5819 pHddStaCtx->conn_info.operationChannel = channelNum;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305820 pRoamProfile->ChannelInfo.ChannelList =
Jeff Johnson295189b2012-06-20 16:38:30 -07005821 &pHddStaCtx->conn_info.operationChannel;
5822 }
5823 else
5824 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305825 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07005826 __func__, channelNum);
5827 return -EINVAL;
5828 }
5829 }
5830
5831 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305832 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -07005833 if (status < 0)
5834 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305835 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -07005836 __func__);
5837 return status;
5838 }
5839
5840 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305841 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Jeff Johnson32d95a32012-09-10 13:15:23 -07005842 params->ssid_len, params->bssid, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005843
5844 if (0 > status)
5845 {
5846 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
5847 return status;
5848 }
5849
5850 return 0;
5851}
5852
5853/*
5854 * FUNCTION: wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305855 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07005856 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305857static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005858 struct net_device *dev
5859 )
5860{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305861 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07005862 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5863 tCsrRoamProfile *pRoamProfile;
5864
5865 ENTER();
5866
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005867 if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress )
5868 {
5869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5870 "%s:LOGP in Progress. Ignore!!!", __func__);
5871 return -EAGAIN;
5872 }
5873
Jeff Johnson295189b2012-06-20 16:38:30 -07005874 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
5875 if (NULL == pWextState)
5876 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305877 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005878 __func__);
5879 return -EIO;
5880 }
5881
5882 pRoamProfile = &pWextState->roamProfile;
5883
5884 /* Issue disconnect only if interface type is set to IBSS */
5885 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
5886 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305887 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -07005888 __func__);
5889 return -EINVAL;
5890 }
5891
5892 /* Issue Disconnect request */
5893 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5894 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
5895 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
5896
5897 return 0;
5898}
5899
5900/*
5901 * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params
5902 * This function is used to set the phy parameters
5903 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
5904 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305905static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005906 u32 changed)
5907{
5908 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5909 tHalHandle hHal = pHddCtx->hHal;
5910
5911 ENTER();
5912
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005913 if ( pHddCtx->isLogpInProgress )
5914 {
5915 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5916 "%s:LOGP in Progress. Ignore!!!", __func__);
5917 return -EAGAIN;
5918 }
5919
Jeff Johnson295189b2012-06-20 16:38:30 -07005920 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
5921 {
5922 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
5923 WNI_CFG_RTS_THRESHOLD_STAMAX :
5924 wiphy->rts_threshold;
5925
5926 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305927 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -07005928 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305929 hddLog(VOS_TRACE_LEVEL_ERROR,
5930 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07005931 __func__, rts_threshold);
5932 return -EINVAL;
5933 }
5934
5935 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
5936 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305937 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005938 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305939 hddLog(VOS_TRACE_LEVEL_ERROR,
5940 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07005941 __func__, rts_threshold);
5942 return -EIO;
5943 }
5944
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305945 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005946 rts_threshold);
5947 }
5948
5949 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
5950 {
5951 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
5952 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
5953 wiphy->frag_threshold;
5954
5955 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305956 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005957 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305958 hddLog(VOS_TRACE_LEVEL_ERROR,
5959 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005960 frag_threshold);
5961 return -EINVAL;
5962 }
5963
5964 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
5965 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305966 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005967 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305968 hddLog(VOS_TRACE_LEVEL_ERROR,
5969 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07005970 __func__, frag_threshold);
5971 return -EIO;
5972 }
5973
5974 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
5975 frag_threshold);
5976 }
5977
5978 if ((changed & WIPHY_PARAM_RETRY_SHORT)
5979 || (changed & WIPHY_PARAM_RETRY_LONG))
5980 {
5981 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
5982 wiphy->retry_short :
5983 wiphy->retry_long;
5984
5985 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
5986 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
5987 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305988 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07005989 __func__, retry_value);
5990 return -EINVAL;
5991 }
5992
5993 if (changed & WIPHY_PARAM_RETRY_SHORT)
5994 {
5995 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
5996 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305997 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005998 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305999 hddLog(VOS_TRACE_LEVEL_ERROR,
6000 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006001 __func__, retry_value);
6002 return -EIO;
6003 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306004 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006005 __func__, retry_value);
6006 }
6007 else if (changed & WIPHY_PARAM_RETRY_SHORT)
6008 {
6009 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
6010 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306011 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006012 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306013 hddLog(VOS_TRACE_LEVEL_ERROR,
6014 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006015 __func__, retry_value);
6016 return -EIO;
6017 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306018 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006019 __func__, retry_value);
6020 }
6021 }
6022
6023 return 0;
6024}
6025
6026/*
6027 * FUNCTION: wlan_hdd_cfg80211_set_txpower
6028 * This function is used to set the txpower
6029 */
6030static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
6031#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306032 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006033#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306034 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006035#endif
6036 int dbm)
6037{
6038 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
6039 tHalHandle hHal = pHddCtx->hHal;
6040 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6041 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6042
6043 ENTER();
6044
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306045 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6046 dbm, ccmCfgSetCallback,
6047 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006048 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306049 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006050 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
6051 return -EIO;
6052 }
6053
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006054 if ( pHddCtx->isLogpInProgress )
6055 {
6056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6057 "%s:LOGP in Progress. Ignore!!!", __func__);
6058 return -EAGAIN;
6059 }
6060
Jeff Johnson295189b2012-06-20 16:38:30 -07006061 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
6062 dbm);
6063
6064 switch(type)
6065 {
6066 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
6067 /* Fall through */
6068 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
6069 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
6070 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306071 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
6072 __func__);
6073 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07006074 }
6075 break;
6076 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306077 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07006078 __func__);
6079 return -EOPNOTSUPP;
6080 break;
6081 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306082 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
6083 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006084 return -EIO;
6085 }
6086
6087 return 0;
6088}
6089
6090/*
6091 * FUNCTION: wlan_hdd_cfg80211_get_txpower
6092 * This function is used to read the txpower
6093 */
6094static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy, int *dbm)
6095{
6096
6097 hdd_adapter_t *pAdapter;
6098 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
6099
Jeff Johnsone7245742012-09-05 17:12:55 -07006100 ENTER();
6101
Jeff Johnson295189b2012-06-20 16:38:30 -07006102 if (NULL == pHddCtx)
6103 {
6104 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD context is Null",__func__);
6105 *dbm = 0;
6106 return -ENOENT;
6107 }
6108
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006109 if ( pHddCtx->isLogpInProgress )
6110 {
6111 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6112 "%s:LOGP in Progress. Ignore!!!", __func__);
6113 return -EAGAIN;
6114 }
6115
Jeff Johnson295189b2012-06-20 16:38:30 -07006116 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
6117 if (NULL == pAdapter)
6118 {
6119 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
6120 return -ENOENT;
6121 }
6122
6123 wlan_hdd_get_classAstats(pAdapter);
6124 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
6125
Jeff Johnsone7245742012-09-05 17:12:55 -07006126 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006127 return 0;
6128}
6129
6130static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
6131 u8* mac, struct station_info *sinfo)
6132{
6133 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6134 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6135 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
6136 tANI_U8 rate_flags;
6137
6138 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
6139 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07006140
6141 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
6142 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
6143 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
6144 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
6145 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
6146 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
6147 tANI_U16 maxRate = 0;
6148 tANI_U16 myRate;
6149 tANI_U16 currentRate = 0;
6150 tANI_U8 maxSpeedMCS = 0;
6151 tANI_U8 maxMCSIdx = 0;
6152 tANI_U8 rateFlag = 1;
6153 tANI_U8 i, j, rssidx;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07006154 tANI_U16 temp;
Jeff Johnson295189b2012-06-20 16:38:30 -07006155
Leo Chang6f8870f2013-03-26 18:11:36 -07006156#ifdef WLAN_FEATURE_11AC
6157 tANI_U32 vht_mcs_map;
6158 eDataRate11ACMaxMcs vhtMaxMcs;
6159#endif /* WLAN_FEATURE_11AC */
6160
Jeff Johnsone7245742012-09-05 17:12:55 -07006161 ENTER();
6162
Jeff Johnson295189b2012-06-20 16:38:30 -07006163 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
6164 (0 == ssidlen))
6165 {
6166 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
6167 " Invalid ssidlen, %d", __func__, ssidlen);
6168 /*To keep GUI happy*/
6169 return 0;
6170 }
6171
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006172 if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress )
6173 {
6174 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6175 "%s:LOGP in Progress. Ignore!!!", __func__);
6176 return -EAGAIN;
6177 }
6178
Jeff Johnson295189b2012-06-20 16:38:30 -07006179 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
6180 sinfo->filled |= STATION_INFO_SIGNAL;
6181
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07006182 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006183 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
6184
6185 //convert to the UI units of 100kbps
6186 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
6187
6188#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -07006189 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 -07006190 sinfo->signal,
6191 pCfg->reportMaxLinkSpeed,
6192 myRate,
6193 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006194 (int) pCfg->linkSpeedRssiMid,
6195 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -07006196 (int) rate_flags,
6197 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07006198#endif //LINKSPEED_DEBUG_ENABLED
6199
6200 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
6201 {
6202 // we do not want to necessarily report the current speed
6203 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
6204 {
6205 // report the max possible speed
6206 rssidx = 0;
6207 }
6208 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
6209 {
6210 // report the max possible speed with RSSI scaling
6211 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
6212 {
6213 // report the max possible speed
6214 rssidx = 0;
6215 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006216 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006217 {
6218 // report middle speed
6219 rssidx = 1;
6220 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006221 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
6222 {
6223 // report middle speed
6224 rssidx = 2;
6225 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006226 else
6227 {
6228 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006229 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07006230 }
6231 }
6232 else
6233 {
6234 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
6235 hddLog(VOS_TRACE_LEVEL_ERROR,
6236 "%s: Invalid value for reportMaxLinkSpeed: %u",
6237 __func__, pCfg->reportMaxLinkSpeed);
6238 rssidx = 0;
6239 }
6240
6241 maxRate = 0;
6242
6243 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306244 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
6245 OperationalRates, &ORLeng))
6246 {
6247 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6248 /*To keep GUI happy*/
6249 return 0;
6250 }
6251
Jeff Johnson295189b2012-06-20 16:38:30 -07006252 for (i = 0; i < ORLeng; i++)
6253 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006254 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006255 {
6256 /* Validate Rate Set */
6257 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
6258 {
6259 currentRate = supported_data_rate[j].supported_rate[rssidx];
6260 break;
6261 }
6262 }
6263 /* Update MAX rate */
6264 maxRate = (currentRate > maxRate)?currentRate:maxRate;
6265 }
6266
6267 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306268 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
6269 ExtendedRates, &ERLeng))
6270 {
6271 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6272 /*To keep GUI happy*/
6273 return 0;
6274 }
6275
Jeff Johnson295189b2012-06-20 16:38:30 -07006276 for (i = 0; i < ERLeng; i++)
6277 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006278 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006279 {
6280 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
6281 {
6282 currentRate = supported_data_rate[j].supported_rate[rssidx];
6283 break;
6284 }
6285 }
6286 /* Update MAX rate */
6287 maxRate = (currentRate > maxRate)?currentRate:maxRate;
6288 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006289 /* Get MCS Rate Set -- but only if we are connected at MCS
6290 rates or if we are always reporting max speed or if we have
6291 good rssi */
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006292 if ((0 == rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -07006293 {
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306294 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
6295 MCSRates, &MCSLeng))
6296 {
6297 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6298 /*To keep GUI happy*/
6299 return 0;
6300 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006301 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -07006302#ifdef WLAN_FEATURE_11AC
6303 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306304 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -07006305 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006306 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306307 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -07006308 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -07006309 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006310 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006311 }
Leo Chang6f8870f2013-03-26 18:11:36 -07006312 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -07006313 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006314 maxMCSIdx = 7;
6315 }
6316 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
6317 {
6318 maxMCSIdx = 8;
6319 }
6320 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
6321 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306322 //VHT20 is supporting 0~8
6323 if (rate_flags & eHAL_TX_RATE_VHT20)
6324 maxMCSIdx = 8;
6325 else
6326 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -07006327 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306328
6329 if (rate_flags & eHAL_TX_RATE_VHT80)
6330 {
6331 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
6332 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
6333 }
6334 else if (rate_flags & eHAL_TX_RATE_VHT40)
6335 {
6336 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
6337 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
6338 }
6339 else if (rate_flags & eHAL_TX_RATE_VHT20)
6340 {
6341 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
6342 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
6343 }
6344
Leo Chang6f8870f2013-03-26 18:11:36 -07006345 maxSpeedMCS = 1;
6346 if (currentRate > maxRate)
6347 {
6348 maxRate = currentRate;
6349 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306350
Leo Chang6f8870f2013-03-26 18:11:36 -07006351 }
6352 else
6353#endif /* WLAN_FEATURE_11AC */
6354 {
6355 if (rate_flags & eHAL_TX_RATE_HT40)
6356 {
6357 rateFlag |= 1;
6358 }
6359 if (rate_flags & eHAL_TX_RATE_SGI)
6360 {
6361 rateFlag |= 2;
6362 }
6363
6364 for (i = 0; i < MCSLeng; i++)
6365 {
6366 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
6367 for (j = 0; j < temp; j++)
6368 {
6369 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
6370 {
6371 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
6372 break;
6373 }
6374 }
6375 if ((j < temp) && (currentRate > maxRate))
6376 {
6377 maxRate = currentRate;
6378 maxSpeedMCS = 1;
6379 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
6380 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006381 }
6382 }
6383 }
6384
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306385 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
6386 {
6387 maxRate = myRate;
6388 maxSpeedMCS = 1;
6389 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
6390 }
6391
Jeff Johnson295189b2012-06-20 16:38:30 -07006392 // make sure we report a value at least as big as our current rate
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006393 if (((maxRate < myRate) && (0 == rssidx)) ||
6394 (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -07006395 {
6396 maxRate = myRate;
6397 if (rate_flags & eHAL_TX_RATE_LEGACY)
6398 {
6399 maxSpeedMCS = 0;
6400 }
6401 else
6402 {
6403 maxSpeedMCS = 1;
6404 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
6405 }
6406 }
6407
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306408 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -07006409 {
6410 sinfo->txrate.legacy = maxRate;
6411#ifdef LINKSPEED_DEBUG_ENABLED
6412 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
6413#endif //LINKSPEED_DEBUG_ENABLED
6414 }
6415 else
6416 {
6417 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -07006418#ifdef WLAN_FEATURE_11AC
6419 sinfo->txrate.nss = 1;
6420 if (rate_flags & eHAL_TX_RATE_VHT80)
6421 {
6422 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306423 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -07006424 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306425 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -07006426 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306427 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
6428 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
6429 }
6430 else if (rate_flags & eHAL_TX_RATE_VHT20)
6431 {
6432 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
6433 }
6434#endif /* WLAN_FEATURE_11AC */
6435 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
6436 {
6437 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
6438 if (rate_flags & eHAL_TX_RATE_HT40)
6439 {
6440 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
6441 }
Leo Chang6f8870f2013-03-26 18:11:36 -07006442 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006443 if (rate_flags & eHAL_TX_RATE_SGI)
6444 {
6445 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
6446 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306447
Jeff Johnson295189b2012-06-20 16:38:30 -07006448#ifdef LINKSPEED_DEBUG_ENABLED
6449 pr_info("Reporting MCS rate %d flags %x\n",
6450 sinfo->txrate.mcs,
6451 sinfo->txrate.flags );
6452#endif //LINKSPEED_DEBUG_ENABLED
6453 }
6454 }
6455 else
6456 {
6457 // report current rate instead of max rate
6458
6459 if (rate_flags & eHAL_TX_RATE_LEGACY)
6460 {
6461 //provide to the UI in units of 100kbps
6462 sinfo->txrate.legacy = myRate;
6463#ifdef LINKSPEED_DEBUG_ENABLED
6464 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
6465#endif //LINKSPEED_DEBUG_ENABLED
6466 }
6467 else
6468 {
6469 //must be MCS
6470 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -07006471#ifdef WLAN_FEATURE_11AC
6472 sinfo->txrate.nss = 1;
6473 if (rate_flags & eHAL_TX_RATE_VHT80)
6474 {
6475 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
6476 }
6477 else
6478#endif /* WLAN_FEATURE_11AC */
6479 {
6480 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
6481 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006482 if (rate_flags & eHAL_TX_RATE_SGI)
6483 {
6484 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
6485 }
6486 if (rate_flags & eHAL_TX_RATE_HT40)
6487 {
6488 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
6489 }
Leo Chang6f8870f2013-03-26 18:11:36 -07006490#ifdef WLAN_FEATURE_11AC
6491 else if (rate_flags & eHAL_TX_RATE_VHT80)
6492 {
6493 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
6494 }
6495#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -07006496#ifdef LINKSPEED_DEBUG_ENABLED
6497 pr_info("Reporting actual MCS rate %d flags %x\n",
6498 sinfo->txrate.mcs,
6499 sinfo->txrate.flags );
6500#endif //LINKSPEED_DEBUG_ENABLED
6501 }
6502 }
6503 sinfo->filled |= STATION_INFO_TX_BITRATE;
6504
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07006505 sinfo->tx_packets =
6506 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
6507 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
6508 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
6509 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
6510
6511 sinfo->tx_retries =
6512 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
6513 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
6514 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
6515 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
6516
6517 sinfo->tx_failed =
6518 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
6519 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
6520 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
6521 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
6522
6523 sinfo->filled |=
6524 STATION_INFO_TX_PACKETS |
6525 STATION_INFO_TX_RETRIES |
6526 STATION_INFO_TX_FAILED;
6527
6528 EXIT();
6529 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006530}
6531
6532static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
6533 struct net_device *dev, bool mode, v_SINT_t timeout)
6534{
6535 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05306536 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006537 VOS_STATUS vos_status;
6538
Jeff Johnsone7245742012-09-05 17:12:55 -07006539 ENTER();
6540
Jeff Johnson295189b2012-06-20 16:38:30 -07006541 if (NULL == pAdapter)
6542 {
6543 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
6544 return -ENODEV;
6545 }
6546
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05306547 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6548 if (NULL == pHddCtx)
6549 {
6550 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HDD context is NULL\n", __func__);
6551 return -ENODEV;
6552 }
6553
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306554 if ( pHddCtx->isLogpInProgress )
6555 {
6556 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6557 "%s:LOGP in Progress. Ignore!!!", __func__);
6558 return -EAGAIN;
6559 }
6560
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05306561 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
6562 (TRUE == pHddCtx->hdd_wlan_suspended) &&
6563 (pHddCtx->cfg_ini->fhostArpOffload) &&
6564 (eConnectionState_Associated ==
6565 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
6566 {
6567 vos_status = hdd_conf_hostarpoffload(pAdapter, TRUE);
6568 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6569 {
6570 hddLog(VOS_TRACE_LEVEL_INFO,
6571 "%s:Failed to enable ARPOFFLOAD Feature %d\n",
6572 __func__, vos_status);
6573 }
6574 }
6575
Jeff Johnson295189b2012-06-20 16:38:30 -07006576 /**The get power cmd from the supplicant gets updated by the nl only
6577 *on successful execution of the function call
6578 *we are oppositely mapped w.r.t mode in the driver
6579 **/
6580 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
6581
Jeff Johnsone7245742012-09-05 17:12:55 -07006582 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006583 if (VOS_STATUS_E_FAILURE == vos_status)
6584 {
6585 return -EINVAL;
6586 }
6587 return 0;
6588}
6589
6590
6591#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
6592static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
6593 struct net_device *netdev,
6594 u8 key_index)
6595{
Jeff Johnsone7245742012-09-05 17:12:55 -07006596 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006597 return 0;
6598}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306599#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -07006600
6601#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
6602static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
6603 struct net_device *dev,
6604 struct ieee80211_txq_params *params)
6605{
Jeff Johnsone7245742012-09-05 17:12:55 -07006606 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006607 return 0;
6608}
6609#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
6610static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
6611 struct ieee80211_txq_params *params)
6612{
Jeff Johnsone7245742012-09-05 17:12:55 -07006613 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006614 return 0;
6615}
6616#endif //LINUX_VERSION_CODE
6617
6618static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
6619 struct net_device *dev, u8 *mac)
6620{
6621 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08006622 VOS_STATUS vos_status;
6623 v_U8_t staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006624
Jeff Johnsone7245742012-09-05 17:12:55 -07006625 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006626 if ( NULL == pAdapter || NULL == pAdapter->pHddCtx)
6627 {
6628 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid Adapter or HDD Context " ,__func__);
6629 return -EINVAL;
6630 }
6631
6632 if (((hdd_context_t*)pAdapter->pHddCtx)->isLoadUnloadInProgress)
6633 {
6634 hddLog( LOGE,
6635 "%s: Wlan Load/Unload is in progress", __func__);
6636 return -EBUSY;
6637 }
6638
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006639 if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress )
6640 {
6641 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6642 "%s:LOGP in Progress. Ignore!!!", __func__);
6643 return -EAGAIN;
6644 }
6645
Jeff Johnson295189b2012-06-20 16:38:30 -07006646 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07006647 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07006648 )
6649 {
6650 if( NULL == mac )
6651 {
6652 v_U16_t i;
6653 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
6654 {
6655 if(pAdapter->aStaInfo[i].isUsed)
6656 {
6657 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
6658 hddLog(VOS_TRACE_LEVEL_INFO,
6659 "%s: Delete STA with MAC::"
6660 "%02x:%02x:%02x:%02x:%02x:%02x",
6661 __func__,
6662 macAddr[0], macAddr[1], macAddr[2],
6663 macAddr[3], macAddr[4], macAddr[5]);
6664 hdd_softap_sta_deauth(pAdapter, macAddr);
6665 }
6666 }
6667 }
6668 else
6669 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08006670
6671 vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId);
6672 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6673 {
6674 hddLog(VOS_TRACE_LEVEL_INFO,
6675 "%s: Skip this DEL STA as this is not used::"
6676 "%02x:%02x:%02x:%02x:%02x:%02x",
6677 __func__,
6678 mac[0], mac[1], mac[2],
6679 mac[3], mac[4], mac[5]);
6680 return -ENOENT;
6681 }
6682
6683 if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE)
6684 {
6685 hddLog(VOS_TRACE_LEVEL_INFO,
6686 "%s: Skip this DEL STA as deauth is in progress::"
6687 "%02x:%02x:%02x:%02x:%02x:%02x",
6688 __func__,
6689 mac[0], mac[1], mac[2],
6690 mac[3], mac[4], mac[5]);
6691 return -ENOENT;
6692 }
6693
6694 pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE;
6695
Jeff Johnson295189b2012-06-20 16:38:30 -07006696 hddLog(VOS_TRACE_LEVEL_INFO,
6697 "%s: Delete STA with MAC::"
6698 "%02x:%02x:%02x:%02x:%02x:%02x",
6699 __func__,
6700 mac[0], mac[1], mac[2],
6701 mac[3], mac[4], mac[5]);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08006702
6703 vos_status = hdd_softap_sta_deauth(pAdapter, mac);
6704 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6705 {
6706 pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE;
6707 hddLog(VOS_TRACE_LEVEL_INFO,
6708 "%s: STA removal failed for ::"
6709 "%02x:%02x:%02x:%02x:%02x:%02x",
6710 __func__,
6711 mac[0], mac[1], mac[2],
6712 mac[3], mac[4], mac[5]);
6713 return -ENOENT;
6714 }
6715
Jeff Johnson295189b2012-06-20 16:38:30 -07006716 }
6717 }
6718
6719 EXIT();
6720
6721 return 0;
6722}
6723
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006724static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
6725 struct net_device *dev, u8 *mac, struct station_parameters *params)
6726{
Gopichand Nakkalab977a972013-02-18 19:15:09 -08006727 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006728#ifdef FEATURE_WLAN_TDLS
6729 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006730 ENTER();
Mohit Khanna698ba2a2012-12-04 15:08:18 -08006731 mask = params->sta_flags_mask;
6732
6733 set = params->sta_flags_set;
6734
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006735#ifdef WLAN_FEATURE_TDLS_DEBUG
6736 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6737 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
6738 __func__, mask, set, MAC_ADDR_ARRAY(mac));
6739#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08006740
6741 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
6742 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006743 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08006744 }
6745 }
6746#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -08006747 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006748}
6749
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006750
6751#ifdef FEATURE_WLAN_LFR
6752static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07006753 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006754{
6755#define MAX_PMKSAIDS_IN_CACHE 8
6756 static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD Local cache
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306757 static tANI_U32 i; // HDD Local Cache index
6758 tANI_U32 j=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006759 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6760 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306761 eHalStatus result;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006762 tANI_U8 BSSIDMatched = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306763
Jeff Johnsone7245742012-09-05 17:12:55 -07006764 ENTER();
6765
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306766 // Validate pAdapter
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006767 if ( NULL == pAdapter || NULL == pAdapter->pHddCtx)
6768 {
6769 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid Adapter or HDD Context " ,__func__);
6770 return -EINVAL;
6771 }
6772
6773 if (((hdd_context_t*)pAdapter->pHddCtx)->isLoadUnloadInProgress)
6774 {
6775 hddLog( LOGE,
6776 "%s: Wlan Load/Unload is in progress", __func__);
6777 return -EBUSY;
6778 }
6779
6780 if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress )
6781 {
6782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6783 "%s:LOGP in Progress. Ignore!!!", __func__);
6784 return -EAGAIN;
6785 }
6786
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306787 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006788 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
6789
6790 for (j = 0; j < i; j++)
6791 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306792 if(vos_mem_compare(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006793 pmksa->bssid, WNI_CFG_BSSID_LEN))
6794 {
6795 /* BSSID matched previous entry. Overwrite it. */
6796 BSSIDMatched = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306797 vos_mem_copy(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006798 pmksa->bssid, WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306799 vos_mem_copy(PMKIDCache[j].PMKID,
6800 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006801 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306802 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006803 __func__, j );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006804 dump_bssid(pmksa->bssid);
6805 dump_pmkid(halHandle, pmksa->pmkid);
6806 break;
6807 }
6808 }
6809
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07006810 /* Check we compared all entries,if then take the first slot now */
6811 if(j == MAX_PMKSAIDS_IN_CACHE) i=0;
6812
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006813 if (!BSSIDMatched)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306814 {
6815 // Now, we DON'T have a BSSID match, so take a new entry in the cache.
6816 vos_mem_copy(PMKIDCache[i].BSSID,
6817 pmksa->bssid, ETHER_ADDR_LEN);
6818 vos_mem_copy(PMKIDCache[i].PMKID,
6819 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006820 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306821 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Adding a new cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006822 __func__, i );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006823 dump_bssid(pmksa->bssid);
6824 dump_pmkid(halHandle, pmksa->pmkid);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306825 // Increment the HDD Local Cache index
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006826 // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306827 if (i<=(MAX_PMKSAIDS_IN_CACHE-1)) i++; else i=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006828 }
6829
6830
6831 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306832 //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006833 // __func__, i );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306834 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006835 __func__, i );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006836 // Finally set the PMKSA ID Cache in CSR
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306837 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
6838 PMKIDCache,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006839 i );
6840 return 0;
6841}
6842
6843
6844static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07006845 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006846{
Jeff Johnsone7245742012-09-05 17:12:55 -07006847 ENTER();
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006848 // TODO: Implement this later.
6849 return 0;
6850}
6851
6852static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
6853{
Jeff Johnsone7245742012-09-05 17:12:55 -07006854 ENTER();
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006855 // TODO: Implement this later.
6856 return 0;
6857}
6858#endif
6859
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07006860#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306861static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07006862 struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie)
6863{
6864 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6865 hdd_station_ctx_t *pHddStaCtx;
6866
6867 if (NULL == pAdapter)
6868 {
6869 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
6870 return -ENODEV;
6871 }
6872
6873 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6874
6875 // Added for debug on reception of Re-assoc Req.
6876 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6877 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306878 hddLog(LOGE, FL("Called with Ie of length = %d when not associated\n"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07006879 ftie->ie_len);
6880 hddLog(LOGE, FL("Should be Re-assoc Req IEs\n"));
6881 }
6882
6883#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306884 hddLog(LOGE, FL("%s called with Ie of length = %d\n"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07006885 ftie->ie_len);
6886#endif
6887
6888 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +05306889 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
6890 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07006891 ftie->ie_len);
6892 return 0;
6893}
6894#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006895
Mohit Khanna698ba2a2012-12-04 15:08:18 -08006896#ifdef FEATURE_WLAN_TDLS
6897static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
6898 u8 *peer, u8 action_code, u8 dialog_token,
6899 u16 status_code, const u8 *buf, size_t len)
6900{
6901
6902 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6903 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08006904 u8 peerMac[6];
6905 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -07006906 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -08006907 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -07006908 long rc;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08006909
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006910 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08006911 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306912 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08006913 "Invalid arguments");
6914 return -EINVAL;
6915 }
6916
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006917 if (pHddCtx->isLogpInProgress)
6918 {
6919 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6920 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07006921 wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006922 return -EBUSY;
6923 }
6924
Hoonki Lee27511902013-03-14 18:19:06 -07006925 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08006926 {
Hoonki Lee27511902013-03-14 18:19:06 -07006927 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
6928 "%s: TDLS mode is disabled OR not enabled in FW."
6929 MAC_ADDRESS_STR " action %d declined.",
6930 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08006931 return -ENOTSUPP;
6932 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08006933
Hoonki Lee27511902013-03-14 18:19:06 -07006934 /* other than teardown frame, other mgmt frames are not sent if disabled */
6935 if (SIR_MAC_TDLS_TEARDOWN != action_code)
6936 {
6937 /* if tdls_mode is disabled to respond to peer's request */
6938 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
6939 {
6940 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
6941 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07006942 " TDLS mode is disabled. action %d declined.",
6943 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -07006944
6945 return -ENOTSUPP;
6946 }
6947 }
6948
Gopichand Nakkalab977a972013-02-18 19:15:09 -08006949 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
6950 {
Hoonki Leefb8df672013-04-10 18:20:34 -07006951 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08006952 {
6953 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006954 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07006955 " TDLS setup is ongoing. action %d declined.",
6956 __func__, MAC_ADDR_ARRAY(peer), action_code);
6957 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08006958 }
6959 }
6960
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006961 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
6962 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -08006963 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006964 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
Lee Hoonkic1262f22013-01-24 21:59:00 -08006965 {
6966 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
6967 we return error code at 'add_station()'. Hence we have this
6968 check again in addtion to add_station().
6969 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006970 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -08006971 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006972 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6973 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07006974 " TDLS Max peer already connected. action %d declined.",
6975 __func__, MAC_ADDR_ARRAY(peer), action_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07006976 goto error;
Lee Hoonkic1262f22013-01-24 21:59:00 -08006977 }
6978 else
6979 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08006980 /* maximum reached. tweak to send error code to peer and return
6981 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -08006982 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006983 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6984 "%s: " MAC_ADDRESS_STR
6985 " TDLS Max peer already connected send response status %d",
6986 __func__, MAC_ADDR_ARRAY(peer), status_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07006987 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08006988 /* fall through to send setup resp with failure status
6989 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -08006990 }
6991 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006992 else
6993 {
6994 hddTdlsPeer_t *pTdlsPeer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006995 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07006996 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006997 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006998 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07006999 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
7000 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007001 return -EPERM;
7002 }
7003 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08007004 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007005 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007006
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007007#ifdef WLAN_FEATURE_TDLS_DEBUG
7008 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007009 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d",
7010 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
7011 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007012#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007013
Hoonki Leea34dd892013-02-05 22:56:02 -08007014 /*Except teardown responder will not be used so just make 0*/
7015 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007016 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -08007017 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07007018
7019 hddTdlsPeer_t *pTdlsPeer;
7020 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac);
7021
7022 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
7023 responder = pTdlsPeer->is_responder;
7024 else
Hoonki Leea34dd892013-02-05 22:56:02 -08007025 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07007026 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7027 "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d",
7028 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
7029 dialog_token, status_code, len);
7030 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -08007031 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007032 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007033
Hoonki Lee14621352013-04-16 17:51:19 -07007034 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
7035 (SIR_MAC_TDLS_DIS_RSP == action_code))
7036 {
7037 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7038 {
7039 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7040 "%s: Sending Disc/Setup Rsp Frame.Disable BMPS", __func__);
7041 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
7042 }
7043 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
7044 }
7045
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007046 /* make sure doesn't call send_mgmt() while it is pending */
7047 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
7048 {
7049 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7050 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY\n",
7051 __func__, MAC_ADDR_ARRAY(peer), action_code);
7052 return -EBUSY;
7053 }
7054
7055 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007056 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
7057
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007058 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Hoonki Leea34dd892013-02-05 22:56:02 -08007059 peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007060
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007061 if (VOS_STATUS_SUCCESS != status)
7062 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007063 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7064 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007065 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -07007066 wlan_hdd_tdls_check_bmps(pAdapter);
7067 goto error;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007068 }
7069
Hoonki Leed37cbb32013-04-20 00:31:14 -07007070 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
7071 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
7072
7073 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007074 {
Hoonki Leed37cbb32013-04-20 00:31:14 -07007075 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7076 "%s: Mgmt Tx Completion failed status %ld TxCompletion %lu",
7077 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007078 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Leed37cbb32013-04-20 00:31:14 -07007079 wlan_hdd_tdls_check_bmps(pAdapter);
7080 goto error;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007081 }
7082
Gopichand Nakkala05922802013-03-14 12:23:19 -07007083 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -07007084 {
7085 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007086 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -07007087 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007088
Hoonki Leea34dd892013-02-05 22:56:02 -08007089 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
7090 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007091 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -08007092 }
7093 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
7094 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007095 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -08007096 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007097
7098 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07007099error:
7100 /* max_sta_failed ; we didn't set to CONNECTING for this case,
7101 because we already know that this transaction will be failed,
7102 but we weren't sure if supplicant call DISABLE_LINK or not. So,
7103 to be safe, do not change the state mahine.
7104 */
7105 if(max_sta_failed == 0 &&
7106 (WLAN_IS_TDLS_SETUP_ACTION(action_code)))
7107 wlan_hdd_tdls_set_link_status(pAdapter, peerMac, eTDLS_LINK_IDLE);
7108 return -EPERM;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007109}
7110
7111static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
7112 u8 *peer, enum nl80211_tdls_operation oper)
7113{
7114 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7115 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05307116#ifdef FEATURE_WLAN_TDLS_OXYGEN_DISAPPEAR_AP
7117 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7118 int status = 0;
7119 tANI_U8 staIdx;
7120#endif
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007121#ifdef WLAN_FEATURE_TDLS_DEBUG
7122 const char *tdls_oper_str[]= {
7123 "NL80211_TDLS_DISCOVERY_REQ",
7124 "NL80211_TDLS_SETUP",
7125 "NL80211_TDLS_TEARDOWN",
7126 "NL80211_TDLS_ENABLE_LINK",
7127 "NL80211_TDLS_DISABLE_LINK",
7128 "NL80211_TDLS_UNKONW_OPER"};
7129#endif
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007130 hddTdlsPeer_t *pTdlsPeer;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007131
Chilam Ngc4244af2013-04-01 15:37:32 -07007132 if ( NULL == pHddCtx || NULL == pHddCtx->cfg_ini || NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007133 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007134 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07007135 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007136 return -EINVAL;
7137 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007138
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007139 if (pHddCtx->isLogpInProgress)
7140 {
7141 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7142 "%s:LOGP in Progress. Ignore!!!", __func__);
7143 return -EBUSY;
7144 }
7145
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007146 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer);
7147
7148 if ( NULL == pTdlsPeer ) {
7149 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR " (oper %d) not exsting. ignored",
7150 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
7151 return -EINVAL;
7152 }
7153
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007154#ifdef WLAN_FEATURE_TDLS_DEBUG
7155 if((int)oper > 4)
7156 oper = 5;
7157
7158 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007159 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
7160 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007161 tdls_oper_str[(int)oper]);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007162#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007163
7164 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007165 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007166 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007167 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07007168 "TDLS Disabled in INI OR not enabled in FW. "
7169 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007170 return -ENOTSUPP;
7171 }
7172
7173 switch (oper) {
7174 case NL80211_TDLS_ENABLE_LINK:
7175 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007176 VOS_STATUS status;
7177
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -07007178 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
7179 {
7180 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
7181 MAC_ADDRESS_STR " failed",
7182 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
7183 return -EINVAL;
7184 }
7185
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007186 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007187 {
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07007188 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007189 /* start TDLS client registration with TL */
7190 status = hdd_roamRegisterTDLSSTA( pAdapter, peer, pTdlsPeer->staId, pTdlsPeer->signature);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07007191 if (VOS_STATUS_SUCCESS == status)
7192 {
Hoonki Lee14621352013-04-16 17:51:19 -07007193 if (pTdlsPeer->is_responder == 0)
7194 {
7195 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
7196
7197 wlan_hdd_tdls_timer_restart(pAdapter,
7198 &pTdlsPeer->initiatorWaitTimeoutTimer,
7199 WAIT_TIME_TDLS_INITIATOR);
7200 /* suspend initiator TX until it receives direct packet from the
7201 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
7202 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
7203 &staId, NULL);
7204 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07007205 wlan_hdd_tdls_increment_peer_count(pAdapter);
7206 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007207 wlan_hdd_tdls_check_bmps(pAdapter);
7208 }
7209
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007210 }
7211 break;
7212 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -08007213 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007214 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -08007215 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007216 long status;
7217
7218 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
7219
Lee Hoonkic1262f22013-01-24 21:59:00 -08007220 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
7221 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007222
7223 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
7224 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
7225 if (status <= 0)
7226 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007227 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007228 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7229 "%s: Del station failed status %ld",
7230 __func__, status);
7231 return -EPERM;
7232 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007233 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Lee Hoonkic1262f22013-01-24 21:59:00 -08007234 }
7235 else
7236 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007237 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7238 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -08007239 }
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05307240#ifdef FEATURE_WLAN_TDLS_OXYGEN_DISAPPEAR_AP
7241 if (pHddTdlsCtx->defer_link_lost_indication)
7242 {
7243 if (( TRUE == pHddCtx->cfg_ini->fEnableTDLSOxygenSupport ) &&
7244 (wlan_hdd_tdlsConnectedPeers(pAdapter) == 0))
7245 {
7246 status = wlan_hdd_disconnect(pAdapter, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7247 if ( 0 != status)
7248 {
7249 hddLog(VOS_TRACE_LEVEL_ERROR,
7250 "%s wlan_hdd_disconnect failure, returned %d \n",
7251 __func__, (int)status );
7252 return -EINVAL;
7253 }
7254 }
7255 }
7256#endif
Lee Hoonkic1262f22013-01-24 21:59:00 -08007257 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007258 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007259 case NL80211_TDLS_TEARDOWN:
7260 case NL80211_TDLS_SETUP:
7261 case NL80211_TDLS_DISCOVERY_REQ:
7262 /* We don't support in-driver setup/teardown/discovery */
7263 return -ENOTSUPP;
7264 default:
7265 return -ENOTSUPP;
7266 }
7267 return 0;
7268}
Chilam NG571c65a2013-01-19 12:27:36 +05307269
7270int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
7271 struct net_device *dev, u8 *peer)
7272{
7273 hddLog(VOS_TRACE_LEVEL_INFO, "tdls send discover req: %x %x %x %x %x %x",
7274 peer[0], peer[1], peer[2], peer[3], peer[4], peer[5]);
7275
7276 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
7277 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
7278}
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007279#endif
7280
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307281#ifdef WLAN_FEATURE_GTK_OFFLOAD
7282/*
7283 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
7284 * Callback rountine called upon receiving response for
7285 * get offload info
7286 */
7287void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
7288 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
7289{
7290
7291 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
7292
7293 ENTER();
7294
7295 if (NULL == pAdapter)
7296 {
7297 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7298 "%s: HDD adapter is Null", __func__);
7299 return ;
7300 }
7301
7302 if (NULL == pGtkOffloadGetInfoRsp)
7303 {
7304 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7305 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
7306 return ;
7307 }
7308
7309 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
7310 {
7311 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7312 "%s: wlan Failed to get replay counter value",
7313 __func__);
7314 return ;
7315 }
7316
7317 /* Update replay counter to NL */
7318 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
7319 (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter, GFP_KERNEL);
7320}
7321
7322/*
7323 * FUNCTION: wlan_hdd_cfg80211_set_rekey_data
7324 * This function is used to offload GTK rekeying job to the firmware.
7325 */
7326int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
7327 struct cfg80211_gtk_rekey_data *data)
7328{
7329 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7330 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7331 hdd_station_ctx_t *pHddStaCtx;
7332 tHalHandle hHal;
7333 tpSirGtkOffloadParams pGtkOffloadReqParams;
7334 eHalStatus status = eHAL_STATUS_FAILURE;
7335
7336 ENTER();
7337
7338 if (NULL == pAdapter)
7339 {
7340 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7341 "%s: HDD adapter is Null", __func__);
7342 return -ENODEV;
7343 }
7344
7345 if (NULL == pHddCtx)
7346 {
7347 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7348 "%s: HDD context is Null!!!", __func__);
7349 return -ENODEV;
7350 }
7351
7352 if (pHddCtx->isLogpInProgress)
7353 {
7354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7355 "%s: LOGP in Progress. Ignore!!!", __func__);
7356 return -EAGAIN;
7357 }
7358
7359 if (pHddCtx->isLoadUnloadInProgress)
7360 {
7361 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7362 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
7363 return -EAGAIN;
7364 }
7365
7366 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7367 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7368 if (NULL == hHal)
7369 {
7370 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7371 "%s: HAL context is Null!!!", __func__);
7372 return -EAGAIN;
7373 }
7374
7375 pGtkOffloadReqParams =
7376 &pHddStaCtx->gtkOffloadRequestParams.gtkOffloadReqParams;
7377
7378 pGtkOffloadReqParams->ulFlags = GTK_OFFLOAD_ENABLE;
7379 memcpy(pGtkOffloadReqParams->aKCK, data->kck, NL80211_KCK_LEN);
7380 memcpy(pGtkOffloadReqParams->aKEK, data->kek, NL80211_KEK_LEN);
7381 memcpy(pGtkOffloadReqParams->bssId, &pHddStaCtx->conn_info.bssId,
7382 WNI_CFG_BSSID_LEN);
7383 memcpy(&pGtkOffloadReqParams->ullKeyReplayCounter, &data->replay_ctr,
7384 sizeof (tANI_U64));
7385
7386 if (TRUE == pHddCtx->hdd_wlan_suspended)
7387 {
7388 /* if wlan is suspended, enable GTK offload directly from here */
7389 status = sme_SetGTKOffload(hHal, pGtkOffloadReqParams,
7390 pAdapter->sessionId);
7391
7392 if (eHAL_STATUS_SUCCESS != status)
7393 {
7394 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7395 "%s: sme_SetGTKOffload failed, returned %d",
7396 __func__, status);
7397 return status;
7398 }
7399 pHddStaCtx->gtkOffloadRequestParams.requested = FALSE;
7400 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7401 "%s: sme_SetGTKOffload successfull", __func__);
7402 }
7403 else
7404 {
7405 pHddStaCtx->gtkOffloadRequestParams.requested = TRUE;
7406 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7407 "%s: wlan not suspended GTKOffload request is stored",
7408 __func__);
7409 return eHAL_STATUS_SUCCESS;
7410 }
7411 return status;
7412}
7413#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
7414
Jeff Johnson295189b2012-06-20 16:38:30 -07007415/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307416static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -07007417{
7418 .add_virtual_intf = wlan_hdd_add_virtual_intf,
7419 .del_virtual_intf = wlan_hdd_del_virtual_intf,
7420 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
7421 .change_station = wlan_hdd_change_station,
7422#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7423 .add_beacon = wlan_hdd_cfg80211_add_beacon,
7424 .del_beacon = wlan_hdd_cfg80211_del_beacon,
7425 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007426#else
7427 .start_ap = wlan_hdd_cfg80211_start_ap,
7428 .change_beacon = wlan_hdd_cfg80211_change_beacon,
7429 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -07007430#endif
7431 .change_bss = wlan_hdd_cfg80211_change_bss,
7432 .add_key = wlan_hdd_cfg80211_add_key,
7433 .get_key = wlan_hdd_cfg80211_get_key,
7434 .del_key = wlan_hdd_cfg80211_del_key,
7435 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08007436#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007437 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08007438#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007439 .scan = wlan_hdd_cfg80211_scan,
7440 .connect = wlan_hdd_cfg80211_connect,
7441 .disconnect = wlan_hdd_cfg80211_disconnect,
7442 .join_ibss = wlan_hdd_cfg80211_join_ibss,
7443 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
7444 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
7445 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
7446 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -07007447 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
7448 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
7449 .mgmt_tx = wlan_hdd_action,
7450#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7451 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
7452 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
7453 .set_txq_params = wlan_hdd_set_txq_params,
7454#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007455 .get_station = wlan_hdd_cfg80211_get_station,
7456 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
7457 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007458 .add_station = wlan_hdd_cfg80211_add_station,
7459#ifdef FEATURE_WLAN_LFR
7460 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
7461 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
7462 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
7463#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007464#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
7465 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
7466#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007467#ifdef FEATURE_WLAN_TDLS
7468 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
7469 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
7470#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307471#ifdef WLAN_FEATURE_GTK_OFFLOAD
7472 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
7473#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07007474};
7475