blob: fcff9ad80bfe547952f83be3629c8459b9ef176f [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2014 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 */
21
22/*
Kiet Lamaa8e15a2014-02-11 23:30:06 -080023 * Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
24 * All Rights Reserved.
25 * Qualcomm Atheros Confidential and Proprietary.
Kiet Lam842dad02014-02-18 18:44:02 -080026 *
Kiet Lamaa8e15a2014-02-11 23:30:06 -080027 */
Kiet Lam842dad02014-02-18 18:44:02 -080028
29
Jeff Johnson295189b2012-06-20 16:38:30 -070030/**========================================================================
31
32 \file wlan_hdd_cfg80211.c
33
34 \brief WLAN Host Device Driver implementation
35
Jeff Johnson295189b2012-06-20 16:38:30 -070036 ========================================================================*/
37
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070038/**=========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070039
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070040 EDIT HISTORY FOR FILE
Jeff Johnson295189b2012-06-20 16:38:30 -070041
42
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070043 This section contains comments describing changes made to the module.
44 Notice that changes are listed in reverse chronological order.
Jeff Johnson295189b2012-06-20 16:38:30 -070045
46
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070047 $Header:$ $DateTime: $ $Author: $
Jeff Johnson295189b2012-06-20 16:38:30 -070048
49
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070050 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070051 -------- --- --------------------------------------------------------
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070052 21/12/09 Ashwani Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070053
54 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070055 Ganesh K
Jeff Johnson295189b2012-06-20 16:38:30 -070056 ==========================================================================*/
57
Jeff Johnson295189b2012-06-20 16:38:30 -070058
59#include <linux/version.h>
60#include <linux/module.h>
61#include <linux/kernel.h>
62#include <linux/init.h>
63#include <linux/wireless.h>
64#include <wlan_hdd_includes.h>
65#include <net/arp.h>
66#include <net/cfg80211.h>
67#include <linux/wireless.h>
68#include <wlan_hdd_wowl.h>
69#include <aniGlobal.h>
70#include "ccmApi.h"
71#include "sirParams.h"
72#include "dot11f.h"
73#include "wlan_hdd_assoc.h"
74#include "wlan_hdd_wext.h"
75#include "sme_Api.h"
76#include "wlan_hdd_p2p.h"
77#include "wlan_hdd_cfg80211.h"
78#include "wlan_hdd_hostapd.h"
79#include "sapInternal.h"
80#include "wlan_hdd_softap_tx_rx.h"
81#include "wlan_hdd_main.h"
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053082#include "wlan_hdd_assoc.h"
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053083#include "wlan_hdd_power.h"
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053084#include "wlan_hdd_trace.h"
85#include "vos_types.h"
86#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070087#ifdef WLAN_BTAMP_FEATURE
88#include "bap_hdd_misc.h"
89#endif
90#include <qc_sap_ioctl.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080091#ifdef FEATURE_WLAN_TDLS
92#include "wlan_hdd_tdls.h"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053093#include "wlan_hdd_wmm.h"
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053094#include "wlan_qct_wda.h"
Mohit Khanna698ba2a2012-12-04 15:08:18 -080095#endif
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053096#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070097#include "wlan_hdd_dev_pwr.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070098
99#define g_mode_rates_size (12)
100#define a_mode_rates_size (8)
101#define FREQ_BASE_80211G (2407)
102#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700103#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +0530104#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -0700105#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
krunal soni2a6a9062014-02-11 14:14:23 -0800106 ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700107
108#define HDD2GHZCHAN(freq, chan, flag) { \
109 .band = IEEE80211_BAND_2GHZ, \
110 .center_freq = (freq), \
111 .hw_value = (chan),\
112 .flags = (flag), \
113 .max_antenna_gain = 0 ,\
114 .max_power = 30, \
115}
116
117#define HDD5GHZCHAN(freq, chan, flag) { \
118 .band = IEEE80211_BAND_5GHZ, \
119 .center_freq = (freq), \
120 .hw_value = (chan),\
121 .flags = (flag), \
122 .max_antenna_gain = 0 ,\
123 .max_power = 30, \
124}
125
126#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
127{\
128 .bitrate = rate, \
129 .hw_value = rate_id, \
130 .flags = flag, \
131}
132
Lee Hoonkic1262f22013-01-24 21:59:00 -0800133#ifndef WLAN_FEATURE_TDLS_DEBUG
134#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_INFO
135#else
136#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_ERROR
137#endif
138
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530139#ifdef WLAN_FEATURE_VOWIFI_11R
140#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
141#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
142#endif
143
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530144#define HDD_CHANNEL_14 14
145
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530146static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700147{
148 WLAN_CIPHER_SUITE_WEP40,
149 WLAN_CIPHER_SUITE_WEP104,
150 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800151#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700152#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
153 WLAN_CIPHER_SUITE_KRK,
154 WLAN_CIPHER_SUITE_CCMP,
155#else
156 WLAN_CIPHER_SUITE_CCMP,
157#endif
158#ifdef FEATURE_WLAN_WAPI
159 WLAN_CIPHER_SUITE_SMS4,
160#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700161#ifdef WLAN_FEATURE_11W
162 WLAN_CIPHER_SUITE_AES_CMAC,
163#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700164};
165
166static inline int is_broadcast_ether_addr(const u8 *addr)
167{
168 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
169 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
170}
171
172static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530173{
Jeff Johnson295189b2012-06-20 16:38:30 -0700174 HDD2GHZCHAN(2412, 1, 0) ,
175 HDD2GHZCHAN(2417, 2, 0) ,
176 HDD2GHZCHAN(2422, 3, 0) ,
177 HDD2GHZCHAN(2427, 4, 0) ,
178 HDD2GHZCHAN(2432, 5, 0) ,
179 HDD2GHZCHAN(2437, 6, 0) ,
180 HDD2GHZCHAN(2442, 7, 0) ,
181 HDD2GHZCHAN(2447, 8, 0) ,
182 HDD2GHZCHAN(2452, 9, 0) ,
183 HDD2GHZCHAN(2457, 10, 0) ,
184 HDD2GHZCHAN(2462, 11, 0) ,
185 HDD2GHZCHAN(2467, 12, 0) ,
186 HDD2GHZCHAN(2472, 13, 0) ,
187 HDD2GHZCHAN(2484, 14, 0) ,
188};
189
Jeff Johnson295189b2012-06-20 16:38:30 -0700190static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
191{
192 HDD2GHZCHAN(2412, 1, 0) ,
193 HDD2GHZCHAN(2437, 6, 0) ,
194 HDD2GHZCHAN(2462, 11, 0) ,
195};
Jeff Johnson295189b2012-06-20 16:38:30 -0700196
197static struct ieee80211_channel hdd_channels_5_GHZ[] =
198{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700199 HDD5GHZCHAN(4920, 240, 0) ,
200 HDD5GHZCHAN(4940, 244, 0) ,
201 HDD5GHZCHAN(4960, 248, 0) ,
202 HDD5GHZCHAN(4980, 252, 0) ,
203 HDD5GHZCHAN(5040, 208, 0) ,
204 HDD5GHZCHAN(5060, 212, 0) ,
205 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700206 HDD5GHZCHAN(5180, 36, 0) ,
207 HDD5GHZCHAN(5200, 40, 0) ,
208 HDD5GHZCHAN(5220, 44, 0) ,
209 HDD5GHZCHAN(5240, 48, 0) ,
210 HDD5GHZCHAN(5260, 52, 0) ,
211 HDD5GHZCHAN(5280, 56, 0) ,
212 HDD5GHZCHAN(5300, 60, 0) ,
213 HDD5GHZCHAN(5320, 64, 0) ,
214 HDD5GHZCHAN(5500,100, 0) ,
215 HDD5GHZCHAN(5520,104, 0) ,
216 HDD5GHZCHAN(5540,108, 0) ,
217 HDD5GHZCHAN(5560,112, 0) ,
218 HDD5GHZCHAN(5580,116, 0) ,
219 HDD5GHZCHAN(5600,120, 0) ,
220 HDD5GHZCHAN(5620,124, 0) ,
221 HDD5GHZCHAN(5640,128, 0) ,
222 HDD5GHZCHAN(5660,132, 0) ,
223 HDD5GHZCHAN(5680,136, 0) ,
224 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800225#ifdef FEATURE_WLAN_CH144
226 HDD5GHZCHAN(5720,144, 0) ,
227#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700228 HDD5GHZCHAN(5745,149, 0) ,
229 HDD5GHZCHAN(5765,153, 0) ,
230 HDD5GHZCHAN(5785,157, 0) ,
231 HDD5GHZCHAN(5805,161, 0) ,
232 HDD5GHZCHAN(5825,165, 0) ,
233};
234
235static struct ieee80211_rate g_mode_rates[] =
236{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530237 HDD_G_MODE_RATETAB(10, 0x1, 0),
238 HDD_G_MODE_RATETAB(20, 0x2, 0),
239 HDD_G_MODE_RATETAB(55, 0x4, 0),
240 HDD_G_MODE_RATETAB(110, 0x8, 0),
241 HDD_G_MODE_RATETAB(60, 0x10, 0),
242 HDD_G_MODE_RATETAB(90, 0x20, 0),
243 HDD_G_MODE_RATETAB(120, 0x40, 0),
244 HDD_G_MODE_RATETAB(180, 0x80, 0),
245 HDD_G_MODE_RATETAB(240, 0x100, 0),
246 HDD_G_MODE_RATETAB(360, 0x200, 0),
247 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700248 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530249};
Jeff Johnson295189b2012-06-20 16:38:30 -0700250
251static struct ieee80211_rate a_mode_rates[] =
252{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530253 HDD_G_MODE_RATETAB(60, 0x10, 0),
254 HDD_G_MODE_RATETAB(90, 0x20, 0),
255 HDD_G_MODE_RATETAB(120, 0x40, 0),
256 HDD_G_MODE_RATETAB(180, 0x80, 0),
257 HDD_G_MODE_RATETAB(240, 0x100, 0),
258 HDD_G_MODE_RATETAB(360, 0x200, 0),
259 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700260 HDD_G_MODE_RATETAB(540, 0x800, 0),
261};
262
263static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
264{
265 .channels = hdd_channels_2_4_GHZ,
266 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
267 .band = IEEE80211_BAND_2GHZ,
268 .bitrates = g_mode_rates,
269 .n_bitrates = g_mode_rates_size,
270 .ht_cap.ht_supported = 1,
271 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
272 | IEEE80211_HT_CAP_GRN_FLD
273 | IEEE80211_HT_CAP_DSSSCCK40
274 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
275 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
276 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
277 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
278 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
279 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
280};
281
Jeff Johnson295189b2012-06-20 16:38:30 -0700282static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
283{
284 .channels = hdd_social_channels_2_4_GHZ,
285 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
286 .band = IEEE80211_BAND_2GHZ,
287 .bitrates = g_mode_rates,
288 .n_bitrates = g_mode_rates_size,
289 .ht_cap.ht_supported = 1,
290 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
291 | IEEE80211_HT_CAP_GRN_FLD
292 | IEEE80211_HT_CAP_DSSSCCK40
293 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
294 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
295 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
296 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
297 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
298 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
299};
Jeff Johnson295189b2012-06-20 16:38:30 -0700300
301static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
302{
303 .channels = hdd_channels_5_GHZ,
304 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
305 .band = IEEE80211_BAND_5GHZ,
306 .bitrates = a_mode_rates,
307 .n_bitrates = a_mode_rates_size,
308 .ht_cap.ht_supported = 1,
309 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
310 | IEEE80211_HT_CAP_GRN_FLD
311 | IEEE80211_HT_CAP_DSSSCCK40
312 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
313 | IEEE80211_HT_CAP_SGI_40
314 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
315 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
316 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
317 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
318 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
319 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
320};
321
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530322/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700323 TX/RX direction for each kind of interface */
324static const struct ieee80211_txrx_stypes
325wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
326 [NL80211_IFTYPE_STATION] = {
327 .tx = 0xffff,
328 .rx = BIT(SIR_MAC_MGMT_ACTION) |
329 BIT(SIR_MAC_MGMT_PROBE_REQ),
330 },
331 [NL80211_IFTYPE_AP] = {
332 .tx = 0xffff,
333 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
334 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
335 BIT(SIR_MAC_MGMT_PROBE_REQ) |
336 BIT(SIR_MAC_MGMT_DISASSOC) |
337 BIT(SIR_MAC_MGMT_AUTH) |
338 BIT(SIR_MAC_MGMT_DEAUTH) |
339 BIT(SIR_MAC_MGMT_ACTION),
340 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700341 [NL80211_IFTYPE_ADHOC] = {
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 [NL80211_IFTYPE_P2P_CLIENT] = {
352 .tx = 0xffff,
353 .rx = BIT(SIR_MAC_MGMT_ACTION) |
354 BIT(SIR_MAC_MGMT_PROBE_REQ),
355 },
356 [NL80211_IFTYPE_P2P_GO] = {
357 /* This is also same as for SoftAP */
358 .tx = 0xffff,
359 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
360 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
361 BIT(SIR_MAC_MGMT_PROBE_REQ) |
362 BIT(SIR_MAC_MGMT_DISASSOC) |
363 BIT(SIR_MAC_MGMT_AUTH) |
364 BIT(SIR_MAC_MGMT_DEAUTH) |
365 BIT(SIR_MAC_MGMT_ACTION),
366 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700367};
368
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800369#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800370static const struct ieee80211_iface_limit
371wlan_hdd_iface_limit[] = {
372 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800373 /* max = 3 ; Our driver create two interfaces during driver init
374 * wlan0 and p2p0 interfaces. p2p0 is considered as station
375 * interface until a group is formed. In JB architecture, once the
376 * group is formed, interface type of p2p0 is changed to P2P GO or
377 * Client.
378 * When supplicant remove the group, it first issue a set interface
379 * cmd to change the mode back to Station. In JB this works fine as
380 * we advertize two station type interface during driver init.
381 * Some vendors create separate interface for P2P GO/Client,
382 * after group formation(Third one). But while group remove
383 * supplicant first tries to change the mode(3rd interface) to STATION
384 * But as we advertized only two sta type interfaces nl80211 was
385 * returning error for the third one which was leading to failure in
386 * delete interface. Ideally while removing the group, supplicant
387 * should not try to change the 3rd interface mode to Station type.
388 * Till we get a fix in wpa_supplicant, we advertize max STA
389 * interface type to 3
390 */
391 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800392 .types = BIT(NL80211_IFTYPE_STATION),
393 },
394 {
395 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700396 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800397 },
398 {
399 .max = 1,
400 .types = BIT(NL80211_IFTYPE_P2P_GO) |
401 BIT(NL80211_IFTYPE_P2P_CLIENT),
402 },
403};
404
405/* By default, only single channel concurrency is allowed */
406static struct ieee80211_iface_combination
407wlan_hdd_iface_combination = {
408 .limits = wlan_hdd_iface_limit,
409 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800410 /*
411 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
412 * and p2p0 interfaces during driver init
413 * Some vendors create separate interface for P2P operations.
414 * wlan0: STA interface
415 * p2p0: P2P Device interface, action frames goes
416 * through this interface.
417 * p2p-xx: P2P interface, After GO negotiation this interface is
418 * created for p2p operations(GO/CLIENT interface).
419 */
420 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800421 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
422 .beacon_int_infra_match = false,
423};
424#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800425
Jeff Johnson295189b2012-06-20 16:38:30 -0700426static struct cfg80211_ops wlan_hdd_cfg80211_ops;
427
428/* Data rate 100KBPS based on IE Index */
429struct index_data_rate_type
430{
431 v_U8_t beacon_rate_index;
432 v_U16_t supported_rate[4];
433};
434
435/* 11B, 11G Rate table include Basic rate and Extended rate
436 The IDX field is the rate index
437 The HI field is the rate when RSSI is strong or being ignored
438 (in this case we report actual rate)
439 The MID field is the rate when RSSI is moderate
440 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
441 The LO field is the rate when RSSI is low
442 (in this case we don't report rates, actual current rate used)
443 */
444static const struct
445{
446 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700447 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700448} supported_data_rate[] =
449{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700450/* IDX HI HM LM LO (RSSI-based index */
451 {2, { 10, 10, 10, 0}},
452 {4, { 20, 20, 10, 0}},
453 {11, { 55, 20, 10, 0}},
454 {12, { 60, 55, 20, 0}},
455 {18, { 90, 55, 20, 0}},
456 {22, {110, 55, 20, 0}},
457 {24, {120, 90, 60, 0}},
458 {36, {180, 120, 60, 0}},
459 {44, {220, 180, 60, 0}},
460 {48, {240, 180, 90, 0}},
461 {66, {330, 180, 90, 0}},
462 {72, {360, 240, 90, 0}},
463 {96, {480, 240, 120, 0}},
464 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700465};
466
467/* MCS Based rate table */
468static struct index_data_rate_type supported_mcs_rate[] =
469{
470/* MCS L20 L40 S20 S40 */
471 {0, {65, 135, 72, 150}},
472 {1, {130, 270, 144, 300}},
473 {2, {195, 405, 217, 450}},
474 {3, {260, 540, 289, 600}},
475 {4, {390, 810, 433, 900}},
476 {5, {520, 1080, 578, 1200}},
477 {6, {585, 1215, 650, 1350}},
478 {7, {650, 1350, 722, 1500}}
479};
480
Leo Chang6f8870f2013-03-26 18:11:36 -0700481#ifdef WLAN_FEATURE_11AC
482
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530483#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700484
485struct index_vht_data_rate_type
486{
487 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530488 v_U16_t supported_VHT80_rate[2];
489 v_U16_t supported_VHT40_rate[2];
490 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700491};
492
493typedef enum
494{
495 DATA_RATE_11AC_MAX_MCS_7,
496 DATA_RATE_11AC_MAX_MCS_8,
497 DATA_RATE_11AC_MAX_MCS_9,
498 DATA_RATE_11AC_MAX_MCS_NA
499} eDataRate11ACMaxMcs;
500
501/* MCS Based VHT rate table */
502static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
503{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530504/* MCS L80 S80 L40 S40 L20 S40*/
505 {0, {293, 325}, {135, 150}, {65, 72}},
506 {1, {585, 650}, {270, 300}, {130, 144}},
507 {2, {878, 975}, {405, 450}, {195, 217}},
508 {3, {1170, 1300}, {540, 600}, {260, 289}},
509 {4, {1755, 1950}, {810, 900}, {390, 433}},
510 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
511 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
512 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
513 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
514 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700515};
516#endif /* WLAN_FEATURE_11AC */
517
Jeff Johnson295189b2012-06-20 16:38:30 -0700518extern struct net_device_ops net_ops_struct;
519
Leo Chang9056f462013-08-01 19:21:11 -0700520#ifdef WLAN_NL80211_TESTMODE
521enum wlan_hdd_tm_attr
522{
523 WLAN_HDD_TM_ATTR_INVALID = 0,
524 WLAN_HDD_TM_ATTR_CMD = 1,
525 WLAN_HDD_TM_ATTR_DATA = 2,
526 WLAN_HDD_TM_ATTR_TYPE = 3,
527 /* keep last */
528 WLAN_HDD_TM_ATTR_AFTER_LAST,
529 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
530};
531
532enum wlan_hdd_tm_cmd
533{
534 WLAN_HDD_TM_CMD_WLAN_HB = 1,
535};
536
537#define WLAN_HDD_TM_DATA_MAX_LEN 5000
538
539static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
540{
541 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
542 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
543 .len = WLAN_HDD_TM_DATA_MAX_LEN },
544};
545#endif /* WLAN_NL80211_TESTMODE */
546
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800547#ifdef FEATURE_WLAN_CH_AVOID
548/*
549 * FUNCTION: wlan_hdd_send_avoid_freq_event
550 * This is called when wlan driver needs to send vendor specific
551 * avoid frequency range event to userspace
552 */
553int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
554 tHddAvoidFreqList *pAvoidFreqList)
555{
556 struct sk_buff *vendor_event;
557
558 ENTER();
559
560 if (!pHddCtx)
561 {
562 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
563 "%s: HDD context is null", __func__);
564 return -1;
565 }
566
567 if (!pAvoidFreqList)
568 {
569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
570 "%s: pAvoidFreqList is null", __func__);
571 return -1;
572 }
573
574 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
575 sizeof(tHddAvoidFreqList),
576 QCOM_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
577 GFP_KERNEL);
578 if (!vendor_event)
579 {
580 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
581 "%s: cfg80211_vendor_event_alloc failed", __func__);
582 return -1;
583 }
584
585 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
586 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
587
588 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
589
590 EXIT();
591 return 0;
592}
593#endif /* FEATURE_WLAN_CH_AVOID */
594
595/* vendor specific events */
596static const struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
597{
598#ifdef FEATURE_WLAN_CH_AVOID
599 {
600 .vendor_id = QCOM_NL80211_VENDOR_ID,
601 .subcmd = QCOM_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
602 },
603#endif /* FEATURE_WLAN_CH_AVOID */
604};
605
Jeff Johnson295189b2012-06-20 16:38:30 -0700606/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530607 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530608 * This function is called by hdd_wlan_startup()
609 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530610 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -0700611 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530612struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -0700613{
614 struct wiphy *wiphy;
615 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530616 /*
617 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -0700618 */
619 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
620
621 if (!wiphy)
622 {
623 /* Print error and jump into err label and free the memory */
624 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
625 return NULL;
626 }
627
628 return wiphy;
629}
630
631/*
632 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530633 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 * private ioctl to change the band value
635 */
636int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
637{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530638 int i, j;
639 eNVChannelEnabledType channelEnabledState;
640
Jeff Johnsone7245742012-09-05 17:12:55 -0700641 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530642
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530643 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700644 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530645
646 if (NULL == wiphy->bands[i])
647 {
648 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
649 __func__, i);
650 continue;
651 }
652
653 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
654 {
655 struct ieee80211_supported_band *band = wiphy->bands[i];
656
657 channelEnabledState = vos_nv_getChannelEnabledState(
658 band->channels[j].hw_value);
659
660 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
661 {
662 // Enable Social channels for P2P
663 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq) &&
664 NV_CHANNEL_ENABLE == channelEnabledState)
665 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
666 else
667 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
668 continue;
669 }
670 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
671 {
672 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
673 continue;
674 }
675
676 if (NV_CHANNEL_DISABLE == channelEnabledState ||
677 NV_CHANNEL_INVALID == channelEnabledState)
678 {
679 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
680 }
681 else if (NV_CHANNEL_DFS == channelEnabledState)
682 {
683 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
684 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
685 }
686 else
687 {
688 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
689 |IEEE80211_CHAN_RADAR);
690 }
691 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700692 }
693 return 0;
694}
695/*
696 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530697 * This function is called by hdd_wlan_startup()
698 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -0700699 * This function is used to initialize and register wiphy structure.
700 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530701int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -0700702 struct wiphy *wiphy,
703 hdd_config_t *pCfg
704 )
705{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530706 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +0530707 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
708
Jeff Johnsone7245742012-09-05 17:12:55 -0700709 ENTER();
710
Jeff Johnson295189b2012-06-20 16:38:30 -0700711 /* Now bind the underlying wlan device with wiphy */
712 set_wiphy_dev(wiphy, dev);
713
714 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -0700715
Kiet Lam6c583332013-10-14 05:37:09 +0530716#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -0700717 /* the flag for the other case would be initialzed in
718 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -0700719 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +0530720#endif
Amar Singhala49cbc52013-10-08 18:37:44 -0700721
Amar Singhalfddc28c2013-09-05 13:03:40 -0700722 /* This will disable updating of NL channels from passive to
723 * active if a beacon is received on passive channel. */
724 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Amar Singhalf0073192013-09-20 12:34:56 -0700725
Amar Singhalfddc28c2013-09-05 13:03:40 -0700726
Amar Singhala49cbc52013-10-08 18:37:44 -0700727
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700728#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -0700729 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
730 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
731 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -0700732 | WIPHY_FLAG_OFFCHAN_TX;
Kiet Lam6c583332013-10-14 05:37:09 +0530733 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700734#endif
Amar Singhala49cbc52013-10-08 18:37:44 -0700735
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800736#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700737 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -0800738#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700739 || pCfg->isFastRoamIniFeatureEnabled
740#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800741#ifdef FEATURE_WLAN_ESE
742 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700743#endif
744 )
745 {
746 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
747 }
James Zmuda77fb5ae2013-01-29 08:00:17 -0800748#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800749#ifdef FEATURE_WLAN_TDLS
750 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
751 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
752#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530753#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +0530754 if (pCfg->configPNOScanSupport)
755 {
756 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
757 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
758 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
759 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
760 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530761#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800762
Amar Singhalfddc28c2013-09-05 13:03:40 -0700763#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700764 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
765 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -0700766 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700767 driver need to determine what to do with both
768 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -0700769
770 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -0700771#else
772 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -0700773#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700774
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530775 wiphy->max_scan_ssids = MAX_SCAN_SSID;
776
Madan Mohan Koyyalamudi6815b162013-07-19 17:17:46 +0530777 wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700778
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +0530779 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
780
Jeff Johnson295189b2012-06-20 16:38:30 -0700781 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530782 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -0700783 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -0700784 | BIT(NL80211_IFTYPE_P2P_CLIENT)
785 | BIT(NL80211_IFTYPE_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -0700786 | BIT(NL80211_IFTYPE_AP);
787
Rashmi Ramannabd3feb72014-02-25 16:14:48 +0530788 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800789 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +0530790#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
791 if( pCfg->enableMCC )
792 {
793 /* Currently, supports up to two channels */
794 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800795
Rashmi Ramannabd3feb72014-02-25 16:14:48 +0530796 if( !pCfg->allowMCCGODiffBI )
797 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800798
Rashmi Ramannabd3feb72014-02-25 16:14:48 +0530799 }
800 wiphy->iface_combinations = &wlan_hdd_iface_combination;
801 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800802#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +0530803 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800804
Jeff Johnson295189b2012-06-20 16:38:30 -0700805 /* Before registering we need to update the ht capabilitied based
806 * on ini values*/
807 if( !pCfg->ShortGI20MhzEnable )
808 {
809 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
810 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
811 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
812 }
813
814 if( !pCfg->ShortGI40MhzEnable )
815 {
816 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
817 }
818
819 if( !pCfg->nChannelBondingMode5GHz )
820 {
821 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
822 }
823
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530824 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +0530825 if (true == hdd_is_5g_supported(pHddCtx))
826 {
827 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
828 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530829
830 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
831 {
832
833 if (NULL == wiphy->bands[i])
834 {
835 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
836 __func__, i);
837 continue;
838 }
839
840 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
841 {
842 struct ieee80211_supported_band *band = wiphy->bands[i];
843
844 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
845 {
846 // Enable social channels for P2P
847 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
848 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
849 else
850 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
851 continue;
852 }
853 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
854 {
855 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
856 continue;
857 }
858 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 }
860 /*Initialise the supported cipher suite details*/
861 wiphy->cipher_suites = hdd_cipher_suites;
862 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
863
864 /*signal strength in mBm (100*dBm) */
865 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
866
867#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 wiphy->max_remain_on_channel_duration = 1000;
869#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700870
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800871 wiphy->n_vendor_commands = 0;
872 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
873 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
874
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530875 EXIT();
876 return 0;
877}
878
879/* In this function we are registering wiphy. */
880int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
881{
882 ENTER();
883 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700884 if (0 > wiphy_register(wiphy))
885 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530886 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -0700887 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
888 return -EIO;
889 }
890
891 EXIT();
892 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530893}
Jeff Johnson295189b2012-06-20 16:38:30 -0700894
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530895/* In this function we are updating channel list when,
896 regulatory domain is FCC and country code is US.
897 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
898 As per FCC smart phone is not a indoor device.
899 GO should not opeate on indoor channels */
900void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
901{
902 int j;
903 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
904 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
905 //Default counrtycode from NV at the time of wiphy initialization.
906 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
907 &defaultCountryCode[0]))
908 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700909 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530910 }
911 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
912 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530913 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
914 {
915 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
916 return;
917 }
918 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
919 {
920 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
921 // Mark UNII -1 band channel as passive
922 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
923 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
924 }
925 }
926}
927
Jeff Johnson295189b2012-06-20 16:38:30 -0700928/* In this function we will do all post VOS start initialization.
929 In this function we will register for all frame in which supplicant
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530930 is interested.
Jeff Johnson295189b2012-06-20 16:38:30 -0700931*/
932void wlan_hdd_cfg80211_post_voss_start(hdd_adapter_t* pAdapter)
933{
Jeff Johnson295189b2012-06-20 16:38:30 -0700934 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
935 /* Register for all P2P action, public action etc frames */
936 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
937
Jeff Johnsone7245742012-09-05 17:12:55 -0700938 ENTER();
939
Jeff Johnson295189b2012-06-20 16:38:30 -0700940 /* Right now we are registering these frame when driver is getting
941 initialized. Once we will move to 2.6.37 kernel, in which we have
942 frame register ops, we will move this code as a part of that */
943 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530944 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -0700945 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
946
947 /* GAS Initial Response */
948 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
949 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530950
Jeff Johnson295189b2012-06-20 16:38:30 -0700951 /* GAS Comeback Request */
952 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
953 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
954
955 /* GAS Comeback Response */
956 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
957 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
958
959 /* P2P Public Action */
960 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530961 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700962 P2P_PUBLIC_ACTION_FRAME_SIZE );
963
964 /* P2P Action */
965 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
966 (v_U8_t*)P2P_ACTION_FRAME,
967 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700968
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +0530969 /* WNM BSS Transition Request frame */
970 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
971 (v_U8_t*)WNM_BSS_ACTION_FRAME,
972 WNM_BSS_ACTION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700973}
974
975void wlan_hdd_cfg80211_pre_voss_stop(hdd_adapter_t* pAdapter)
976{
Jeff Johnson295189b2012-06-20 16:38:30 -0700977 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
978 /* Register for all P2P action, public action etc frames */
979 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
980
Jeff Johnsone7245742012-09-05 17:12:55 -0700981 ENTER();
982
Jeff Johnson295189b2012-06-20 16:38:30 -0700983 /* Right now we are registering these frame when driver is getting
984 initialized. Once we will move to 2.6.37 kernel, in which we have
985 frame register ops, we will move this code as a part of that */
986 /* GAS Initial Request */
987
988 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
989 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
990
991 /* GAS Initial Response */
992 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
993 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530994
Jeff Johnson295189b2012-06-20 16:38:30 -0700995 /* GAS Comeback Request */
996 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
997 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
998
999 /* GAS Comeback Response */
1000 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
1001 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
1002
1003 /* P2P Public Action */
1004 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301005 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07001006 P2P_PUBLIC_ACTION_FRAME_SIZE );
1007
1008 /* P2P Action */
1009 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
1010 (v_U8_t*)P2P_ACTION_FRAME,
1011 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07001012
1013#ifdef WLAN_FEATURE_11W
1014 /* SA Query Response Action Frame */
1015 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
1016 (v_U8_t*)SA_QUERY_FRAME_RSP,
1017 SA_QUERY_FRAME_RSP_SIZE );
1018#endif /* WLAN_FEATURE_11W */
Jeff Johnson295189b2012-06-20 16:38:30 -07001019}
1020
1021#ifdef FEATURE_WLAN_WAPI
1022void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
1023 const u8 *mac_addr, u8 *key , int key_Len)
1024{
1025 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1026 tCsrRoamSetKey setKey;
1027 v_BOOL_t isConnected = TRUE;
1028 int status = 0;
1029 v_U32_t roamId= 0xFF;
1030 tANI_U8 *pKeyPtr = NULL;
1031 int n = 0;
1032
Arif Hussain6d2a3322013-11-17 19:50:10 -08001033 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 __func__,pAdapter->device_mode);
1035
Gopichand Nakkalae7480202013-02-11 15:24:22 +05301036 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07001037 setKey.keyId = key_index; // Store Key ID
1038 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
1039 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
1040 setKey.paeRole = 0 ; // the PAE role
1041 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
1042 {
1043 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
1044 }
1045 else
1046 {
1047 isConnected = hdd_connIsConnected(pHddStaCtx);
1048 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
1049 }
1050 setKey.keyLength = key_Len;
1051 pKeyPtr = setKey.Key;
1052 memcpy( pKeyPtr, key, key_Len);
1053
Arif Hussain6d2a3322013-11-17 19:50:10 -08001054 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07001055 __func__, key_Len);
1056 for (n = 0 ; n < key_Len; n++)
1057 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
1058 __func__,n,setKey.Key[n]);
1059
1060 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
1061 if ( isConnected )
1062 {
1063 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
1064 pAdapter->sessionId, &setKey, &roamId );
1065 }
1066 if ( status != 0 )
1067 {
1068 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1069 "[%4d] sme_RoamSetKey returned ERROR status= %d",
1070 __LINE__, status );
1071 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1072 }
1073}
1074#endif /* FEATURE_WLAN_WAPI*/
1075
1076#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301077int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001078 beacon_data_t **ppBeacon,
1079 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001080#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301081int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001082 beacon_data_t **ppBeacon,
1083 struct cfg80211_beacon_data *params,
1084 int dtim_period)
1085#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301086{
Jeff Johnson295189b2012-06-20 16:38:30 -07001087 int size;
1088 beacon_data_t *beacon = NULL;
1089 beacon_data_t *old = NULL;
1090 int head_len,tail_len;
1091
Jeff Johnsone7245742012-09-05 17:12:55 -07001092 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001093 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301094 {
1095 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1096 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001097 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301098 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001099
1100 old = pAdapter->sessionCtx.ap.beacon;
1101
1102 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301103 {
1104 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1105 FL("session(%d) old and new heads points to NULL"),
1106 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001107 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301108 }
1109
1110 if (params->tail && !params->tail_len)
1111 {
1112 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1113 FL("tail_len is zero but tail is not NULL"));
1114 return -EINVAL;
1115 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001116
Jeff Johnson295189b2012-06-20 16:38:30 -07001117#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
1118 /* Kernel 3.0 is not updating dtim_period for set beacon */
1119 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301120 {
1121 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1122 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301124 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001125#endif
1126
1127 if(params->head)
1128 head_len = params->head_len;
1129 else
1130 head_len = old->head_len;
1131
1132 if(params->tail || !old)
1133 tail_len = params->tail_len;
1134 else
1135 tail_len = old->tail_len;
1136
1137 size = sizeof(beacon_data_t) + head_len + tail_len;
1138
1139 beacon = kzalloc(size, GFP_KERNEL);
1140
1141 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301142 {
1143 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1144 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001145 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301146 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001147
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001148#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001149 if(params->dtim_period || !old )
1150 beacon->dtim_period = params->dtim_period;
1151 else
1152 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001153#else
1154 if(dtim_period || !old )
1155 beacon->dtim_period = dtim_period;
1156 else
1157 beacon->dtim_period = old->dtim_period;
1158#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301159
Jeff Johnson295189b2012-06-20 16:38:30 -07001160 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
1161 beacon->tail = beacon->head + head_len;
1162 beacon->head_len = head_len;
1163 beacon->tail_len = tail_len;
1164
1165 if(params->head) {
1166 memcpy (beacon->head,params->head,beacon->head_len);
1167 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301168 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001169 if(old)
1170 memcpy (beacon->head,old->head,beacon->head_len);
1171 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301172
Jeff Johnson295189b2012-06-20 16:38:30 -07001173 if(params->tail) {
1174 memcpy (beacon->tail,params->tail,beacon->tail_len);
1175 }
1176 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301177 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07001178 memcpy (beacon->tail,old->tail,beacon->tail_len);
1179 }
1180
1181 *ppBeacon = beacon;
1182
1183 kfree(old);
1184
1185 return 0;
1186
1187}
Jeff Johnson295189b2012-06-20 16:38:30 -07001188
1189v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
1190{
1191 int left = length;
1192 v_U8_t *ptr = pIes;
1193 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301194
Jeff Johnson295189b2012-06-20 16:38:30 -07001195 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301196 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001197 elem_id = ptr[0];
1198 elem_len = ptr[1];
1199 left -= 2;
1200 if(elem_len > left)
1201 {
1202 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001203 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001204 eid,elem_len,left);
1205 return NULL;
1206 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301207 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07001208 {
1209 return ptr;
1210 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301211
Jeff Johnson295189b2012-06-20 16:38:30 -07001212 left -= elem_len;
1213 ptr += (elem_len + 2);
1214 }
1215 return NULL;
1216}
1217
Jeff Johnson295189b2012-06-20 16:38:30 -07001218/* Check if rate is 11g rate or not */
1219static int wlan_hdd_rate_is_11g(u8 rate)
1220{
Sanjay Devnani28322e22013-06-21 16:13:40 -07001221 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001222 u8 i;
1223 for (i = 0; i < 8; i++)
1224 {
1225 if(rate == gRateArray[i])
1226 return TRUE;
1227 }
1228 return FALSE;
1229}
1230
1231/* Check for 11g rate and set proper 11g only mode */
1232static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
1233 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
1234{
1235 u8 i, num_rates = pIe[0];
1236
1237 pIe += 1;
1238 for ( i = 0; i < num_rates; i++)
1239 {
1240 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
1241 {
1242 /* If rate set have 11g rate than change the mode to 11G */
1243 *pSapHw_mode = eSAP_DOT11_MODE_11g;
1244 if (pIe[i] & BASIC_RATE_MASK)
1245 {
1246 /* If we have 11g rate as basic rate, it means mode
1247 is 11g only mode.
1248 */
1249 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
1250 *pCheckRatesfor11g = FALSE;
1251 }
1252 }
1253 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
1254 {
1255 *require_ht = TRUE;
1256 }
1257 }
1258 return;
1259}
1260
1261static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
1262{
1263 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1264 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1265 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1266 u8 checkRatesfor11g = TRUE;
1267 u8 require_ht = FALSE;
1268 u8 *pIe=NULL;
1269
1270 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
1271
1272 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
1273 pBeacon->head_len, WLAN_EID_SUPP_RATES);
1274 if (pIe != NULL)
1275 {
1276 pIe += 1;
1277 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1278 &pConfig->SapHw_mode);
1279 }
1280
1281 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1282 WLAN_EID_EXT_SUPP_RATES);
1283 if (pIe != NULL)
1284 {
1285
1286 pIe += 1;
1287 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1288 &pConfig->SapHw_mode);
1289 }
1290
1291 if( pConfig->channel > 14 )
1292 {
1293 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
1294 }
1295
1296 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1297 WLAN_EID_HT_CAPABILITY);
1298
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301299 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001300 {
1301 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
1302 if(require_ht)
1303 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
1304 }
1305}
1306
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301307static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
1308 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
1309{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001310 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301311 v_U8_t *pIe = NULL;
1312 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1313
1314 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
1315 pBeacon->tail, pBeacon->tail_len);
1316
1317 if (pIe)
1318 {
1319 ielen = pIe[1] + 2;
1320 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1321 {
1322 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
1323 }
1324 else
1325 {
1326 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
1327 return -EINVAL;
1328 }
1329 *total_ielen += ielen;
1330 }
1331 return 0;
1332}
1333
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001334static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
1335 v_U8_t *genie, v_U8_t *total_ielen)
1336{
1337 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1338 int left = pBeacon->tail_len;
1339 v_U8_t *ptr = pBeacon->tail;
1340 v_U8_t elem_id, elem_len;
1341 v_U16_t ielen = 0;
1342
1343 if ( NULL == ptr || 0 == left )
1344 return;
1345
1346 while (left >= 2)
1347 {
1348 elem_id = ptr[0];
1349 elem_len = ptr[1];
1350 left -= 2;
1351 if (elem_len > left)
1352 {
1353 hddLog( VOS_TRACE_LEVEL_ERROR,
1354 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
1355 elem_id, elem_len, left);
1356 return;
1357 }
1358 if (IE_EID_VENDOR == elem_id)
1359 {
1360 /* skipping the VSIE's which we don't want to include or
1361 * it will be included by existing code
1362 */
1363 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
1364#ifdef WLAN_FEATURE_WFD
1365 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
1366#endif
1367 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1368 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1369 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
1370 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1371 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
1372 {
1373 ielen = ptr[1] + 2;
1374 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1375 {
1376 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
1377 *total_ielen += ielen;
1378 }
1379 else
1380 {
1381 hddLog( VOS_TRACE_LEVEL_ERROR,
1382 "IE Length is too big "
1383 "IEs eid=%d elem_len=%d total_ie_lent=%d",
1384 elem_id, elem_len, *total_ielen);
1385 }
1386 }
1387 }
1388
1389 left -= elem_len;
1390 ptr += (elem_len + 2);
1391 }
1392 return;
1393}
1394
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001395#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001396static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1397 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001398#else
1399static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1400 struct cfg80211_beacon_data *params)
1401#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001402{
1403 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301404 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001405 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07001406 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001407
1408 genie = vos_mem_malloc(MAX_GENIE_LEN);
1409
1410 if(genie == NULL) {
1411
1412 return -ENOMEM;
1413 }
1414
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301415 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1416 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301418 hddLog(LOGE,
1419 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301420 ret = -EINVAL;
1421 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001422 }
1423
1424#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301425 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1426 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
1427 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301428 hddLog(LOGE,
1429 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301430 ret = -EINVAL;
1431 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001432 }
1433#endif
1434
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301435 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1436 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001437 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301438 hddLog(LOGE,
1439 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301440 ret = -EINVAL;
1441 goto done;
1442 }
1443
1444 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
1445 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001446 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001447 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001448
1449 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1450 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
1451 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
1452 {
1453 hddLog(LOGE,
1454 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001455 ret = -EINVAL;
1456 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001457 }
1458
1459 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1460 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
1461 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1462 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1463 ==eHAL_STATUS_FAILURE)
1464 {
1465 hddLog(LOGE,
1466 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001467 ret = -EINVAL;
1468 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001469 }
1470
1471 // Added for ProResp IE
1472 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
1473 {
1474 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
1475 u8 probe_rsp_ie_len[3] = {0};
1476 u8 counter = 0;
1477 /* Check Probe Resp Length if it is greater then 255 then Store
1478 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
1479 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
1480 Store More then 255 bytes into One Variable.
1481 */
1482 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
1483 {
1484 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
1485 {
1486 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
1487 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
1488 }
1489 else
1490 {
1491 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
1492 rem_probe_resp_ie_len = 0;
1493 }
1494 }
1495
1496 rem_probe_resp_ie_len = 0;
1497
1498 if (probe_rsp_ie_len[0] > 0)
1499 {
1500 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1501 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
1502 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1503 probe_rsp_ie_len[0], NULL,
1504 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1505 {
1506 hddLog(LOGE,
1507 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001508 ret = -EINVAL;
1509 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001510 }
1511 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
1512 }
1513
1514 if (probe_rsp_ie_len[1] > 0)
1515 {
1516 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1517 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
1518 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1519 probe_rsp_ie_len[1], NULL,
1520 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1521 {
1522 hddLog(LOGE,
1523 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001524 ret = -EINVAL;
1525 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001526 }
1527 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
1528 }
1529
1530 if (probe_rsp_ie_len[2] > 0)
1531 {
1532 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1533 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
1534 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1535 probe_rsp_ie_len[2], NULL,
1536 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1537 {
1538 hddLog(LOGE,
1539 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001540 ret = -EINVAL;
1541 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001542 }
1543 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
1544 }
1545
1546 if (probe_rsp_ie_len[1] == 0 )
1547 {
1548 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1549 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
1550 eANI_BOOLEAN_FALSE) )
1551 {
1552 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001553 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07001554 }
1555 }
1556
1557 if (probe_rsp_ie_len[2] == 0 )
1558 {
1559 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1560 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
1561 eANI_BOOLEAN_FALSE) )
1562 {
1563 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001564 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07001565 }
1566 }
1567
1568 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1569 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
1570 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1571 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1572 == eHAL_STATUS_FAILURE)
1573 {
1574 hddLog(LOGE,
1575 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001576 ret = -EINVAL;
1577 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001578 }
1579 }
1580 else
1581 {
1582 // Reset WNI_CFG_PROBE_RSP Flags
1583 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
1584
1585 hddLog(VOS_TRACE_LEVEL_INFO,
1586 "%s: No Probe Response IE received in set beacon",
1587 __func__);
1588 }
1589
1590 // Added for AssocResp IE
1591 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
1592 {
1593 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1594 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
1595 params->assocresp_ies_len, NULL,
1596 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1597 {
1598 hddLog(LOGE,
1599 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001600 ret = -EINVAL;
1601 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001602 }
1603
1604 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1605 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
1606 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1607 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1608 == eHAL_STATUS_FAILURE)
1609 {
1610 hddLog(LOGE,
1611 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001612 ret = -EINVAL;
1613 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001614 }
1615 }
1616 else
1617 {
1618 hddLog(VOS_TRACE_LEVEL_INFO,
1619 "%s: No Assoc Response IE received in set beacon",
1620 __func__);
1621
1622 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1623 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
1624 eANI_BOOLEAN_FALSE) )
1625 {
1626 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001627 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07001628 }
1629 }
1630
Jeff Johnsone7245742012-09-05 17:12:55 -07001631done:
Jeff Johnson295189b2012-06-20 16:38:30 -07001632 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301633 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001634}
Jeff Johnson295189b2012-06-20 16:38:30 -07001635
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301636/*
Jeff Johnson295189b2012-06-20 16:38:30 -07001637 * FUNCTION: wlan_hdd_validate_operation_channel
1638 * called by wlan_hdd_cfg80211_start_bss() and
1639 * wlan_hdd_cfg80211_set_channel()
1640 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301641 * channel list.
1642 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001643VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001644{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301645
Jeff Johnson295189b2012-06-20 16:38:30 -07001646 v_U32_t num_ch = 0;
1647 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1648 u32 indx = 0;
1649 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301650 v_U8_t fValidChannel = FALSE, count = 0;
1651 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301652
Jeff Johnson295189b2012-06-20 16:38:30 -07001653 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1654
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301655 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001656 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301657 /* Validate the channel */
1658 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001659 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301660 if ( channel == rfChannels[count].channelNum )
1661 {
1662 fValidChannel = TRUE;
1663 break;
1664 }
1665 }
1666 if (fValidChannel != TRUE)
1667 {
1668 hddLog(VOS_TRACE_LEVEL_ERROR,
1669 "%s: Invalid Channel [%d]", __func__, channel);
1670 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001671 }
1672 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301673 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001674 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301675 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1676 valid_ch, &num_ch))
1677 {
1678 hddLog(VOS_TRACE_LEVEL_ERROR,
1679 "%s: failed to get valid channel list", __func__);
1680 return VOS_STATUS_E_FAILURE;
1681 }
1682 for (indx = 0; indx < num_ch; indx++)
1683 {
1684 if (channel == valid_ch[indx])
1685 {
1686 break;
1687 }
1688 }
1689
1690 if (indx >= num_ch)
1691 {
1692 hddLog(VOS_TRACE_LEVEL_ERROR,
1693 "%s: Invalid Channel [%d]", __func__, channel);
1694 return VOS_STATUS_E_FAILURE;
1695 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001696 }
1697 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301698
Jeff Johnson295189b2012-06-20 16:38:30 -07001699}
1700
Viral Modi3a32cc52013-02-08 11:14:52 -08001701/**
1702 * FUNCTION: wlan_hdd_cfg80211_set_channel
1703 * This function is used to set the channel number
1704 */
1705static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
1706 struct ieee80211_channel *chan,
1707 enum nl80211_channel_type channel_type
1708 )
1709{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05301710 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08001711 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07001712 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08001713 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301714 hdd_context_t *pHddCtx;
1715 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001716
1717 ENTER();
1718
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05301719
Viral Modi3a32cc52013-02-08 11:14:52 -08001720 if( NULL == dev )
1721 {
1722 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001723 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08001724 return -ENODEV;
1725 }
1726 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
1727
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05301728 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
1729 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
1730 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08001731 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001732 "%s: device_mode = %d freq = %d", __func__,
Viral Modi3a32cc52013-02-08 11:14:52 -08001733 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301734
1735 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1736 status = wlan_hdd_validate_context(pHddCtx);
1737
1738 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08001739 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301740 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1741 "%s: HDD context is not valid", __func__);
1742 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001743 }
1744
1745 /*
1746 * Do freq to chan conversion
1747 * TODO: for 11a
1748 */
1749
1750 channel = ieee80211_frequency_to_channel(freq);
1751
1752 /* Check freq range */
1753 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
1754 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
1755 {
1756 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001757 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08001758 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
1759 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1760 return -EINVAL;
1761 }
1762
1763 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1764
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05301765 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
1766 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08001767 {
1768 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
1769 {
1770 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001771 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08001772 return -EINVAL;
1773 }
1774 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1775 "%s: set channel to [%d] for device mode =%d",
1776 __func__, channel,pAdapter->device_mode);
1777 }
1778 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08001779 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08001780 )
1781 {
1782 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1783 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
1784 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1785
1786 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
1787 {
1788 /* Link is up then return cant set channel*/
1789 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001790 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08001791 return -EINVAL;
1792 }
1793
1794 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
1795 pHddStaCtx->conn_info.operationChannel = channel;
1796 pRoamProfile->ChannelInfo.ChannelList =
1797 &pHddStaCtx->conn_info.operationChannel;
1798 }
1799 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08001800 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08001801 )
1802 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301803 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
1804 {
1805 if(VOS_STATUS_SUCCESS !=
1806 wlan_hdd_validate_operation_channel(pAdapter,channel))
1807 {
1808 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001809 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301810 return -EINVAL;
1811 }
1812 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1813 }
1814 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08001815 {
1816 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1817
1818 /* If auto channel selection is configured as enable/ 1 then ignore
1819 channel set by supplicant
1820 */
1821 if ( cfg_param->apAutoChannelSelection )
1822 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301823 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
1824 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08001825 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1826 "%s: set channel to auto channel (0) for device mode =%d",
1827 __func__, pAdapter->device_mode);
1828 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301829 else
1830 {
1831 if(VOS_STATUS_SUCCESS !=
1832 wlan_hdd_validate_operation_channel(pAdapter,channel))
1833 {
1834 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001835 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301836 return -EINVAL;
1837 }
1838 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1839 }
Viral Modi3a32cc52013-02-08 11:14:52 -08001840 }
1841 }
1842 else
1843 {
1844 hddLog(VOS_TRACE_LEVEL_FATAL,
1845 "%s: Invalid device mode failed to set valid channel", __func__);
1846 return -EINVAL;
1847 }
1848 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301849 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001850}
1851
Jeff Johnson295189b2012-06-20 16:38:30 -07001852#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
1853static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1854 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001855#else
1856static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1857 struct cfg80211_beacon_data *params,
1858 const u8 *ssid, size_t ssid_len,
1859 enum nl80211_hidden_ssid hidden_ssid)
1860#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001861{
1862 tsap_Config_t *pConfig;
1863 beacon_data_t *pBeacon = NULL;
1864 struct ieee80211_mgmt *pMgmt_frame;
1865 v_U8_t *pIe=NULL;
1866 v_U16_t capab_info;
1867 eCsrAuthType RSNAuthType;
1868 eCsrEncryptionType RSNEncryptType;
1869 eCsrEncryptionType mcRSNEncryptType;
1870 int status = VOS_STATUS_SUCCESS;
1871 tpWLAN_SAPEventCB pSapEventCallback;
1872 hdd_hostapd_state_t *pHostapdState;
1873 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
1874 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301875 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001876 struct qc_mac_acl_entry *acl_entry = NULL;
1877 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08001878 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Chet Lanctot8cecea22014-02-11 19:09:36 -08001879 v_BOOL_t MFPCapable;
1880 v_BOOL_t MFPRequired;
Abhishek Singhf0ac1752014-03-05 17:47:09 +05301881 eHddDot11Mode sapDot11Mode =
1882 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001883
1884 ENTER();
1885
1886 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
1887
1888 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1889
1890 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1891
1892 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1893
1894 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
1895
1896 //channel is already set in the set_channel Call back
1897 //pConfig->channel = pCommitConfig->channel;
1898
1899 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301900 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07001901 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
1902
1903 pConfig->dtim_period = pBeacon->dtim_period;
1904
Arif Hussain6d2a3322013-11-17 19:50:10 -08001905 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07001906 pConfig->dtim_period);
1907
1908
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08001909 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07001910 {
1911 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001912 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05301913 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
1914 {
1915 tANI_BOOLEAN restartNeeded;
1916 pConfig->ieee80211d = 1;
1917 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
1918 sme_setRegInfo(hHal, pConfig->countryCode);
1919 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
1920 }
1921 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001922 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07001923 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07001924 pConfig->ieee80211d = 1;
1925 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
1926 sme_setRegInfo(hHal, pConfig->countryCode);
1927 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07001928 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001929 else
1930 {
1931 pConfig->ieee80211d = 0;
1932 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301933 /*
1934 * If auto channel is configured i.e. channel is 0,
1935 * so skip channel validation.
1936 */
1937 if( AUTO_CHANNEL_SELECT != pConfig->channel )
1938 {
1939 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
1940 {
1941 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001942 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301943 return -EINVAL;
1944 }
1945 }
1946 else
1947 {
1948 if(1 != pHddCtx->is_dynamic_channel_range_set)
1949 {
1950 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
1951 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
1952 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
1953 }
1954 pHddCtx->is_dynamic_channel_range_set = 0;
1955 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001956 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001957 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001958 {
1959 pConfig->ieee80211d = 0;
1960 }
1961 pConfig->authType = eSAP_AUTO_SWITCH;
1962
1963 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301964
1965 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07001966 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
1967
1968 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
1969
1970 /*Set wps station to configured*/
1971 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
1972
1973 if(pIe)
1974 {
1975 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
1976 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001977 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07001978 return -EINVAL;
1979 }
1980 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
1981 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001982 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07001983 /* Check 15 bit of WPS IE as it contain information for wps state
1984 * WPS state
1985 */
1986 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
1987 {
1988 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
1989 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
1990 {
1991 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
1992 }
1993 }
1994 }
1995 else
1996 {
1997 pConfig->wps_state = SAP_WPS_DISABLED;
1998 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301999 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07002000
2001 pConfig->RSNWPAReqIELength = 0;
2002 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302003 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07002004 WLAN_EID_RSN);
2005 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302006 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002007 pConfig->RSNWPAReqIELength = pIe[1] + 2;
2008 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
2009 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302010 /* The actual processing may eventually be more extensive than
2011 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07002012 * by the app.
2013 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302014 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07002015 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
2016 &RSNEncryptType,
2017 &mcRSNEncryptType,
2018 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08002019 &MFPCapable,
2020 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07002021 pConfig->pRSNWPAReqIE[1]+2,
2022 pConfig->pRSNWPAReqIE );
2023
2024 if( VOS_STATUS_SUCCESS == status )
2025 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302026 /* Now copy over all the security attributes you have
2027 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 * */
2029 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
2030 pConfig->mcRSNEncryptType = mcRSNEncryptType;
2031 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
2032 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05302033 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002034 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002035 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
2036 }
2037 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302038
Jeff Johnson295189b2012-06-20 16:38:30 -07002039 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
2040 pBeacon->tail, pBeacon->tail_len);
2041
2042 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
2043 {
2044 if (pConfig->pRSNWPAReqIE)
2045 {
2046 /*Mixed mode WPA/WPA2*/
2047 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
2048 pConfig->RSNWPAReqIELength += pIe[1] + 2;
2049 }
2050 else
2051 {
2052 pConfig->RSNWPAReqIELength = pIe[1] + 2;
2053 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
2054 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302055 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07002056 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
2057 &RSNEncryptType,
2058 &mcRSNEncryptType,
2059 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08002060 &MFPCapable,
2061 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07002062 pConfig->pRSNWPAReqIE[1]+2,
2063 pConfig->pRSNWPAReqIE );
2064
2065 if( VOS_STATUS_SUCCESS == status )
2066 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302067 /* Now copy over all the security attributes you have
2068 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07002069 * */
2070 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
2071 pConfig->mcRSNEncryptType = mcRSNEncryptType;
2072 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
2073 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05302074 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002075 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002076 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
2077 }
2078 }
2079 }
2080
Jeff Johnson4416a782013-03-25 14:17:50 -07002081 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
2082 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
2083 return -EINVAL;
2084 }
2085
Jeff Johnson295189b2012-06-20 16:38:30 -07002086 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
2087
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002088#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002089 if (params->ssid != NULL)
2090 {
2091 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
2092 pConfig->SSIDinfo.ssid.length = params->ssid_len;
2093 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
2094 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
2095 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002096#else
2097 if (ssid != NULL)
2098 {
2099 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
2100 pConfig->SSIDinfo.ssid.length = ssid_len;
2101 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
2102 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
2103 }
2104#endif
2105
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302106 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07002107 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302108
Jeff Johnson295189b2012-06-20 16:38:30 -07002109 /* default value */
2110 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
2111 pConfig->num_accept_mac = 0;
2112 pConfig->num_deny_mac = 0;
2113
2114 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
2115 pBeacon->tail, pBeacon->tail_len);
2116
2117 /* pIe for black list is following form:
2118 type : 1 byte
2119 length : 1 byte
2120 OUI : 4 bytes
2121 acl type : 1 byte
2122 no of mac addr in black list: 1 byte
2123 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302124 */
2125 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002126 {
2127 pConfig->SapMacaddr_acl = pIe[6];
2128 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08002129 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002130 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302131 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
2132 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002133 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
2134 for (i = 0; i < pConfig->num_deny_mac; i++)
2135 {
2136 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
2137 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302138 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002139 }
2140 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
2141 pBeacon->tail, pBeacon->tail_len);
2142
2143 /* pIe for white list is following form:
2144 type : 1 byte
2145 length : 1 byte
2146 OUI : 4 bytes
2147 acl type : 1 byte
2148 no of mac addr in white list: 1 byte
2149 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302150 */
2151 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002152 {
2153 pConfig->SapMacaddr_acl = pIe[6];
2154 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08002155 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002156 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302157 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
2158 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
2160 for (i = 0; i < pConfig->num_accept_mac; i++)
2161 {
2162 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
2163 acl_entry++;
2164 }
2165 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302166
Jeff Johnson295189b2012-06-20 16:38:30 -07002167 wlan_hdd_set_sapHwmode(pHostapdAdapter);
2168
Jeff Johnsone7245742012-09-05 17:12:55 -07002169#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002170 /* Overwrite the hostapd setting for HW mode only for 11ac.
Kiet Lam0f320422013-11-21 19:29:17 +05302171 * This is valid only if mode is set to 11n in hostapd, either AUTO or
2172 * 11ac in .ini and 11ac is supported by both host and firmware.
2173 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
2174 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002175 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
2176 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Abhishek Singhf0ac1752014-03-05 17:47:09 +05302177 (( sapDot11Mode == eHDD_DOT11_MODE_AUTO ) ||
2178 ( sapDot11Mode == eHDD_DOT11_MODE_11ac ) ||
2179 ( sapDot11Mode == eHDD_DOT11_MODE_11ac_ONLY ) ) &&
2180 (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
2181 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07002182 {
2183 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07002184
2185 /* Disable VHT support in 2.4 GHz band */
2186 if (pConfig->channel <= 14 &&
2187 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->enableVhtFor24GHzBand == FALSE)
2188 {
2189 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
2190 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002191 }
2192#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302193
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07002194 if ( AUTO_CHANNEL_SELECT != pConfig->channel )
2195 {
2196 sme_SelectCBMode(hHal,
2197 sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode),
2198 pConfig->channel);
2199 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 // ht_capab is not what the name conveys,this is used for protection bitmap
2201 pConfig->ht_capab =
2202 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
2203
2204 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
2205 {
2206 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
2207 return -EINVAL;
2208 }
2209
2210 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302211 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07002212 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
2213 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302214 pConfig->obssProtEnabled =
2215 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07002216
Chet Lanctot8cecea22014-02-11 19:09:36 -08002217#ifdef WLAN_FEATURE_11W
2218 pConfig->mfpCapable = MFPCapable;
2219 pConfig->mfpRequired = MFPRequired;
2220 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
2221 pConfig->mfpCapable, pConfig->mfpRequired);
2222#endif
2223
Arif Hussain6d2a3322013-11-17 19:50:10 -08002224 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07002225 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08002226 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
2227 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
2228 (int)pConfig->channel);
2229 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
2230 pConfig->SapHw_mode, pConfig->privacy,
2231 pConfig->authType);
2232 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
2233 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
2234 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
2235 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07002236
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302237 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07002238 {
2239 //Bss already started. just return.
2240 //TODO Probably it should update some beacon params.
2241 hddLog( LOGE, "Bss Already started...Ignore the request");
2242 EXIT();
2243 return 0;
2244 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302245
Jeff Johnson295189b2012-06-20 16:38:30 -07002246 pConfig->persona = pHostapdAdapter->device_mode;
2247
2248 pSapEventCallback = hdd_hostapd_SAPEventCB;
2249 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
2250 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
2251 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002252 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 return -EINVAL;
2254 }
2255
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302256 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002257 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
2258
2259 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302260
Jeff Johnson295189b2012-06-20 16:38:30 -07002261 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302262 {
2263 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002264 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07002265 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002266 VOS_ASSERT(0);
2267 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302268
Jeff Johnson295189b2012-06-20 16:38:30 -07002269 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
2270
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002271#ifdef WLAN_FEATURE_P2P_DEBUG
2272 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
2273 {
2274 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
2275 {
2276 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2277 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002278 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002279 }
2280 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
2281 {
2282 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2283 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002284 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002285 }
2286 }
2287#endif
2288
Jeff Johnson295189b2012-06-20 16:38:30 -07002289 pHostapdState->bCommit = TRUE;
2290 EXIT();
2291
2292 return 0;
2293}
2294
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002295#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302296static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
2297 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002298 struct beacon_parameters *params)
2299{
2300 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302301 hdd_context_t *pHddCtx;
2302 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002303
2304 ENTER();
2305
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302306 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2307 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
2308 pAdapter->sessionId, params->interval));
Arif Hussain6d2a3322013-11-17 19:50:10 -08002309 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d",pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002310
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302311 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2312 status = wlan_hdd_validate_context(pHddCtx);
2313
2314 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002315 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302316 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2317 "%s: HDD context is not valid", __func__);
2318 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002319 }
2320
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302321 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002322 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002323 )
2324 {
2325 beacon_data_t *old,*new;
2326
2327 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302328
Jeff Johnson295189b2012-06-20 16:38:30 -07002329 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302330 {
2331 hddLog(VOS_TRACE_LEVEL_WARN,
2332 FL("already beacon info added to session(%d)"),
2333 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002334 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302335 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002336
2337 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2338
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302339 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002340 {
2341 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002342 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002343 return -EINVAL;
2344 }
2345
2346 pAdapter->sessionCtx.ap.beacon = new;
2347
2348 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2349 }
2350
2351 EXIT();
2352 return status;
2353}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302354
2355static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07002356 struct net_device *dev,
2357 struct beacon_parameters *params)
2358{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302359 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302360 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302361 hdd_context_t *pHddCtx;
2362 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002363
2364 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302365 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2366 TRACE_CODE_HDD_CFG80211_SET_BEACON,
2367 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
Arif Hussain6d2a3322013-11-17 19:50:10 -08002368 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002369 __func__,pAdapter->device_mode);
2370
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302371 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2372 status = wlan_hdd_validate_context(pHddCtx);
2373
2374 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002375 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302376 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2377 "%s: HDD context is not valid", __func__);
2378 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002379 }
2380
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302381 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002382 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302383 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002384 {
2385 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302386
Jeff Johnson295189b2012-06-20 16:38:30 -07002387 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302388
Jeff Johnson295189b2012-06-20 16:38:30 -07002389 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302390 {
2391 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2392 FL("session(%d) old and new heads points to NULL"),
2393 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002394 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302395 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002396
2397 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2398
2399 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302400 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002401 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002402 return -EINVAL;
2403 }
2404
2405 pAdapter->sessionCtx.ap.beacon = new;
2406
2407 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2408 }
2409
2410 EXIT();
2411 return status;
2412}
2413
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002414#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
2415
2416#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002417static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
2418 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002419#else
2420static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
2421 struct net_device *dev)
2422#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002423{
2424 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07002425 hdd_context_t *pHddCtx = NULL;
2426 hdd_scaninfo_t *pScanInfo = NULL;
2427 hdd_adapter_t *staAdapter = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302428 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002429
2430 ENTER();
2431
2432 if (NULL == pAdapter)
2433 {
2434 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002435 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002436 return -ENODEV;
2437 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002438
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302439 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2440 TRACE_CODE_HDD_CFG80211_STOP_AP,
2441 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302442 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2443 status = wlan_hdd_validate_context(pHddCtx);
2444
2445 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002446 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302447 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2448 "%s: HDD context is not valid", __func__);
2449 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07002450 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002451
2452 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
2453 if (NULL == staAdapter)
2454 {
2455 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
2456 if (NULL == staAdapter)
2457 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2459 "%s: HDD adapter context for STA/P2P-CLI is Null",
2460 __func__);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002461 }
2462 }
2463
2464 pScanInfo = &pHddCtx->scan_info;
2465
Arif Hussain6d2a3322013-11-17 19:50:10 -08002466 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002467 __func__,pAdapter->device_mode);
2468
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002469 if ((pScanInfo != NULL) && pScanInfo->mScanPending && staAdapter)
Jeff Johnsone7245742012-09-05 17:12:55 -07002470 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302471 long ret;
2472
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002473 INIT_COMPLETION(pScanInfo->abortscan_event_var);
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05302474 hdd_abort_mac_scan(staAdapter->pHddCtx, pAdapter->sessionId,
2475 eCSR_SCAN_ABORT_DEFAULT);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302476 ret = wait_for_completion_interruptible_timeout(
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002477 &pScanInfo->abortscan_event_var,
Jeff Johnsone7245742012-09-05 17:12:55 -07002478 msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302479 if (ret <= 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07002480 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002481 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302482 FL("Timeout occurred while waiting for abortscan %ld"),
2483 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08002484
2485 if (pHddCtx->isLogpInProgress)
2486 {
2487 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2488 "%s: LOGP in Progress. Ignore!!!", __func__);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302489
2490 VOS_ASSERT(pScanInfo->mScanPending);
Yue Ma4f55ef32014-01-23 16:45:33 -08002491 return -EAGAIN;
2492 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002493 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07002494 }
2495 }
2496
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05302497 hdd_hostapd_stop(dev);
2498
Jeff Johnson295189b2012-06-20 16:38:30 -07002499 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002500 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002501 )
2502 {
2503 beacon_data_t *old;
2504
2505 old = pAdapter->sessionCtx.ap.beacon;
2506
2507 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302508 {
2509 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2510 FL("session(%d) beacon data points to NULL"),
2511 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002512 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302513 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002514
Jeff Johnson295189b2012-06-20 16:38:30 -07002515 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002516
2517 mutex_lock(&pHddCtx->sap_lock);
2518 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
2519 {
Jeff Johnson4416a782013-03-25 14:17:50 -07002520 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002521 {
2522 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
2523
2524 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
2525
2526 if (!VOS_IS_STATUS_SUCCESS(status))
2527 {
2528 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002529 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002530 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302531 }
2532 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002533 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
2534 }
2535 mutex_unlock(&pHddCtx->sap_lock);
2536
2537 if(status != VOS_STATUS_SUCCESS)
2538 {
2539 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002540 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002541 return -EINVAL;
2542 }
2543
Jeff Johnson4416a782013-03-25 14:17:50 -07002544 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002545 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
2546 ==eHAL_STATUS_FAILURE)
2547 {
2548 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002549 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07002550 }
2551
Jeff Johnson4416a782013-03-25 14:17:50 -07002552 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002553 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
2554 eANI_BOOLEAN_FALSE) )
2555 {
2556 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002557 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07002558 }
2559
2560 // Reset WNI_CFG_PROBE_RSP Flags
2561 wlan_hdd_reset_prob_rspies(pAdapter);
2562
2563 pAdapter->sessionCtx.ap.beacon = NULL;
2564 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002565#ifdef WLAN_FEATURE_P2P_DEBUG
2566 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
2567 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
2568 {
2569 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
2570 "GO got removed");
2571 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
2572 }
2573#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 }
2575 EXIT();
2576 return status;
2577}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002578
2579#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2580
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302581static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
2582 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002583 struct cfg80211_ap_settings *params)
2584{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302585 hdd_adapter_t *pAdapter;
2586 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302587 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002588
2589 ENTER();
2590
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302591 if (NULL == dev)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002592 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302593 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302594 "%s: Device is Null", __func__);
2595 return -ENODEV;
2596 }
2597
2598 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2599 if (NULL == pAdapter)
2600 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302601 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302602 "%s: HDD adapter is Null", __func__);
2603 return -ENODEV;
2604 }
2605
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302606 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2607 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
2608 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302609 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
2610 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302611 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302612 "%s: HDD adapter magic is invalid", __func__);
2613 return -ENODEV;
2614 }
2615
2616 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302617 status = wlan_hdd_validate_context(pHddCtx);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302618
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302619 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302620 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302621 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2622 "%s: HDD context is not valid", __func__);
2623 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302624 }
2625
2626 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %d",
2627 __func__, pAdapter->device_mode);
2628
2629 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002630 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002631 )
2632 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302633 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002634
2635 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302636
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002637 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302638 {
2639 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2640 FL("already beacon info added to session(%d)"),
2641 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002642 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302643 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002644
2645 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, &params->beacon, params->dtim_period);
2646
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302647 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002648 {
2649 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302650 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002651 return -EINVAL;
2652 }
2653 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08002654#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07002655 wlan_hdd_cfg80211_set_channel(wiphy, dev,
2656#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
2657 params->channel, params->channel_type);
2658#else
2659 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
2660#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08002661#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002662 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
2663 params->ssid_len, params->hidden_ssid);
2664 }
2665
2666 EXIT();
2667 return status;
2668}
2669
2670
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302671static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002672 struct net_device *dev,
2673 struct cfg80211_beacon_data *params)
2674{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302675 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302676 hdd_context_t *pHddCtx;
2677 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002678
2679 ENTER();
2680
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302681 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2682 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
2683 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08002684 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002685 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302686
2687 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2688 status = wlan_hdd_validate_context(pHddCtx);
2689
2690 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002691 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302692 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2693 "%s: HDD context is not valid", __func__);
2694 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002695 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002696
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302697 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002698 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302699 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002700 {
2701 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302702
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002703 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302704
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002705 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302706 {
2707 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2708 FL("session(%d) beacon data points to NULL"),
2709 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002710 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302711 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002712
2713 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
2714
2715 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302716 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002717 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002718 return -EINVAL;
2719 }
2720
2721 pAdapter->sessionCtx.ap.beacon = new;
2722
2723 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
2724 }
2725
2726 EXIT();
2727 return status;
2728}
2729
2730#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2731
Jeff Johnson295189b2012-06-20 16:38:30 -07002732
2733static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
2734 struct net_device *dev,
2735 struct bss_parameters *params)
2736{
2737 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2738
2739 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302740
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302741 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2742 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
2743 pAdapter->sessionId, params->ap_isolate));
Arif Hussain6d2a3322013-11-17 19:50:10 -08002744 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002745 __func__,pAdapter->device_mode);
2746
2747 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002748 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302749 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002750 {
2751 /* ap_isolate == -1 means that in change bss, upper layer doesn't
2752 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302753 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07002754 {
2755 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302756 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002757 }
2758
2759 EXIT();
2760 return 0;
2761}
2762
Kiet Lam10841362013-11-01 11:36:50 +05302763/* FUNCTION: wlan_hdd_change_country_code_cd
2764* to wait for contry code completion
2765*/
2766void* wlan_hdd_change_country_code_cb(void *pAdapter)
2767{
2768 hdd_adapter_t *call_back_pAdapter = pAdapter;
2769 complete(&call_back_pAdapter->change_country_code);
2770 return NULL;
2771}
2772
Jeff Johnson295189b2012-06-20 16:38:30 -07002773/*
2774 * FUNCTION: wlan_hdd_cfg80211_change_iface
2775 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
2776 */
2777int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
2778 struct net_device *ndev,
2779 enum nl80211_iftype type,
2780 u32 *flags,
2781 struct vif_params *params
2782 )
2783{
2784 struct wireless_dev *wdev;
2785 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002786 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07002787 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002788 tCsrRoamProfile *pRoamProfile = NULL;
2789 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302790 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002791 eMib_dot11DesiredBssType connectedBssType;
2792 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302793 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002794
2795 ENTER();
2796
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302797 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002798 {
2799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2800 "%s: Adapter context is null", __func__);
2801 return VOS_STATUS_E_FAILURE;
2802 }
2803
2804 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2805 if (!pHddCtx)
2806 {
2807 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2808 "%s: HDD context is null", __func__);
2809 return VOS_STATUS_E_FAILURE;
2810 }
2811
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302812 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2813 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
2814 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302815 status = wlan_hdd_validate_context(pHddCtx);
2816
2817 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002818 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302819 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2820 "%s: HDD context is not valid", __func__);
2821 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002822 }
2823
2824 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
2825 __func__, pAdapter->device_mode);
2826
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302827 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07002828 wdev = ndev->ieee80211_ptr;
2829
2830#ifdef WLAN_BTAMP_FEATURE
2831 if((NL80211_IFTYPE_P2P_CLIENT == type)||
2832 (NL80211_IFTYPE_ADHOC == type)||
2833 (NL80211_IFTYPE_AP == type)||
2834 (NL80211_IFTYPE_P2P_GO == type))
2835 {
2836 pHddCtx->isAmpAllowed = VOS_FALSE;
2837 // stop AMP traffic
2838 status = WLANBAP_StopAmp();
2839 if(VOS_STATUS_SUCCESS != status )
2840 {
2841 pHddCtx->isAmpAllowed = VOS_TRUE;
2842 hddLog(VOS_TRACE_LEVEL_FATAL,
2843 "%s: Failed to stop AMP", __func__);
2844 return -EINVAL;
2845 }
2846 }
2847#endif //WLAN_BTAMP_FEATURE
2848 /* Reset the current device mode bit mask*/
2849 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
2850
2851 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07002852 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07002853 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002854 )
2855 {
2856 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002857 if (!pWextState)
2858 {
2859 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2860 "%s: pWextState is null", __func__);
2861 return VOS_STATUS_E_FAILURE;
2862 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002863 pRoamProfile = &pWextState->roamProfile;
2864 LastBSSType = pRoamProfile->BSSType;
2865
2866 switch (type)
2867 {
2868 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002869 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002870 hddLog(VOS_TRACE_LEVEL_INFO,
2871 "%s: setting interface Type to INFRASTRUCTURE", __func__);
2872 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002873#ifdef WLAN_FEATURE_11AC
2874 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
2875 {
2876 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
2877 }
2878#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302879 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07002880 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002881 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002882 //Check for sub-string p2p to confirm its a p2p interface
2883 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302884 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002885 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2886 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2887 }
2888 else
2889 {
2890 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002891 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002892 }
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05302893#ifdef FEATURE_WLAN_TDLS
2894 /* The open adapter for the p2p shall skip initializations in
2895 * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for
2896 * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke
2897 * tdls_init when the change_iface sets the device mode to
2898 * WLAN_HDD_P2P_CLIENT.
2899 */
2900
2901 if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2902 {
2903 if (0 != wlan_hdd_tdls_init (pAdapter))
2904 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302905 hddLog(VOS_TRACE_LEVEL_ERROR,
2906 "%s: tdls initialization failed", __func__);
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05302907 return -EINVAL;
2908 }
2909 }
2910#endif
2911
Jeff Johnson295189b2012-06-20 16:38:30 -07002912 break;
2913 case NL80211_IFTYPE_ADHOC:
2914 hddLog(VOS_TRACE_LEVEL_INFO,
2915 "%s: setting interface Type to ADHOC", __func__);
2916 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2917 pRoamProfile->phyMode =
2918 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002919 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002920 wdev->iftype = type;
2921 break;
2922
2923 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002924 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002925 {
2926 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2927 "%s: setting interface Type to %s", __func__,
2928 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
2929
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002930 //Cancel any remain on channel for GO mode
2931 if (NL80211_IFTYPE_P2P_GO == type)
2932 {
2933 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
2934 }
Mohit Khanna0f232092012-09-11 14:46:08 -07002935 if (NL80211_IFTYPE_AP == type)
2936 {
2937 /* As Loading WLAN Driver one interface being created for p2p device
2938 * address. This will take one HW STA and the max number of clients
2939 * that can connect to softAP will be reduced by one. so while changing
2940 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
2941 * interface as it is not required in SoftAP mode.
2942 */
2943
2944 // Get P2P Adapter
2945 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
2946
2947 if (pP2pAdapter)
2948 {
2949 hdd_stop_adapter(pHddCtx, pP2pAdapter);
2950 hdd_deinit_adapter(pHddCtx, pP2pAdapter);
2951 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
2952 }
2953 }
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302954#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07002955
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302956 /* A Mutex Lock is introduced while changing the mode to
2957 * protect the concurrent access for the Adapters by TDLS
2958 * module.
2959 */
2960 if (mutex_lock_interruptible(&pHddCtx->tdls_lock))
2961 {
2962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2963 "%s: unable to lock list", __func__);
2964 return -EINVAL;
2965 }
2966#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002967 //De-init the adapter.
2968 hdd_stop_adapter( pHddCtx, pAdapter );
2969 hdd_deinit_adapter( pHddCtx, pAdapter );
2970 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07002971 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2972 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302973#ifdef FEATURE_WLAN_TDLS
2974 mutex_unlock(&pHddCtx->tdls_lock);
2975#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07002976
2977 //Disable BMPS and IMPS if enabled
2978 //before starting Go
2979 if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
2980 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302981 if(VOS_STATUS_E_FAILURE ==
Jeff Johnson32d95a32012-09-10 13:15:23 -07002982 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
2983 {
2984 //Fail to Exit BMPS
2985 VOS_ASSERT(0);
2986 }
2987 }
2988
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07002989 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
2990 (pConfig->apRandomBssidEnabled))
2991 {
2992 /* To meet Android requirements create a randomized
2993 MAC address of the form 02:1A:11:Fx:xx:xx */
2994 get_random_bytes(&ndev->dev_addr[3], 3);
2995 ndev->dev_addr[0] = 0x02;
2996 ndev->dev_addr[1] = 0x1A;
2997 ndev->dev_addr[2] = 0x11;
2998 ndev->dev_addr[3] |= 0xF0;
2999 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
3000 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08003001 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
3002 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07003003 }
3004
Jeff Johnson295189b2012-06-20 16:38:30 -07003005 hdd_set_ap_ops( pAdapter->dev );
3006
Kiet Lam10841362013-11-01 11:36:50 +05303007 /* This is for only SAP mode where users can
3008 * control country through ini.
3009 * P2P GO follows station country code
3010 * acquired during the STA scanning. */
3011 if((NL80211_IFTYPE_AP == type) &&
3012 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
3013 {
3014 int status = 0;
3015 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
3016 "%s: setting country code from INI ", __func__);
3017 init_completion(&pAdapter->change_country_code);
3018 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
3019 (void *)(tSmeChangeCountryCallback)
3020 wlan_hdd_change_country_code_cb,
3021 pConfig->apCntryCode, pAdapter,
3022 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05303023 eSIR_FALSE,
3024 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05303025 if (eHAL_STATUS_SUCCESS == status)
3026 {
3027 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303028 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05303029 &pAdapter->change_country_code,
3030 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303031 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05303032 {
3033 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303034 FL("SME Timed out while setting country code %ld"),
3035 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08003036
3037 if (pHddCtx->isLogpInProgress)
3038 {
3039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3040 "%s: LOGP in Progress. Ignore!!!", __func__);
3041 return -EAGAIN;
3042 }
Kiet Lam10841362013-11-01 11:36:50 +05303043 }
3044 }
3045 else
3046 {
3047 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003048 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05303049 return -EINVAL;
3050 }
3051 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003052 status = hdd_init_ap_mode(pAdapter);
3053 if(status != VOS_STATUS_SUCCESS)
3054 {
3055 hddLog(VOS_TRACE_LEVEL_FATAL,
3056 "%s: Error initializing the ap mode", __func__);
3057 return -EINVAL;
3058 }
3059 hdd_set_conparam(1);
3060
Jeff Johnson295189b2012-06-20 16:38:30 -07003061 /*interface type changed update in wiphy structure*/
3062 if(wdev)
3063 {
3064 wdev->iftype = type;
3065 pHddCtx->change_iface = type;
3066 }
3067 else
3068 {
3069 hddLog(VOS_TRACE_LEVEL_ERROR,
3070 "%s: ERROR !!!! Wireless dev is NULL", __func__);
3071 return -EINVAL;
3072 }
3073 goto done;
3074 }
3075
3076 default:
3077 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
3078 __func__);
3079 return -EOPNOTSUPP;
3080 }
3081 }
3082 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07003083 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07003084 )
3085 {
3086 switch(type)
3087 {
3088 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07003089 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07003090 case NL80211_IFTYPE_ADHOC:
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303091#ifdef FEATURE_WLAN_TDLS
3092
3093 /* A Mutex Lock is introduced while changing the mode to
3094 * protect the concurrent access for the Adapters by TDLS
3095 * module.
3096 */
3097 if (mutex_lock_interruptible(&pHddCtx->tdls_lock))
3098 {
3099 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3100 "%s: unable to lock list", __func__);
3101 return -EINVAL;
3102 }
3103#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07003104 hdd_stop_adapter( pHddCtx, pAdapter );
3105 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07003106 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08003107 //Check for sub-string p2p to confirm its a p2p interface
3108 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08003109 {
3110 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
3111 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
3112 }
3113 else
3114 {
3115 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07003116 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08003117 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003118 hdd_set_conparam(0);
3119 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07003120 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
3121 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303122#ifdef FEATURE_WLAN_TDLS
3123 mutex_unlock(&pHddCtx->tdls_lock);
3124#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05303125 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07003126 if( VOS_STATUS_SUCCESS != status )
3127 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07003128 /* In case of JB, for P2P-GO, only change interface will be called,
3129 * This is the right place to enable back bmps_imps()
3130 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05303131 if (pHddCtx->hdd_wlan_suspended)
3132 {
3133 hdd_set_pwrparams(pHddCtx);
3134 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003135 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07003136 goto done;
3137 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07003138 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07003139 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07003140 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
3141 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003142 goto done;
3143 default:
3144 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
3145 __func__);
3146 return -EOPNOTSUPP;
3147
3148 }
3149
3150 }
3151 else
3152 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303153 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%d)",
3154 __func__, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003155 return -EOPNOTSUPP;
3156 }
3157
3158
3159 if(pRoamProfile)
3160 {
3161 if ( LastBSSType != pRoamProfile->BSSType )
3162 {
3163 /*interface type changed update in wiphy structure*/
3164 wdev->iftype = type;
3165
3166 /*the BSS mode changed, We need to issue disconnect
3167 if connected or in IBSS disconnect state*/
3168 if ( hdd_connGetConnectedBssType(
3169 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
3170 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
3171 {
3172 /*need to issue a disconnect to CSR.*/
3173 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3174 if( eHAL_STATUS_SUCCESS ==
3175 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
3176 pAdapter->sessionId,
3177 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
3178 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303179 ret = wait_for_completion_interruptible_timeout(
3180 &pAdapter->disconnect_comp_var,
3181 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3182 if (ret <= 0)
3183 {
3184 hddLog(VOS_TRACE_LEVEL_ERROR,
3185 FL("wait on disconnect_comp_var failed %ld"), ret);
3186 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003187 }
3188 }
3189 }
3190 }
3191
3192done:
3193 /*set bitmask based on updated value*/
3194 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07003195
3196 /* Only STA mode support TM now
3197 * all other mode, TM feature should be disabled */
3198 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
3199 (~VOS_STA & pHddCtx->concurrency_mode) )
3200 {
3201 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
3202 }
3203
Jeff Johnson295189b2012-06-20 16:38:30 -07003204#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303205 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003206 (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
3207 {
3208 //we are ok to do AMP
3209 pHddCtx->isAmpAllowed = VOS_TRUE;
3210 }
3211#endif //WLAN_BTAMP_FEATURE
3212 EXIT();
3213 return 0;
3214}
3215
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003216#ifdef FEATURE_WLAN_TDLS
3217static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
3218 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
3219{
3220 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3221 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3222 VOS_STATUS status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003223 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303224 long ret;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003225
3226 ENTER();
3227
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303228 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003229 {
3230 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3231 "Invalid arguments");
3232 return -EINVAL;
3233 }
Hoonki Lee27511902013-03-14 18:19:06 -07003234
3235 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
3236 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
3237 {
3238 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3239 "%s: TDLS mode is disabled OR not enabled in FW."
3240 MAC_ADDRESS_STR " Request declined.",
3241 __func__, MAC_ADDR_ARRAY(mac));
3242 return -ENOTSUPP;
3243 }
3244
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003245 if (pHddCtx->isLogpInProgress)
3246 {
3247 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3248 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07003249 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003250 return -EBUSY;
3251 }
3252
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05303253 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003254
3255 if ( NULL == pTdlsPeer ) {
3256 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3257 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
3258 __func__, MAC_ADDR_ARRAY(mac), update);
3259 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003260 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003261
3262 /* in add station, we accept existing valid staId if there is */
3263 if ((0 == update) &&
3264 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
3265 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003266 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003267 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003268 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003269 " link_status %d. staId %d. add station ignored.",
3270 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
3271 return 0;
3272 }
3273 /* in change station, we accept only when staId is valid */
3274 if ((1 == update) &&
3275 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
3276 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
3277 {
3278 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3279 "%s: " MAC_ADDRESS_STR
3280 " link status %d. staId %d. change station %s.",
3281 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
3282 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
3283 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003284 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003285
3286 /* when others are on-going, we want to change link_status to idle */
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303287 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003288 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003289 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3290 "%s: " MAC_ADDRESS_STR
3291 " TDLS setup is ongoing. Request declined.",
3292 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07003293 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003294 }
3295
3296 /* first to check if we reached to maximum supported TDLS peer.
3297 TODO: for now, return -EPERM looks working fine,
3298 but need to check if any other errno fit into this category.*/
3299 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
3300 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003301 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3302 "%s: " MAC_ADDRESS_STR
3303 " TDLS Max peer already connected. Request declined.",
3304 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07003305 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003306 }
3307 else
3308 {
3309 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303310 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003311 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003312 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003313 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3314 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
3315 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003316 return -EPERM;
3317 }
3318 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003319 if (0 == update)
3320 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003321
Jeff Johnsond75fe012013-04-06 10:53:06 -07003322 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303323 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003324 {
3325 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3326 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003327 if(StaParams->htcap_present)
3328 {
3329 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3330 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
3331 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3332 "ht_capa->extended_capabilities: %0x",
3333 StaParams->HTCap.extendedHtCapInfo);
3334 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003335 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3336 "params->capability: %0x",StaParams->capability);
3337 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003338 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003339 if(StaParams->vhtcap_present)
3340 {
3341 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3342 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
3343 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
3344 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
3345 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003346 {
3347 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003348 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003349 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
3350 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3351 "[%d]: %x ", i, StaParams->supported_rates[i]);
3352 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07003353 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303354 else if ((1 == update) && (NULL == StaParams))
3355 {
3356 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3357 "%s : update is true, but staParams is NULL. Error!", __func__);
3358 return -EPERM;
3359 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003360
3361 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
3362
3363 if (!update)
3364 {
3365 status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3366 pAdapter->sessionId, mac);
3367 }
3368 else
3369 {
3370 status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3371 pAdapter->sessionId, mac, StaParams);
3372 }
3373
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303374 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003375 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
3376
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303377 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003378 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003379 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303380 "%s: timeout waiting for tdls add station indication %ld",
3381 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003382 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003383 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303384
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003385 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
3386 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003387 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003388 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003389 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003390 }
3391
3392 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07003393
3394error:
3395 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
3396 return -EPERM;
3397
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003398}
3399#endif
3400
Jeff Johnson295189b2012-06-20 16:38:30 -07003401static int wlan_hdd_change_station(struct wiphy *wiphy,
3402 struct net_device *dev,
3403 u8 *mac,
3404 struct station_parameters *params)
3405{
3406 VOS_STATUS status = VOS_STATUS_SUCCESS;
3407 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkala29149562013-05-10 21:43:41 +05303408 hdd_context_t *pHddCtx;
3409 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 v_MACADDR_t STAMacAddress;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003411#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003412 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003413 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05303414 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003415#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003416 ENTER();
3417
Gopichand Nakkala29149562013-05-10 21:43:41 +05303418 if ((NULL == pAdapter))
3419 {
3420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3421 "invalid adapter ");
3422 return -EINVAL;
3423 }
3424
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303425 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
3426 TRACE_CODE_HDD_CHANGE_STATION,
3427 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05303428 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3429 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3430
3431 if ((NULL == pHddCtx) || (NULL == pHddStaCtx))
3432 {
3433 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3434 "invalid HDD state or HDD station context");
3435 return -EINVAL;
3436 }
3437
3438 if (pHddCtx->isLogpInProgress)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003439 {
3440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3441 "%s:LOGP in Progress. Ignore!!!", __func__);
3442 return -EAGAIN;
3443 }
3444
Jeff Johnson295189b2012-06-20 16:38:30 -07003445 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
3446
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003447 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
3448 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07003449 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003450 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07003451 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303452 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07003453 WLANTL_STA_AUTHENTICATED);
3454
Gopichand Nakkala29149562013-05-10 21:43:41 +05303455 if (status != VOS_STATUS_SUCCESS)
3456 {
3457 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3458 "%s: Not able to change TL state to AUTHENTICATED", __func__);
3459 return -EINVAL;
3460 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003461 }
3462 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07003463 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
3464 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303465#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003466 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
3467 StaParams.capability = params->capability;
3468 StaParams.uapsd_queues = params->uapsd_queues;
3469 StaParams.max_sp = params->max_sp;
3470
Naresh Jayaram3180aa42014-02-12 21:47:26 +05303471 /* Convert (first channel , number of channels) tuple to
3472 * the total list of channels. This goes with the assumption
3473 * that if the first channel is < 14, then the next channels
3474 * are an incremental of 1 else an incremental of 4 till the number
3475 * of channels.
3476 */
3477 if (0 != params->supported_channels_len) {
3478 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
3479 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
3480 {
3481 int wifi_chan_index;
3482 StaParams.supported_channels[j] = params->supported_channels[i];
3483 wifi_chan_index =
3484 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
3485 no_of_channels = params->supported_channels[i+1];
3486 for(k=1; k <= no_of_channels; k++)
3487 {
3488 StaParams.supported_channels[j+1] =
3489 StaParams.supported_channels[j] + wifi_chan_index;
3490 j+=1;
3491 }
3492 }
3493 StaParams.supported_channels_len = j;
3494 }
3495 vos_mem_copy(StaParams.supported_oper_classes,
3496 params->supported_oper_classes,
3497 params->supported_oper_classes_len);
3498 StaParams.supported_oper_classes_len =
3499 params->supported_oper_classes_len;
3500
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003501 if (0 != params->ext_capab_len)
3502 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
3503 sizeof(StaParams.extn_capability));
3504
3505 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003506 {
3507 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003508 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003509 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003510
3511 StaParams.supported_rates_len = params->supported_rates_len;
3512
3513 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
3514 * The supported_rates array , for all the structures propogating till Add Sta
3515 * to the firmware has to be modified , if the supplicant (ieee80211) is
3516 * modified to send more rates.
3517 */
3518
3519 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
3520 */
3521 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
3522 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
3523
3524 if (0 != StaParams.supported_rates_len) {
3525 int i = 0;
3526 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
3527 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003528 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003529 "Supported Rates with Length %d", StaParams.supported_rates_len);
3530 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003531 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003532 "[%d]: %0x", i, StaParams.supported_rates[i]);
3533 }
3534
3535 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003536 {
3537 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003538 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003539 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003540
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003541 if (0 != params->ext_capab_len ) {
3542 /*Define A Macro : TODO Sunil*/
3543 if ((1<<4) & StaParams.extn_capability[3]) {
3544 isBufSta = 1;
3545 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05303546 /* TDLS Channel Switching Support */
3547 if ((1<<6) & StaParams.extn_capability[3]) {
3548 isOffChannelSupported = 1;
3549 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003550 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05303551 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
3552 &StaParams, isBufSta,
3553 isOffChannelSupported);
3554
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303555 if (VOS_STATUS_SUCCESS != status) {
3556 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3557 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
3558 return -EINVAL;
3559 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003560 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
3561
3562 if (VOS_STATUS_SUCCESS != status) {
3563 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3564 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
3565 return -EINVAL;
3566 }
3567 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003568#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05303569 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003570 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003571 return status;
3572}
3573
3574/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003575 * FUNCTION: wlan_hdd_cfg80211_add_key
3576 * This function is used to initialize the key information
3577 */
3578#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003579static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003580 struct net_device *ndev,
3581 u8 key_index, bool pairwise,
3582 const u8 *mac_addr,
3583 struct key_params *params
3584 )
3585#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003586static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003587 struct net_device *ndev,
3588 u8 key_index, const u8 *mac_addr,
3589 struct key_params *params
3590 )
3591#endif
3592{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003593 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003594 tCsrRoamSetKey setKey;
3595 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303596 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003597 v_U32_t roamId= 0xFF;
3598 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003599 hdd_hostapd_state_t *pHostapdState;
3600 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003601 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303602 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003603
3604 ENTER();
3605
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303606 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
3607 TRACE_CODE_HDD_CFG80211_ADD_KEY,
3608 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303609 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3610 status = wlan_hdd_validate_context(pHddCtx);
3611
3612 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003613 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303614 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3615 "%s: HDD context is not valid", __func__);
3616 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003617 }
3618
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003619 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
3620 __func__, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003621
3622 if (CSR_MAX_NUM_KEY <= key_index)
3623 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003624 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003625 key_index);
3626
3627 return -EINVAL;
3628 }
3629
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003630 if (CSR_MAX_KEY_LEN < params->key_len)
3631 {
3632 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
3633 params->key_len);
3634
3635 return -EINVAL;
3636 }
3637
3638 hddLog(VOS_TRACE_LEVEL_INFO,
3639 "%s: called with key index = %d & key length %d",
3640 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003641
3642 /*extract key idx, key len and key*/
3643 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3644 setKey.keyId = key_index;
3645 setKey.keyLength = params->key_len;
3646 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
3647
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003648 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 {
3650 case WLAN_CIPHER_SUITE_WEP40:
3651 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3652 break;
3653
3654 case WLAN_CIPHER_SUITE_WEP104:
3655 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3656 break;
3657
3658 case WLAN_CIPHER_SUITE_TKIP:
3659 {
3660 u8 *pKey = &setKey.Key[0];
3661 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3662
3663 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3664
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003665 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07003666
3667 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003668 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003669 |--------------|----------|----------|
3670 <---16bytes---><--8bytes--><--8bytes-->
3671
3672 */
3673 /*Sme expects the 32 bytes key to be in the below order
3674
3675 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003676 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003677 |--------------|----------|----------|
3678 <---16bytes---><--8bytes--><--8bytes-->
3679 */
3680 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003681 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07003682
3683 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003684 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003685
3686 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003687 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003688
3689
3690 break;
3691 }
3692
3693 case WLAN_CIPHER_SUITE_CCMP:
3694 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3695 break;
3696
3697#ifdef FEATURE_WLAN_WAPI
3698 case WLAN_CIPHER_SUITE_SMS4:
3699 {
3700 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3701 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
3702 params->key, params->key_len);
3703 return 0;
3704 }
3705#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003706
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003707#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003708 case WLAN_CIPHER_SUITE_KRK:
3709 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3710 break;
3711#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003712
3713#ifdef WLAN_FEATURE_11W
3714 case WLAN_CIPHER_SUITE_AES_CMAC:
3715 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07003716 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07003717#endif
3718
Jeff Johnson295189b2012-06-20 16:38:30 -07003719 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003720 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07003721 __func__, params->cipher);
3722 return -EOPNOTSUPP;
3723 }
3724
3725 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
3726 __func__, setKey.encType);
3727
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003728 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07003729#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3730 (!pairwise)
3731#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003732 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07003733#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003734 )
3735 {
3736 /* set group key*/
3737 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3738 "%s- %d: setting Broadcast key",
3739 __func__, __LINE__);
3740 setKey.keyDirection = eSIR_RX_ONLY;
3741 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3742 }
3743 else
3744 {
3745 /* set pairwise key*/
3746 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3747 "%s- %d: setting pairwise key",
3748 __func__, __LINE__);
3749 setKey.keyDirection = eSIR_TX_RX;
3750 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3751 }
3752 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
3753 {
3754 setKey.keyDirection = eSIR_TX_RX;
3755 /*Set the group key*/
3756 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3757 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003758
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003759 if ( 0 != status )
3760 {
3761 hddLog(VOS_TRACE_LEVEL_ERROR,
3762 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3763 return -EINVAL;
3764 }
3765 /*Save the keys here and call sme_RoamSetKey for setting
3766 the PTK after peer joins the IBSS network*/
3767 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
3768 &setKey, sizeof(tCsrRoamSetKey));
3769 return status;
3770 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05303771 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
3772 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
3773 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003774 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003775 if( pHostapdState->bssState == BSS_START )
3776 {
c_hpothu7c55da62014-01-23 18:34:02 +05303777 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3778 vos_status = wlan_hdd_check_ula_done(pAdapter);
3779
3780 if ( vos_status != VOS_STATUS_SUCCESS )
3781 {
3782 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3783 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3784 __LINE__, vos_status );
3785
3786 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3787
3788 return -EINVAL;
3789 }
3790
Jeff Johnson295189b2012-06-20 16:38:30 -07003791 status = WLANSAP_SetKeySta( pVosContext, &setKey);
3792
3793 if ( status != eHAL_STATUS_SUCCESS )
3794 {
3795 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3796 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3797 __LINE__, status );
3798 }
3799 }
3800
3801 /* Saving WEP keys */
3802 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
3803 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
3804 {
3805 //Save the wep key in ap context. Issue setkey after the BSS is started.
3806 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3807 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
3808 }
3809 else
3810 {
3811 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003812 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003813 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
3814 }
3815 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003816 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
3817 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003818 {
3819 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3820 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3821
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303822#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3823 if (!pairwise)
3824#else
3825 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
3826#endif
3827 {
3828 /* set group key*/
3829 if (pHddStaCtx->roam_info.deferKeyComplete)
3830 {
3831 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3832 "%s- %d: Perform Set key Complete",
3833 __func__, __LINE__);
3834 hdd_PerformRoamSetKeyComplete(pAdapter);
3835 }
3836 }
3837
Jeff Johnson295189b2012-06-20 16:38:30 -07003838 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
3839
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08003840 pWextState->roamProfile.Keys.defaultIndex = key_index;
3841
3842
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003843 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003844 params->key, params->key_len);
3845
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303846
Jeff Johnson295189b2012-06-20 16:38:30 -07003847 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3848
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303849 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003850 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303851 __func__, setKey.peerMac[0], setKey.peerMac[1],
3852 setKey.peerMac[2], setKey.peerMac[3],
3853 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003854 setKey.keyDirection);
3855
3856 vos_status = wlan_hdd_check_ula_done(pAdapter);
3857
3858 if ( vos_status != VOS_STATUS_SUCCESS )
3859 {
3860 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3861 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3862 __LINE__, vos_status );
3863
3864 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3865
3866 return -EINVAL;
3867
3868 }
3869
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003870#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303871 /* The supplicant may attempt to set the PTK once pre-authentication
3872 is done. Save the key in the UMAC and include it in the ADD BSS
3873 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003874 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303875 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003876 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303877 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3878 "%s: Update PreAuth Key success", __func__);
3879 return 0;
3880 }
3881 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3882 {
3883 hddLog(VOS_TRACE_LEVEL_ERROR,
3884 "%s: Update PreAuth Key failed", __func__);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05303885 return -EINVAL;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003886 }
3887#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07003888
3889 /* issue set key request to SME*/
3890 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3891 pAdapter->sessionId, &setKey, &roamId );
3892
3893 if ( 0 != status )
3894 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303895 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003896 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3897 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3898 return -EINVAL;
3899 }
3900
3901
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303902 /* in case of IBSS as there was no information available about WEP keys during
3903 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07003904 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303905 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
3906 !( ( IW_AUTH_KEY_MGMT_802_1X
3907 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003908 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
3909 )
3910 &&
3911 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
3912 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
3913 )
3914 )
3915 {
3916 setKey.keyDirection = eSIR_RX_ONLY;
3917 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3918
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303919 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003920 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303921 __func__, setKey.peerMac[0], setKey.peerMac[1],
3922 setKey.peerMac[2], setKey.peerMac[3],
3923 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003924 setKey.keyDirection);
3925
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303926 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003927 pAdapter->sessionId, &setKey, &roamId );
3928
3929 if ( 0 != status )
3930 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303931 hddLog(VOS_TRACE_LEVEL_ERROR,
3932 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003933 __func__, status);
3934 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3935 return -EINVAL;
3936 }
3937 }
3938 }
3939
3940 return 0;
3941}
3942
3943/*
3944 * FUNCTION: wlan_hdd_cfg80211_get_key
3945 * This function is used to get the key information
3946 */
3947#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303948static int wlan_hdd_cfg80211_get_key(
3949 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003950 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303951 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003952 const u8 *mac_addr, void *cookie,
3953 void (*callback)(void *cookie, struct key_params*)
3954 )
3955#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303956static int wlan_hdd_cfg80211_get_key(
3957 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003958 struct net_device *ndev,
3959 u8 key_index, const u8 *mac_addr, void *cookie,
3960 void (*callback)(void *cookie, struct key_params*)
3961 )
3962#endif
3963{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303964 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003965 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3966 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3967 struct key_params params;
3968
3969 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303970
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303971 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
3972 TRACE_CODE_HDD_CFG80211_GET_KEY,
3973 pAdapter->sessionId, params.cipher));
Arif Hussain6d2a3322013-11-17 19:50:10 -08003974 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003975 __func__,pAdapter->device_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303976
Jeff Johnson295189b2012-06-20 16:38:30 -07003977 memset(&params, 0, sizeof(params));
3978
3979 if (CSR_MAX_NUM_KEY <= key_index)
3980 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303981 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07003982 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303983 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003984
3985 switch(pRoamProfile->EncryptionType.encryptionType[0])
3986 {
3987 case eCSR_ENCRYPT_TYPE_NONE:
3988 params.cipher = IW_AUTH_CIPHER_NONE;
3989 break;
3990
3991 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3992 case eCSR_ENCRYPT_TYPE_WEP40:
3993 params.cipher = WLAN_CIPHER_SUITE_WEP40;
3994 break;
3995
3996 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3997 case eCSR_ENCRYPT_TYPE_WEP104:
3998 params.cipher = WLAN_CIPHER_SUITE_WEP104;
3999 break;
4000
4001 case eCSR_ENCRYPT_TYPE_TKIP:
4002 params.cipher = WLAN_CIPHER_SUITE_TKIP;
4003 break;
4004
4005 case eCSR_ENCRYPT_TYPE_AES:
4006 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
4007 break;
4008
4009 default:
4010 params.cipher = IW_AUTH_CIPHER_NONE;
4011 break;
4012 }
4013
4014 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
4015 params.seq_len = 0;
4016 params.seq = NULL;
4017 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
4018 callback(cookie, &params);
4019 return 0;
4020}
4021
4022/*
4023 * FUNCTION: wlan_hdd_cfg80211_del_key
4024 * This function is used to delete the key information
4025 */
4026#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304027static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004028 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304029 u8 key_index,
4030 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07004031 const u8 *mac_addr
4032 )
4033#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304034static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004035 struct net_device *ndev,
4036 u8 key_index,
4037 const u8 *mac_addr
4038 )
4039#endif
4040{
4041 int status = 0;
4042
4043 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304044 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 //it is observed that this is invalidating peer
4046 //key index whenever re-key is done. This is affecting data link.
4047 //It should be ok to ignore del_key.
4048#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304049 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
4050 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004051 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4052 tCsrRoamSetKey setKey;
4053 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304054
Jeff Johnson295189b2012-06-20 16:38:30 -07004055 ENTER();
4056
4057 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
4058 __func__,pAdapter->device_mode);
4059
4060 if (CSR_MAX_NUM_KEY <= key_index)
4061 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304062 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004063 key_index);
4064
4065 return -EINVAL;
4066 }
4067
4068 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4069 setKey.keyId = key_index;
4070
4071 if (mac_addr)
4072 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
4073 else
4074 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
4075
4076 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4077
4078 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07004079 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304080 )
4081 {
4082
4083 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07004084 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
4085 if( pHostapdState->bssState == BSS_START)
4086 {
4087 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304088
Jeff Johnson295189b2012-06-20 16:38:30 -07004089 if ( status != eHAL_STATUS_SUCCESS )
4090 {
4091 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4092 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
4093 __LINE__, status );
4094 }
4095 }
4096 }
4097 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304098 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07004099 )
4100 {
4101 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4102
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304103 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
4104
4105 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304107 __func__, setKey.peerMac[0], setKey.peerMac[1],
4108 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07004109 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304110 if(pAdapter->sessionCtx.station.conn_info.connState ==
4111 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07004112 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304113 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07004114 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304115
Jeff Johnson295189b2012-06-20 16:38:30 -07004116 if ( 0 != status )
4117 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304118 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004119 "%s: sme_RoamSetKey failure, returned %d",
4120 __func__, status);
4121 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4122 return -EINVAL;
4123 }
4124 }
4125 }
4126#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07004127 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004128 return status;
4129}
4130
4131/*
4132 * FUNCTION: wlan_hdd_cfg80211_set_default_key
4133 * This function is used to set the default tx key index
4134 */
4135#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
4136static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
4137 struct net_device *ndev,
4138 u8 key_index,
4139 bool unicast, bool multicast)
4140#else
4141static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
4142 struct net_device *ndev,
4143 u8 key_index)
4144#endif
4145{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304146 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304147 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05304148 hdd_wext_state_t *pWextState;
4149 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304150 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004151
4152 ENTER();
4153
Gopichand Nakkala29149562013-05-10 21:43:41 +05304154 if ((NULL == pAdapter))
4155 {
4156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4157 "invalid adapter");
4158 return -EINVAL;
4159 }
4160
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304161 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
4162 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
4163 pAdapter->sessionId, key_index));
4164
Gopichand Nakkala29149562013-05-10 21:43:41 +05304165 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4166 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4167
4168 if ((NULL == pWextState) || (NULL == pHddStaCtx))
4169 {
4170 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4171 "invalid Wext state or HDD context");
4172 return -EINVAL;
4173 }
4174
Arif Hussain6d2a3322013-11-17 19:50:10 -08004175 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004176 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304177
Jeff Johnson295189b2012-06-20 16:38:30 -07004178 if (CSR_MAX_NUM_KEY <= key_index)
4179 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304180 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004181 key_index);
4182
4183 return -EINVAL;
4184 }
4185
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304186 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4187 status = wlan_hdd_validate_context(pHddCtx);
4188
4189 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004190 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304191 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4192 "%s: HDD context is not valid", __func__);
4193 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004194 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304195
Jeff Johnson295189b2012-06-20 16:38:30 -07004196 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07004197 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304198 )
Jeff Johnson295189b2012-06-20 16:38:30 -07004199 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05304200 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08004201 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304202 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08004203 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07004204 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304205 {
4206 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07004207 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304208
Jeff Johnson295189b2012-06-20 16:38:30 -07004209 tCsrRoamSetKey setKey;
4210 v_U32_t roamId= 0xFF;
4211 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304212
4213 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004214 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304215
Jeff Johnson295189b2012-06-20 16:38:30 -07004216 Keys->defaultIndex = (u8)key_index;
4217 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4218 setKey.keyId = key_index;
4219 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304220
4221 vos_mem_copy(&setKey.Key[0],
4222 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07004223 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304224
Gopichand Nakkala29149562013-05-10 21:43:41 +05304225 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304226
4227 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07004228 &pHddStaCtx->conn_info.bssId[0],
4229 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304230
Gopichand Nakkala29149562013-05-10 21:43:41 +05304231 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
4232 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
4233 eCSR_ENCRYPT_TYPE_WEP104)
4234 {
4235 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
4236 even though ap is configured for WEP-40 encryption. In this canse the key length
4237 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
4238 type(104) and switching encryption type to 40*/
4239 pWextState->roamProfile.EncryptionType.encryptionType[0] =
4240 eCSR_ENCRYPT_TYPE_WEP40;
4241 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
4242 eCSR_ENCRYPT_TYPE_WEP40;
4243 }
4244
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304245 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07004246 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304247
Jeff Johnson295189b2012-06-20 16:38:30 -07004248 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304249 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07004250 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304251
Jeff Johnson295189b2012-06-20 16:38:30 -07004252 if ( 0 != status )
4253 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304254 hddLog(VOS_TRACE_LEVEL_ERROR,
4255 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004256 status);
4257 return -EINVAL;
4258 }
4259 }
4260 }
4261
4262 /* In SoftAp mode setting key direction for default mode */
4263 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
4264 {
4265 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
4266 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
4267 (eCSR_ENCRYPT_TYPE_AES !=
4268 pWextState->roamProfile.EncryptionType.encryptionType[0])
4269 )
4270 {
4271 /* Saving key direction for default key index to TX default */
4272 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
4273 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
4274 }
4275 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304276
Jeff Johnson295189b2012-06-20 16:38:30 -07004277 return status;
4278}
4279
Jeff Johnson295189b2012-06-20 16:38:30 -07004280/*
4281 * FUNCTION: wlan_hdd_cfg80211_inform_bss
4282 * This function is used to inform the BSS details to nl80211 interface.
4283 */
4284static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
4285 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
4286{
4287 struct net_device *dev = pAdapter->dev;
4288 struct wireless_dev *wdev = dev->ieee80211_ptr;
4289 struct wiphy *wiphy = wdev->wiphy;
4290 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
4291 int chan_no;
4292 int ie_length;
4293 const char *ie;
4294 unsigned int freq;
4295 struct ieee80211_channel *chan;
4296 int rssi = 0;
4297 struct cfg80211_bss *bss = NULL;
4298
4299 ENTER();
4300
4301 if( NULL == pBssDesc )
4302 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004303 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004304 return bss;
4305 }
4306
4307 chan_no = pBssDesc->channelId;
4308 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
4309 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
4310
4311 if( NULL == ie )
4312 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004313 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004314 return bss;
4315 }
4316
4317#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
4318 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
4319 {
4320 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4321 }
4322 else
4323 {
4324 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4325 }
4326#else
4327 freq = ieee80211_channel_to_frequency(chan_no);
4328#endif
4329
4330 chan = __ieee80211_get_channel(wiphy, freq);
4331
4332 bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId,
4333 &roamProfile->SSID.ssId[0], roamProfile->SSID.length,
4334 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
4335 if (bss == NULL)
4336 {
4337 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
4338
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304339 return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
4340 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07004341 pBssDesc->capabilityInfo,
4342 pBssDesc->beaconInterval, ie, ie_length,
4343 rssi, GFP_KERNEL ));
4344}
4345 else
4346 {
4347 return bss;
4348 }
4349}
4350
4351
4352
4353/*
4354 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
4355 * This function is used to inform the BSS details to nl80211 interface.
4356 */
4357struct cfg80211_bss*
4358wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
4359 tSirBssDescription *bss_desc
4360 )
4361{
4362 /*
4363 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
4364 already exists in bss data base of cfg80211 for that particular BSS ID.
4365 Using cfg80211_inform_bss_frame to update the bss entry instead of
4366 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
4367 now there is no possibility to get the mgmt(probe response) frame from PE,
4368 converting bss_desc to ieee80211_mgmt(probe response) and passing to
4369 cfg80211_inform_bss_frame.
4370 */
4371 struct net_device *dev = pAdapter->dev;
4372 struct wireless_dev *wdev = dev->ieee80211_ptr;
4373 struct wiphy *wiphy = wdev->wiphy;
4374 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004375#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4376 qcom_ie_age *qie_age = NULL;
4377 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
4378#else
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004380#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004381 const char *ie =
4382 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
4383 unsigned int freq;
4384 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05304385 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004386 struct cfg80211_bss *bss_status = NULL;
4387 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
4388 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07004389 hdd_context_t *pHddCtx;
4390 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07004391#ifdef WLAN_OPEN_SOURCE
4392 struct timespec ts;
4393#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004394
Wilson Yangf80a0542013-10-07 13:02:37 -07004395 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4396 status = wlan_hdd_validate_context(pHddCtx);
4397
4398 /*bss_update is not allowed during wlan driver loading or unloading*/
4399 if (pHddCtx->isLoadUnloadInProgress)
4400 {
4401 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4402 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
4403 return NULL;
4404 }
4405
4406
4407 if (0 != status)
4408 {
4409 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4410 "%s: HDD context is not valid", __func__);
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07004411 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07004412 }
4413
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05304414 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -07004415 if (!mgmt)
4416 {
4417 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4418 "%s: memory allocation failed ", __func__);
4419 return NULL;
4420 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07004421
Jeff Johnson295189b2012-06-20 16:38:30 -07004422 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07004423
4424#ifdef WLAN_OPEN_SOURCE
4425 /* Android does not want the timestamp from the frame.
4426 Instead it wants a monotonic increasing value */
4427 get_monotonic_boottime(&ts);
4428 mgmt->u.probe_resp.timestamp =
4429 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
4430#else
4431 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07004432 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
4433 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07004434
4435#endif
4436
Jeff Johnson295189b2012-06-20 16:38:30 -07004437 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
4438 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004439
4440#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4441 /* GPS Requirement: need age ie per entry. Using vendor specific. */
4442 /* Assuming this is the last IE, copy at the end */
4443 ie_length -=sizeof(qcom_ie_age);
4444 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
4445 qie_age->element_id = QCOM_VENDOR_IE_ID;
4446 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
4447 qie_age->oui_1 = QCOM_OUI1;
4448 qie_age->oui_2 = QCOM_OUI2;
4449 qie_age->oui_3 = QCOM_OUI3;
4450 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
4451 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
4452#endif
4453
Jeff Johnson295189b2012-06-20 16:38:30 -07004454 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05304455 if (bss_desc->fProbeRsp)
4456 {
4457 mgmt->frame_control |=
4458 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
4459 }
4460 else
4461 {
4462 mgmt->frame_control |=
4463 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
4464 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004465
4466#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304467 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004468 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
4469 {
4470 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4471 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304472 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004473 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
4474
4475 {
4476 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4477 }
4478 else
4479 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05304480 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
4481 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -07004482 kfree(mgmt);
4483 return NULL;
4484 }
4485#else
4486 freq = ieee80211_channel_to_frequency(chan_no);
4487#endif
4488 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004489 /*when the band is changed on the fly using the GUI, three things are done
4490 * 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)
4491 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
4492 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
4493 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
4494 * and discards the channels correponding to previous band and calls back with zero bss results.
4495 * 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
4496 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
4497 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
4498 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
4499 * So drop the bss and continue to next bss.
4500 */
4501 if(chan == NULL)
4502 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05304503 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07004504 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004505 return NULL;
4506 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004507 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304508 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07004509 * */
4510 if (( eConnectionState_Associated ==
4511 pAdapter->sessionCtx.station.conn_info.connState ) &&
4512 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
4513 pAdapter->sessionCtx.station.conn_info.bssId,
4514 WNI_CFG_BSSID_LEN)))
4515 {
4516 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
4517 rssi = (pAdapter->rssi * 100);
4518 }
4519 else
4520 {
4521 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
4522 }
4523
Nirav Shah20ac06f2013-12-12 18:14:06 +05304524 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
4525 "RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
4526 chan->center_freq, (int)(rssi/100));
4527
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
4529 frame_len, rssi, GFP_KERNEL);
4530 kfree(mgmt);
4531 return bss_status;
4532}
4533
4534/*
4535 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
4536 * This function is used to update the BSS data base of CFG8011
4537 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304538struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004539 tCsrRoamInfo *pRoamInfo
4540 )
4541{
4542 tCsrRoamConnectedProfile roamProfile;
4543 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4544 struct cfg80211_bss *bss = NULL;
4545
4546 ENTER();
4547
4548 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
4549 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
4550
4551 if (NULL != roamProfile.pBssDesc)
4552 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304553 bss = wlan_hdd_cfg80211_inform_bss(pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004554 &roamProfile);
4555
4556 if (NULL == bss)
4557 {
4558 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
4559 __func__);
4560 }
4561
4562 sme_RoamFreeConnectProfile(hHal, &roamProfile);
4563 }
4564 else
4565 {
4566 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
4567 __func__);
4568 }
4569 return bss;
4570}
4571
4572/*
4573 * FUNCTION: wlan_hdd_cfg80211_update_bss
4574 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304575static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
4576 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07004577 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304578{
Jeff Johnson295189b2012-06-20 16:38:30 -07004579 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4580 tCsrScanResultInfo *pScanResult;
4581 eHalStatus status = 0;
4582 tScanResultHandle pResult;
4583 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07004584 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004585
4586 ENTER();
4587
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304588 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
4589 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
4590 NO_SESSION, pAdapter->sessionId));
4591
Wilson Yangf80a0542013-10-07 13:02:37 -07004592 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4593
4594 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -07004595 {
Wilson Yangf80a0542013-10-07 13:02:37 -07004596 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4597 "%s:LOGP in Progress. Ignore!!!",__func__);
4598 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004599 }
4600
Wilson Yangf80a0542013-10-07 13:02:37 -07004601
4602 /*bss_update is not allowed during wlan driver loading or unloading*/
4603 if (pHddCtx->isLoadUnloadInProgress)
4604 {
4605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4606 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
4607 return VOS_STATUS_E_PERM;
4608 }
4609
4610
Jeff Johnson295189b2012-06-20 16:38:30 -07004611 /*
4612 * start getting scan results and populate cgf80211 BSS database
4613 */
4614 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
4615
4616 /* no scan results */
4617 if (NULL == pResult)
4618 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05304619 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
4620 __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004621 return status;
4622 }
4623
4624 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
4625
4626 while (pScanResult)
4627 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304628 /*
4629 * cfg80211_inform_bss() is not updating ie field of bss entry, if
4630 * entry already exists in bss data base of cfg80211 for that
4631 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
4632 * bss entry instead of cfg80211_inform_bss, But this call expects
4633 * mgmt packet as input. As of now there is no possibility to get
4634 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07004635 * ieee80211_mgmt(probe response) and passing to c
4636 * fg80211_inform_bss_frame.
4637 * */
4638
4639 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
4640 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304641
Jeff Johnson295189b2012-06-20 16:38:30 -07004642
4643 if (NULL == bss_status)
4644 {
4645 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004646 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004647 }
4648 else
4649 {
Yue Maf49ba872013-08-19 12:04:25 -07004650 cfg80211_put_bss(
4651#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
4652 wiphy,
4653#endif
4654 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004655 }
4656
4657 pScanResult = sme_ScanResultGetNext(hHal, pResult);
4658 }
4659
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304660 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07004661
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304662 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004663}
4664
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004665void
4666hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
4667{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304668 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -08004669 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004670} /****** end hddPrintMacAddr() ******/
4671
4672void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004673hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004674{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304675 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004676 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004677 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
4678 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
4679 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004680} /****** end hddPrintPmkId() ******/
4681
4682//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
4683//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
4684
4685//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
4686//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
4687
4688#define dump_bssid(bssid) \
4689 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004690 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
4691 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004692 }
4693
4694#define dump_pmkid(pMac, pmkid) \
4695 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004696 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
4697 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004698 }
4699
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004700#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004701/*
4702 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
4703 * This function is used to notify the supplicant of a new PMKSA candidate.
4704 */
4705int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304706 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004707 int index, bool preauth )
4708{
Jeff Johnsone7245742012-09-05 17:12:55 -07004709#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004710 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004711 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004712
4713 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07004714 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004715
4716 if( NULL == pRoamInfo )
4717 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004718 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004719 return -EINVAL;
4720 }
4721
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004722 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
4723 {
4724 dump_bssid(pRoamInfo->bssid);
4725 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004726 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004727 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004728#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304729 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004730}
4731#endif //FEATURE_WLAN_LFR
4732
Yue Maef608272013-04-08 23:09:17 -07004733#ifdef FEATURE_WLAN_LFR_METRICS
4734/*
4735 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
4736 * 802.11r/LFR metrics reporting function to report preauth initiation
4737 *
4738 */
4739#define MAX_LFR_METRICS_EVENT_LENGTH 100
4740VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
4741 tCsrRoamInfo *pRoamInfo)
4742{
4743 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4744 union iwreq_data wrqu;
4745
4746 ENTER();
4747
4748 if (NULL == pAdapter)
4749 {
4750 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4751 return VOS_STATUS_E_FAILURE;
4752 }
4753
4754 /* create the event */
4755 memset(&wrqu, 0, sizeof(wrqu));
4756 memset(metrics_notification, 0, sizeof(metrics_notification));
4757
4758 wrqu.data.pointer = metrics_notification;
4759 wrqu.data.length = scnprintf(metrics_notification,
4760 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
4761 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
4762
4763 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4764
4765 EXIT();
4766
4767 return VOS_STATUS_SUCCESS;
4768}
4769
4770/*
4771 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
4772 * 802.11r/LFR metrics reporting function to report preauth completion
4773 * or failure
4774 */
4775VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
4776 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
4777{
4778 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4779 union iwreq_data wrqu;
4780
4781 ENTER();
4782
4783 if (NULL == pAdapter)
4784 {
4785 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4786 return VOS_STATUS_E_FAILURE;
4787 }
4788
4789 /* create the event */
4790 memset(&wrqu, 0, sizeof(wrqu));
4791 memset(metrics_notification, 0, sizeof(metrics_notification));
4792
4793 scnprintf(metrics_notification, sizeof(metrics_notification),
4794 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
4795 MAC_ADDR_ARRAY(pRoamInfo->bssid));
4796
4797 if (1 == preauth_status)
4798 strncat(metrics_notification, " TRUE", 5);
4799 else
4800 strncat(metrics_notification, " FALSE", 6);
4801
4802 wrqu.data.pointer = metrics_notification;
4803 wrqu.data.length = strlen(metrics_notification);
4804
4805 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4806
4807 EXIT();
4808
4809 return VOS_STATUS_SUCCESS;
4810}
4811
4812/*
4813 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
4814 * 802.11r/LFR metrics reporting function to report handover initiation
4815 *
4816 */
4817VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
4818 tCsrRoamInfo *pRoamInfo)
4819{
4820 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4821 union iwreq_data wrqu;
4822
4823 ENTER();
4824
4825 if (NULL == pAdapter)
4826 {
4827 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4828 return VOS_STATUS_E_FAILURE;
4829 }
4830
4831 /* create the event */
4832 memset(&wrqu, 0, sizeof(wrqu));
4833 memset(metrics_notification, 0, sizeof(metrics_notification));
4834
4835 wrqu.data.pointer = metrics_notification;
4836 wrqu.data.length = scnprintf(metrics_notification,
4837 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
4838 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
4839
4840 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4841
4842 EXIT();
4843
4844 return VOS_STATUS_SUCCESS;
4845}
4846#endif
4847
Jeff Johnson295189b2012-06-20 16:38:30 -07004848/*
4849 * FUNCTION: hdd_cfg80211_scan_done_callback
4850 * scanning callback function, called after finishing scan
4851 *
4852 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304853static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -07004854 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
4855{
4856 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304857 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004858 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004859 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4860 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07004861 struct cfg80211_scan_request *req = NULL;
4862 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05304863 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304864 long waitRet = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004865
4866 ENTER();
4867
4868 hddLog(VOS_TRACE_LEVEL_INFO,
4869 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -08004870 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004871 __func__, halHandle, pContext, (int) scanId, (int) status);
4872
Kiet Lamac06e2c2013-10-23 16:25:07 +05304873 pScanInfo->mScanPendingCounter = 0;
4874
Jeff Johnson295189b2012-06-20 16:38:30 -07004875 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304876 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -07004877 &pScanInfo->scan_req_completion_event,
4878 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304879 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004880 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304881 hddLog(VOS_TRACE_LEVEL_ERROR,
4882 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -07004883 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004884 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004885 }
4886
Yue Maef608272013-04-08 23:09:17 -07004887 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004888 {
4889 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004890 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004891 }
4892
4893 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304894 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -07004895 {
4896 hddLog(VOS_TRACE_LEVEL_INFO,
4897 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004898 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004899 (int) scanId);
4900 }
4901
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304902 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004903 pAdapter);
4904
4905 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304906 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004907
4908
4909 /* If any client wait scan result through WEXT
4910 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004911 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07004912 {
4913 /* The other scan request waiting for current scan finish
4914 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004915 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004916 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004917 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07004918 }
4919 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004920 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004921 {
4922 struct net_device *dev = pAdapter->dev;
4923 union iwreq_data wrqu;
4924 int we_event;
4925 char *msg;
4926
4927 memset(&wrqu, '\0', sizeof(wrqu));
4928 we_event = SIOCGIWSCAN;
4929 msg = NULL;
4930 wireless_send_event(dev, we_event, &wrqu, msg);
4931 }
4932 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004933 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004934
4935 /* Get the Scan Req */
4936 req = pAdapter->request;
4937
4938 if (!req)
4939 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004940 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004941 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004942 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004943 }
4944
4945 /*
4946 * setting up 0, just in case.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304947 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004948 req->n_ssids = 0;
4949 req->n_channels = 0;
4950 req->ie = 0;
4951
Jeff Johnson295189b2012-06-20 16:38:30 -07004952 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07004953 /* Scan is no longer pending */
4954 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004955
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -07004956 /*
4957 * cfg80211_scan_done informing NL80211 about completion
4958 * of scanning
4959 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05304960 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
4961 {
4962 aborted = true;
4963 }
4964 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08004965 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07004966
Jeff Johnsone7245742012-09-05 17:12:55 -07004967allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004968 /* release the wake lock at the end of the scan*/
4969 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07004970
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004971 /* Acquire wakelock to handle the case where APP's tries to suspend
4972 * immediatly after the driver gets connect request(i.e after scan)
4973 * from supplicant, this result in app's is suspending and not able
4974 * to process the connect request to AP */
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05304975 hdd_prevent_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004976
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004977#ifdef FEATURE_WLAN_TDLS
4978 wlan_hdd_tdls_scan_done_callback(pAdapter);
4979#endif
4980
Jeff Johnson295189b2012-06-20 16:38:30 -07004981 EXIT();
4982 return 0;
4983}
4984
4985/*
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004986 * FUNCTION: hdd_isScanAllowed
4987 * Go through each adapter and check if scan allowed
4988 *
4989 */
4990v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx )
4991{
4992 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
4993 hdd_station_ctx_t *pHddStaCtx = NULL;
4994 hdd_adapter_t *pAdapter = NULL;
4995 VOS_STATUS status = 0;
4996 v_U8_t staId = 0;
4997 v_U8_t *staMac = NULL;
4998
c_hpothu9b781ba2013-12-30 20:57:45 +05304999 if (TRUE == pHddCtx->btCoexModeSet)
5000 {
5001 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5002 FL("BTCoex Mode operation in progress, Do not allow scan"));
5003 return VOS_FALSE;
5004 }
5005
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005006 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
5007
5008 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
5009 {
5010 pAdapter = pAdapterNode->pAdapter;
5011
5012 if( pAdapter )
5013 {
5014 hddLog(VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305015 "%s: Adapter with device mode %d exists",
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005016 __func__, pAdapter->device_mode);
5017 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
5018 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
5019 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
5020 {
5021 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5022 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
5023 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
5024 {
5025 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
5026 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08005027 "%s: client " MAC_ADDRESS_STR
5028 " is in the middle of WPS/EAPOL exchange.", __func__,
5029 MAC_ADDR_ARRAY(staMac));
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005030 return VOS_FALSE;
5031 }
5032 }
5033 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
5034 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
5035 {
5036 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
5037 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305038 if ((pAdapter->aStaInfo[staId].isUsed) &&
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005039 (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState))
5040 {
5041 staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
5042
5043 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08005044 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
5045 "middle of WPS/EAPOL exchange.", __func__,
5046 MAC_ADDR_ARRAY(staMac));
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005047 return VOS_FALSE;
5048 }
5049 }
5050 }
5051 }
5052 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
5053 pAdapterNode = pNext;
5054 }
5055 hddLog(VOS_TRACE_LEVEL_INFO,
5056 "%s: Scan allowed", __func__);
5057 return VOS_TRUE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305058}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005059
5060/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005061 * FUNCTION: wlan_hdd_cfg80211_scan
5062 * this scan respond to scan trigger and update cfg80211 scan database
5063 * later, scan dump command can be used to recieve scan results
5064 */
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08005065int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
5066#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
5067 struct net_device *dev,
5068#endif
5069 struct cfg80211_scan_request *request)
5070{
5071#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
5072 struct net_device *dev = request->wdev->netdev;
5073#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305074 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07005075 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5076 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305077 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005078 tCsrScanRequest scanRequest;
5079 tANI_U8 *channelList = NULL, i;
5080 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305081 int status;
5082 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005083 v_U8_t* pP2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005084
5085 ENTER();
5086
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305087 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
5088 TRACE_CODE_HDD_CFG80211_SCAN,
5089 pAdapter->sessionId, request->n_channels));
5090
Arif Hussain6d2a3322013-11-17 19:50:10 -08005091 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005092 __func__,pAdapter->device_mode);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005093
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305094 status = wlan_hdd_validate_context(pHddCtx);
5095
5096 if (0 != status)
5097 {
5098 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5099 "%s: HDD context is not valid", __func__);
5100 return status;
5101 }
5102
5103 cfg_param = pHddCtx->cfg_ini;
5104 pScanInfo = &pHddCtx->scan_info;
5105
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005106 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005107 (eConnectionState_Connecting ==
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005108 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005109 {
5110 hddLog(VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005111 "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \
5112 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005113 return -EBUSY;
5114 }
5115
Jeff Johnson295189b2012-06-20 16:38:30 -07005116#ifdef WLAN_BTAMP_FEATURE
5117 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005118 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -07005119 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005120 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005121 "%s: No scanning when AMP is on", __func__);
5122 return -EOPNOTSUPP;
5123 }
5124#endif
5125 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005126 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07005127 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005128 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005129 "%s: Not scanning on device_mode = %d",
5130 __func__, pAdapter->device_mode);
5131 return -EOPNOTSUPP;
5132 }
5133
5134 if (TRUE == pScanInfo->mScanPending)
5135 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05305136 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
5137 {
5138 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
5139 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005140 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005141 }
5142
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305143 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -07005144 //Channel and action frame is pending
5145 //Otherwise Cancel Remain On Channel and allow Scan
5146 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005147 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -07005148 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05305149 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -07005150 return -EBUSY;
5151 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005152#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07005153 /* if tdls disagree scan right now, return immediately.
5154 tdls will schedule the scan when scan is allowed. (return SUCCESS)
5155 or will reject the scan if any TDLS is in progress. (return -EBUSY)
5156 */
5157 status = wlan_hdd_tdls_scan_callback (pAdapter,
5158 wiphy,
5159#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
5160 dev,
Gopichand Nakkalac3c42b92013-03-20 19:42:34 -07005161#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07005162 request);
5163 if(status <= 0)
5164 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05305165 if(!status)
5166 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
5167 "scan rejected %d", __func__, status);
5168 else
5169 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
5170 __func__, status);
5171
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07005172 return status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005173 }
5174#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07005175
Jeff Johnson295189b2012-06-20 16:38:30 -07005176 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
5177 {
5178 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -08005179 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005180 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305181 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005182 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
5183 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05305184 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005185 "%s: MAX TM Level Scan not allowed", __func__);
5186 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305187 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005188 }
5189 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
5190
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005191 /* Check if scan is allowed at this point of time.
5192 */
5193 if (!hdd_isScanAllowed(pHddCtx))
5194 {
5195 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
5196 return -EBUSY;
5197 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305198
Jeff Johnson295189b2012-06-20 16:38:30 -07005199 vos_mem_zero( &scanRequest, sizeof(scanRequest));
5200
5201 if (NULL != request)
5202 {
5203 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305204 (int)request->n_ssids);
Jeff Johnson295189b2012-06-20 16:38:30 -07005205
5206 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
5207 * Becasue of this, driver is assuming that this is not wildcard scan and so
5208 * is not aging out the scan results.
5209 */
Jeff Johnson32d95a32012-09-10 13:15:23 -07005210 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07005211 {
5212 request->n_ssids = 0;
5213 }
5214
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07005215 if ((request->ssids) && (0 < request->n_ssids))
Jeff Johnson295189b2012-06-20 16:38:30 -07005216 {
5217 tCsrSSIDInfo *SsidInfo;
5218 int j;
5219 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
5220 /* Allocate num_ssid tCsrSSIDInfo structure */
5221 SsidInfo = scanRequest.SSIDs.SSIDList =
5222 ( tCsrSSIDInfo *)vos_mem_malloc(
5223 request->n_ssids*sizeof(tCsrSSIDInfo));
5224
5225 if(NULL == scanRequest.SSIDs.SSIDList)
5226 {
5227 hddLog(VOS_TRACE_LEVEL_ERROR,
Nirav Shah20ac06f2013-12-12 18:14:06 +05305228 "%s: memory alloc failed SSIDInfo buffer", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005229 return -ENOMEM;
5230 }
5231
5232 /* copy all the ssid's and their length */
5233 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
5234 {
5235 /* get the ssid length */
5236 SsidInfo->SSID.length = request->ssids[j].ssid_len;
5237 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
5238 SsidInfo->SSID.length);
5239 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
Nirav Shah20ac06f2013-12-12 18:14:06 +05305240 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005241 j, SsidInfo->SSID.ssId);
5242 }
5243 /* set the scan type to active */
5244 scanRequest.scanType = eSIR_ACTIVE_SCAN;
5245 }
5246 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
5247 {
5248 /* set the scan type to active */
5249 scanRequest.scanType = eSIR_ACTIVE_SCAN;
5250 }
5251 else
5252 {
5253 /*Set the scan type to default type, in this case it is ACTIVE*/
5254 scanRequest.scanType = pScanInfo->scan_mode;
5255 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305256 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07005257 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
5258 }
5259 else
5260 {
5261 /* set the scan type to active */
5262 scanRequest.scanType = eSIR_ACTIVE_SCAN;
5263 vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff );
5264
5265 /* set min and max channel time to zero */
5266 scanRequest.minChnTime = 0;
5267 scanRequest.maxChnTime = 0;
5268 }
5269
5270 /* set BSSType to default type */
5271 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
5272
5273 /*TODO: scan the requested channels only*/
5274
5275 /*Right now scanning all the channels */
5276 if( request )
5277 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05305278 hddLog(VOS_TRACE_LEVEL_INFO,
5279 "No of Scan Channels: %d", request->n_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07005280 if( request->n_channels )
5281 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05305282 char chList [(request->n_channels*5)+1];
5283 int len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005284 channelList = vos_mem_malloc( request->n_channels );
5285 if( NULL == channelList )
5286 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305287 hddLog(VOS_TRACE_LEVEL_ERROR,
Nirav Shah20ac06f2013-12-12 18:14:06 +05305288 "%s: memory alloc failed channelList", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005289 status = -ENOMEM;
5290 goto free_mem;
5291 }
5292
Nirav Shah20ac06f2013-12-12 18:14:06 +05305293 for( i = 0, len = 0; i < request->n_channels ; i++ )
5294 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005295 channelList[i] = request->channels[i]->hw_value;
Nirav Shah20ac06f2013-12-12 18:14:06 +05305296 len += snprintf(chList+len, 5, "%d ", channelList[i]);
5297 }
5298
5299 hddLog(VOS_TRACE_LEVEL_INFO,
5300 "Channel-List: %s ", chList);
Jeff Johnson295189b2012-06-20 16:38:30 -07005301 }
5302
5303 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
5304 scanRequest.ChannelInfo.ChannelList = channelList;
5305
5306 /* set requestType to full scan */
5307 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305308
5309 /* Flush the scan results(only p2p beacons) for STA scan and P2P
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08005310 * search (Flush on both full scan and social scan but not on single
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305311 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08005312 */
5313
5314 /* Supplicant does single channel scan after 8-way handshake
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305315 * and in that case driver shoudnt flush scan results. If
5316 * driver flushes the scan results here and unfortunately if
5317 * the AP doesnt respond to our probe req then association
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08005318 * fails which is not desired
5319 */
5320
5321 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
5322 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05305323 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08005324 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
5325 pAdapter->sessionId );
5326 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005327
5328 if( request->ie_len )
5329 {
5330 /* save this for future association (join requires this) */
Agarwal Ashish4f616132013-12-30 23:32:50 +05305331 /*TODO: Array needs to be converted to dynamic allocation,
5332 * as multiple ie.s can be sent in cfg80211_scan_request structure
5333 * CR 597966
5334 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005335 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
5336 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
5337 pScanInfo->scanAddIE.length = request->ie_len;
5338
Agarwal Ashish4f616132013-12-30 23:32:50 +05305339 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07005340 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
Agarwal Ashish4f616132013-12-30 23:32:50 +05305341 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07005342 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05305343 if ( request->ie_len <= SIR_MAC_MAX_IE_LENGTH)
5344 {
5345 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
5346 memcpy( pwextBuf->roamProfile.addIEScan,
5347 request->ie, request->ie_len);
5348 }
5349 else
5350 {
5351 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
5352 "%d", request->ie_len);
5353 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005354
Agarwal Ashish4f616132013-12-30 23:32:50 +05305355 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005356 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
5357 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
5358
Jeff Johnson295189b2012-06-20 16:38:30 -07005359 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
5360 request->ie_len);
5361 if (pP2pIe != NULL)
5362 {
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07005363#ifdef WLAN_FEATURE_P2P_DEBUG
5364 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
5365 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
5366 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5367 {
5368 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
5369 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
5370 "Go nego completed to Connection is started");
5371 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
5372 "for 8way Handshake");
5373 }
5374 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
5375 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5376 {
5377 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
5378 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
5379 "Disconnected state to Connection is started");
5380 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
5381 "for 4way Handshake");
5382 }
5383#endif
5384
Jeff Johnsone7245742012-09-05 17:12:55 -07005385 /* no_cck will be set during p2p find to disable 11b rates */
5386 if(TRUE == request->no_cck)
Jeff Johnson295189b2012-06-20 16:38:30 -07005387 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005388 hddLog(VOS_TRACE_LEVEL_INFO,
5389 "%s: This is a P2P Search", __func__);
5390 scanRequest.p2pSearch = 1;
Jeff Johnsone7245742012-09-05 17:12:55 -07005391
Jeff Johnsone7245742012-09-05 17:12:55 -07005392 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
5393 {
Madan Mohan Koyyalamudi1b1d9e82012-10-21 11:38:33 -07005394 /* set requestType to P2P Discovery */
5395 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
Jeff Johnsone7245742012-09-05 17:12:55 -07005396 }
5397
5398 /*
5399 Skip Dfs Channel in case of P2P Search
5400 if it is set in ini file
5401 */
5402 if(cfg_param->skipDfsChnlInP2pSearch)
5403 {
5404 scanRequest.skipDfsChnlInP2pSearch = 1;
5405 }
5406 else
5407 {
5408 scanRequest.skipDfsChnlInP2pSearch = 0;
5409 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005410
Jeff Johnson295189b2012-06-20 16:38:30 -07005411 }
5412 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005413 }
5414 }
5415
5416 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
5417
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07005418 /* acquire the wakelock to avoid the apps suspend during the scan. To
5419 * address the following issues.
5420 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
5421 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
5422 * for long time, this result in apps running at full power for long time.
5423 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
5424 * be stuck in full power because of resume BMPS
5425 */
5426 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07005427
Nirav Shah20ac06f2013-12-12 18:14:06 +05305428 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5429 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
5430 "p2pSearch %d, skipDfsChnlInP2pSearch %d", scanRequest.requestType,
5431 scanRequest.scanType, scanRequest.minChnTime, scanRequest.maxChnTime,
5432 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
5433
Jeff Johnsone7245742012-09-05 17:12:55 -07005434 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005435 pAdapter->sessionId, &scanRequest, &scanId,
5436 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -07005437
Jeff Johnson295189b2012-06-20 16:38:30 -07005438 if (eHAL_STATUS_SUCCESS != status)
5439 {
5440 hddLog(VOS_TRACE_LEVEL_ERROR,
5441 "%s: sme_ScanRequest returned error %d", __func__, status);
5442 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07005443 if(eHAL_STATUS_RESOURCES == status)
5444 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05305445 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
5446 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07005447 status = -EBUSY;
5448 } else {
5449 status = -EIO;
5450 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07005451 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07005452 goto free_mem;
5453 }
5454
5455 pScanInfo->mScanPending = TRUE;
5456 pAdapter->request = request;
5457 pScanInfo->scanId = scanId;
5458
5459 complete(&pScanInfo->scan_req_completion_event);
5460
5461free_mem:
5462 if( scanRequest.SSIDs.SSIDList )
5463 {
5464 vos_mem_free(scanRequest.SSIDs.SSIDList);
5465 }
5466
5467 if( channelList )
5468 vos_mem_free( channelList );
5469
5470 EXIT();
5471
5472 return status;
5473}
5474
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005475
5476void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
5477{
5478 v_U8_t iniDot11Mode =
5479 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
5480 eHddDot11Mode hddDot11Mode = iniDot11Mode;
5481
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05305482 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
5483 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005484 switch ( iniDot11Mode )
5485 {
5486 case eHDD_DOT11_MODE_AUTO:
5487 case eHDD_DOT11_MODE_11ac:
5488 case eHDD_DOT11_MODE_11ac_ONLY:
5489#ifdef WLAN_FEATURE_11AC
5490 hddDot11Mode = eHDD_DOT11_MODE_11ac;
5491#else
5492 hddDot11Mode = eHDD_DOT11_MODE_11n;
5493#endif
5494 break;
5495 case eHDD_DOT11_MODE_11n:
5496 case eHDD_DOT11_MODE_11n_ONLY:
5497 hddDot11Mode = eHDD_DOT11_MODE_11n;
5498 break;
5499 default:
5500 hddDot11Mode = iniDot11Mode;
5501 break;
5502 }
5503 /* This call decides required channel bonding mode */
5504 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
5505 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
5506 operationChannel);
5507}
5508
Jeff Johnson295189b2012-06-20 16:38:30 -07005509/*
5510 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305511 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -07005512 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305513int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -07005514 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07005515{
5516 int status = 0;
5517 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -08005518 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005519 v_U32_t roamId;
5520 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005521 eCsrAuthType RSNAuthType;
5522
5523 ENTER();
5524
5525 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -08005526 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5527
5528 status = wlan_hdd_validate_context(pHddCtx);
5529 if (status)
5530 {
5531 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5532 "%s: HDD context is not valid!", __func__);
5533 return status;
5534 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305535
Jeff Johnson295189b2012-06-20 16:38:30 -07005536 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
5537 {
5538 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
5539 return -EINVAL;
5540 }
5541
5542 pRoamProfile = &pWextState->roamProfile;
5543
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305544 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07005545 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005546 hdd_station_ctx_t *pHddStaCtx;
5547 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005548
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305549 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07005550 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
5551 {
5552 /*QoS not enabled in cfg file*/
5553 pRoamProfile->uapsd_mask = 0;
5554 }
5555 else
5556 {
5557 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305558 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -07005559 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
5560 }
5561
5562 pRoamProfile->SSIDs.numOfSSIDs = 1;
5563 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
5564 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305565 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005566 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
5567 ssid, ssid_len);
5568
5569 if (bssid)
5570 {
5571 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
5572 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
5573 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305574 /* Save BSSID in seperate variable as well, as RoamProfile
5575 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -07005576 case of join failure we should send valid BSSID to supplicant
5577 */
5578 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
5579 WNI_CFG_BSSID_LEN);
5580 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07005581 else
5582 {
5583 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
5584 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005585
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05305586 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
5587 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07005588 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
5589 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305590 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005591 /*set gen ie*/
5592 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
5593 /*set auth*/
5594 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5595 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005596#ifdef FEATURE_WLAN_WAPI
5597 if (pAdapter->wapi_info.nWapiMode)
5598 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005599 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005600 switch (pAdapter->wapi_info.wapiAuthMode)
5601 {
5602 case WAPI_AUTH_MODE_PSK:
5603 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005604 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005605 pAdapter->wapi_info.wapiAuthMode);
5606 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5607 break;
5608 }
5609 case WAPI_AUTH_MODE_CERT:
5610 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005611 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005612 pAdapter->wapi_info.wapiAuthMode);
5613 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5614 break;
5615 }
5616 } // End of switch
5617 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5618 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
5619 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005620 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005621 pRoamProfile->AuthType.numEntries = 1;
5622 pRoamProfile->EncryptionType.numEntries = 1;
5623 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5624 pRoamProfile->mcEncryptionType.numEntries = 1;
5625 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5626 }
5627 }
5628#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305629#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305630 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305631 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
5632 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5633 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305634 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
5635 sizeof (tSirGtkOffloadParams));
5636 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305637 }
5638#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005639 pRoamProfile->csrPersona = pAdapter->device_mode;
5640
Jeff Johnson32d95a32012-09-10 13:15:23 -07005641 if( operatingChannel )
5642 {
5643 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
5644 pRoamProfile->ChannelInfo.numOfChannels = 1;
5645 }
Chet Lanctot186b5732013-03-18 10:26:30 -07005646 else
5647 {
5648 pRoamProfile->ChannelInfo.ChannelList = NULL;
5649 pRoamProfile->ChannelInfo.numOfChannels = 0;
5650 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005651 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
5652 {
5653 hdd_select_cbmode(pAdapter,operatingChannel);
5654 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05305655
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005656 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
5657 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305658 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005659 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005660 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
5661 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305662 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5663 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005664 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5665 eConnectionState_Connecting);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305666
5667 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005668 pAdapter->sessionId, pRoamProfile, &roamId);
5669
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305670 if ((eHAL_STATUS_SUCCESS != status) &&
5671 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5672 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305673
5674 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005675 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
5676 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
5677 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305678 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005679 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305680 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005681
5682 pRoamProfile->ChannelInfo.ChannelList = NULL;
5683 pRoamProfile->ChannelInfo.numOfChannels = 0;
5684
Jeff Johnson295189b2012-06-20 16:38:30 -07005685 }
5686 else
5687 {
5688 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
5689 return -EINVAL;
5690 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005691 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005692 return status;
5693}
5694
5695/*
5696 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
5697 * This function is used to set the authentication type (OPEN/SHARED).
5698 *
5699 */
5700static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
5701 enum nl80211_auth_type auth_type)
5702{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305703 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005704 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5705
5706 ENTER();
5707
5708 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305709 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -07005710 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005711 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305712 hddLog(VOS_TRACE_LEVEL_INFO,
5713 "%s: set authentication type to AUTOSWITCH", __func__);
5714 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
5715 break;
5716
5717 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07005718#ifdef WLAN_FEATURE_VOWIFI_11R
5719 case NL80211_AUTHTYPE_FT:
5720#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305721 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005722 "%s: set authentication type to OPEN", __func__);
5723 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5724 break;
5725
5726 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305727 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005728 "%s: set authentication type to SHARED", __func__);
5729 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
5730 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005731#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005732 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305733 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005734 "%s: set authentication type to CCKM WPA", __func__);
5735 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
5736 break;
5737#endif
5738
5739
5740 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305741 hddLog(VOS_TRACE_LEVEL_ERROR,
5742 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005743 auth_type);
5744 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
5745 return -EINVAL;
5746 }
5747
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305748 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005749 pHddStaCtx->conn_info.authType;
5750 return 0;
5751}
5752
5753/*
5754 * FUNCTION: wlan_hdd_set_akm_suite
5755 * This function is used to set the key mgmt type(PSK/8021x).
5756 *
5757 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305758static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005759 u32 key_mgmt
5760 )
5761{
5762 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5763 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305764
Jeff Johnson295189b2012-06-20 16:38:30 -07005765 /*set key mgmt type*/
5766 switch(key_mgmt)
5767 {
5768 case WLAN_AKM_SUITE_PSK:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305769#ifdef WLAN_FEATURE_VOWIFI_11R
5770 case WLAN_AKM_SUITE_FT_PSK:
5771#endif
5772 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -07005773 __func__);
5774 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5775 break;
5776
5777 case WLAN_AKM_SUITE_8021X:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305778#ifdef WLAN_FEATURE_VOWIFI_11R
5779 case WLAN_AKM_SUITE_FT_8021X:
5780#endif
5781 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -07005782 __func__);
5783 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5784 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005785#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005786#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
5787#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5788 case WLAN_AKM_SUITE_CCKM:
5789 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
5790 __func__);
5791 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
5792 break;
5793#endif
5794
5795 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305796 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005797 __func__, key_mgmt);
5798 return -EINVAL;
5799
5800 }
5801 return 0;
5802}
5803
5804/*
5805 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305806 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -07005807 * (NONE/WEP40/WEP104/TKIP/CCMP).
5808 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305809static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
5810 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -07005811 bool ucast
5812 )
5813{
5814 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305815 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005816 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5817
5818 ENTER();
5819
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305820 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005821 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305822 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -07005823 __func__, cipher);
5824 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5825 }
5826 else
5827 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305828
Jeff Johnson295189b2012-06-20 16:38:30 -07005829 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305830 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005831 {
5832 case IW_AUTH_CIPHER_NONE:
5833 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5834 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305835
Jeff Johnson295189b2012-06-20 16:38:30 -07005836 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305837 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07005838 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305839
Jeff Johnson295189b2012-06-20 16:38:30 -07005840 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305841 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -07005842 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305843
Jeff Johnson295189b2012-06-20 16:38:30 -07005844 case WLAN_CIPHER_SUITE_TKIP:
5845 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5846 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305847
Jeff Johnson295189b2012-06-20 16:38:30 -07005848 case WLAN_CIPHER_SUITE_CCMP:
5849 encryptionType = eCSR_ENCRYPT_TYPE_AES;
5850 break;
5851#ifdef FEATURE_WLAN_WAPI
5852 case WLAN_CIPHER_SUITE_SMS4:
5853 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
5854 break;
5855#endif
5856
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005857#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005858 case WLAN_CIPHER_SUITE_KRK:
5859 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
5860 break;
5861#endif
5862 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305863 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005864 __func__, cipher);
5865 return -EOPNOTSUPP;
5866 }
5867 }
5868
5869 if (ucast)
5870 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305871 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005872 __func__, encryptionType);
5873 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
5874 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305875 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005876 encryptionType;
5877 }
5878 else
5879 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305880 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005881 __func__, encryptionType);
5882 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
5883 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5884 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
5885 }
5886
5887 return 0;
5888}
5889
5890
5891/*
5892 * FUNCTION: wlan_hdd_cfg80211_set_ie
5893 * This function is used to parse WPA/RSN IE's.
5894 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305895int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
5896 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -07005897 size_t ie_len
5898 )
5899{
5900 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5901 u8 *genie = ie;
5902 v_U16_t remLen = ie_len;
5903#ifdef FEATURE_WLAN_WAPI
5904 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
5905 u16 *tmp;
5906 v_U16_t akmsuiteCount;
5907 int *akmlist;
5908#endif
5909 ENTER();
5910
5911 /* clear previous assocAddIE */
5912 pWextState->assocAddIE.length = 0;
5913 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
5914
5915 while (remLen >= 2)
5916 {
5917 v_U16_t eLen = 0;
5918 v_U8_t elementId;
5919 elementId = *genie++;
5920 eLen = *genie++;
5921 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305922
Arif Hussain6d2a3322013-11-17 19:50:10 -08005923 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07005924 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305925
5926 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -07005927 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305928 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005929 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 -07005930 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305931 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005932 "%s: Invalid WPA IE", __func__);
5933 return -EINVAL;
5934 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305935 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -07005936 {
5937 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305938 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005939 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305940
Jeff Johnson295189b2012-06-20 16:38:30 -07005941 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5942 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005943 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
5944 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005945 VOS_ASSERT(0);
5946 return -ENOMEM;
5947 }
5948 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5949 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5950 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305951
Jeff Johnson295189b2012-06-20 16:38:30 -07005952 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
5953 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5954 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5955 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305956 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
5957 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005958 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
5959 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5960 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
5961 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
5962 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
5963 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305964 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +05305965 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -07005966 {
5967 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305968 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005969 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305970
Jeff Johnson295189b2012-06-20 16:38:30 -07005971 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5972 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005973 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5974 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005975 VOS_ASSERT(0);
5976 return -ENOMEM;
5977 }
5978 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5979 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5980 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305981
Jeff Johnson295189b2012-06-20 16:38:30 -07005982 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5983 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5984 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005985#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305986 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
5987 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005988 /*Consider WFD IE, only for P2P Client */
5989 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5990 {
5991 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305992 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005993 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305994
Jeff Johnson295189b2012-06-20 16:38:30 -07005995 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5996 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005997 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5998 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005999 VOS_ASSERT(0);
6000 return -ENOMEM;
6001 }
6002 // WFD IE is saved to Additional IE ; it should be accumulated to handle
6003 // WPS IE + P2P IE + WFD IE
6004 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
6005 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306006
Jeff Johnson295189b2012-06-20 16:38:30 -07006007 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
6008 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
6009 }
6010#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006011 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306012 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006013 HS20_OUI_TYPE_SIZE)) )
6014 {
6015 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306016 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006017 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006018
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006019 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
6020 {
Jeff Johnson902c9832012-12-10 14:28:09 -08006021 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
6022 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006023 VOS_ASSERT(0);
6024 return -ENOMEM;
6025 }
6026 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
6027 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006028
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006029 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
6030 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
6031 }
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006032
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -07006033 if (WLAN_HDD_IBSS == pAdapter->device_mode) {
6034
6035 /* populating as ADDIE in beacon frames */
6036 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
6037 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
6038 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
6039 {
6040 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
6041 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
6042 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6043 {
6044 hddLog(LOGE,
6045 "Coldn't pass "
6046 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
6047 }
6048 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
6049 else
6050 hddLog(LOGE,
6051 "Could not pass on "
6052 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
6053
6054 /* IBSS mode doesn't contain params->proberesp_ies still
6055 beaconIE's need to be populated in probe response frames */
6056 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
6057 {
6058 u16 rem_probe_resp_ie_len = eLen + 2;
6059 u8 probe_rsp_ie_len[3] = {0};
6060 u8 counter = 0;
6061
6062 /* Check Probe Resp Length if it is greater then 255 then
6063 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
6064 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
6065 not able Store More then 255 bytes into One Variable */
6066
6067 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
6068 {
6069 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
6070 {
6071 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
6072 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
6073 }
6074 else
6075 {
6076 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
6077 rem_probe_resp_ie_len = 0;
6078 }
6079 }
6080
6081 rem_probe_resp_ie_len = 0;
6082
6083 if (probe_rsp_ie_len[0] > 0)
6084 {
6085 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
6086 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
6087 (tANI_U8*)(genie - 2),
6088 probe_rsp_ie_len[0], NULL,
6089 eANI_BOOLEAN_FALSE)
6090 == eHAL_STATUS_FAILURE)
6091 {
6092 hddLog(LOGE,
6093 "Could not pass"
6094 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
6095 }
6096 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
6097 }
6098
6099 if (probe_rsp_ie_len[1] > 0)
6100 {
6101 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
6102 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
6103 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
6104 probe_rsp_ie_len[1], NULL,
6105 eANI_BOOLEAN_FALSE)
6106 == eHAL_STATUS_FAILURE)
6107 {
6108 hddLog(LOGE,
6109 "Could not pass"
6110 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
6111 }
6112 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
6113 }
6114
6115 if (probe_rsp_ie_len[2] > 0)
6116 {
6117 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
6118 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
6119 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
6120 probe_rsp_ie_len[2], NULL,
6121 eANI_BOOLEAN_FALSE)
6122 == eHAL_STATUS_FAILURE)
6123 {
6124 hddLog(LOGE,
6125 "Could not pass"
6126 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
6127 }
6128 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
6129 }
6130
6131 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
6132 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
6133 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6134 {
6135 hddLog(LOGE,
6136 "Could not pass"
6137 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
6138 }
6139 }
6140 else
6141 {
6142 // Reset WNI_CFG_PROBE_RSP Flags
6143 wlan_hdd_reset_prob_rspies(pAdapter);
6144
6145 hddLog(VOS_TRACE_LEVEL_INFO,
6146 "%s: No Probe Response IE received in set beacon",
6147 __func__);
6148 }
6149 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -07006150 break;
6151 case DOT11F_EID_RSN:
6152 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
6153 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
6154 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
6155 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
6156 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
6157 break;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006158 /* Appending Extended Capabilities with Interworking bit set in Assoc Req */
6159 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306160 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006161 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306162 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006163 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306164
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006165 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
6166 {
Jeff Johnson902c9832012-12-10 14:28:09 -08006167 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
6168 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006169 VOS_ASSERT(0);
6170 return -ENOMEM;
6171 }
6172 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
6173 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306174
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006175 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
6176 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
6177 break;
6178 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006179#ifdef FEATURE_WLAN_WAPI
6180 case WLAN_EID_WAPI:
6181 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006182 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07006183 pAdapter->wapi_info.nWapiMode);
6184 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306185 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -07006186 akmsuiteCount = WPA_GET_LE16(tmp);
6187 tmp = tmp + 1;
6188 akmlist = (int *)(tmp);
6189 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
6190 {
6191 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
6192 }
6193 else
6194 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006195 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -07006196 VOS_ASSERT(0);
6197 return -EINVAL;
6198 }
6199
6200 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
6201 {
6202 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006203 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006204 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306205 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006206 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306207 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006208 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006209 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006210 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
6211 }
6212 break;
6213#endif
6214 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306215 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006216 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006217 /* when Unknown IE is received we should break and continue
6218 * to the next IE in the buffer instead we were returning
6219 * so changing this to break */
6220 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006221 }
6222 genie += eLen;
6223 remLen -= eLen;
6224 }
6225 EXIT();
6226 return 0;
6227}
6228
6229/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +05306230 * FUNCTION: hdd_isWPAIEPresent
6231 * Parse the received IE to find the WPA IE
6232 *
6233 */
6234static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
6235{
6236 v_U8_t eLen = 0;
6237 v_U16_t remLen = ie_len;
6238 v_U8_t elementId = 0;
6239
6240 while (remLen >= 2)
6241 {
6242 elementId = *ie++;
6243 eLen = *ie++;
6244 remLen -= 2;
6245 if (eLen > remLen)
6246 {
6247 hddLog(VOS_TRACE_LEVEL_ERROR,
6248 "%s: IE length is wrong %d", __func__, eLen);
6249 return FALSE;
6250 }
6251 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
6252 {
6253 /* OUI - 0x00 0X50 0XF2
6254 WPA Information Element - 0x01
6255 WPA version - 0x01*/
6256 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
6257 return TRUE;
6258 }
6259 ie += eLen;
6260 remLen -= eLen;
6261 }
6262 return FALSE;
6263}
6264
6265/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306267 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006268 * parameters during connect operation.
6269 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306270int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006271 struct cfg80211_connect_params *req
6272 )
6273{
6274 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306275 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006276 ENTER();
6277
6278 /*set wpa version*/
6279 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
6280
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306281 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07006282 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +05306283 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07006284 {
6285 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
6286 }
6287 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
6288 {
6289 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
6290 }
6291 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306292
6293 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006294 pWextState->wpaVersion);
6295
6296 /*set authentication type*/
6297 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
6298
6299 if (0 > status)
6300 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306301 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006302 "%s: failed to set authentication type ", __func__);
6303 return status;
6304 }
6305
6306 /*set key mgmt type*/
6307 if (req->crypto.n_akm_suites)
6308 {
6309 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
6310 if (0 > status)
6311 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306312 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -07006313 __func__);
6314 return status;
6315 }
6316 }
6317
6318 /*set pairwise cipher type*/
6319 if (req->crypto.n_ciphers_pairwise)
6320 {
6321 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
6322 req->crypto.ciphers_pairwise[0], true);
6323 if (0 > status)
6324 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306325 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006326 "%s: failed to set unicast cipher type", __func__);
6327 return status;
6328 }
6329 }
6330 else
6331 {
6332 /*Reset previous cipher suite to none*/
6333 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
6334 if (0 > status)
6335 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306336 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006337 "%s: failed to set unicast cipher type", __func__);
6338 return status;
6339 }
6340 }
6341
6342 /*set group cipher type*/
6343 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
6344 false);
6345
6346 if (0 > status)
6347 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306348 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -07006349 __func__);
6350 return status;
6351 }
6352
Chet Lanctot186b5732013-03-18 10:26:30 -07006353#ifdef WLAN_FEATURE_11W
6354 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
6355#endif
6356
Jeff Johnson295189b2012-06-20 16:38:30 -07006357 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
6358 if (req->ie_len)
6359 {
6360 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
6361 if ( 0 > status)
6362 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306363 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006364 __func__);
6365 return status;
6366 }
6367 }
6368
6369 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306370 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006371 {
6372 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
6373 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
6374 )
6375 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306376 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -07006377 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
6378 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306379 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07006380 __func__);
6381 return -EOPNOTSUPP;
6382 }
6383 else
6384 {
6385 u8 key_len = req->key_len;
6386 u8 key_idx = req->key_idx;
6387
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306388 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006389 && (CSR_MAX_NUM_KEY > key_idx)
6390 )
6391 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306392 hddLog(VOS_TRACE_LEVEL_INFO,
6393 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006394 __func__, key_idx, key_len);
6395 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306396 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07006397 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306398 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -07006399 (u8)key_len;
6400 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
6401 }
6402 }
6403 }
6404 }
6405
6406 return status;
6407}
6408
6409/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +05306410 * FUNCTION: wlan_hdd_try_disconnect
6411 * This function is used to disconnect from previous
6412 * connection
6413 */
6414static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
6415{
6416 long ret = 0;
6417 hdd_station_ctx_t *pHddStaCtx;
6418 eMib_dot11DesiredBssType connectedBssType;
6419
6420 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6421
6422 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
6423
6424 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
6425 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
6426 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
6427 {
6428 /* Issue disconnect to CSR */
6429 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6430 if( eHAL_STATUS_SUCCESS ==
6431 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
6432 pAdapter->sessionId,
6433 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
6434 {
6435 ret = wait_for_completion_interruptible_timeout(
6436 &pAdapter->disconnect_comp_var,
6437 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6438 if (0 >= ret)
6439 {
6440 hddLog(LOGE, FL("Failed to receive disconnect event"));
6441 return -EALREADY;
6442 }
6443 }
6444 }
6445 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
6446 {
6447 ret = wait_for_completion_interruptible_timeout(
6448 &pAdapter->disconnect_comp_var,
6449 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6450 if (0 >= ret)
6451 {
6452 hddLog(LOGE, FL("Failed to receive disconnect event"));
6453 return -EALREADY;
6454 }
6455 }
6456
6457 return 0;
6458}
6459
6460/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006461 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306462 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006463 * parameters during connect operation.
6464 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306465static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006466 struct net_device *ndev,
6467 struct cfg80211_connect_params *req
6468 )
6469{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306470 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306471 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006472 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -08006473 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006474
6475 ENTER();
6476
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306477 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6478 TRACE_CODE_HDD_CFG80211_CONNECT,
6479 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306480 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006481 "%s: device_mode = %d",__func__,pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006482
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306483 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08006484 if (!pHddCtx)
6485 {
6486 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6487 "%s: HDD context is null", __func__);
6488 return VOS_STATUS_E_FAILURE;
6489 }
6490
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306491 status = wlan_hdd_validate_context(pHddCtx);
6492
6493 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006494 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306495 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6496 "%s: HDD context is not valid", __func__);
6497 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006498 }
6499
6500#ifdef WLAN_BTAMP_FEATURE
6501 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306502 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -07006503 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306504 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006505 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08006506 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -07006507 }
6508#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +05306509
6510 //If Device Mode is Station Concurrent Sessions Exit BMps
6511 //P2P Mode will be taken care in Open/close adapter
6512 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
6513 (vos_concurrent_sessions_running()))
6514 {
6515 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
6516 }
6517
6518 /*Try disconnecting if already in connected state*/
6519 status = wlan_hdd_try_disconnect(pAdapter);
6520 if ( 0 > status)
6521 {
6522 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
6523 " connection"));
6524 return -EALREADY;
6525 }
6526
Jeff Johnson295189b2012-06-20 16:38:30 -07006527 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306528 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -07006529
6530 if ( 0 > status)
6531 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306532 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -07006533 __func__);
6534 return status;
6535 }
6536
Mohit Khanna765234a2012-09-11 15:08:35 -07006537 if ( req->channel )
6538 {
6539 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
6540 req->ssid_len, req->bssid,
6541 req->channel->hw_value);
6542 }
6543 else
6544 {
6545 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306546 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -07006547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006548
6549 if (0 > status)
6550 {
6551 //ReEnable BMPS if disabled
6552 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
6553 (NULL != pHddCtx))
6554 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306555 if (pHddCtx->hdd_wlan_suspended)
6556 {
6557 hdd_set_pwrparams(pHddCtx);
6558 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006559 //ReEnable Bmps and Imps back
6560 hdd_enable_bmps_imps(pHddCtx);
6561 }
6562
6563 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6564 return status;
6565 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306566 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006567 EXIT();
6568 return status;
6569}
6570
6571
6572/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306573 * FUNCTION: wlan_hdd_disconnect
6574 * This function is used to issue a disconnect request to SME
6575 */
6576int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
6577{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306578 int status;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306579 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306580 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6581
6582 status = wlan_hdd_validate_context(pHddCtx);
6583
6584 if (0 != status)
6585 {
6586 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6587 "%s: HDD context is not valid", __func__);
6588 return status;
6589 }
6590
6591 pHddCtx->isAmpAllowed = VOS_TRUE;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306592 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306593 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306594
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306595 /*issue disconnect*/
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05306596
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306597 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
6598 pAdapter->sessionId, reason);
6599
6600 if ( 0 != status )
6601 {
6602 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006603 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306604 __func__, (int)status );
6605 return -EINVAL;
6606 }
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05306607 status = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306608 &pAdapter->disconnect_comp_var,
6609 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05306610 if (!status)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306611 {
6612 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05306613 "%s: Failed to disconnect, timed out", __func__);
6614 return -ETIMEDOUT;
6615 }
6616 else if (status == -ERESTARTSYS)
6617 {
6618 hddLog(VOS_TRACE_LEVEL_ERROR,
6619 "%s: Failed to disconnect, wait interrupted", __func__);
6620 return status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306621 }
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306622 /*stop tx queues*/
6623 netif_tx_disable(pAdapter->dev);
6624 netif_carrier_off(pAdapter->dev);
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05306625 return 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306626}
6627
6628
6629/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006630 * FUNCTION: wlan_hdd_cfg80211_disconnect
6631 * This function is used to issue a disconnect request to SME
6632 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306633static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006634 struct net_device *dev,
6635 u16 reason
6636 )
6637{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306638 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6639 tCsrRoamProfile *pRoamProfile =
Jeff Johnson295189b2012-06-20 16:38:30 -07006640 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306641 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006642 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006643 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306644#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006645 tANI_U8 staIdx;
6646#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306647
Jeff Johnson295189b2012-06-20 16:38:30 -07006648 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306649
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306650 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6651 TRACE_CODE_HDD_CFG80211_DISCONNECT,
6652 pAdapter->sessionId, reason));
6653 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006654 __func__,pAdapter->device_mode);
6655
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306656 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
6657 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006658
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306659 status = wlan_hdd_validate_context(pHddCtx);
6660
6661 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006662 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306663 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6664 "%s: HDD context is not valid", __func__);
6665 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006666 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306667
Jeff Johnson295189b2012-06-20 16:38:30 -07006668 if (NULL != pRoamProfile)
6669 {
6670 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +05306671 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
6672 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -07006673 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306674 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07006675 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306676 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07006677 switch(reason)
6678 {
6679 case WLAN_REASON_MIC_FAILURE:
6680 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
6681 break;
6682
6683 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
6684 case WLAN_REASON_DISASSOC_AP_BUSY:
6685 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
6686 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
6687 break;
6688
6689 case WLAN_REASON_PREV_AUTH_NOT_VALID:
6690 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
6691 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
6692 break;
6693
6694 case WLAN_REASON_DEAUTH_LEAVING:
6695 default:
6696 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
6697 break;
6698 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306699 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
6700 pScanInfo = &pHddCtx->scan_info;
6701 if (pScanInfo->mScanPending)
6702 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306703 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306704 "Aborting Scan");
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306705 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
6706 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306707 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006708
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006709#ifdef FEATURE_WLAN_TDLS
6710 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006711 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006712 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006713 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
6714 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006715 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006716 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006717 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006718 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006719 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006720 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006721 MAC_ADDR_ARRAY(mac));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006722 sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006723 pAdapter->sessionId,
6724 mac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006725 }
6726 }
6727#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05306728 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306729 status = wlan_hdd_disconnect(pAdapter, reasonCode);
6730 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -07006731 {
6732 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006733 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006734 __func__, (int)status );
6735 return -EINVAL;
6736 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006737 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +05306738 else
6739 {
6740 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
6741 "called while in %d state", __func__,
6742 pHddStaCtx->conn_info.connState);
6743 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006744 }
6745 else
6746 {
6747 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
6748 }
6749
6750 return status;
6751}
6752
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306753
Jeff Johnson295189b2012-06-20 16:38:30 -07006754/*
6755 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306756 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006757 * settings in IBSS mode.
6758 */
6759static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306760 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006761 struct cfg80211_ibss_params *params
6762 )
6763{
6764 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306765 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006766 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6767 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306768
Jeff Johnson295189b2012-06-20 16:38:30 -07006769 ENTER();
6770
6771 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -07006772 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006773
6774 if (params->ie_len && ( NULL != params->ie) )
6775 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006776 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6777 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006778 {
6779 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
6780 encryptionType = eCSR_ENCRYPT_TYPE_AES;
6781 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006782 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006783 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006784 tDot11fIEWPA dot11WPAIE;
6785 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006786 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006787
Wilson Yang00256342013-10-10 23:13:38 -07006788 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006789 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6790 params->ie_len, DOT11F_EID_WPA);
6791 if ( NULL != ie )
6792 {
6793 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
6794 // Unpack the WPA IE
6795 //Skip past the EID byte and length byte - and four byte WiFi OUI
6796 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
6797 &ie[2+4],
6798 ie[1] - 4,
6799 &dot11WPAIE);
6800 /*Extract the multicast cipher, the encType for unicast
6801 cipher for wpa-none is none*/
6802 encryptionType =
6803 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
6804 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006805 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006806
Jeff Johnson295189b2012-06-20 16:38:30 -07006807 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
6808
6809 if (0 > status)
6810 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306811 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006812 __func__);
6813 return status;
6814 }
6815 }
6816
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306817 pWextState->roamProfile.AuthType.authType[0] =
6818 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -07006819 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6820
6821 if (params->privacy)
6822 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306823 /* Security enabled IBSS, At this time there is no information available
6824 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -07006825 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306826 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -07006827 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306828 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -07006829 *enable privacy bit in beacons */
6830
6831 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6832 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006833 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
6834 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07006835 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
6836 pWextState->roamProfile.EncryptionType.numEntries = 1;
6837 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07006838 return status;
6839}
6840
6841/*
6842 * FUNCTION: wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306843 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006844 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306845static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006846 struct net_device *dev,
6847 struct cfg80211_ibss_params *params
6848 )
6849{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306850 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006851 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6852 tCsrRoamProfile *pRoamProfile;
6853 int status;
krunal sonie9002db2013-11-25 14:24:17 -08006854 bool alloc_bssid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006855 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306856 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006857
6858 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306859
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306860 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6861 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
6862 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306863 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006864 "%s: device_mode = %d",__func__,pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006865
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306866 status = wlan_hdd_validate_context(pHddCtx);
6867
6868 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006869 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306870 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6871 "%s: HDD context is not valid", __func__);
6872 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006873 }
6874
6875 if (NULL == pWextState)
6876 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006877 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -07006878 __func__);
6879 return -EIO;
6880 }
6881
Vinay Krishna Eranna21042322014-01-08 19:21:39 +05306882 /*Try disconnecting if already in connected state*/
6883 status = wlan_hdd_try_disconnect(pAdapter);
6884 if ( 0 > status)
6885 {
6886 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
6887 " IBSS connection"));
6888 return -EALREADY;
6889 }
6890
Jeff Johnson295189b2012-06-20 16:38:30 -07006891 pRoamProfile = &pWextState->roamProfile;
6892
6893 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
6894 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306895 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006896 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006897 return -EINVAL;
6898 }
6899
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -07006900 /* BSSID is provided by upper layers hence no need to AUTO generate */
6901 if (NULL != params->bssid) {
6902 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
6903 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
6904 hddLog (VOS_TRACE_LEVEL_ERROR,
6905 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
6906 return -EIO;
6907 }
6908 }
krunal sonie9002db2013-11-25 14:24:17 -08006909 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
6910 {
6911 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
6912 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
6913 {
6914 hddLog (VOS_TRACE_LEVEL_ERROR,
6915 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
6916 return -EIO;
6917 }
6918 params->bssid = vos_mem_malloc(sizeof(VOS_MAC_ADDR_SIZE));
6919 if (!params->bssid)
6920 {
6921 hddLog (VOS_TRACE_LEVEL_ERROR,
6922 "%s:Failed memory allocation", __func__);
6923 return -EIO;
6924 }
6925 vos_mem_copy((v_U8_t *)params->bssid,
6926 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
6927 VOS_MAC_ADDR_SIZE);
6928 alloc_bssid = VOS_TRUE;
6929 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -07006930
Jeff Johnson295189b2012-06-20 16:38:30 -07006931 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -07006932 if (NULL !=
6933#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6934 params->chandef.chan)
6935#else
6936 params->channel)
6937#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006938 {
6939 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006940 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6941 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6942 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6943 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006944
6945 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306946 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -07006947 ieee80211_frequency_to_channel(
6948#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6949 params->chandef.chan->center_freq);
6950#else
6951 params->channel->center_freq);
6952#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006953
6954 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6955 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -07006956 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006957 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
6958 __func__);
6959 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -07006960 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006961
6962 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006963 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006964 if (channelNum == validChan[indx])
6965 {
6966 break;
6967 }
6968 }
6969 if (indx >= numChans)
6970 {
6971 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006972 __func__, channelNum);
6973 return -EINVAL;
6974 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006975 /* Set the Operational Channel */
6976 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
6977 channelNum);
6978 pRoamProfile->ChannelInfo.numOfChannels = 1;
6979 pHddStaCtx->conn_info.operationChannel = channelNum;
6980 pRoamProfile->ChannelInfo.ChannelList =
6981 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006982 }
6983
6984 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306985 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -07006986 if (status < 0)
6987 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306988 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -07006989 __func__);
6990 return status;
6991 }
6992
6993 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306994 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006995 params->ssid_len, params->bssid,
6996 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006997
6998 if (0 > status)
6999 {
7000 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
7001 return status;
7002 }
7003
krunal sonie9002db2013-11-25 14:24:17 -08007004 if (NULL != params->bssid &&
7005 pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 &&
7006 alloc_bssid == VOS_TRUE)
7007 {
7008 vos_mem_free(params->bssid);
7009 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007010 return 0;
7011}
7012
7013/*
7014 * FUNCTION: wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307015 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07007016 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307017static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007018 struct net_device *dev
7019 )
7020{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307021 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07007022 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7023 tCsrRoamProfile *pRoamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307024 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7025 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007026
7027 ENTER();
7028
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307029 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7030 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
7031 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307032 status = wlan_hdd_validate_context(pHddCtx);
7033
7034 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007035 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307036 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7037 "%s: HDD context is not valid", __func__);
7038 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007039 }
7040
Arif Hussain6d2a3322013-11-17 19:50:10 -08007041 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",__func__,pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007042 if (NULL == pWextState)
7043 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007044 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -07007045 __func__);
7046 return -EIO;
7047 }
7048
7049 pRoamProfile = &pWextState->roamProfile;
7050
7051 /* Issue disconnect only if interface type is set to IBSS */
7052 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
7053 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307054 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -07007055 __func__);
7056 return -EINVAL;
7057 }
7058
7059 /* Issue Disconnect request */
7060 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7061 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
7062 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
7063
7064 return 0;
7065}
7066
7067/*
7068 * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params
7069 * This function is used to set the phy parameters
7070 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
7071 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307072static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007073 u32 changed)
7074{
7075 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7076 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307077 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007078
7079 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307080 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7081 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
7082 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307083 status = wlan_hdd_validate_context(pHddCtx);
7084
7085 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007086 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307087 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7088 "%s: HDD context is not valid", __func__);
7089 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007090 }
7091
Jeff Johnson295189b2012-06-20 16:38:30 -07007092 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
7093 {
7094 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
7095 WNI_CFG_RTS_THRESHOLD_STAMAX :
7096 wiphy->rts_threshold;
7097
7098 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307099 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -07007100 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307101 hddLog(VOS_TRACE_LEVEL_ERROR,
7102 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007103 __func__, rts_threshold);
7104 return -EINVAL;
7105 }
7106
7107 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
7108 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307109 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07007110 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307111 hddLog(VOS_TRACE_LEVEL_ERROR,
7112 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007113 __func__, rts_threshold);
7114 return -EIO;
7115 }
7116
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307117 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007118 rts_threshold);
7119 }
7120
7121 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
7122 {
7123 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
7124 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
7125 wiphy->frag_threshold;
7126
7127 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307128 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007129 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307130 hddLog(VOS_TRACE_LEVEL_ERROR,
7131 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007132 frag_threshold);
7133 return -EINVAL;
7134 }
7135
7136 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
7137 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307138 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07007139 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307140 hddLog(VOS_TRACE_LEVEL_ERROR,
7141 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007142 __func__, frag_threshold);
7143 return -EIO;
7144 }
7145
7146 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
7147 frag_threshold);
7148 }
7149
7150 if ((changed & WIPHY_PARAM_RETRY_SHORT)
7151 || (changed & WIPHY_PARAM_RETRY_LONG))
7152 {
7153 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
7154 wiphy->retry_short :
7155 wiphy->retry_long;
7156
7157 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
7158 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
7159 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307160 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007161 __func__, retry_value);
7162 return -EINVAL;
7163 }
7164
7165 if (changed & WIPHY_PARAM_RETRY_SHORT)
7166 {
7167 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
7168 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307169 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07007170 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307171 hddLog(VOS_TRACE_LEVEL_ERROR,
7172 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007173 __func__, retry_value);
7174 return -EIO;
7175 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307176 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007177 __func__, retry_value);
7178 }
7179 else if (changed & WIPHY_PARAM_RETRY_SHORT)
7180 {
7181 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
7182 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307183 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07007184 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307185 hddLog(VOS_TRACE_LEVEL_ERROR,
7186 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007187 __func__, retry_value);
7188 return -EIO;
7189 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307190 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007191 __func__, retry_value);
7192 }
7193 }
7194
7195 return 0;
7196}
7197
7198/*
7199 * FUNCTION: wlan_hdd_cfg80211_set_txpower
7200 * This function is used to set the txpower
7201 */
7202static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07007203#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
7204 struct wireless_dev *wdev,
7205#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007206#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307207 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07007208#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307209 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07007210#endif
7211 int dbm)
7212{
7213 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307214 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007215 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
7216 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307217 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007218
7219 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307220 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7221 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
7222 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307223 status = wlan_hdd_validate_context(pHddCtx);
7224
7225 if (0 != status)
7226 {
7227 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7228 "%s: HDD context is not valid", __func__);
7229 return status;
7230 }
7231
7232 hHal = pHddCtx->hHal;
7233
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307234 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
7235 dbm, ccmCfgSetCallback,
7236 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07007237 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307238 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007239 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
7240 return -EIO;
7241 }
7242
7243 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
7244 dbm);
7245
7246 switch(type)
7247 {
7248 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
7249 /* Fall through */
7250 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
7251 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
7252 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307253 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
7254 __func__);
7255 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07007256 }
7257 break;
7258 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307259 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07007260 __func__);
7261 return -EOPNOTSUPP;
7262 break;
7263 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307264 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
7265 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -07007266 return -EIO;
7267 }
7268
7269 return 0;
7270}
7271
7272/*
7273 * FUNCTION: wlan_hdd_cfg80211_get_txpower
7274 * This function is used to read the txpower
7275 */
Yue Maf49ba872013-08-19 12:04:25 -07007276static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
7277#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
7278 struct wireless_dev *wdev,
7279#endif
7280 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -07007281{
7282
7283 hdd_adapter_t *pAdapter;
7284 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307285 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007286
Jeff Johnsone7245742012-09-05 17:12:55 -07007287 ENTER();
7288
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307289 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007290
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307291 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007292 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307293 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7294 "%s: HDD context is not valid", __func__);
7295 *dbm = 0;
7296 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007297 }
7298
Jeff Johnson295189b2012-06-20 16:38:30 -07007299 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
7300 if (NULL == pAdapter)
7301 {
7302 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
7303 return -ENOENT;
7304 }
7305
7306 wlan_hdd_get_classAstats(pAdapter);
7307 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
7308
Jeff Johnsone7245742012-09-05 17:12:55 -07007309 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007310 return 0;
7311}
7312
7313static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
7314 u8* mac, struct station_info *sinfo)
7315{
7316 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
7317 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7318 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
7319 tANI_U8 rate_flags;
7320
7321 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
7322 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07007323
7324 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
7325 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
7326 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
7327 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
7328 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
7329 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
7330 tANI_U16 maxRate = 0;
7331 tANI_U16 myRate;
7332 tANI_U16 currentRate = 0;
7333 tANI_U8 maxSpeedMCS = 0;
7334 tANI_U8 maxMCSIdx = 0;
7335 tANI_U8 rateFlag = 1;
7336 tANI_U8 i, j, rssidx;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07007337 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307338 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007339
Leo Chang6f8870f2013-03-26 18:11:36 -07007340#ifdef WLAN_FEATURE_11AC
7341 tANI_U32 vht_mcs_map;
7342 eDataRate11ACMaxMcs vhtMaxMcs;
7343#endif /* WLAN_FEATURE_11AC */
7344
Jeff Johnsone7245742012-09-05 17:12:55 -07007345 ENTER();
7346
Jeff Johnson295189b2012-06-20 16:38:30 -07007347 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
7348 (0 == ssidlen))
7349 {
7350 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
7351 " Invalid ssidlen, %d", __func__, ssidlen);
7352 /*To keep GUI happy*/
7353 return 0;
7354 }
7355
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307356 status = wlan_hdd_validate_context(pHddCtx);
7357
7358 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007359 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307360 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7361 "%s: HDD context is not valid", __func__);
7362 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007363 }
7364
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07007365 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007366 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
7367
Kiet Lam3b17fc82013-09-27 05:24:08 +05307368 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
7369 sinfo->filled |= STATION_INFO_SIGNAL;
7370
Jeff Johnson295189b2012-06-20 16:38:30 -07007371 //convert to the UI units of 100kbps
7372 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
7373
7374#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -07007375 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 -07007376 sinfo->signal,
7377 pCfg->reportMaxLinkSpeed,
7378 myRate,
7379 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007380 (int) pCfg->linkSpeedRssiMid,
7381 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -07007382 (int) rate_flags,
7383 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07007384#endif //LINKSPEED_DEBUG_ENABLED
7385
7386 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
7387 {
7388 // we do not want to necessarily report the current speed
7389 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
7390 {
7391 // report the max possible speed
7392 rssidx = 0;
7393 }
7394 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
7395 {
7396 // report the max possible speed with RSSI scaling
7397 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
7398 {
7399 // report the max possible speed
7400 rssidx = 0;
7401 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007402 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -07007403 {
7404 // report middle speed
7405 rssidx = 1;
7406 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007407 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
7408 {
7409 // report middle speed
7410 rssidx = 2;
7411 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007412 else
7413 {
7414 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007415 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07007416 }
7417 }
7418 else
7419 {
7420 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
7421 hddLog(VOS_TRACE_LEVEL_ERROR,
7422 "%s: Invalid value for reportMaxLinkSpeed: %u",
7423 __func__, pCfg->reportMaxLinkSpeed);
7424 rssidx = 0;
7425 }
7426
7427 maxRate = 0;
7428
7429 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05307430 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
7431 OperationalRates, &ORLeng))
7432 {
7433 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
7434 /*To keep GUI happy*/
7435 return 0;
7436 }
7437
Jeff Johnson295189b2012-06-20 16:38:30 -07007438 for (i = 0; i < ORLeng; i++)
7439 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007440 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07007441 {
7442 /* Validate Rate Set */
7443 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
7444 {
7445 currentRate = supported_data_rate[j].supported_rate[rssidx];
7446 break;
7447 }
7448 }
7449 /* Update MAX rate */
7450 maxRate = (currentRate > maxRate)?currentRate:maxRate;
7451 }
7452
7453 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05307454 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
7455 ExtendedRates, &ERLeng))
7456 {
7457 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
7458 /*To keep GUI happy*/
7459 return 0;
7460 }
7461
Jeff Johnson295189b2012-06-20 16:38:30 -07007462 for (i = 0; i < ERLeng; i++)
7463 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007464 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07007465 {
7466 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
7467 {
7468 currentRate = supported_data_rate[j].supported_rate[rssidx];
7469 break;
7470 }
7471 }
7472 /* Update MAX rate */
7473 maxRate = (currentRate > maxRate)?currentRate:maxRate;
7474 }
Kiet Lamb69f8dc2013-11-15 15:34:27 +05307475 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +05307476 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +05307477 if we have good rssi */
Kaushik, Sushantdc304d82014-01-22 10:58:37 +05307478 if ((0 == rssidx) ||
Kiet Lamb69f8dc2013-11-15 15:34:27 +05307479 (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed))
Jeff Johnson295189b2012-06-20 16:38:30 -07007480 {
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05307481 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
7482 MCSRates, &MCSLeng))
7483 {
7484 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
7485 /*To keep GUI happy*/
7486 return 0;
7487 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007488 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -07007489#ifdef WLAN_FEATURE_11AC
7490 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307491 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -07007492 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007493 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307494 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -07007495 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -07007496 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007497 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007498 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007499 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -07007500 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007501 maxMCSIdx = 7;
7502 }
7503 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
7504 {
7505 maxMCSIdx = 8;
7506 }
7507 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
7508 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307509 //VHT20 is supporting 0~8
7510 if (rate_flags & eHAL_TX_RATE_VHT20)
7511 maxMCSIdx = 8;
7512 else
7513 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -07007514 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307515
7516 if (rate_flags & eHAL_TX_RATE_VHT80)
7517 {
7518 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
7519 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
7520 }
7521 else if (rate_flags & eHAL_TX_RATE_VHT40)
7522 {
7523 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
7524 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
7525 }
7526 else if (rate_flags & eHAL_TX_RATE_VHT20)
7527 {
7528 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
7529 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
7530 }
7531
Leo Chang6f8870f2013-03-26 18:11:36 -07007532 maxSpeedMCS = 1;
7533 if (currentRate > maxRate)
7534 {
7535 maxRate = currentRate;
7536 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307537
Leo Chang6f8870f2013-03-26 18:11:36 -07007538 }
7539 else
7540#endif /* WLAN_FEATURE_11AC */
7541 {
7542 if (rate_flags & eHAL_TX_RATE_HT40)
7543 {
7544 rateFlag |= 1;
7545 }
7546 if (rate_flags & eHAL_TX_RATE_SGI)
7547 {
7548 rateFlag |= 2;
7549 }
7550
7551 for (i = 0; i < MCSLeng; i++)
7552 {
7553 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
7554 for (j = 0; j < temp; j++)
7555 {
7556 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
7557 {
7558 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
7559 break;
7560 }
7561 }
7562 if ((j < temp) && (currentRate > maxRate))
7563 {
7564 maxRate = currentRate;
7565 maxSpeedMCS = 1;
7566 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
7567 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007568 }
7569 }
7570 }
7571
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307572 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
7573 {
7574 maxRate = myRate;
7575 maxSpeedMCS = 1;
7576 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
7577 }
7578
Jeff Johnson295189b2012-06-20 16:38:30 -07007579 // make sure we report a value at least as big as our current rate
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007580 if (((maxRate < myRate) && (0 == rssidx)) ||
7581 (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -07007582 {
7583 maxRate = myRate;
7584 if (rate_flags & eHAL_TX_RATE_LEGACY)
7585 {
7586 maxSpeedMCS = 0;
7587 }
7588 else
7589 {
7590 maxSpeedMCS = 1;
7591 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
7592 }
7593 }
7594
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307595 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -07007596 {
7597 sinfo->txrate.legacy = maxRate;
7598#ifdef LINKSPEED_DEBUG_ENABLED
7599 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
7600#endif //LINKSPEED_DEBUG_ENABLED
7601 }
7602 else
7603 {
7604 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -07007605#ifdef WLAN_FEATURE_11AC
7606 sinfo->txrate.nss = 1;
7607 if (rate_flags & eHAL_TX_RATE_VHT80)
7608 {
7609 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307610 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -07007611 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307612 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -07007613 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307614 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7615 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7616 }
7617 else if (rate_flags & eHAL_TX_RATE_VHT20)
7618 {
7619 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7620 }
7621#endif /* WLAN_FEATURE_11AC */
7622 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
7623 {
7624 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7625 if (rate_flags & eHAL_TX_RATE_HT40)
7626 {
7627 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7628 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007629 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007630 if (rate_flags & eHAL_TX_RATE_SGI)
7631 {
7632 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7633 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307634
Jeff Johnson295189b2012-06-20 16:38:30 -07007635#ifdef LINKSPEED_DEBUG_ENABLED
7636 pr_info("Reporting MCS rate %d flags %x\n",
7637 sinfo->txrate.mcs,
7638 sinfo->txrate.flags );
7639#endif //LINKSPEED_DEBUG_ENABLED
7640 }
7641 }
7642 else
7643 {
7644 // report current rate instead of max rate
7645
7646 if (rate_flags & eHAL_TX_RATE_LEGACY)
7647 {
7648 //provide to the UI in units of 100kbps
7649 sinfo->txrate.legacy = myRate;
7650#ifdef LINKSPEED_DEBUG_ENABLED
7651 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
7652#endif //LINKSPEED_DEBUG_ENABLED
7653 }
7654 else
7655 {
7656 //must be MCS
7657 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -07007658#ifdef WLAN_FEATURE_11AC
7659 sinfo->txrate.nss = 1;
7660 if (rate_flags & eHAL_TX_RATE_VHT80)
7661 {
7662 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7663 }
7664 else
7665#endif /* WLAN_FEATURE_11AC */
7666 {
7667 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7668 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007669 if (rate_flags & eHAL_TX_RATE_SGI)
7670 {
7671 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7672 }
7673 if (rate_flags & eHAL_TX_RATE_HT40)
7674 {
7675 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7676 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007677#ifdef WLAN_FEATURE_11AC
7678 else if (rate_flags & eHAL_TX_RATE_VHT80)
7679 {
7680 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
7681 }
7682#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -07007683#ifdef LINKSPEED_DEBUG_ENABLED
7684 pr_info("Reporting actual MCS rate %d flags %x\n",
7685 sinfo->txrate.mcs,
7686 sinfo->txrate.flags );
7687#endif //LINKSPEED_DEBUG_ENABLED
7688 }
7689 }
7690 sinfo->filled |= STATION_INFO_TX_BITRATE;
7691
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07007692 sinfo->tx_packets =
7693 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
7694 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
7695 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
7696 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
7697
7698 sinfo->tx_retries =
7699 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
7700 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
7701 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
7702 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
7703
7704 sinfo->tx_failed =
7705 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
7706 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
7707 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
7708 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
7709
7710 sinfo->filled |=
7711 STATION_INFO_TX_PACKETS |
7712 STATION_INFO_TX_RETRIES |
7713 STATION_INFO_TX_FAILED;
7714
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307715 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7716 TRACE_CODE_HDD_CFG80211_GET_STA,
7717 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07007718 EXIT();
7719 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007720}
7721
7722static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -07007723 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -07007724{
7725 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307726 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007727 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307728 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007729
Jeff Johnsone7245742012-09-05 17:12:55 -07007730 ENTER();
7731
Jeff Johnson295189b2012-06-20 16:38:30 -07007732 if (NULL == pAdapter)
7733 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007734 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007735 return -ENODEV;
7736 }
7737
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307738 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7739 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
7740 pAdapter->sessionId, timeout));
7741
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307742 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307743 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307744
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307745 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307746 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307747 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7748 "%s: HDD context is not valid", __func__);
7749 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307750 }
7751
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307752 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
7753 (TRUE == pHddCtx->hdd_wlan_suspended) &&
7754 (pHddCtx->cfg_ini->fhostArpOffload) &&
7755 (eConnectionState_Associated ==
7756 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
7757 {
Amar Singhald53568e2013-09-26 11:03:45 -07007758
7759 hddLog(VOS_TRACE_LEVEL_INFO,
7760 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307761 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307762 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7763 {
7764 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007765 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307766 __func__, vos_status);
7767 }
7768 }
7769
Jeff Johnson295189b2012-06-20 16:38:30 -07007770 /**The get power cmd from the supplicant gets updated by the nl only
7771 *on successful execution of the function call
7772 *we are oppositely mapped w.r.t mode in the driver
7773 **/
7774 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
7775
Jeff Johnsone7245742012-09-05 17:12:55 -07007776 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007777 if (VOS_STATUS_E_FAILURE == vos_status)
7778 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307779 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7780 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007781 return -EINVAL;
7782 }
7783 return 0;
7784}
7785
7786
7787#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7788static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
7789 struct net_device *netdev,
7790 u8 key_index)
7791{
Jeff Johnsone7245742012-09-05 17:12:55 -07007792 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007793 return 0;
7794}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307795#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -07007796
7797#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7798static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7799 struct net_device *dev,
7800 struct ieee80211_txq_params *params)
7801{
Jeff Johnsone7245742012-09-05 17:12:55 -07007802 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007803 return 0;
7804}
7805#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7806static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7807 struct ieee80211_txq_params *params)
7808{
Jeff Johnsone7245742012-09-05 17:12:55 -07007809 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007810 return 0;
7811}
7812#endif //LINUX_VERSION_CODE
7813
7814static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
7815 struct net_device *dev, u8 *mac)
7816{
7817 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307818 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007819 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307820 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007821 v_U8_t staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007822
Jeff Johnsone7245742012-09-05 17:12:55 -07007823 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307824
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307825 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -07007826 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307827 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007828 return -EINVAL;
7829 }
7830
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307831 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7832 TRACE_CODE_HDD_CFG80211_DEL_STA,
7833 pAdapter->sessionId, pAdapter->device_mode));
7834
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307835 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7836 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007837
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307838 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007839 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307840 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7841 "%s: HDD context is not valid", __func__);
7842 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007843 }
7844
Jeff Johnson295189b2012-06-20 16:38:30 -07007845 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007846 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007847 )
7848 {
7849 if( NULL == mac )
7850 {
7851 v_U16_t i;
7852 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
7853 {
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007854 if ((pAdapter->aStaInfo[i].isUsed) &&
7855 (!pAdapter->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -07007856 {
7857 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
7858 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007859 "%s: Delete STA with MAC::"
7860 MAC_ADDRESS_STR,
7861 __func__, MAC_ADDR_ARRAY(macAddr));
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007862 vos_status = hdd_softap_sta_deauth(pAdapter, macAddr);
7863 if (VOS_IS_STATUS_SUCCESS(vos_status))
7864 pAdapter->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007865 }
7866 }
7867 }
7868 else
7869 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007870
7871 vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId);
7872 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7873 {
7874 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007875 "%s: Skip this DEL STA as this is not used::"
7876 MAC_ADDRESS_STR,
7877 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007878 return -ENOENT;
7879 }
7880
7881 if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE)
7882 {
7883 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007884 "%s: Skip this DEL STA as deauth is in progress::"
7885 MAC_ADDRESS_STR,
7886 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007887 return -ENOENT;
7888 }
7889
7890 pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE;
7891
Jeff Johnson295189b2012-06-20 16:38:30 -07007892 hddLog(VOS_TRACE_LEVEL_INFO,
7893 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -08007894 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007895 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -08007896 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007897
7898 vos_status = hdd_softap_sta_deauth(pAdapter, mac);
7899 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7900 {
7901 pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE;
7902 hddLog(VOS_TRACE_LEVEL_INFO,
7903 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -08007904 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007905 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -08007906 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007907 return -ENOENT;
7908 }
7909
Jeff Johnson295189b2012-06-20 16:38:30 -07007910 }
7911 }
7912
7913 EXIT();
7914
7915 return 0;
7916}
7917
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007918static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
7919 struct net_device *dev, u8 *mac, struct station_parameters *params)
7920{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307921 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007922 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007923#ifdef FEATURE_WLAN_TDLS
7924 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007925 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307926
7927 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7928 TRACE_CODE_HDD_CFG80211_ADD_STA,
7929 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007930 mask = params->sta_flags_mask;
7931
7932 set = params->sta_flags_set;
7933
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007934#ifdef WLAN_FEATURE_TDLS_DEBUG
7935 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7936 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
7937 __func__, mask, set, MAC_ADDR_ARRAY(mac));
7938#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007939
7940 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
7941 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007942 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007943 }
7944 }
7945#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007946 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007947}
7948
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007949
7950#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -07007951#define MAX_PMKSAIDS_IN_CACHE 8
7952
7953static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD local cache
7954static tANI_U32 PMKIDCacheIndex; // HDD local Cache index
7955
7956
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007957static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07007958 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007959{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307960 tANI_U32 j=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007961 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7962 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307963 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307964 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007965 tANI_U8 BSSIDMatched = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307966 hdd_context_t *pHddCtx;
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007967 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
7968 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07007969
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307970 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307971 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007972 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307973 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007974 return -EINVAL;
7975 }
7976
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307977 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7978 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007979
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307980 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007981 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307982 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7983 "%s: HDD context is not valid", __func__);
7984 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007985 }
7986
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307987 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007988 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7989
Wilson Yang6507c4e2013-10-01 20:11:19 -07007990 for (j = 0; j < PMKIDCacheIndex; j++)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007991 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307992 if(vos_mem_compare(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007993 pmksa->bssid, WNI_CFG_BSSID_LEN))
7994 {
7995 /* BSSID matched previous entry. Overwrite it. */
7996 BSSIDMatched = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307997 vos_mem_copy(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007998 pmksa->bssid, WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307999 vos_mem_copy(PMKIDCache[j].PMKID,
8000 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008001 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308002 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008003 __func__, j );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008004 dump_bssid(pmksa->bssid);
8005 dump_pmkid(halHandle, pmksa->pmkid);
8006 break;
8007 }
8008 }
8009
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07008010 /* Check we compared all entries,if then take the first slot now */
Wilson Yang6507c4e2013-10-01 20:11:19 -07008011 if(j == MAX_PMKSAIDS_IN_CACHE) PMKIDCacheIndex=0;
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07008012
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008013 if (!BSSIDMatched)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308014 {
8015 // Now, we DON'T have a BSSID match, so take a new entry in the cache.
Wilson Yang6507c4e2013-10-01 20:11:19 -07008016 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].BSSID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308017 pmksa->bssid, ETHER_ADDR_LEN);
Wilson Yang6507c4e2013-10-01 20:11:19 -07008018 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].PMKID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308019 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008020 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308021 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Adding a new cache entry %d.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07008022 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008023 dump_bssid(pmksa->bssid);
8024 dump_pmkid(halHandle, pmksa->pmkid);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308025 // Increment the HDD Local Cache index
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008026 // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME
Wilson Yang6507c4e2013-10-01 20:11:19 -07008027 if (PMKIDCacheIndex <= (MAX_PMKSAIDS_IN_CACHE-1)) PMKIDCacheIndex++; else PMKIDCacheIndex = 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008028 }
8029
8030
8031 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308032 //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008033 // __func__, i );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308034 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07008035 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008036 // Finally set the PMKSA ID Cache in CSR
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308037 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
8038 PMKIDCache,
Wilson Yang6507c4e2013-10-01 20:11:19 -07008039 PMKIDCacheIndex);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308040 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8041 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
8042 pAdapter->sessionId, result));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008043 return 0;
8044}
8045
8046
Wilson Yang6507c4e2013-10-01 20:11:19 -07008047
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008048static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -07008049 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008050{
Wilson Yang6507c4e2013-10-01 20:11:19 -07008051 tANI_U32 j=0;
8052 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8053 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008054 tANI_U8 BSSIDMatched = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008055 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -08008056 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008057
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008058 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
8059 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -07008060
8061 /* Validate pAdapter */
8062 if (NULL == pAdapter)
8063 {
8064 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
8065 return -EINVAL;
8066 }
8067
8068 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8069 status = wlan_hdd_validate_context(pHddCtx);
8070
8071 if (0 != status)
8072 {
8073 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8074 "%s: HDD context is not valid", __func__);
8075 return status;
8076 }
8077
8078 /*Retrieve halHandle*/
8079 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
8080
8081 /*in case index is 0,no entry to delete*/
8082 if (0 == PMKIDCacheIndex)
8083 {
8084 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" ,
8085 __func__);
8086 return -EINVAL;
8087 }
8088
8089 /*find the matching PMKSA entry from j=0 to (index-1),
8090 * and delete the matched one
8091 */
8092 for (j = 0; j<PMKIDCacheIndex; j++)
8093 {
8094 if (vos_mem_compare(PMKIDCache[j].BSSID,
8095 pmksa->bssid,
8096 WNI_CFG_BSSID_LEN))
8097 {
8098 /* BSSID matched entry */
8099 BSSIDMatched = 1;
8100
8101 if (j<PMKIDCacheIndex-1)
8102 {
8103 /*replace the matching entry with the last entry in HDD local cache*/
8104 vos_mem_copy(PMKIDCache[j].BSSID,
8105 PMKIDCache[PMKIDCacheIndex-1].BSSID,
8106 WNI_CFG_BSSID_LEN);
8107 vos_mem_copy(PMKIDCache[j].PMKID,
8108 PMKIDCache[PMKIDCacheIndex-1].PMKID,
8109 CSR_RSN_PMKID_SIZE);
8110 }
8111
8112 /*clear the last entry in HDD cache ---[index-1]*/
Wilson Yang6507c4e2013-10-01 20:11:19 -07008113 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].BSSID, WNI_CFG_BSSID_LEN);
8114 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].PMKID, CSR_RSN_PMKID_SIZE);
8115
8116 /*reduce the PMKID array index*/
8117 PMKIDCacheIndex--;
8118
8119 /*delete the last PMKID cache in CSR*/
Wilson Yangef657d32014-01-15 19:19:23 -08008120 if (eHAL_STATUS_SUCCESS !=
8121 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pmksa->bssid))
Wilson Yang6507c4e2013-10-01 20:11:19 -07008122 {
8123 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cannot delete PMKSA %d CONTENT.",
8124 __func__,PMKIDCacheIndex);
Wilson Yangef657d32014-01-15 19:19:23 -08008125 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008126 }
8127
8128 dump_bssid(pmksa->bssid);
8129 dump_pmkid(halHandle,pmksa->pmkid);
8130
8131 break;
8132 }
8133 }
8134
8135 /* we compare all entries,but cannot find matching entry */
8136 if (j == MAX_PMKSAIDS_IN_CACHE && !BSSIDMatched)
8137 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008138 hddLog(VOS_TRACE_LEVEL_FATAL,
8139 "%s: No such PMKSA entry existed " MAC_ADDRESS_STR,
8140 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -07008141 dump_bssid(pmksa->bssid);
8142 dump_pmkid(halHandle, pmksa->pmkid);
8143 return -EINVAL;
8144 }
Wilson Yangef657d32014-01-15 19:19:23 -08008145 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008146}
8147
Wilson Yang6507c4e2013-10-01 20:11:19 -07008148
8149
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008150static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
8151{
Wilson Yang6507c4e2013-10-01 20:11:19 -07008152 tANI_U32 j=0;
8153 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8154 tHalHandle halHandle;
8155 hdd_context_t *pHddCtx;
8156 tANI_U8 *pBSSId;
Wilson Yangef657d32014-01-15 19:19:23 -08008157 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008158
8159 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__);
8160
8161 /* Validate pAdapter */
8162 if (NULL == pAdapter)
8163 {
8164 hddLog(VOS_TRACE_LEVEL_ERROR,
8165 "%s: Invalid Adapter" ,__func__);
8166 return -EINVAL;
8167 }
8168
8169 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8170 status = wlan_hdd_validate_context(pHddCtx);
8171
8172 if (0 != status)
8173 {
8174 hddLog(VOS_TRACE_LEVEL_ERROR,
8175 "%s: HDD context is not valid", __func__);
8176 return status;
8177 }
8178
8179 /*Retrieve halHandle*/
8180 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
8181
8182 /*in case index is 0,no entry to delete*/
8183 if (0 == PMKIDCacheIndex)
8184 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +05308185 hddLog(VOS_TRACE_LEVEL_ERROR, FL("No entries to flush"));
Wilson Yang6507c4e2013-10-01 20:11:19 -07008186 return -EINVAL;
8187 }
8188
8189 /*delete all the PMKSA one by one */
8190 for (j = 0; j<PMKIDCacheIndex; j++)
8191 {
Wilson Yang6507c4e2013-10-01 20:11:19 -07008192 pBSSId =(tANI_U8 *)(PMKIDCache[j].BSSID);
Wilson Yang6507c4e2013-10-01 20:11:19 -07008193
8194 /*delete the PMKID in CSR*/
Wilson Yangef657d32014-01-15 19:19:23 -08008195 if (eHAL_STATUS_SUCCESS !=
8196 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId))
Wilson Yang6507c4e2013-10-01 20:11:19 -07008197 {
8198 hddLog(VOS_TRACE_LEVEL_ERROR ,"%s cannot flush PMKIDCache %d.",
8199 __func__,j);
Wilson Yangef657d32014-01-15 19:19:23 -08008200 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008201 }
Kiet Lam8d21d5b2013-10-31 17:18:29 +05308202 /*clear the entry in HDD cache 0--index-1 */
8203 vos_mem_zero(PMKIDCache[j].BSSID, WNI_CFG_BSSID_LEN);
8204 vos_mem_zero(PMKIDCache[j].PMKID, CSR_RSN_PMKID_SIZE);
Wilson Yang6507c4e2013-10-01 20:11:19 -07008205 }
8206
8207 PMKIDCacheIndex = 0;
Wilson Yangef657d32014-01-15 19:19:23 -08008208 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008209}
8210#endif
8211
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008212#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308213static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008214 struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie)
8215{
8216 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8217 hdd_station_ctx_t *pHddStaCtx;
8218
8219 if (NULL == pAdapter)
8220 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008221 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008222 return -ENODEV;
8223 }
8224
8225 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8226
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308227 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8228 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
8229 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008230 // Added for debug on reception of Re-assoc Req.
8231 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8232 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008233 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008234 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008235 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008236 }
8237
8238#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08008239 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008240 ftie->ie_len);
8241#endif
8242
8243 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +05308244 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
8245 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008246 ftie->ie_len);
8247 return 0;
8248}
8249#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008250
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308251#ifdef FEATURE_WLAN_SCAN_PNO
8252
8253void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
8254 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
8255{
8256 int ret;
8257 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
8258 hdd_context_t *pHddCtx;
8259
Nirav Shah80830bf2013-12-31 16:35:12 +05308260 ENTER();
8261
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308262 if (NULL == pAdapter)
8263 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05308264 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308265 "%s: HDD adapter is Null", __func__);
8266 return ;
8267 }
8268
8269 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8270 if (NULL == pHddCtx)
8271 {
8272 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8273 "%s: HDD context is Null!!!", __func__);
8274 return ;
8275 }
8276
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308277 spin_lock(&pHddCtx->schedScan_lock);
8278 if (TRUE == pHddCtx->isWiphySuspended)
8279 {
8280 pHddCtx->isSchedScanUpdatePending = TRUE;
8281 spin_unlock(&pHddCtx->schedScan_lock);
8282 hddLog(VOS_TRACE_LEVEL_INFO,
8283 "%s: Update cfg80211 scan database after it resume", __func__);
8284 return ;
8285 }
8286 spin_unlock(&pHddCtx->schedScan_lock);
8287
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308288 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
8289
8290 if (0 > ret)
8291 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
8292
8293 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308294 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8295 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308296}
8297
8298/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308299 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +05308300 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308301 */
8302static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
8303{
8304 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
8305 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308306 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308307 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8308 int status = 0;
8309 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
8310
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +05308311 /* The current firmware design does not allow PNO during any
8312 * active sessions. Hence, determine the active sessions
8313 * and return a failure.
8314 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308315 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
8316 {
8317 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308318 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308319
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308320 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
8321 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
8322 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
8323 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
8324 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
8325 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308326 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308327 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308328 }
8329 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
8330 pAdapterNode = pNext;
8331 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308332 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308333}
8334
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +05308335void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
8336{
8337 hdd_adapter_t *pAdapter = callbackContext;
8338 hdd_context_t *pHddCtx;
8339
8340 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
8341 {
8342 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8343 FL("Invalid adapter or adapter has invalid magic"));
8344 return;
8345 }
8346
8347 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8348 if (0 != wlan_hdd_validate_context(pHddCtx))
8349 {
8350 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8351 FL("HDD context is not valid"));
8352 return;
8353 }
8354
8355 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8356 FL("PNO enable response status = %d"), status);
8357
8358 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
8359 complete(&pAdapter->pno_comp_var);
8360}
8361
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308362/*
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308363 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
8364 * NL interface to enable PNO
8365 */
8366static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
8367 struct net_device *dev, struct cfg80211_sched_scan_request *request)
8368{
8369 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8370 tpSirPNOScanReq pPnoRequest = NULL;
8371 hdd_context_t *pHddCtx;
8372 tHalHandle hHal;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05308373 v_U32_t i, indx, num_ch, tempInterval;
Sushant Kaushikd62d9782014-02-19 15:39:40 +05308374 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
8375 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308376 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
8377 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308378 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308379
8380 if (NULL == pAdapter)
8381 {
8382 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8383 "%s: HDD adapter is Null", __func__);
8384 return -ENODEV;
8385 }
8386
8387 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308388 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308389
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308390 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308391 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308392 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8393 "%s: HDD context is not valid", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308394 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308395 }
8396
8397 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8398 if (NULL == hHal)
8399 {
8400 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8401 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308402 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308403 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308404
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308405 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308406 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +05308407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308408 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308409 return -EBUSY;
8410 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308411
8412 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
8413 if (NULL == pPnoRequest)
8414 {
8415 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8416 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308417 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308418 }
8419
Madan Mohan Koyyalamudic3f04352013-09-26 19:21:48 +05308420 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308421 pPnoRequest->enable = 1; /*Enable PNO */
8422 pPnoRequest->ucNetworksCount = request->n_match_sets;
8423
8424 if (( !pPnoRequest->ucNetworksCount ) ||
8425 ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
8426 {
8427 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +05308428 "%s: Network input is not correct %d",
8429 __func__, pPnoRequest->ucNetworksCount);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308430 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308431 goto error;
8432 }
8433
8434 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
8435 {
8436 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +05308437 "%s: Incorrect number of channels %d",
8438 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308439 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308440 goto error;
8441 }
8442
8443 /* Framework provides one set of channels(all)
8444 * common for all saved profile */
8445 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
8446 channels_allowed, &num_channels_allowed))
8447 {
8448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8449 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308450 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308451 goto error;
8452 }
8453 /* Checking each channel against allowed channel list */
8454 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +05308455 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308456 {
Nirav Shah80830bf2013-12-31 16:35:12 +05308457 char chList [(request->n_channels*5)+1];
8458 int len;
8459 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308460 {
Nirav Shah80830bf2013-12-31 16:35:12 +05308461 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308462 {
Nirav Shah80830bf2013-12-31 16:35:12 +05308463 if (request->channels[i]->hw_value == channels_allowed[indx])
8464 {
8465 valid_ch[num_ch++] = request->channels[i]->hw_value;
8466 len += snprintf(chList+len, 5, "%d ",
8467 request->channels[i]->hw_value);
8468 break ;
8469 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308470 }
8471 }
Nirav Shah80830bf2013-12-31 16:35:12 +05308472 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
8473 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308474
8475 /* Filling per profile params */
8476 for (i = 0; i < pPnoRequest->ucNetworksCount; i++)
8477 {
8478 pPnoRequest->aNetworks[i].ssId.length =
8479 request->match_sets[i].ssid.ssid_len;
8480
8481 if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) ||
8482 ( pPnoRequest->aNetworks[i].ssId.length > 32 ) )
8483 {
8484 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +05308485 "%s: SSID Len %d is not correct for network %d",
8486 __func__, pPnoRequest->aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308487 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308488 goto error;
8489 }
8490
8491 memcpy(pPnoRequest->aNetworks[i].ssId.ssId,
8492 request->match_sets[i].ssid.ssid,
8493 request->match_sets[i].ssid.ssid_len);
8494 pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
8495 pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/
8496 pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
8497
8498 /*Copying list of valid channel into request */
8499 memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch);
8500 pPnoRequest->aNetworks[i].ucChannelCount = num_ch;
8501
8502 pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value
8503 }
8504
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +05308505 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -08008506 "request->ie_len = %zu", request->ie_len);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +05308507 if ((0 < request->ie_len) && (NULL != request->ie))
8508 {
8509 pPnoRequest->us24GProbeTemplateLen = request->ie_len;
8510 memcpy(&pPnoRequest->p24GProbeTemplate, request->ie,
8511 pPnoRequest->us24GProbeTemplateLen);
8512
8513 pPnoRequest->us5GProbeTemplateLen = request->ie_len;
8514 memcpy(&pPnoRequest->p5GProbeTemplate, request->ie,
8515 pPnoRequest->us5GProbeTemplateLen);
8516 }
8517
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05308518 /* Driver gets only one time interval which is hardcoded in
8519 * supplicant for 10000ms. Taking power consumption into account 6 timers
8520 * will be used, Timervalue is increased exponentially i.e 10,20,40,
8521 * 80,160,320 secs. And number of scan cycle for each timer
8522 * is configurable through INI param gPNOScanTimerRepeatValue.
8523 * If it is set to 0 only one timer will be used and PNO scan cycle
8524 * will be repeated after each interval specified by supplicant
8525 * till PNO is disabled.
8526 */
8527 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
8528 pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
8529 else
8530 pPnoRequest->scanTimers.ucScanTimersCount =
8531 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
8532
8533 tempInterval = (request->interval)/1000;
8534 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8535 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
8536 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
8537 for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++)
8538 {
8539 pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat =
8540 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
8541 pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval;
8542 tempInterval *= 2;
8543 }
8544 //Repeat last timer until pno disabled.
8545 pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
8546
Madan Mohan Koyyalamudid206c7b2013-09-26 22:54:51 +05308547 pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308548
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +05308549 INIT_COMPLETION(pAdapter->pno_comp_var);
8550 pPnoRequest->statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
8551 pPnoRequest->callbackContext = pAdapter;
8552 pAdapter->pno_req_status = 0;
8553
Nirav Shah80830bf2013-12-31 16:35:12 +05308554 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8555 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
8556 pAdapter->sessionId, pPnoRequest->enable, pPnoRequest->modePNO,
8557 pPnoRequest->scanTimers.ucScanTimersCount);
8558
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308559 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
8560 pPnoRequest, pAdapter->sessionId,
8561 hdd_cfg80211_sched_scan_done_callback, pAdapter);
8562 if (eHAL_STATUS_SUCCESS != status)
8563 {
8564 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +05308565 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308566 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308567 goto error;
8568 }
8569
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +05308570 ret = wait_for_completion_timeout(
8571 &pAdapter->pno_comp_var,
8572 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
8573 if (0 >= ret)
8574 {
8575 // Did not receive the response for PNO enable in time.
8576 // Assuming the PNO enable was success.
8577 // Returning error from here, because we timeout, results
8578 // in side effect of Wifi (Wifi Setting) not to work.
8579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8580 FL("Timed out waiting for PNO to be Enabled"));
8581 ret = 0;
8582 goto error;
8583 }
8584
8585 ret = pAdapter->pno_req_status;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308586
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308587error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +05308588 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8589 FL("PNO scanRequest offloaded ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308590 vos_mem_free(pPnoRequest);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308591 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308592}
8593
8594/*
8595 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
8596 * NL interface to disable PNO
8597 */
8598static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
8599 struct net_device *dev)
8600{
8601 eHalStatus status = eHAL_STATUS_FAILURE;
8602 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8603 hdd_context_t *pHddCtx;
8604 tHalHandle hHal;
8605 tpSirPNOScanReq pPnoRequest = NULL;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308606 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308607
8608 ENTER();
8609
8610 if (NULL == pAdapter)
8611 {
8612 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8613 "%s: HDD adapter is Null", __func__);
8614 return -ENODEV;
8615 }
8616
8617 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308618
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308619 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308620 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308621 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308622 "%s: HDD context is Null", __func__);
8623 return -ENODEV;
8624 }
8625
8626 /* The return 0 is intentional when isLogpInProgress and
8627 * isLoadUnloadInProgress. We did observe a crash due to a return of
8628 * failure in sched_scan_stop , especially for a case where the unload
8629 * of the happens at the same time. The function __cfg80211_stop_sched_scan
8630 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
8631 * success. If it returns a failure , then its next invocation due to the
8632 * clean up of the second interface will have the dev pointer corresponding
8633 * to the first one leading to a crash.
8634 */
8635 if (pHddCtx->isLogpInProgress)
8636 {
8637 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8638 "%s: LOGP in Progress. Ignore!!!", __func__);
8639 return ret;
8640 }
8641
8642 if (pHddCtx->isLoadUnloadInProgress)
8643 {
8644 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8645 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
8646 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308647 }
8648
8649 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8650 if (NULL == hHal)
8651 {
8652 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8653 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308654 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308655 }
8656
8657 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
8658 if (NULL == pPnoRequest)
8659 {
8660 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8661 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308662 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308663 }
8664
8665 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
8666 pPnoRequest->enable = 0; /* Disable PNO */
8667 pPnoRequest->ucNetworksCount = 0;
8668
8669 status = sme_SetPreferredNetworkList(hHal, pPnoRequest,
8670 pAdapter->sessionId,
8671 NULL, pAdapter);
8672 if (eHAL_STATUS_SUCCESS != status)
8673 {
8674 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8675 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308676 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +05308677 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308678 }
8679
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +05308680error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308681 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +05308682 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308683 vos_mem_free(pPnoRequest);
8684
8685 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308686 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308687}
8688
8689#endif /*FEATURE_WLAN_SCAN_PNO*/
8690
8691
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008692#ifdef FEATURE_WLAN_TDLS
8693static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
8694 u8 *peer, u8 action_code, u8 dialog_token,
8695 u16 status_code, const u8 *buf, size_t len)
8696{
8697
8698 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8699 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008700 u8 peerMac[6];
8701 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008702 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -08008703 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -07008704 long rc;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008705
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308706 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8707 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
8708 pAdapter->sessionId, action_code));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008709 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008710 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308711 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008712 "Invalid arguments");
8713 return -EINVAL;
8714 }
8715
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008716 if (pHddCtx->isLogpInProgress)
8717 {
8718 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8719 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008720 wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008721 return -EBUSY;
8722 }
8723
Hoonki Lee27511902013-03-14 18:19:06 -07008724 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008725 {
Hoonki Lee27511902013-03-14 18:19:06 -07008726 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8727 "%s: TDLS mode is disabled OR not enabled in FW."
8728 MAC_ADDRESS_STR " action %d declined.",
8729 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008730 return -ENOTSUPP;
8731 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008732
Hoonki Lee27511902013-03-14 18:19:06 -07008733 /* other than teardown frame, other mgmt frames are not sent if disabled */
8734 if (SIR_MAC_TDLS_TEARDOWN != action_code)
8735 {
8736 /* if tdls_mode is disabled to respond to peer's request */
8737 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
8738 {
8739 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8740 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008741 " TDLS mode is disabled. action %d declined.",
8742 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -07008743
8744 return -ENOTSUPP;
8745 }
8746 }
8747
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008748 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
8749 {
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308750 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008751 {
8752 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008753 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008754 " TDLS setup is ongoing. action %d declined.",
8755 __func__, MAC_ADDR_ARRAY(peer), action_code);
8756 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008757 }
8758 }
8759
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008760 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
8761 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -08008762 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008763 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
Lee Hoonkic1262f22013-01-24 21:59:00 -08008764 {
8765 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
8766 we return error code at 'add_station()'. Hence we have this
8767 check again in addtion to add_station().
8768 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008769 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -08008770 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008771 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8772 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008773 " TDLS Max peer already connected. action %d declined.",
8774 __func__, MAC_ADDR_ARRAY(peer), action_code);
Sunil Dutt388ac8f2013-11-28 18:06:52 +05308775 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -08008776 }
8777 else
8778 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008779 /* maximum reached. tweak to send error code to peer and return
8780 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -08008781 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008782 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8783 "%s: " MAC_ADDRESS_STR
8784 " TDLS Max peer already connected send response status %d",
8785 __func__, MAC_ADDR_ARRAY(peer), status_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008786 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008787 /* fall through to send setup resp with failure status
8788 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -08008789 }
8790 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008791 else
8792 {
8793 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308794 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008795 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008796 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008797 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008798 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
8799 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008800 return -EPERM;
8801 }
8802 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008803 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008804 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008805
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008806#ifdef WLAN_FEATURE_TDLS_DEBUG
8807 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +05308808 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008809 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
8810 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008811#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008812
Hoonki Leea34dd892013-02-05 22:56:02 -08008813 /*Except teardown responder will not be used so just make 0*/
8814 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008815 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -08008816 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008817
8818 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308819 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008820
8821 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
8822 responder = pTdlsPeer->is_responder;
8823 else
Hoonki Leea34dd892013-02-05 22:56:02 -08008824 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008825 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +05308826 "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %zu",
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008827 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
8828 dialog_token, status_code, len);
8829 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -08008830 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008831 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008832
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308833 /* For explicit trigger of DIS_REQ come out of BMPS for
8834 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -07008835 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308836 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
8837 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -07008838 {
8839 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
8840 {
8841 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308842 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Hoonki Lee14621352013-04-16 17:51:19 -07008843 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
8844 }
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308845 if (SIR_MAC_TDLS_DIS_REQ != action_code)
8846 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
Hoonki Lee14621352013-04-16 17:51:19 -07008847 }
8848
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008849 /* make sure doesn't call send_mgmt() while it is pending */
8850 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
8851 {
8852 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008853 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008854 __func__, MAC_ADDR_ARRAY(peer), action_code);
8855 return -EBUSY;
8856 }
8857
8858 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008859 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
8860
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008861 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Hoonki Leea34dd892013-02-05 22:56:02 -08008862 peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008863
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008864 if (VOS_STATUS_SUCCESS != status)
8865 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008866 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8867 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008868 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -07008869 wlan_hdd_tdls_check_bmps(pAdapter);
Sunil Dutt388ac8f2013-11-28 18:06:52 +05308870 return -EINVAL;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008871 }
8872
Hoonki Leed37cbb32013-04-20 00:31:14 -07008873 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
8874 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
8875
8876 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008877 {
Hoonki Leed37cbb32013-04-20 00:31:14 -07008878 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008879 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -07008880 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008881 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -08008882
8883 if (pHddCtx->isLogpInProgress)
8884 {
8885 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8886 "%s: LOGP in Progress. Ignore!!!", __func__);
8887 return -EAGAIN;
8888 }
8889
Hoonki Leed37cbb32013-04-20 00:31:14 -07008890 wlan_hdd_tdls_check_bmps(pAdapter);
Sunil Dutt388ac8f2013-11-28 18:06:52 +05308891 return -EINVAL;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008892 }
8893
Gopichand Nakkala05922802013-03-14 12:23:19 -07008894 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -07008895 {
8896 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008897 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -07008898 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008899
Hoonki Leea34dd892013-02-05 22:56:02 -08008900 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
8901 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008902 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -08008903 }
8904 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
8905 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008906 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -08008907 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008908
8909 return 0;
8910}
8911
8912static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
8913 u8 *peer, enum nl80211_tdls_operation oper)
8914{
8915 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8916 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308917 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008918 hddTdlsPeer_t *pTdlsPeer;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008919
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308920 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8921 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
8922 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308923 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008924 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008925 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07008926 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008927 return -EINVAL;
8928 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008929
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308930 status = wlan_hdd_validate_context(pHddCtx);
8931
8932 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008933 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308934 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8935 "%s: HDD context is not valid", __func__);
8936 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008937 }
8938
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008939
8940 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008941 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008942 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008943 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07008944 "TDLS Disabled in INI OR not enabled in FW. "
8945 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008946 return -ENOTSUPP;
8947 }
8948
8949 switch (oper) {
8950 case NL80211_TDLS_ENABLE_LINK:
8951 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008952 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308953 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308954 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008955
Sunil Dutt41de4e22013-11-14 18:09:02 +05308956 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
8957
8958 if ( NULL == pTdlsPeer ) {
8959 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
8960 " (oper %d) not exsting. ignored",
8961 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
8962 return -EINVAL;
8963 }
8964
8965 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8966 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
8967 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
8968 "NL80211_TDLS_ENABLE_LINK");
8969
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -07008970 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
8971 {
8972 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
8973 MAC_ADDRESS_STR " failed",
8974 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
8975 return -EINVAL;
8976 }
8977
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008978 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008979 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308980 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05308981
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308982 if (0 != wlan_hdd_tdls_get_link_establish_params(
8983 pAdapter, peer,&tdlsLinkEstablishParams)) {
8984 return -EINVAL;
8985 }
8986 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308987
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308988 sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter),
8989 pAdapter->sessionId, peer, &tdlsLinkEstablishParams);
8990 /* Send TDLS peer UAPSD capabilities to the firmware and
8991 * register with the TL on after the response for this operation
8992 * is received .
8993 */
8994 ret = wait_for_completion_interruptible_timeout(
8995 &pAdapter->tdls_link_establish_req_comp,
8996 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
8997 if (ret <= 0)
8998 {
8999 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9000 "%s: Link Establish Request Faled Status %ld",
9001 __func__, ret);
9002 return -EINVAL;
9003 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05309004 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07009005 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED);
Gopichand Nakkala471708b2013-06-04 20:03:01 +05309006 /* Mark TDLS client Authenticated .*/
9007 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
9008 pTdlsPeer->staId,
9009 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07009010 if (VOS_STATUS_SUCCESS == status)
9011 {
Hoonki Lee14621352013-04-16 17:51:19 -07009012 if (pTdlsPeer->is_responder == 0)
9013 {
9014 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
9015
9016 wlan_hdd_tdls_timer_restart(pAdapter,
9017 &pTdlsPeer->initiatorWaitTimeoutTimer,
9018 WAIT_TIME_TDLS_INITIATOR);
9019 /* suspend initiator TX until it receives direct packet from the
9020 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
9021 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9022 &staId, NULL);
9023 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07009024 wlan_hdd_tdls_increment_peer_count(pAdapter);
9025 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009026 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05309027
9028 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05309029 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
9030 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05309031 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05309032 int ac;
9033 uint8 ucAc[4] = { WLANTL_AC_VO,
9034 WLANTL_AC_VI,
9035 WLANTL_AC_BK,
9036 WLANTL_AC_BE };
9037 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
9038 for(ac=0; ac < 4; ac++)
9039 {
9040 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9041 pTdlsPeer->staId, ucAc[ac],
9042 tlTid[ac], tlTid[ac], 0, 0,
9043 WLANTL_BI_DIR );
9044 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05309045 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009046 }
9047
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009048 }
9049 break;
9050 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -08009051 {
Sunil Dutt41de4e22013-11-14 18:09:02 +05309052 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
9053
9054 if ( NULL == pTdlsPeer ) {
9055 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
9056 " (oper %d) not exsting. ignored",
9057 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
9058 return -EINVAL;
9059 }
9060
9061 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9062 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
9063 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
9064 "NL80211_TDLS_DISABLE_LINK");
9065
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009066 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -08009067 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009068 long status;
9069
9070 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
9071
Lee Hoonkic1262f22013-01-24 21:59:00 -08009072 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
9073 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009074
9075 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
9076 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
9077 if (status <= 0)
9078 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009079 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9081 "%s: Del station failed status %ld",
9082 __func__, status);
9083 return -EPERM;
9084 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009085 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Lee Hoonkic1262f22013-01-24 21:59:00 -08009086 }
9087 else
9088 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009089 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9090 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -08009091 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08009092 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009093 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009094 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +05309095 {
9096 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9097 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
9098 __func__, MAC_ADDR_ARRAY(peer));
9099
9100 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
9101 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
9102
9103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9104 " %s TDLS External control and Implicit Trigger not enabled ",
9105 __func__);
9106 return -ENOTSUPP;
9107 }
9108
Sunil Dutt41de4e22013-11-14 18:09:02 +05309109
9110 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
9111
9112 if ( NULL == pTdlsPeer ) {
9113 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
9114 " peer not exsting",
9115 __func__, MAC_ADDR_ARRAY(peer));
Naresh Jayaram937abdf2013-11-26 19:50:25 +05309116 return -EINVAL;
Sunil Dutt41de4e22013-11-14 18:09:02 +05309117 }
9118 else {
9119 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
9120 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
9121 }
Naresh Jayaram937abdf2013-11-26 19:50:25 +05309122
9123 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) )
9124 return -EINVAL;
Sunil Dutt41de4e22013-11-14 18:09:02 +05309125 break;
9126 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009127 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +05309128 {
Naresh Jayaramdb4514b2013-11-25 18:08:10 +05309129 hddTdlsPeer_t *pTdlsPeer;
Sunil Dutt41de4e22013-11-14 18:09:02 +05309130 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9131 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
9132 __func__, MAC_ADDR_ARRAY(peer));
9133
9134 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
9135 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
9136
9137 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9138 " %s TDLS External control and Implicit Trigger not enabled ",
9139 __func__);
9140 return -ENOTSUPP;
9141 }
9142
Naresh Jayaramdb4514b2013-11-25 18:08:10 +05309143 /* To cater the requirement of establishing the TDLS link
9144 * irrespective of the data traffic , get an entry of TDLS peer.
9145 */
9146 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
9147 if (pTdlsPeer == NULL) {
9148 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9149 "%s: peer " MAC_ADDRESS_STR " not existing",
9150 __func__, MAC_ADDR_ARRAY(peer));
9151 return -EINVAL;
9152 }
Naresh Jayaram937abdf2013-11-26 19:50:25 +05309153
9154 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
9155
9156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9157 " %s TDLS Add Force Peer Failed",
9158 __func__);
9159 return -EINVAL;
9160 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +05309161 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +05309162 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009163 case NL80211_TDLS_DISCOVERY_REQ:
9164 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309165 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9166 "%s: We don't support in-driver setup/teardown/discovery "
9167 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009168 return -ENOTSUPP;
9169 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309170 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9171 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009172 return -ENOTSUPP;
9173 }
9174 return 0;
9175}
Chilam NG571c65a2013-01-19 12:27:36 +05309176
9177int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
9178 struct net_device *dev, u8 *peer)
9179{
Arif Hussaina7c8e412013-11-20 11:06:42 -08009180 hddLog(VOS_TRACE_LEVEL_INFO,
9181 "tdls send discover req: "MAC_ADDRESS_STR,
9182 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +05309183
9184 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
9185 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
9186}
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009187#endif
9188
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309189#ifdef WLAN_FEATURE_GTK_OFFLOAD
9190/*
9191 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
9192 * Callback rountine called upon receiving response for
9193 * get offload info
9194 */
9195void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
9196 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
9197{
9198
9199 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309200 tANI_U8 tempReplayCounter[8];
9201 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309202
9203 ENTER();
9204
9205 if (NULL == pAdapter)
9206 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309207 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309208 "%s: HDD adapter is Null", __func__);
9209 return ;
9210 }
9211
9212 if (NULL == pGtkOffloadGetInfoRsp)
9213 {
9214 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9215 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
9216 return ;
9217 }
9218
9219 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
9220 {
9221 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9222 "%s: wlan Failed to get replay counter value",
9223 __func__);
9224 return ;
9225 }
9226
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309227 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9228 /* Update replay counter */
9229 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
9230 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
9231
9232 {
9233 /* changing from little to big endian since supplicant
9234 * works on big endian format
9235 */
9236 int i;
9237 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
9238
9239 for (i = 0; i < 8; i++)
9240 {
9241 tempReplayCounter[7-i] = (tANI_U8)p[i];
9242 }
9243 }
9244
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309245 /* Update replay counter to NL */
9246 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309247 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309248}
9249
9250/*
9251 * FUNCTION: wlan_hdd_cfg80211_set_rekey_data
9252 * This function is used to offload GTK rekeying job to the firmware.
9253 */
9254int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
9255 struct cfg80211_gtk_rekey_data *data)
9256{
9257 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9258 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9259 hdd_station_ctx_t *pHddStaCtx;
9260 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309261 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309262 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309263 eHalStatus status = eHAL_STATUS_FAILURE;
9264
9265 ENTER();
9266
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309267
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309268 if (NULL == pAdapter)
9269 {
9270 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9271 "%s: HDD adapter is Null", __func__);
9272 return -ENODEV;
9273 }
9274
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309275 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9276 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
9277 pAdapter->sessionId, pAdapter->device_mode));
9278
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309279 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309280
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309281 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309282 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309283 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9284 "%s: HDD context is not valid", __func__);
9285 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309286 }
9287
9288 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9289 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9290 if (NULL == hHal)
9291 {
9292 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9293 "%s: HAL context is Null!!!", __func__);
9294 return -EAGAIN;
9295 }
9296
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309297 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
9298 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
9299 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
9300 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309301 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309302 {
9303 /* changing from big to little endian since driver
9304 * works on little endian format
9305 */
9306 tANI_U8 *p =
9307 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
9308 int i;
9309
9310 for (i = 0; i < 8; i++)
9311 {
9312 p[7-i] = data->replay_ctr[i];
9313 }
9314 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309315
9316 if (TRUE == pHddCtx->hdd_wlan_suspended)
9317 {
9318 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309319 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
9320 sizeof (tSirGtkOffloadParams));
9321 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309322 pAdapter->sessionId);
9323
9324 if (eHAL_STATUS_SUCCESS != status)
9325 {
9326 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9327 "%s: sme_SetGTKOffload failed, returned %d",
9328 __func__, status);
9329 return status;
9330 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9332 "%s: sme_SetGTKOffload successfull", __func__);
9333 }
9334 else
9335 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309336 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9337 "%s: wlan not suspended GTKOffload request is stored",
9338 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309339 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309340
9341 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309342}
9343#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
9344
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309345/*
9346 * FUNCTION: wlan_hdd_cfg80211_set_mac_acl
9347 * This function is used to set access control policy
9348 */
9349static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
9350 struct net_device *dev, const struct cfg80211_acl_data *params)
9351{
9352 int i;
9353 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9354 hdd_hostapd_state_t *pHostapdState;
9355 tsap_Config_t *pConfig;
9356 v_CONTEXT_t pVosContext = NULL;
9357 hdd_context_t *pHddCtx;
9358 int status;
9359
9360 ENTER();
9361
9362 if (NULL == pAdapter)
9363 {
9364 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9365 "%s: HDD adapter is Null", __func__);
9366 return -ENODEV;
9367 }
9368
9369 if (NULL == params)
9370 {
9371 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9372 "%s: params is Null", __func__);
9373 return -EINVAL;
9374 }
9375
9376 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9377 status = wlan_hdd_validate_context(pHddCtx);
9378
9379 if (0 != status)
9380 {
9381 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9382 "%s: HDD context is not valid", __func__);
9383 return status;
9384 }
9385
9386 pVosContext = pHddCtx->pvosContext;
9387 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
9388
9389 if (NULL == pHostapdState)
9390 {
9391 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9392 "%s: pHostapdState is Null", __func__);
9393 return -EINVAL;
9394 }
9395
9396 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
9397 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
9398
9399 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
9400 {
9401 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
9402
9403 /* default value */
9404 pConfig->num_accept_mac = 0;
9405 pConfig->num_deny_mac = 0;
9406
9407 /**
9408 * access control policy
9409 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
9410 * listed in hostapd.deny file.
9411 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
9412 * listed in hostapd.accept file.
9413 */
9414 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
9415 {
9416 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
9417 }
9418 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
9419 {
9420 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
9421 }
9422 else
9423 {
9424 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9425 "%s:Acl Policy : %d is not supported",
9426 __func__, params->acl_policy);
9427 return -ENOTSUPP;
9428 }
9429
9430 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
9431 {
9432 pConfig->num_accept_mac = params->n_acl_entries;
9433 for (i = 0; i < params->n_acl_entries; i++)
9434 {
9435 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9436 "** Add ACL MAC entry %i in WhiletList :"
9437 MAC_ADDRESS_STR, i,
9438 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
9439
9440 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
9441 sizeof(qcmacaddr));
9442 }
9443 }
9444 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
9445 {
9446 pConfig->num_deny_mac = params->n_acl_entries;
9447 for (i = 0; i < params->n_acl_entries; i++)
9448 {
9449 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9450 "** Add ACL MAC entry %i in BlackList :"
9451 MAC_ADDRESS_STR, i,
9452 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
9453
9454 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
9455 sizeof(qcmacaddr));
9456 }
9457 }
9458
9459 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
9460 {
9461 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9462 "%s: SAP Set Mac Acl fail", __func__);
9463 return -EINVAL;
9464 }
9465 }
9466 else
9467 {
9468 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9469 "%s: Invalid device_mode = %d",
9470 __func__, pAdapter->device_mode);
9471 return -EINVAL;
9472 }
9473
9474 return 0;
9475}
9476
Leo Chang9056f462013-08-01 19:21:11 -07009477#ifdef WLAN_NL80211_TESTMODE
9478#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -07009479void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -07009480(
9481 void *pAdapter,
9482 void *indCont
9483)
9484{
Leo Changd9df8aa2013-09-26 13:32:26 -07009485 tSirLPHBInd *lphbInd;
9486 struct sk_buff *skb;
Leo Chang9056f462013-08-01 19:21:11 -07009487
9488 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07009489 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -07009490
9491 if (NULL == indCont)
9492 {
9493 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07009494 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -07009495 return;
9496 }
9497
Leo Changd9df8aa2013-09-26 13:32:26 -07009498 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -07009499 skb = cfg80211_testmode_alloc_event_skb(
9500 ((hdd_adapter_t *)pAdapter)->wdev.wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -07009501 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -07009502 GFP_ATOMIC);
9503 if (!skb)
9504 {
9505 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9506 "LPHB timeout, NL buffer alloc fail");
9507 return;
9508 }
9509
Leo Changac3ba772013-10-07 09:47:04 -07009510 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -07009511 {
9512 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9513 "WLAN_HDD_TM_ATTR_CMD put fail");
9514 goto nla_put_failure;
9515 }
Leo Changac3ba772013-10-07 09:47:04 -07009516 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -07009517 {
9518 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9519 "WLAN_HDD_TM_ATTR_TYPE put fail");
9520 goto nla_put_failure;
9521 }
Leo Changac3ba772013-10-07 09:47:04 -07009522 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -07009523 sizeof(tSirLPHBInd), lphbInd))
9524 {
9525 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9526 "WLAN_HDD_TM_ATTR_DATA put fail");
9527 goto nla_put_failure;
9528 }
Leo Chang9056f462013-08-01 19:21:11 -07009529 cfg80211_testmode_event(skb, GFP_ATOMIC);
9530 return;
9531
9532nla_put_failure:
9533 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9534 "NLA Put fail");
9535 kfree_skb(skb);
9536
9537 return;
9538}
9539#endif /* FEATURE_WLAN_LPHB */
9540
9541static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
9542{
9543 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
9544 int err = 0;
9545#ifdef FEATURE_WLAN_LPHB
9546 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -07009547 eHalStatus smeStatus;
Leo Chang9056f462013-08-01 19:21:11 -07009548#endif /* FEATURE_WLAN_LPHB */
9549
9550 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
9551 if (err)
9552 {
9553 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9554 "%s Testmode INV ATTR", __func__);
9555 return err;
9556 }
9557
9558 if (!tb[WLAN_HDD_TM_ATTR_CMD])
9559 {
9560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9561 "%s Testmode INV CMD", __func__);
9562 return -EINVAL;
9563 }
9564
9565 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
9566 {
9567#ifdef FEATURE_WLAN_LPHB
9568 /* Low Power Heartbeat configuration request */
9569 case WLAN_HDD_TM_CMD_WLAN_HB:
9570 {
9571 int buf_len;
9572 void *buf;
9573 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -08009574 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -07009575
9576 if (!tb[WLAN_HDD_TM_ATTR_DATA])
9577 {
9578 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9579 "%s Testmode INV DATA", __func__);
9580 return -EINVAL;
9581 }
9582
9583 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
9584 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -08009585
9586 hb_params_temp =(tSirLPHBReq *)buf;
9587 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
9588 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
9589 return -EINVAL;
9590
Leo Chang9056f462013-08-01 19:21:11 -07009591 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
9592 if (NULL == hb_params)
9593 {
9594 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9595 "%s Request Buffer Alloc Fail", __func__);
9596 return -EINVAL;
9597 }
9598
9599 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -07009600 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
9601 hb_params,
9602 wlan_hdd_cfg80211_lphb_ind_handler);
9603 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -07009604 {
Leo Changd9df8aa2013-09-26 13:32:26 -07009605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9606 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -07009607 vos_mem_free(hb_params);
9608 }
Leo Chang9056f462013-08-01 19:21:11 -07009609 return 0;
9610 }
9611#endif /* FEATURE_WLAN_LPHB */
9612 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309613 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9614 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -07009615 return -EOPNOTSUPP;
9616 }
9617
9618 return err;
9619}
9620#endif /* CONFIG_NL80211_TESTMODE */
9621
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309622static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
9623 struct net_device *dev,
9624 int idx, struct survey_info *survey)
9625{
9626 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9627 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +05309628 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309629 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +05309630 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309631 v_S7_t snr,rssi;
9632 int status, i, j, filled = 0;
9633
9634 ENTER();
9635
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309636 if (NULL == pAdapter)
9637 {
9638 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9639 "%s: HDD adapter is Null", __func__);
9640 return -ENODEV;
9641 }
9642
9643 if (NULL == wiphy)
9644 {
9645 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9646 "%s: wiphy is Null", __func__);
9647 return -ENODEV;
9648 }
9649
9650 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9651 status = wlan_hdd_validate_context(pHddCtx);
9652
9653 if (0 != status)
9654 {
9655 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9656 "%s: HDD context is not valid", __func__);
9657 return status;
9658 }
9659
Mihir Sheted9072e02013-08-21 17:02:29 +05309660 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9661
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309662 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +05309663 0 != pAdapter->survey_idx ||
9664 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309665 {
9666 /* The survey dump ops when implemented completely is expected to
9667 * return a survey of all channels and the ops is called by the
9668 * kernel with incremental values of the argument 'idx' till it
9669 * returns -ENONET. But we can only support the survey for the
9670 * operating channel for now. survey_idx is used to track
9671 * that the ops is called only once and then return -ENONET for
9672 * the next iteration
9673 */
9674 pAdapter->survey_idx = 0;
9675 return -ENONET;
9676 }
9677
9678 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
9679
9680 wlan_hdd_get_snr(pAdapter, &snr);
9681 wlan_hdd_get_rssi(pAdapter, &rssi);
9682
9683 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
9684 hdd_wlan_get_freq(channel, &freq);
9685
9686
9687 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
9688 {
9689 if (NULL == wiphy->bands[i])
9690 {
9691 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9692 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
9693 continue;
9694 }
9695
9696 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
9697 {
9698 struct ieee80211_supported_band *band = wiphy->bands[i];
9699
9700 if (band->channels[j].center_freq == (v_U16_t)freq)
9701 {
9702 survey->channel = &band->channels[j];
9703 /* The Rx BDs contain SNR values in dB for the received frames
9704 * while the supplicant expects noise. So we calculate and
9705 * return the value of noise (dBm)
9706 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
9707 */
9708 survey->noise = rssi - snr;
9709 survey->filled = SURVEY_INFO_NOISE_DBM;
9710 filled = 1;
9711 }
9712 }
9713 }
9714
9715 if (filled)
9716 pAdapter->survey_idx = 1;
9717 else
9718 {
9719 pAdapter->survey_idx = 0;
9720 return -ENONET;
9721 }
9722
9723 return 0;
9724}
9725
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309726/*
9727 * FUNCTION: wlan_hdd_cfg80211_resume_wlan
9728 * this is called when cfg80211 driver resume
9729 * driver updates latest sched_scan scan result(if any) to cfg80211 database
9730 */
9731int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
9732{
9733 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9734 hdd_adapter_t *pAdapter;
9735 hdd_adapter_list_node_t *pAdapterNode, *pNext;
9736 VOS_STATUS status = VOS_STATUS_SUCCESS;
9737
9738 ENTER();
9739
9740 if ( NULL == pHddCtx )
9741 {
9742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9743 "%s: HddCtx validation failed", __func__);
9744 return 0;
9745 }
9746
9747 if (pHddCtx->isLogpInProgress)
9748 {
9749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9750 "%s: LOGP in Progress. Ignore!!!", __func__);
9751 return 0;
9752 }
9753
9754 if (pHddCtx->isLoadUnloadInProgress)
9755 {
9756 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9757 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
9758 return 0;
9759 }
9760
9761 spin_lock(&pHddCtx->schedScan_lock);
9762 pHddCtx->isWiphySuspended = FALSE;
9763 if (TRUE != pHddCtx->isSchedScanUpdatePending)
9764 {
9765 spin_unlock(&pHddCtx->schedScan_lock);
9766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9767 "%s: Return resume is not due to PNO indication", __func__);
9768 return 0;
9769 }
9770 // Reset flag to avoid updatating cfg80211 data old results again
9771 pHddCtx->isSchedScanUpdatePending = FALSE;
9772 spin_unlock(&pHddCtx->schedScan_lock);
9773
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05309774
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309775 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
9776
9777 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
9778 {
9779 pAdapter = pAdapterNode->pAdapter;
9780 if ( (NULL != pAdapter) &&
9781 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
9782 {
9783 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05309784 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309785 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9786 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05309787 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309788 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05309789 {
9790 /* Acquire wakelock to handle the case where APP's tries to
9791 * suspend immediately after updating the scan results. Whis
9792 * results in app's is in suspended state and not able to
9793 * process the connect request to AP
9794 */
9795 hdd_prevent_suspend_timeout(2000);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309796 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05309797 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309798
9799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9800 "%s : cfg80211 scan result database updated", __func__);
9801
9802 return 0;
9803
9804 }
9805 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
9806 pAdapterNode = pNext;
9807 }
9808
9809 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9810 "%s: Failed to find Adapter", __func__);
9811 return 0;
9812}
9813
9814/*
9815 * FUNCTION: wlan_hdd_cfg80211_suspend_wlan
9816 * this is called when cfg80211 driver suspends
9817 */
9818int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
9819 struct cfg80211_wowlan *wow)
9820{
9821 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9822
9823 ENTER();
9824 if (NULL == pHddCtx)
9825 {
9826 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9827 "%s: HddCtx validation failed", __func__);
9828 return 0;
9829 }
9830
9831 pHddCtx->isWiphySuspended = TRUE;
9832
9833 EXIT();
9834
9835 return 0;
9836}
9837
Jeff Johnson295189b2012-06-20 16:38:30 -07009838/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309839static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -07009840{
9841 .add_virtual_intf = wlan_hdd_add_virtual_intf,
9842 .del_virtual_intf = wlan_hdd_del_virtual_intf,
9843 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
9844 .change_station = wlan_hdd_change_station,
9845#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9846 .add_beacon = wlan_hdd_cfg80211_add_beacon,
9847 .del_beacon = wlan_hdd_cfg80211_del_beacon,
9848 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009849#else
9850 .start_ap = wlan_hdd_cfg80211_start_ap,
9851 .change_beacon = wlan_hdd_cfg80211_change_beacon,
9852 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -07009853#endif
9854 .change_bss = wlan_hdd_cfg80211_change_bss,
9855 .add_key = wlan_hdd_cfg80211_add_key,
9856 .get_key = wlan_hdd_cfg80211_get_key,
9857 .del_key = wlan_hdd_cfg80211_del_key,
9858 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009859#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009860 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009861#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009862 .scan = wlan_hdd_cfg80211_scan,
9863 .connect = wlan_hdd_cfg80211_connect,
9864 .disconnect = wlan_hdd_cfg80211_disconnect,
9865 .join_ibss = wlan_hdd_cfg80211_join_ibss,
9866 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
9867 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
9868 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
9869 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -07009870 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
9871 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +05309872 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -07009873#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9874 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
9875 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
9876 .set_txq_params = wlan_hdd_set_txq_params,
9877#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009878 .get_station = wlan_hdd_cfg80211_get_station,
9879 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
9880 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009881 .add_station = wlan_hdd_cfg80211_add_station,
9882#ifdef FEATURE_WLAN_LFR
9883 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
9884 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
9885 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
9886#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009887#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
9888 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
9889#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009890#ifdef FEATURE_WLAN_TDLS
9891 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
9892 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
9893#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309894#ifdef WLAN_FEATURE_GTK_OFFLOAD
9895 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
9896#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309897#ifdef FEATURE_WLAN_SCAN_PNO
9898 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
9899 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
9900#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309901 .resume = wlan_hdd_cfg80211_resume_wlan,
9902 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309903 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -07009904#ifdef WLAN_NL80211_TESTMODE
9905 .testmode_cmd = wlan_hdd_cfg80211_testmode,
9906#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309907 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009908};
9909