blob: 77bce6870679226c1b2a46295f9a75a083fc0dc0 [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,
151#ifdef FEATURE_WLAN_CCX
152#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
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700736#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
737 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
741#ifdef FEATURE_WLAN_CCX
742 || pCfg->isCcxIniFeatureEnabled
743#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;
Jeff Johnson295189b2012-06-20 16:38:30 -07001881
1882 ENTER();
1883
1884 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
1885
1886 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1887
1888 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1889
1890 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1891
1892 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
1893
1894 //channel is already set in the set_channel Call back
1895 //pConfig->channel = pCommitConfig->channel;
1896
1897 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301898 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07001899 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
1900
1901 pConfig->dtim_period = pBeacon->dtim_period;
1902
Arif Hussain6d2a3322013-11-17 19:50:10 -08001903 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07001904 pConfig->dtim_period);
1905
1906
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08001907 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07001908 {
1909 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001910 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05301911 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
1912 {
1913 tANI_BOOLEAN restartNeeded;
1914 pConfig->ieee80211d = 1;
1915 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
1916 sme_setRegInfo(hHal, pConfig->countryCode);
1917 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
1918 }
1919 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001920 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07001921 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07001922 pConfig->ieee80211d = 1;
1923 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
1924 sme_setRegInfo(hHal, pConfig->countryCode);
1925 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07001926 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001927 else
1928 {
1929 pConfig->ieee80211d = 0;
1930 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301931 /*
1932 * If auto channel is configured i.e. channel is 0,
1933 * so skip channel validation.
1934 */
1935 if( AUTO_CHANNEL_SELECT != pConfig->channel )
1936 {
1937 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
1938 {
1939 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001940 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301941 return -EINVAL;
1942 }
1943 }
1944 else
1945 {
1946 if(1 != pHddCtx->is_dynamic_channel_range_set)
1947 {
1948 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
1949 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
1950 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
1951 }
1952 pHddCtx->is_dynamic_channel_range_set = 0;
1953 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001954 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001955 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001956 {
1957 pConfig->ieee80211d = 0;
1958 }
1959 pConfig->authType = eSAP_AUTO_SWITCH;
1960
1961 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301962
1963 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07001964 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
1965
1966 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
1967
1968 /*Set wps station to configured*/
1969 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
1970
1971 if(pIe)
1972 {
1973 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
1974 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001975 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07001976 return -EINVAL;
1977 }
1978 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
1979 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001980 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07001981 /* Check 15 bit of WPS IE as it contain information for wps state
1982 * WPS state
1983 */
1984 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
1985 {
1986 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
1987 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
1988 {
1989 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
1990 }
1991 }
1992 }
1993 else
1994 {
1995 pConfig->wps_state = SAP_WPS_DISABLED;
1996 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301997 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07001998
1999 pConfig->RSNWPAReqIELength = 0;
2000 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302001 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07002002 WLAN_EID_RSN);
2003 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302004 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002005 pConfig->RSNWPAReqIELength = pIe[1] + 2;
2006 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
2007 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302008 /* The actual processing may eventually be more extensive than
2009 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07002010 * by the app.
2011 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302012 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07002013 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
2014 &RSNEncryptType,
2015 &mcRSNEncryptType,
2016 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08002017 &MFPCapable,
2018 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07002019 pConfig->pRSNWPAReqIE[1]+2,
2020 pConfig->pRSNWPAReqIE );
2021
2022 if( VOS_STATUS_SUCCESS == status )
2023 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302024 /* Now copy over all the security attributes you have
2025 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07002026 * */
2027 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
2028 pConfig->mcRSNEncryptType = mcRSNEncryptType;
2029 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
2030 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05302031 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002032 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002033 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
2034 }
2035 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302036
Jeff Johnson295189b2012-06-20 16:38:30 -07002037 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
2038 pBeacon->tail, pBeacon->tail_len);
2039
2040 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
2041 {
2042 if (pConfig->pRSNWPAReqIE)
2043 {
2044 /*Mixed mode WPA/WPA2*/
2045 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
2046 pConfig->RSNWPAReqIELength += pIe[1] + 2;
2047 }
2048 else
2049 {
2050 pConfig->RSNWPAReqIELength = pIe[1] + 2;
2051 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
2052 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302053 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07002054 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
2055 &RSNEncryptType,
2056 &mcRSNEncryptType,
2057 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08002058 &MFPCapable,
2059 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07002060 pConfig->pRSNWPAReqIE[1]+2,
2061 pConfig->pRSNWPAReqIE );
2062
2063 if( VOS_STATUS_SUCCESS == status )
2064 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302065 /* Now copy over all the security attributes you have
2066 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07002067 * */
2068 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
2069 pConfig->mcRSNEncryptType = mcRSNEncryptType;
2070 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
2071 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05302072 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002073 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002074 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
2075 }
2076 }
2077 }
2078
Jeff Johnson4416a782013-03-25 14:17:50 -07002079 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
2080 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
2081 return -EINVAL;
2082 }
2083
Jeff Johnson295189b2012-06-20 16:38:30 -07002084 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
2085
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002086#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002087 if (params->ssid != NULL)
2088 {
2089 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
2090 pConfig->SSIDinfo.ssid.length = params->ssid_len;
2091 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
2092 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
2093 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002094#else
2095 if (ssid != NULL)
2096 {
2097 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
2098 pConfig->SSIDinfo.ssid.length = ssid_len;
2099 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
2100 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
2101 }
2102#endif
2103
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302104 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07002105 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302106
Jeff Johnson295189b2012-06-20 16:38:30 -07002107 /* default value */
2108 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
2109 pConfig->num_accept_mac = 0;
2110 pConfig->num_deny_mac = 0;
2111
2112 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
2113 pBeacon->tail, pBeacon->tail_len);
2114
2115 /* pIe for black list is following form:
2116 type : 1 byte
2117 length : 1 byte
2118 OUI : 4 bytes
2119 acl type : 1 byte
2120 no of mac addr in black list: 1 byte
2121 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302122 */
2123 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002124 {
2125 pConfig->SapMacaddr_acl = pIe[6];
2126 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08002127 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002128 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302129 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
2130 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002131 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
2132 for (i = 0; i < pConfig->num_deny_mac; i++)
2133 {
2134 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
2135 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302136 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002137 }
2138 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
2139 pBeacon->tail, pBeacon->tail_len);
2140
2141 /* pIe for white list is following form:
2142 type : 1 byte
2143 length : 1 byte
2144 OUI : 4 bytes
2145 acl type : 1 byte
2146 no of mac addr in white list: 1 byte
2147 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302148 */
2149 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002150 {
2151 pConfig->SapMacaddr_acl = pIe[6];
2152 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08002153 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002154 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302155 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
2156 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002157 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
2158 for (i = 0; i < pConfig->num_accept_mac; i++)
2159 {
2160 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
2161 acl_entry++;
2162 }
2163 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302164
Jeff Johnson295189b2012-06-20 16:38:30 -07002165 wlan_hdd_set_sapHwmode(pHostapdAdapter);
2166
Jeff Johnsone7245742012-09-05 17:12:55 -07002167#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002168 /* Overwrite the hostapd setting for HW mode only for 11ac.
Kiet Lam0f320422013-11-21 19:29:17 +05302169 * This is valid only if mode is set to 11n in hostapd, either AUTO or
2170 * 11ac in .ini and 11ac is supported by both host and firmware.
2171 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
2172 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002173 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
2174 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302175 (((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_AUTO) ||
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002176 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac) ||
Kiet Lam0f320422013-11-21 19:29:17 +05302177 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY)) &&
2178 (sme_IsFeatureSupportedByDriver(DOT11AC)) && (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07002179 {
2180 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07002181
2182 /* Disable VHT support in 2.4 GHz band */
2183 if (pConfig->channel <= 14 &&
2184 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->enableVhtFor24GHzBand == FALSE)
2185 {
2186 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
2187 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002188 }
2189#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302190
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07002191 if ( AUTO_CHANNEL_SELECT != pConfig->channel )
2192 {
2193 sme_SelectCBMode(hHal,
2194 sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode),
2195 pConfig->channel);
2196 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002197 // ht_capab is not what the name conveys,this is used for protection bitmap
2198 pConfig->ht_capab =
2199 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
2200
2201 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
2202 {
2203 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
2204 return -EINVAL;
2205 }
2206
2207 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302208 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07002209 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
2210 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302211 pConfig->obssProtEnabled =
2212 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07002213
Chet Lanctot8cecea22014-02-11 19:09:36 -08002214#ifdef WLAN_FEATURE_11W
2215 pConfig->mfpCapable = MFPCapable;
2216 pConfig->mfpRequired = MFPRequired;
2217 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
2218 pConfig->mfpCapable, pConfig->mfpRequired);
2219#endif
2220
Arif Hussain6d2a3322013-11-17 19:50:10 -08002221 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07002222 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08002223 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
2224 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
2225 (int)pConfig->channel);
2226 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
2227 pConfig->SapHw_mode, pConfig->privacy,
2228 pConfig->authType);
2229 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
2230 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
2231 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
2232 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07002233
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302234 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07002235 {
2236 //Bss already started. just return.
2237 //TODO Probably it should update some beacon params.
2238 hddLog( LOGE, "Bss Already started...Ignore the request");
2239 EXIT();
2240 return 0;
2241 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302242
Jeff Johnson295189b2012-06-20 16:38:30 -07002243 pConfig->persona = pHostapdAdapter->device_mode;
2244
2245 pSapEventCallback = hdd_hostapd_SAPEventCB;
2246 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
2247 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
2248 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002249 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002250 return -EINVAL;
2251 }
2252
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302253 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002254 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
2255
2256 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302257
Jeff Johnson295189b2012-06-20 16:38:30 -07002258 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302259 {
2260 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002261 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07002262 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002263 VOS_ASSERT(0);
2264 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302265
Jeff Johnson295189b2012-06-20 16:38:30 -07002266 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
2267
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002268#ifdef WLAN_FEATURE_P2P_DEBUG
2269 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
2270 {
2271 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
2272 {
2273 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2274 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002275 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002276 }
2277 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
2278 {
2279 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2280 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002281 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002282 }
2283 }
2284#endif
2285
Jeff Johnson295189b2012-06-20 16:38:30 -07002286 pHostapdState->bCommit = TRUE;
2287 EXIT();
2288
2289 return 0;
2290}
2291
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002292#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302293static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
2294 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002295 struct beacon_parameters *params)
2296{
2297 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302298 hdd_context_t *pHddCtx;
2299 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002300
2301 ENTER();
2302
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302303 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2304 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
2305 pAdapter->sessionId, params->interval));
Arif Hussain6d2a3322013-11-17 19:50:10 -08002306 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d",pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002307
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302308 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2309 status = wlan_hdd_validate_context(pHddCtx);
2310
2311 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002312 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302313 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2314 "%s: HDD context is not valid", __func__);
2315 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002316 }
2317
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302318 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002319 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002320 )
2321 {
2322 beacon_data_t *old,*new;
2323
2324 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302325
Jeff Johnson295189b2012-06-20 16:38:30 -07002326 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302327 {
2328 hddLog(VOS_TRACE_LEVEL_WARN,
2329 FL("already beacon info added to session(%d)"),
2330 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002331 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302332 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002333
2334 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2335
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302336 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002337 {
2338 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002339 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002340 return -EINVAL;
2341 }
2342
2343 pAdapter->sessionCtx.ap.beacon = new;
2344
2345 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2346 }
2347
2348 EXIT();
2349 return status;
2350}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302351
2352static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07002353 struct net_device *dev,
2354 struct beacon_parameters *params)
2355{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302356 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302357 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302358 hdd_context_t *pHddCtx;
2359 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002360
2361 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302362 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2363 TRACE_CODE_HDD_CFG80211_SET_BEACON,
2364 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
Arif Hussain6d2a3322013-11-17 19:50:10 -08002365 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002366 __func__,pAdapter->device_mode);
2367
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302368 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2369 status = wlan_hdd_validate_context(pHddCtx);
2370
2371 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002372 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302373 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2374 "%s: HDD context is not valid", __func__);
2375 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002376 }
2377
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302378 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002379 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302380 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002381 {
2382 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302383
Jeff Johnson295189b2012-06-20 16:38:30 -07002384 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302385
Jeff Johnson295189b2012-06-20 16:38:30 -07002386 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302387 {
2388 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2389 FL("session(%d) old and new heads points to NULL"),
2390 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002391 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302392 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002393
2394 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2395
2396 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302397 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002398 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002399 return -EINVAL;
2400 }
2401
2402 pAdapter->sessionCtx.ap.beacon = new;
2403
2404 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2405 }
2406
2407 EXIT();
2408 return status;
2409}
2410
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002411#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
2412
2413#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002414static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
2415 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002416#else
2417static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
2418 struct net_device *dev)
2419#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002420{
2421 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07002422 hdd_context_t *pHddCtx = NULL;
2423 hdd_scaninfo_t *pScanInfo = NULL;
2424 hdd_adapter_t *staAdapter = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302425 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002426
2427 ENTER();
2428
2429 if (NULL == pAdapter)
2430 {
2431 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002432 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002433 return -ENODEV;
2434 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002435
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302436 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2437 TRACE_CODE_HDD_CFG80211_STOP_AP,
2438 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302439 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2440 status = wlan_hdd_validate_context(pHddCtx);
2441
2442 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002443 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302444 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2445 "%s: HDD context is not valid", __func__);
2446 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07002447 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002448
2449 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
2450 if (NULL == staAdapter)
2451 {
2452 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
2453 if (NULL == staAdapter)
2454 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002455 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2456 "%s: HDD adapter context for STA/P2P-CLI is Null",
2457 __func__);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002458 }
2459 }
2460
2461 pScanInfo = &pHddCtx->scan_info;
2462
Arif Hussain6d2a3322013-11-17 19:50:10 -08002463 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002464 __func__,pAdapter->device_mode);
2465
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002466 if ((pScanInfo != NULL) && pScanInfo->mScanPending && staAdapter)
Jeff Johnsone7245742012-09-05 17:12:55 -07002467 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302468 long ret;
2469
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002470 INIT_COMPLETION(pScanInfo->abortscan_event_var);
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05302471 hdd_abort_mac_scan(staAdapter->pHddCtx, pAdapter->sessionId,
2472 eCSR_SCAN_ABORT_DEFAULT);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302473 ret = wait_for_completion_interruptible_timeout(
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002474 &pScanInfo->abortscan_event_var,
Jeff Johnsone7245742012-09-05 17:12:55 -07002475 msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302476 if (ret <= 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07002477 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002478 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302479 FL("Timeout occurred while waiting for abortscan %ld"),
2480 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08002481
2482 if (pHddCtx->isLogpInProgress)
2483 {
2484 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2485 "%s: LOGP in Progress. Ignore!!!", __func__);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302486
2487 VOS_ASSERT(pScanInfo->mScanPending);
Yue Ma4f55ef32014-01-23 16:45:33 -08002488 return -EAGAIN;
2489 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002490 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07002491 }
2492 }
2493
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05302494 hdd_hostapd_stop(dev);
2495
Jeff Johnson295189b2012-06-20 16:38:30 -07002496 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002497 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002498 )
2499 {
2500 beacon_data_t *old;
2501
2502 old = pAdapter->sessionCtx.ap.beacon;
2503
2504 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302505 {
2506 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2507 FL("session(%d) beacon data points to NULL"),
2508 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302510 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002511
Jeff Johnson295189b2012-06-20 16:38:30 -07002512 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002513
2514 mutex_lock(&pHddCtx->sap_lock);
2515 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
2516 {
Jeff Johnson4416a782013-03-25 14:17:50 -07002517 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002518 {
2519 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
2520
2521 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
2522
2523 if (!VOS_IS_STATUS_SUCCESS(status))
2524 {
2525 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002526 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002527 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302528 }
2529 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002530 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
2531 }
2532 mutex_unlock(&pHddCtx->sap_lock);
2533
2534 if(status != VOS_STATUS_SUCCESS)
2535 {
2536 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002537 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002538 return -EINVAL;
2539 }
2540
Jeff Johnson4416a782013-03-25 14:17:50 -07002541 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002542 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
2543 ==eHAL_STATUS_FAILURE)
2544 {
2545 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002546 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07002547 }
2548
Jeff Johnson4416a782013-03-25 14:17:50 -07002549 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002550 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
2551 eANI_BOOLEAN_FALSE) )
2552 {
2553 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002554 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07002555 }
2556
2557 // Reset WNI_CFG_PROBE_RSP Flags
2558 wlan_hdd_reset_prob_rspies(pAdapter);
2559
2560 pAdapter->sessionCtx.ap.beacon = NULL;
2561 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002562#ifdef WLAN_FEATURE_P2P_DEBUG
2563 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
2564 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
2565 {
2566 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
2567 "GO got removed");
2568 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
2569 }
2570#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002571 }
2572 EXIT();
2573 return status;
2574}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002575
2576#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2577
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302578static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
2579 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002580 struct cfg80211_ap_settings *params)
2581{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302582 hdd_adapter_t *pAdapter;
2583 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302584 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002585
2586 ENTER();
2587
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302588 if (NULL == dev)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002589 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302590 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302591 "%s: Device is Null", __func__);
2592 return -ENODEV;
2593 }
2594
2595 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2596 if (NULL == pAdapter)
2597 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302598 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302599 "%s: HDD adapter is Null", __func__);
2600 return -ENODEV;
2601 }
2602
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302603 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2604 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
2605 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302606 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
2607 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302608 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302609 "%s: HDD adapter magic is invalid", __func__);
2610 return -ENODEV;
2611 }
2612
2613 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302614 status = wlan_hdd_validate_context(pHddCtx);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302615
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302616 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302617 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302618 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2619 "%s: HDD context is not valid", __func__);
2620 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302621 }
2622
2623 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %d",
2624 __func__, pAdapter->device_mode);
2625
2626 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002627 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002628 )
2629 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302630 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002631
2632 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302633
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002634 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302635 {
2636 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2637 FL("already beacon info added to session(%d)"),
2638 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002639 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302640 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002641
2642 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, &params->beacon, params->dtim_period);
2643
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302644 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002645 {
2646 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302647 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002648 return -EINVAL;
2649 }
2650 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08002651#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07002652 wlan_hdd_cfg80211_set_channel(wiphy, dev,
2653#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
2654 params->channel, params->channel_type);
2655#else
2656 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
2657#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08002658#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002659 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
2660 params->ssid_len, params->hidden_ssid);
2661 }
2662
2663 EXIT();
2664 return status;
2665}
2666
2667
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302668static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002669 struct net_device *dev,
2670 struct cfg80211_beacon_data *params)
2671{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302672 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302673 hdd_context_t *pHddCtx;
2674 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002675
2676 ENTER();
2677
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302678 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2679 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
2680 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08002681 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002682 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302683
2684 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2685 status = wlan_hdd_validate_context(pHddCtx);
2686
2687 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002688 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302689 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2690 "%s: HDD context is not valid", __func__);
2691 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002692 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002693
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302694 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002695 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302696 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002697 {
2698 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302699
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002700 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302701
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002702 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302703 {
2704 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2705 FL("session(%d) beacon data points to NULL"),
2706 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002707 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302708 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002709
2710 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
2711
2712 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302713 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002714 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002715 return -EINVAL;
2716 }
2717
2718 pAdapter->sessionCtx.ap.beacon = new;
2719
2720 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
2721 }
2722
2723 EXIT();
2724 return status;
2725}
2726
2727#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2728
Jeff Johnson295189b2012-06-20 16:38:30 -07002729
2730static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
2731 struct net_device *dev,
2732 struct bss_parameters *params)
2733{
2734 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2735
2736 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302737
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302738 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2739 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
2740 pAdapter->sessionId, params->ap_isolate));
Arif Hussain6d2a3322013-11-17 19:50:10 -08002741 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002742 __func__,pAdapter->device_mode);
2743
2744 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002745 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302746 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002747 {
2748 /* ap_isolate == -1 means that in change bss, upper layer doesn't
2749 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302750 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07002751 {
2752 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302753 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002754 }
2755
2756 EXIT();
2757 return 0;
2758}
2759
Kiet Lam10841362013-11-01 11:36:50 +05302760/* FUNCTION: wlan_hdd_change_country_code_cd
2761* to wait for contry code completion
2762*/
2763void* wlan_hdd_change_country_code_cb(void *pAdapter)
2764{
2765 hdd_adapter_t *call_back_pAdapter = pAdapter;
2766 complete(&call_back_pAdapter->change_country_code);
2767 return NULL;
2768}
2769
Jeff Johnson295189b2012-06-20 16:38:30 -07002770/*
2771 * FUNCTION: wlan_hdd_cfg80211_change_iface
2772 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
2773 */
2774int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
2775 struct net_device *ndev,
2776 enum nl80211_iftype type,
2777 u32 *flags,
2778 struct vif_params *params
2779 )
2780{
2781 struct wireless_dev *wdev;
2782 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002783 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07002784 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002785 tCsrRoamProfile *pRoamProfile = NULL;
2786 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302787 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002788 eMib_dot11DesiredBssType connectedBssType;
2789 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302790 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002791
2792 ENTER();
2793
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302794 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002795 {
2796 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2797 "%s: Adapter context is null", __func__);
2798 return VOS_STATUS_E_FAILURE;
2799 }
2800
2801 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2802 if (!pHddCtx)
2803 {
2804 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2805 "%s: HDD context is null", __func__);
2806 return VOS_STATUS_E_FAILURE;
2807 }
2808
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302809 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2810 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
2811 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302812 status = wlan_hdd_validate_context(pHddCtx);
2813
2814 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002815 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302816 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2817 "%s: HDD context is not valid", __func__);
2818 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002819 }
2820
2821 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
2822 __func__, pAdapter->device_mode);
2823
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302824 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07002825 wdev = ndev->ieee80211_ptr;
2826
2827#ifdef WLAN_BTAMP_FEATURE
2828 if((NL80211_IFTYPE_P2P_CLIENT == type)||
2829 (NL80211_IFTYPE_ADHOC == type)||
2830 (NL80211_IFTYPE_AP == type)||
2831 (NL80211_IFTYPE_P2P_GO == type))
2832 {
2833 pHddCtx->isAmpAllowed = VOS_FALSE;
2834 // stop AMP traffic
2835 status = WLANBAP_StopAmp();
2836 if(VOS_STATUS_SUCCESS != status )
2837 {
2838 pHddCtx->isAmpAllowed = VOS_TRUE;
2839 hddLog(VOS_TRACE_LEVEL_FATAL,
2840 "%s: Failed to stop AMP", __func__);
2841 return -EINVAL;
2842 }
2843 }
2844#endif //WLAN_BTAMP_FEATURE
2845 /* Reset the current device mode bit mask*/
2846 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
2847
2848 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07002849 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07002850 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002851 )
2852 {
2853 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002854 if (!pWextState)
2855 {
2856 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2857 "%s: pWextState is null", __func__);
2858 return VOS_STATUS_E_FAILURE;
2859 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 pRoamProfile = &pWextState->roamProfile;
2861 LastBSSType = pRoamProfile->BSSType;
2862
2863 switch (type)
2864 {
2865 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002866 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002867 hddLog(VOS_TRACE_LEVEL_INFO,
2868 "%s: setting interface Type to INFRASTRUCTURE", __func__);
2869 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002870#ifdef WLAN_FEATURE_11AC
2871 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
2872 {
2873 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
2874 }
2875#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302876 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07002877 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002879 //Check for sub-string p2p to confirm its a p2p interface
2880 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302881 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002882 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2883 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2884 }
2885 else
2886 {
2887 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002889 }
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05302890#ifdef FEATURE_WLAN_TDLS
2891 /* The open adapter for the p2p shall skip initializations in
2892 * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for
2893 * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke
2894 * tdls_init when the change_iface sets the device mode to
2895 * WLAN_HDD_P2P_CLIENT.
2896 */
2897
2898 if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2899 {
2900 if (0 != wlan_hdd_tdls_init (pAdapter))
2901 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302902 hddLog(VOS_TRACE_LEVEL_ERROR,
2903 "%s: tdls initialization failed", __func__);
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05302904 return -EINVAL;
2905 }
2906 }
2907#endif
2908
Jeff Johnson295189b2012-06-20 16:38:30 -07002909 break;
2910 case NL80211_IFTYPE_ADHOC:
2911 hddLog(VOS_TRACE_LEVEL_INFO,
2912 "%s: setting interface Type to ADHOC", __func__);
2913 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2914 pRoamProfile->phyMode =
2915 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002916 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002917 wdev->iftype = type;
2918 break;
2919
2920 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002921 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002922 {
2923 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2924 "%s: setting interface Type to %s", __func__,
2925 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
2926
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002927 //Cancel any remain on channel for GO mode
2928 if (NL80211_IFTYPE_P2P_GO == type)
2929 {
2930 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
2931 }
Mohit Khanna0f232092012-09-11 14:46:08 -07002932 if (NL80211_IFTYPE_AP == type)
2933 {
2934 /* As Loading WLAN Driver one interface being created for p2p device
2935 * address. This will take one HW STA and the max number of clients
2936 * that can connect to softAP will be reduced by one. so while changing
2937 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
2938 * interface as it is not required in SoftAP mode.
2939 */
2940
2941 // Get P2P Adapter
2942 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
2943
2944 if (pP2pAdapter)
2945 {
2946 hdd_stop_adapter(pHddCtx, pP2pAdapter);
2947 hdd_deinit_adapter(pHddCtx, pP2pAdapter);
2948 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
2949 }
2950 }
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302951#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07002952
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302953 /* A Mutex Lock is introduced while changing the mode to
2954 * protect the concurrent access for the Adapters by TDLS
2955 * module.
2956 */
2957 if (mutex_lock_interruptible(&pHddCtx->tdls_lock))
2958 {
2959 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2960 "%s: unable to lock list", __func__);
2961 return -EINVAL;
2962 }
2963#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002964 //De-init the adapter.
2965 hdd_stop_adapter( pHddCtx, pAdapter );
2966 hdd_deinit_adapter( pHddCtx, pAdapter );
2967 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07002968 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2969 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302970#ifdef FEATURE_WLAN_TDLS
2971 mutex_unlock(&pHddCtx->tdls_lock);
2972#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07002973
2974 //Disable BMPS and IMPS if enabled
2975 //before starting Go
2976 if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
2977 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302978 if(VOS_STATUS_E_FAILURE ==
Jeff Johnson32d95a32012-09-10 13:15:23 -07002979 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
2980 {
2981 //Fail to Exit BMPS
2982 VOS_ASSERT(0);
2983 }
2984 }
2985
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07002986 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
2987 (pConfig->apRandomBssidEnabled))
2988 {
2989 /* To meet Android requirements create a randomized
2990 MAC address of the form 02:1A:11:Fx:xx:xx */
2991 get_random_bytes(&ndev->dev_addr[3], 3);
2992 ndev->dev_addr[0] = 0x02;
2993 ndev->dev_addr[1] = 0x1A;
2994 ndev->dev_addr[2] = 0x11;
2995 ndev->dev_addr[3] |= 0xF0;
2996 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
2997 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08002998 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
2999 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07003000 }
3001
Jeff Johnson295189b2012-06-20 16:38:30 -07003002 hdd_set_ap_ops( pAdapter->dev );
3003
Kiet Lam10841362013-11-01 11:36:50 +05303004 /* This is for only SAP mode where users can
3005 * control country through ini.
3006 * P2P GO follows station country code
3007 * acquired during the STA scanning. */
3008 if((NL80211_IFTYPE_AP == type) &&
3009 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
3010 {
3011 int status = 0;
3012 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
3013 "%s: setting country code from INI ", __func__);
3014 init_completion(&pAdapter->change_country_code);
3015 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
3016 (void *)(tSmeChangeCountryCallback)
3017 wlan_hdd_change_country_code_cb,
3018 pConfig->apCntryCode, pAdapter,
3019 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05303020 eSIR_FALSE,
3021 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05303022 if (eHAL_STATUS_SUCCESS == status)
3023 {
3024 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303025 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05303026 &pAdapter->change_country_code,
3027 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303028 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05303029 {
3030 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303031 FL("SME Timed out while setting country code %ld"),
3032 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08003033
3034 if (pHddCtx->isLogpInProgress)
3035 {
3036 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3037 "%s: LOGP in Progress. Ignore!!!", __func__);
3038 return -EAGAIN;
3039 }
Kiet Lam10841362013-11-01 11:36:50 +05303040 }
3041 }
3042 else
3043 {
3044 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003045 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05303046 return -EINVAL;
3047 }
3048 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003049 status = hdd_init_ap_mode(pAdapter);
3050 if(status != VOS_STATUS_SUCCESS)
3051 {
3052 hddLog(VOS_TRACE_LEVEL_FATAL,
3053 "%s: Error initializing the ap mode", __func__);
3054 return -EINVAL;
3055 }
3056 hdd_set_conparam(1);
3057
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 /*interface type changed update in wiphy structure*/
3059 if(wdev)
3060 {
3061 wdev->iftype = type;
3062 pHddCtx->change_iface = type;
3063 }
3064 else
3065 {
3066 hddLog(VOS_TRACE_LEVEL_ERROR,
3067 "%s: ERROR !!!! Wireless dev is NULL", __func__);
3068 return -EINVAL;
3069 }
3070 goto done;
3071 }
3072
3073 default:
3074 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
3075 __func__);
3076 return -EOPNOTSUPP;
3077 }
3078 }
3079 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07003080 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07003081 )
3082 {
3083 switch(type)
3084 {
3085 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07003086 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07003087 case NL80211_IFTYPE_ADHOC:
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303088#ifdef FEATURE_WLAN_TDLS
3089
3090 /* A Mutex Lock is introduced while changing the mode to
3091 * protect the concurrent access for the Adapters by TDLS
3092 * module.
3093 */
3094 if (mutex_lock_interruptible(&pHddCtx->tdls_lock))
3095 {
3096 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3097 "%s: unable to lock list", __func__);
3098 return -EINVAL;
3099 }
3100#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07003101 hdd_stop_adapter( pHddCtx, pAdapter );
3102 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07003103 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08003104 //Check for sub-string p2p to confirm its a p2p interface
3105 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08003106 {
3107 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
3108 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
3109 }
3110 else
3111 {
3112 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07003113 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08003114 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003115 hdd_set_conparam(0);
3116 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07003117 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
3118 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303119#ifdef FEATURE_WLAN_TDLS
3120 mutex_unlock(&pHddCtx->tdls_lock);
3121#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05303122 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07003123 if( VOS_STATUS_SUCCESS != status )
3124 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07003125 /* In case of JB, for P2P-GO, only change interface will be called,
3126 * This is the right place to enable back bmps_imps()
3127 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05303128 if (pHddCtx->hdd_wlan_suspended)
3129 {
3130 hdd_set_pwrparams(pHddCtx);
3131 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003132 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07003133 goto done;
3134 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07003136 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07003137 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
3138 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003139 goto done;
3140 default:
3141 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
3142 __func__);
3143 return -EOPNOTSUPP;
3144
3145 }
3146
3147 }
3148 else
3149 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303150 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%d)",
3151 __func__, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 return -EOPNOTSUPP;
3153 }
3154
3155
3156 if(pRoamProfile)
3157 {
3158 if ( LastBSSType != pRoamProfile->BSSType )
3159 {
3160 /*interface type changed update in wiphy structure*/
3161 wdev->iftype = type;
3162
3163 /*the BSS mode changed, We need to issue disconnect
3164 if connected or in IBSS disconnect state*/
3165 if ( hdd_connGetConnectedBssType(
3166 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
3167 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
3168 {
3169 /*need to issue a disconnect to CSR.*/
3170 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3171 if( eHAL_STATUS_SUCCESS ==
3172 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
3173 pAdapter->sessionId,
3174 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
3175 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303176 ret = wait_for_completion_interruptible_timeout(
3177 &pAdapter->disconnect_comp_var,
3178 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3179 if (ret <= 0)
3180 {
3181 hddLog(VOS_TRACE_LEVEL_ERROR,
3182 FL("wait on disconnect_comp_var failed %ld"), ret);
3183 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003184 }
3185 }
3186 }
3187 }
3188
3189done:
3190 /*set bitmask based on updated value*/
3191 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07003192
3193 /* Only STA mode support TM now
3194 * all other mode, TM feature should be disabled */
3195 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
3196 (~VOS_STA & pHddCtx->concurrency_mode) )
3197 {
3198 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
3199 }
3200
Jeff Johnson295189b2012-06-20 16:38:30 -07003201#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303202 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003203 (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
3204 {
3205 //we are ok to do AMP
3206 pHddCtx->isAmpAllowed = VOS_TRUE;
3207 }
3208#endif //WLAN_BTAMP_FEATURE
3209 EXIT();
3210 return 0;
3211}
3212
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003213#ifdef FEATURE_WLAN_TDLS
3214static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
3215 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
3216{
3217 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3218 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3219 VOS_STATUS status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003220 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303221 long ret;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003222
3223 ENTER();
3224
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303225 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003226 {
3227 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3228 "Invalid arguments");
3229 return -EINVAL;
3230 }
Hoonki Lee27511902013-03-14 18:19:06 -07003231
3232 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
3233 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
3234 {
3235 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3236 "%s: TDLS mode is disabled OR not enabled in FW."
3237 MAC_ADDRESS_STR " Request declined.",
3238 __func__, MAC_ADDR_ARRAY(mac));
3239 return -ENOTSUPP;
3240 }
3241
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003242 if (pHddCtx->isLogpInProgress)
3243 {
3244 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3245 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07003246 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003247 return -EBUSY;
3248 }
3249
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05303250 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003251
3252 if ( NULL == pTdlsPeer ) {
3253 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3254 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
3255 __func__, MAC_ADDR_ARRAY(mac), update);
3256 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003257 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003258
3259 /* in add station, we accept existing valid staId if there is */
3260 if ((0 == update) &&
3261 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
3262 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003263 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003264 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003265 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003266 " link_status %d. staId %d. add station ignored.",
3267 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
3268 return 0;
3269 }
3270 /* in change station, we accept only when staId is valid */
3271 if ((1 == update) &&
3272 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
3273 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
3274 {
3275 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3276 "%s: " MAC_ADDRESS_STR
3277 " link status %d. staId %d. change station %s.",
3278 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
3279 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
3280 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003281 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003282
3283 /* when others are on-going, we want to change link_status to idle */
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303284 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003285 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003286 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3287 "%s: " MAC_ADDRESS_STR
3288 " TDLS setup is ongoing. Request declined.",
3289 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07003290 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003291 }
3292
3293 /* first to check if we reached to maximum supported TDLS peer.
3294 TODO: for now, return -EPERM looks working fine,
3295 but need to check if any other errno fit into this category.*/
3296 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
3297 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003298 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3299 "%s: " MAC_ADDRESS_STR
3300 " TDLS Max peer already connected. Request declined.",
3301 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07003302 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003303 }
3304 else
3305 {
3306 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303307 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003308 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003309 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003310 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3311 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
3312 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003313 return -EPERM;
3314 }
3315 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003316 if (0 == update)
3317 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003318
Jeff Johnsond75fe012013-04-06 10:53:06 -07003319 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303320 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003321 {
3322 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3323 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003324 if(StaParams->htcap_present)
3325 {
3326 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3327 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
3328 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3329 "ht_capa->extended_capabilities: %0x",
3330 StaParams->HTCap.extendedHtCapInfo);
3331 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003332 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3333 "params->capability: %0x",StaParams->capability);
3334 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003335 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003336 if(StaParams->vhtcap_present)
3337 {
3338 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3339 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
3340 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
3341 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
3342 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003343 {
3344 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003345 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003346 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
3347 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3348 "[%d]: %x ", i, StaParams->supported_rates[i]);
3349 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07003350 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303351 else if ((1 == update) && (NULL == StaParams))
3352 {
3353 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3354 "%s : update is true, but staParams is NULL. Error!", __func__);
3355 return -EPERM;
3356 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003357
3358 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
3359
3360 if (!update)
3361 {
3362 status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3363 pAdapter->sessionId, mac);
3364 }
3365 else
3366 {
3367 status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3368 pAdapter->sessionId, mac, StaParams);
3369 }
3370
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303371 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003372 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
3373
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303374 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003375 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003376 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303377 "%s: timeout waiting for tdls add station indication %ld",
3378 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003379 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003380 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303381
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003382 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
3383 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003384 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003385 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003386 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003387 }
3388
3389 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07003390
3391error:
3392 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
3393 return -EPERM;
3394
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003395}
3396#endif
3397
Jeff Johnson295189b2012-06-20 16:38:30 -07003398static int wlan_hdd_change_station(struct wiphy *wiphy,
3399 struct net_device *dev,
3400 u8 *mac,
3401 struct station_parameters *params)
3402{
3403 VOS_STATUS status = VOS_STATUS_SUCCESS;
3404 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkala29149562013-05-10 21:43:41 +05303405 hdd_context_t *pHddCtx;
3406 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003407 v_MACADDR_t STAMacAddress;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003408#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003409 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003410 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05303411 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003412#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003413 ENTER();
3414
Gopichand Nakkala29149562013-05-10 21:43:41 +05303415 if ((NULL == pAdapter))
3416 {
3417 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3418 "invalid adapter ");
3419 return -EINVAL;
3420 }
3421
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303422 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
3423 TRACE_CODE_HDD_CHANGE_STATION,
3424 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05303425 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3426 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3427
3428 if ((NULL == pHddCtx) || (NULL == pHddStaCtx))
3429 {
3430 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3431 "invalid HDD state or HDD station context");
3432 return -EINVAL;
3433 }
3434
3435 if (pHddCtx->isLogpInProgress)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003436 {
3437 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3438 "%s:LOGP in Progress. Ignore!!!", __func__);
3439 return -EAGAIN;
3440 }
3441
Jeff Johnson295189b2012-06-20 16:38:30 -07003442 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
3443
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003444 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
3445 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07003446 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003447 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07003448 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303449 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07003450 WLANTL_STA_AUTHENTICATED);
3451
Gopichand Nakkala29149562013-05-10 21:43:41 +05303452 if (status != VOS_STATUS_SUCCESS)
3453 {
3454 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3455 "%s: Not able to change TL state to AUTHENTICATED", __func__);
3456 return -EINVAL;
3457 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003458 }
3459 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07003460 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
3461 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303462#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003463 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
3464 StaParams.capability = params->capability;
3465 StaParams.uapsd_queues = params->uapsd_queues;
3466 StaParams.max_sp = params->max_sp;
3467
Naresh Jayaram3180aa42014-02-12 21:47:26 +05303468 /* Convert (first channel , number of channels) tuple to
3469 * the total list of channels. This goes with the assumption
3470 * that if the first channel is < 14, then the next channels
3471 * are an incremental of 1 else an incremental of 4 till the number
3472 * of channels.
3473 */
3474 if (0 != params->supported_channels_len) {
3475 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
3476 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
3477 {
3478 int wifi_chan_index;
3479 StaParams.supported_channels[j] = params->supported_channels[i];
3480 wifi_chan_index =
3481 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
3482 no_of_channels = params->supported_channels[i+1];
3483 for(k=1; k <= no_of_channels; k++)
3484 {
3485 StaParams.supported_channels[j+1] =
3486 StaParams.supported_channels[j] + wifi_chan_index;
3487 j+=1;
3488 }
3489 }
3490 StaParams.supported_channels_len = j;
3491 }
3492 vos_mem_copy(StaParams.supported_oper_classes,
3493 params->supported_oper_classes,
3494 params->supported_oper_classes_len);
3495 StaParams.supported_oper_classes_len =
3496 params->supported_oper_classes_len;
3497
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003498 if (0 != params->ext_capab_len)
3499 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
3500 sizeof(StaParams.extn_capability));
3501
3502 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003503 {
3504 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003505 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003506 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003507
3508 StaParams.supported_rates_len = params->supported_rates_len;
3509
3510 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
3511 * The supported_rates array , for all the structures propogating till Add Sta
3512 * to the firmware has to be modified , if the supplicant (ieee80211) is
3513 * modified to send more rates.
3514 */
3515
3516 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
3517 */
3518 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
3519 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
3520
3521 if (0 != StaParams.supported_rates_len) {
3522 int i = 0;
3523 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
3524 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003525 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003526 "Supported Rates with Length %d", StaParams.supported_rates_len);
3527 for (i=0; i < StaParams.supported_rates_len; i++)
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 "[%d]: %0x", i, StaParams.supported_rates[i]);
3530 }
3531
3532 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003533 {
3534 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003535 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003536 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003537
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003538 if (0 != params->ext_capab_len ) {
3539 /*Define A Macro : TODO Sunil*/
3540 if ((1<<4) & StaParams.extn_capability[3]) {
3541 isBufSta = 1;
3542 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05303543 /* TDLS Channel Switching Support */
3544 if ((1<<6) & StaParams.extn_capability[3]) {
3545 isOffChannelSupported = 1;
3546 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003547 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05303548 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
3549 &StaParams, isBufSta,
3550 isOffChannelSupported);
3551
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303552 if (VOS_STATUS_SUCCESS != status) {
3553 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3554 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
3555 return -EINVAL;
3556 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003557 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
3558
3559 if (VOS_STATUS_SUCCESS != status) {
3560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3561 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
3562 return -EINVAL;
3563 }
3564 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003565#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05303566 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003567 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003568 return status;
3569}
3570
3571/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003572 * FUNCTION: wlan_hdd_cfg80211_add_key
3573 * This function is used to initialize the key information
3574 */
3575#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003576static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003577 struct net_device *ndev,
3578 u8 key_index, bool pairwise,
3579 const u8 *mac_addr,
3580 struct key_params *params
3581 )
3582#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003583static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003584 struct net_device *ndev,
3585 u8 key_index, const u8 *mac_addr,
3586 struct key_params *params
3587 )
3588#endif
3589{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003590 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003591 tCsrRoamSetKey setKey;
3592 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303593 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003594 v_U32_t roamId= 0xFF;
3595 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003596 hdd_hostapd_state_t *pHostapdState;
3597 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003598 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303599 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003600
3601 ENTER();
3602
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303603 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
3604 TRACE_CODE_HDD_CFG80211_ADD_KEY,
3605 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303606 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3607 status = wlan_hdd_validate_context(pHddCtx);
3608
3609 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003610 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303611 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3612 "%s: HDD context is not valid", __func__);
3613 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003614 }
3615
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003616 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
3617 __func__, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003618
3619 if (CSR_MAX_NUM_KEY <= key_index)
3620 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003621 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003622 key_index);
3623
3624 return -EINVAL;
3625 }
3626
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003627 if (CSR_MAX_KEY_LEN < params->key_len)
3628 {
3629 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
3630 params->key_len);
3631
3632 return -EINVAL;
3633 }
3634
3635 hddLog(VOS_TRACE_LEVEL_INFO,
3636 "%s: called with key index = %d & key length %d",
3637 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003638
3639 /*extract key idx, key len and key*/
3640 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3641 setKey.keyId = key_index;
3642 setKey.keyLength = params->key_len;
3643 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
3644
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003645 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07003646 {
3647 case WLAN_CIPHER_SUITE_WEP40:
3648 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3649 break;
3650
3651 case WLAN_CIPHER_SUITE_WEP104:
3652 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3653 break;
3654
3655 case WLAN_CIPHER_SUITE_TKIP:
3656 {
3657 u8 *pKey = &setKey.Key[0];
3658 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3659
3660 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3661
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003662 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07003663
3664 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003665 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003666 |--------------|----------|----------|
3667 <---16bytes---><--8bytes--><--8bytes-->
3668
3669 */
3670 /*Sme expects the 32 bytes key to be in the below order
3671
3672 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003673 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003674 |--------------|----------|----------|
3675 <---16bytes---><--8bytes--><--8bytes-->
3676 */
3677 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003678 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07003679
3680 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003681 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003682
3683 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003684 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003685
3686
3687 break;
3688 }
3689
3690 case WLAN_CIPHER_SUITE_CCMP:
3691 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3692 break;
3693
3694#ifdef FEATURE_WLAN_WAPI
3695 case WLAN_CIPHER_SUITE_SMS4:
3696 {
3697 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3698 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
3699 params->key, params->key_len);
3700 return 0;
3701 }
3702#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003703
Jeff Johnson295189b2012-06-20 16:38:30 -07003704#ifdef FEATURE_WLAN_CCX
3705 case WLAN_CIPHER_SUITE_KRK:
3706 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3707 break;
3708#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003709
3710#ifdef WLAN_FEATURE_11W
3711 case WLAN_CIPHER_SUITE_AES_CMAC:
3712 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07003713 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07003714#endif
3715
Jeff Johnson295189b2012-06-20 16:38:30 -07003716 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003717 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07003718 __func__, params->cipher);
3719 return -EOPNOTSUPP;
3720 }
3721
3722 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
3723 __func__, setKey.encType);
3724
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003725 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07003726#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3727 (!pairwise)
3728#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003729 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07003730#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003731 )
3732 {
3733 /* set group key*/
3734 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3735 "%s- %d: setting Broadcast key",
3736 __func__, __LINE__);
3737 setKey.keyDirection = eSIR_RX_ONLY;
3738 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3739 }
3740 else
3741 {
3742 /* set pairwise key*/
3743 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3744 "%s- %d: setting pairwise key",
3745 __func__, __LINE__);
3746 setKey.keyDirection = eSIR_TX_RX;
3747 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3748 }
3749 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
3750 {
3751 setKey.keyDirection = eSIR_TX_RX;
3752 /*Set the group key*/
3753 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3754 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003755
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003756 if ( 0 != status )
3757 {
3758 hddLog(VOS_TRACE_LEVEL_ERROR,
3759 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3760 return -EINVAL;
3761 }
3762 /*Save the keys here and call sme_RoamSetKey for setting
3763 the PTK after peer joins the IBSS network*/
3764 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
3765 &setKey, sizeof(tCsrRoamSetKey));
3766 return status;
3767 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05303768 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
3769 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
3770 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003771 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003772 if( pHostapdState->bssState == BSS_START )
3773 {
c_hpothu7c55da62014-01-23 18:34:02 +05303774 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3775 vos_status = wlan_hdd_check_ula_done(pAdapter);
3776
3777 if ( vos_status != VOS_STATUS_SUCCESS )
3778 {
3779 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3780 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3781 __LINE__, vos_status );
3782
3783 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3784
3785 return -EINVAL;
3786 }
3787
Jeff Johnson295189b2012-06-20 16:38:30 -07003788 status = WLANSAP_SetKeySta( pVosContext, &setKey);
3789
3790 if ( status != eHAL_STATUS_SUCCESS )
3791 {
3792 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3793 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3794 __LINE__, status );
3795 }
3796 }
3797
3798 /* Saving WEP keys */
3799 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
3800 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
3801 {
3802 //Save the wep key in ap context. Issue setkey after the BSS is started.
3803 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3804 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
3805 }
3806 else
3807 {
3808 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003809 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003810 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
3811 }
3812 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003813 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
3814 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003815 {
3816 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3817 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3818
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303819#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3820 if (!pairwise)
3821#else
3822 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
3823#endif
3824 {
3825 /* set group key*/
3826 if (pHddStaCtx->roam_info.deferKeyComplete)
3827 {
3828 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3829 "%s- %d: Perform Set key Complete",
3830 __func__, __LINE__);
3831 hdd_PerformRoamSetKeyComplete(pAdapter);
3832 }
3833 }
3834
Jeff Johnson295189b2012-06-20 16:38:30 -07003835 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
3836
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08003837 pWextState->roamProfile.Keys.defaultIndex = key_index;
3838
3839
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003840 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003841 params->key, params->key_len);
3842
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303843
Jeff Johnson295189b2012-06-20 16:38:30 -07003844 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3845
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303846 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003847 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303848 __func__, setKey.peerMac[0], setKey.peerMac[1],
3849 setKey.peerMac[2], setKey.peerMac[3],
3850 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003851 setKey.keyDirection);
3852
3853 vos_status = wlan_hdd_check_ula_done(pAdapter);
3854
3855 if ( vos_status != VOS_STATUS_SUCCESS )
3856 {
3857 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3858 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3859 __LINE__, vos_status );
3860
3861 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3862
3863 return -EINVAL;
3864
3865 }
3866
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003867#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303868 /* The supplicant may attempt to set the PTK once pre-authentication
3869 is done. Save the key in the UMAC and include it in the ADD BSS
3870 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003871 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303872 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003873 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303874 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3875 "%s: Update PreAuth Key success", __func__);
3876 return 0;
3877 }
3878 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3879 {
3880 hddLog(VOS_TRACE_LEVEL_ERROR,
3881 "%s: Update PreAuth Key failed", __func__);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05303882 return -EINVAL;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003883 }
3884#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07003885
3886 /* issue set key request to SME*/
3887 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3888 pAdapter->sessionId, &setKey, &roamId );
3889
3890 if ( 0 != status )
3891 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303892 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003893 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3894 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3895 return -EINVAL;
3896 }
3897
3898
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303899 /* in case of IBSS as there was no information available about WEP keys during
3900 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07003901 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303902 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
3903 !( ( IW_AUTH_KEY_MGMT_802_1X
3904 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003905 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
3906 )
3907 &&
3908 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
3909 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
3910 )
3911 )
3912 {
3913 setKey.keyDirection = eSIR_RX_ONLY;
3914 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3915
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303916 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003917 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303918 __func__, setKey.peerMac[0], setKey.peerMac[1],
3919 setKey.peerMac[2], setKey.peerMac[3],
3920 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003921 setKey.keyDirection);
3922
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303923 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003924 pAdapter->sessionId, &setKey, &roamId );
3925
3926 if ( 0 != status )
3927 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303928 hddLog(VOS_TRACE_LEVEL_ERROR,
3929 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003930 __func__, status);
3931 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3932 return -EINVAL;
3933 }
3934 }
3935 }
3936
3937 return 0;
3938}
3939
3940/*
3941 * FUNCTION: wlan_hdd_cfg80211_get_key
3942 * This function is used to get the key information
3943 */
3944#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303945static int wlan_hdd_cfg80211_get_key(
3946 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303948 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003949 const u8 *mac_addr, void *cookie,
3950 void (*callback)(void *cookie, struct key_params*)
3951 )
3952#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303953static int wlan_hdd_cfg80211_get_key(
3954 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003955 struct net_device *ndev,
3956 u8 key_index, const u8 *mac_addr, void *cookie,
3957 void (*callback)(void *cookie, struct key_params*)
3958 )
3959#endif
3960{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303961 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003962 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3963 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3964 struct key_params params;
3965
3966 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303967
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303968 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
3969 TRACE_CODE_HDD_CFG80211_GET_KEY,
3970 pAdapter->sessionId, params.cipher));
Arif Hussain6d2a3322013-11-17 19:50:10 -08003971 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003972 __func__,pAdapter->device_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303973
Jeff Johnson295189b2012-06-20 16:38:30 -07003974 memset(&params, 0, sizeof(params));
3975
3976 if (CSR_MAX_NUM_KEY <= key_index)
3977 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303978 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303980 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003981
3982 switch(pRoamProfile->EncryptionType.encryptionType[0])
3983 {
3984 case eCSR_ENCRYPT_TYPE_NONE:
3985 params.cipher = IW_AUTH_CIPHER_NONE;
3986 break;
3987
3988 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3989 case eCSR_ENCRYPT_TYPE_WEP40:
3990 params.cipher = WLAN_CIPHER_SUITE_WEP40;
3991 break;
3992
3993 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3994 case eCSR_ENCRYPT_TYPE_WEP104:
3995 params.cipher = WLAN_CIPHER_SUITE_WEP104;
3996 break;
3997
3998 case eCSR_ENCRYPT_TYPE_TKIP:
3999 params.cipher = WLAN_CIPHER_SUITE_TKIP;
4000 break;
4001
4002 case eCSR_ENCRYPT_TYPE_AES:
4003 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
4004 break;
4005
4006 default:
4007 params.cipher = IW_AUTH_CIPHER_NONE;
4008 break;
4009 }
4010
4011 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
4012 params.seq_len = 0;
4013 params.seq = NULL;
4014 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
4015 callback(cookie, &params);
4016 return 0;
4017}
4018
4019/*
4020 * FUNCTION: wlan_hdd_cfg80211_del_key
4021 * This function is used to delete the key information
4022 */
4023#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304024static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004025 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304026 u8 key_index,
4027 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07004028 const u8 *mac_addr
4029 )
4030#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304031static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004032 struct net_device *ndev,
4033 u8 key_index,
4034 const u8 *mac_addr
4035 )
4036#endif
4037{
4038 int status = 0;
4039
4040 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304041 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07004042 //it is observed that this is invalidating peer
4043 //key index whenever re-key is done. This is affecting data link.
4044 //It should be ok to ignore del_key.
4045#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304046 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
4047 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004048 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4049 tCsrRoamSetKey setKey;
4050 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304051
Jeff Johnson295189b2012-06-20 16:38:30 -07004052 ENTER();
4053
4054 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
4055 __func__,pAdapter->device_mode);
4056
4057 if (CSR_MAX_NUM_KEY <= key_index)
4058 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304059 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004060 key_index);
4061
4062 return -EINVAL;
4063 }
4064
4065 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4066 setKey.keyId = key_index;
4067
4068 if (mac_addr)
4069 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
4070 else
4071 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
4072
4073 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4074
4075 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07004076 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304077 )
4078 {
4079
4080 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07004081 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
4082 if( pHostapdState->bssState == BSS_START)
4083 {
4084 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304085
Jeff Johnson295189b2012-06-20 16:38:30 -07004086 if ( status != eHAL_STATUS_SUCCESS )
4087 {
4088 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4089 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
4090 __LINE__, status );
4091 }
4092 }
4093 }
4094 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304095 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07004096 )
4097 {
4098 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4099
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304100 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
4101
4102 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07004103 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304104 __func__, setKey.peerMac[0], setKey.peerMac[1],
4105 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304107 if(pAdapter->sessionCtx.station.conn_info.connState ==
4108 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07004109 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304110 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07004111 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304112
Jeff Johnson295189b2012-06-20 16:38:30 -07004113 if ( 0 != status )
4114 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304115 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004116 "%s: sme_RoamSetKey failure, returned %d",
4117 __func__, status);
4118 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4119 return -EINVAL;
4120 }
4121 }
4122 }
4123#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07004124 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004125 return status;
4126}
4127
4128/*
4129 * FUNCTION: wlan_hdd_cfg80211_set_default_key
4130 * This function is used to set the default tx key index
4131 */
4132#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
4133static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
4134 struct net_device *ndev,
4135 u8 key_index,
4136 bool unicast, bool multicast)
4137#else
4138static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
4139 struct net_device *ndev,
4140 u8 key_index)
4141#endif
4142{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304143 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304144 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05304145 hdd_wext_state_t *pWextState;
4146 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304147 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004148
4149 ENTER();
4150
Gopichand Nakkala29149562013-05-10 21:43:41 +05304151 if ((NULL == pAdapter))
4152 {
4153 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4154 "invalid adapter");
4155 return -EINVAL;
4156 }
4157
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304158 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
4159 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
4160 pAdapter->sessionId, key_index));
4161
Gopichand Nakkala29149562013-05-10 21:43:41 +05304162 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4163 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4164
4165 if ((NULL == pWextState) || (NULL == pHddStaCtx))
4166 {
4167 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4168 "invalid Wext state or HDD context");
4169 return -EINVAL;
4170 }
4171
Arif Hussain6d2a3322013-11-17 19:50:10 -08004172 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004173 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304174
Jeff Johnson295189b2012-06-20 16:38:30 -07004175 if (CSR_MAX_NUM_KEY <= key_index)
4176 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304177 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004178 key_index);
4179
4180 return -EINVAL;
4181 }
4182
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304183 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4184 status = wlan_hdd_validate_context(pHddCtx);
4185
4186 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004187 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304188 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4189 "%s: HDD context is not valid", __func__);
4190 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004191 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304192
Jeff Johnson295189b2012-06-20 16:38:30 -07004193 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07004194 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304195 )
Jeff Johnson295189b2012-06-20 16:38:30 -07004196 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05304197 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08004198 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304199 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08004200 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07004201 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304202 {
4203 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07004204 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304205
Jeff Johnson295189b2012-06-20 16:38:30 -07004206 tCsrRoamSetKey setKey;
4207 v_U32_t roamId= 0xFF;
4208 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304209
4210 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004211 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304212
Jeff Johnson295189b2012-06-20 16:38:30 -07004213 Keys->defaultIndex = (u8)key_index;
4214 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4215 setKey.keyId = key_index;
4216 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304217
4218 vos_mem_copy(&setKey.Key[0],
4219 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07004220 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304221
Gopichand Nakkala29149562013-05-10 21:43:41 +05304222 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304223
4224 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07004225 &pHddStaCtx->conn_info.bssId[0],
4226 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304227
Gopichand Nakkala29149562013-05-10 21:43:41 +05304228 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
4229 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
4230 eCSR_ENCRYPT_TYPE_WEP104)
4231 {
4232 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
4233 even though ap is configured for WEP-40 encryption. In this canse the key length
4234 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
4235 type(104) and switching encryption type to 40*/
4236 pWextState->roamProfile.EncryptionType.encryptionType[0] =
4237 eCSR_ENCRYPT_TYPE_WEP40;
4238 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
4239 eCSR_ENCRYPT_TYPE_WEP40;
4240 }
4241
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304242 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07004243 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304244
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304246 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07004247 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304248
Jeff Johnson295189b2012-06-20 16:38:30 -07004249 if ( 0 != status )
4250 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304251 hddLog(VOS_TRACE_LEVEL_ERROR,
4252 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004253 status);
4254 return -EINVAL;
4255 }
4256 }
4257 }
4258
4259 /* In SoftAp mode setting key direction for default mode */
4260 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
4261 {
4262 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
4263 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
4264 (eCSR_ENCRYPT_TYPE_AES !=
4265 pWextState->roamProfile.EncryptionType.encryptionType[0])
4266 )
4267 {
4268 /* Saving key direction for default key index to TX default */
4269 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
4270 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
4271 }
4272 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304273
Jeff Johnson295189b2012-06-20 16:38:30 -07004274 return status;
4275}
4276
Jeff Johnson295189b2012-06-20 16:38:30 -07004277/*
4278 * FUNCTION: wlan_hdd_cfg80211_inform_bss
4279 * This function is used to inform the BSS details to nl80211 interface.
4280 */
4281static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
4282 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
4283{
4284 struct net_device *dev = pAdapter->dev;
4285 struct wireless_dev *wdev = dev->ieee80211_ptr;
4286 struct wiphy *wiphy = wdev->wiphy;
4287 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
4288 int chan_no;
4289 int ie_length;
4290 const char *ie;
4291 unsigned int freq;
4292 struct ieee80211_channel *chan;
4293 int rssi = 0;
4294 struct cfg80211_bss *bss = NULL;
4295
4296 ENTER();
4297
4298 if( NULL == pBssDesc )
4299 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004300 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004301 return bss;
4302 }
4303
4304 chan_no = pBssDesc->channelId;
4305 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
4306 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
4307
4308 if( NULL == ie )
4309 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004310 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004311 return bss;
4312 }
4313
4314#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
4315 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
4316 {
4317 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4318 }
4319 else
4320 {
4321 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4322 }
4323#else
4324 freq = ieee80211_channel_to_frequency(chan_no);
4325#endif
4326
4327 chan = __ieee80211_get_channel(wiphy, freq);
4328
4329 bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId,
4330 &roamProfile->SSID.ssId[0], roamProfile->SSID.length,
4331 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
4332 if (bss == NULL)
4333 {
4334 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
4335
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304336 return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
4337 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07004338 pBssDesc->capabilityInfo,
4339 pBssDesc->beaconInterval, ie, ie_length,
4340 rssi, GFP_KERNEL ));
4341}
4342 else
4343 {
4344 return bss;
4345 }
4346}
4347
4348
4349
4350/*
4351 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
4352 * This function is used to inform the BSS details to nl80211 interface.
4353 */
4354struct cfg80211_bss*
4355wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
4356 tSirBssDescription *bss_desc
4357 )
4358{
4359 /*
4360 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
4361 already exists in bss data base of cfg80211 for that particular BSS ID.
4362 Using cfg80211_inform_bss_frame to update the bss entry instead of
4363 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
4364 now there is no possibility to get the mgmt(probe response) frame from PE,
4365 converting bss_desc to ieee80211_mgmt(probe response) and passing to
4366 cfg80211_inform_bss_frame.
4367 */
4368 struct net_device *dev = pAdapter->dev;
4369 struct wireless_dev *wdev = dev->ieee80211_ptr;
4370 struct wiphy *wiphy = wdev->wiphy;
4371 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004372#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4373 qcom_ie_age *qie_age = NULL;
4374 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
4375#else
Jeff Johnson295189b2012-06-20 16:38:30 -07004376 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004377#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004378 const char *ie =
4379 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
4380 unsigned int freq;
4381 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05304382 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004383 struct cfg80211_bss *bss_status = NULL;
4384 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
4385 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07004386 hdd_context_t *pHddCtx;
4387 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07004388#ifdef WLAN_OPEN_SOURCE
4389 struct timespec ts;
4390#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004391
Wilson Yangf80a0542013-10-07 13:02:37 -07004392 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4393 status = wlan_hdd_validate_context(pHddCtx);
4394
4395 /*bss_update is not allowed during wlan driver loading or unloading*/
4396 if (pHddCtx->isLoadUnloadInProgress)
4397 {
4398 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4399 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
4400 return NULL;
4401 }
4402
4403
4404 if (0 != status)
4405 {
4406 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4407 "%s: HDD context is not valid", __func__);
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07004408 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07004409 }
4410
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05304411 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -07004412 if (!mgmt)
4413 {
4414 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4415 "%s: memory allocation failed ", __func__);
4416 return NULL;
4417 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07004418
Jeff Johnson295189b2012-06-20 16:38:30 -07004419 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07004420
4421#ifdef WLAN_OPEN_SOURCE
4422 /* Android does not want the timestamp from the frame.
4423 Instead it wants a monotonic increasing value */
4424 get_monotonic_boottime(&ts);
4425 mgmt->u.probe_resp.timestamp =
4426 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
4427#else
4428 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07004429 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
4430 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07004431
4432#endif
4433
Jeff Johnson295189b2012-06-20 16:38:30 -07004434 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
4435 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004436
4437#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4438 /* GPS Requirement: need age ie per entry. Using vendor specific. */
4439 /* Assuming this is the last IE, copy at the end */
4440 ie_length -=sizeof(qcom_ie_age);
4441 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
4442 qie_age->element_id = QCOM_VENDOR_IE_ID;
4443 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
4444 qie_age->oui_1 = QCOM_OUI1;
4445 qie_age->oui_2 = QCOM_OUI2;
4446 qie_age->oui_3 = QCOM_OUI3;
4447 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
4448 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
4449#endif
4450
Jeff Johnson295189b2012-06-20 16:38:30 -07004451 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05304452 if (bss_desc->fProbeRsp)
4453 {
4454 mgmt->frame_control |=
4455 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
4456 }
4457 else
4458 {
4459 mgmt->frame_control |=
4460 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
4461 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004462
4463#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304464 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004465 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
4466 {
4467 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4468 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304469 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004470 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
4471
4472 {
4473 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4474 }
4475 else
4476 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05304477 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
4478 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -07004479 kfree(mgmt);
4480 return NULL;
4481 }
4482#else
4483 freq = ieee80211_channel_to_frequency(chan_no);
4484#endif
4485 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004486 /*when the band is changed on the fly using the GUI, three things are done
4487 * 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)
4488 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
4489 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
4490 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
4491 * and discards the channels correponding to previous band and calls back with zero bss results.
4492 * 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
4493 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
4494 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
4495 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
4496 * So drop the bss and continue to next bss.
4497 */
4498 if(chan == NULL)
4499 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05304500 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07004501 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004502 return NULL;
4503 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004504 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304505 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07004506 * */
4507 if (( eConnectionState_Associated ==
4508 pAdapter->sessionCtx.station.conn_info.connState ) &&
4509 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
4510 pAdapter->sessionCtx.station.conn_info.bssId,
4511 WNI_CFG_BSSID_LEN)))
4512 {
4513 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
4514 rssi = (pAdapter->rssi * 100);
4515 }
4516 else
4517 {
4518 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
4519 }
4520
Nirav Shah20ac06f2013-12-12 18:14:06 +05304521 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
4522 "RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
4523 chan->center_freq, (int)(rssi/100));
4524
Jeff Johnson295189b2012-06-20 16:38:30 -07004525 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
4526 frame_len, rssi, GFP_KERNEL);
4527 kfree(mgmt);
4528 return bss_status;
4529}
4530
4531/*
4532 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
4533 * This function is used to update the BSS data base of CFG8011
4534 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304535struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004536 tCsrRoamInfo *pRoamInfo
4537 )
4538{
4539 tCsrRoamConnectedProfile roamProfile;
4540 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4541 struct cfg80211_bss *bss = NULL;
4542
4543 ENTER();
4544
4545 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
4546 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
4547
4548 if (NULL != roamProfile.pBssDesc)
4549 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304550 bss = wlan_hdd_cfg80211_inform_bss(pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004551 &roamProfile);
4552
4553 if (NULL == bss)
4554 {
4555 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
4556 __func__);
4557 }
4558
4559 sme_RoamFreeConnectProfile(hHal, &roamProfile);
4560 }
4561 else
4562 {
4563 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
4564 __func__);
4565 }
4566 return bss;
4567}
4568
4569/*
4570 * FUNCTION: wlan_hdd_cfg80211_update_bss
4571 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304572static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
4573 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07004574 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304575{
Jeff Johnson295189b2012-06-20 16:38:30 -07004576 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4577 tCsrScanResultInfo *pScanResult;
4578 eHalStatus status = 0;
4579 tScanResultHandle pResult;
4580 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07004581 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004582
4583 ENTER();
4584
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304585 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
4586 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
4587 NO_SESSION, pAdapter->sessionId));
4588
Wilson Yangf80a0542013-10-07 13:02:37 -07004589 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4590
4591 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -07004592 {
Wilson Yangf80a0542013-10-07 13:02:37 -07004593 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4594 "%s:LOGP in Progress. Ignore!!!",__func__);
4595 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004596 }
4597
Wilson Yangf80a0542013-10-07 13:02:37 -07004598
4599 /*bss_update is not allowed during wlan driver loading or unloading*/
4600 if (pHddCtx->isLoadUnloadInProgress)
4601 {
4602 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4603 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
4604 return VOS_STATUS_E_PERM;
4605 }
4606
4607
Jeff Johnson295189b2012-06-20 16:38:30 -07004608 /*
4609 * start getting scan results and populate cgf80211 BSS database
4610 */
4611 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
4612
4613 /* no scan results */
4614 if (NULL == pResult)
4615 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05304616 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
4617 __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004618 return status;
4619 }
4620
4621 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
4622
4623 while (pScanResult)
4624 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304625 /*
4626 * cfg80211_inform_bss() is not updating ie field of bss entry, if
4627 * entry already exists in bss data base of cfg80211 for that
4628 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
4629 * bss entry instead of cfg80211_inform_bss, But this call expects
4630 * mgmt packet as input. As of now there is no possibility to get
4631 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07004632 * ieee80211_mgmt(probe response) and passing to c
4633 * fg80211_inform_bss_frame.
4634 * */
4635
4636 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
4637 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304638
Jeff Johnson295189b2012-06-20 16:38:30 -07004639
4640 if (NULL == bss_status)
4641 {
4642 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004643 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004644 }
4645 else
4646 {
Yue Maf49ba872013-08-19 12:04:25 -07004647 cfg80211_put_bss(
4648#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
4649 wiphy,
4650#endif
4651 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004652 }
4653
4654 pScanResult = sme_ScanResultGetNext(hHal, pResult);
4655 }
4656
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304657 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07004658
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304659 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004660}
4661
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004662void
4663hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
4664{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304665 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -08004666 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004667} /****** end hddPrintMacAddr() ******/
4668
4669void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004670hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004671{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304672 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004673 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004674 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
4675 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
4676 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004677} /****** end hddPrintPmkId() ******/
4678
4679//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
4680//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
4681
4682//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
4683//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
4684
4685#define dump_bssid(bssid) \
4686 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004687 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
4688 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004689 }
4690
4691#define dump_pmkid(pMac, pmkid) \
4692 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004693 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
4694 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004695 }
4696
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004697#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004698/*
4699 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
4700 * This function is used to notify the supplicant of a new PMKSA candidate.
4701 */
4702int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304703 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004704 int index, bool preauth )
4705{
Jeff Johnsone7245742012-09-05 17:12:55 -07004706#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004707 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004708 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004709
4710 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07004711 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004712
4713 if( NULL == pRoamInfo )
4714 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004715 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004716 return -EINVAL;
4717 }
4718
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004719 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
4720 {
4721 dump_bssid(pRoamInfo->bssid);
4722 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004723 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004724 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004725#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304726 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004727}
4728#endif //FEATURE_WLAN_LFR
4729
Yue Maef608272013-04-08 23:09:17 -07004730#ifdef FEATURE_WLAN_LFR_METRICS
4731/*
4732 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
4733 * 802.11r/LFR metrics reporting function to report preauth initiation
4734 *
4735 */
4736#define MAX_LFR_METRICS_EVENT_LENGTH 100
4737VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
4738 tCsrRoamInfo *pRoamInfo)
4739{
4740 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4741 union iwreq_data wrqu;
4742
4743 ENTER();
4744
4745 if (NULL == pAdapter)
4746 {
4747 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4748 return VOS_STATUS_E_FAILURE;
4749 }
4750
4751 /* create the event */
4752 memset(&wrqu, 0, sizeof(wrqu));
4753 memset(metrics_notification, 0, sizeof(metrics_notification));
4754
4755 wrqu.data.pointer = metrics_notification;
4756 wrqu.data.length = scnprintf(metrics_notification,
4757 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
4758 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
4759
4760 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4761
4762 EXIT();
4763
4764 return VOS_STATUS_SUCCESS;
4765}
4766
4767/*
4768 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
4769 * 802.11r/LFR metrics reporting function to report preauth completion
4770 * or failure
4771 */
4772VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
4773 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
4774{
4775 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4776 union iwreq_data wrqu;
4777
4778 ENTER();
4779
4780 if (NULL == pAdapter)
4781 {
4782 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4783 return VOS_STATUS_E_FAILURE;
4784 }
4785
4786 /* create the event */
4787 memset(&wrqu, 0, sizeof(wrqu));
4788 memset(metrics_notification, 0, sizeof(metrics_notification));
4789
4790 scnprintf(metrics_notification, sizeof(metrics_notification),
4791 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
4792 MAC_ADDR_ARRAY(pRoamInfo->bssid));
4793
4794 if (1 == preauth_status)
4795 strncat(metrics_notification, " TRUE", 5);
4796 else
4797 strncat(metrics_notification, " FALSE", 6);
4798
4799 wrqu.data.pointer = metrics_notification;
4800 wrqu.data.length = strlen(metrics_notification);
4801
4802 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4803
4804 EXIT();
4805
4806 return VOS_STATUS_SUCCESS;
4807}
4808
4809/*
4810 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
4811 * 802.11r/LFR metrics reporting function to report handover initiation
4812 *
4813 */
4814VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
4815 tCsrRoamInfo *pRoamInfo)
4816{
4817 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4818 union iwreq_data wrqu;
4819
4820 ENTER();
4821
4822 if (NULL == pAdapter)
4823 {
4824 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4825 return VOS_STATUS_E_FAILURE;
4826 }
4827
4828 /* create the event */
4829 memset(&wrqu, 0, sizeof(wrqu));
4830 memset(metrics_notification, 0, sizeof(metrics_notification));
4831
4832 wrqu.data.pointer = metrics_notification;
4833 wrqu.data.length = scnprintf(metrics_notification,
4834 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
4835 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
4836
4837 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4838
4839 EXIT();
4840
4841 return VOS_STATUS_SUCCESS;
4842}
4843#endif
4844
Jeff Johnson295189b2012-06-20 16:38:30 -07004845/*
4846 * FUNCTION: hdd_cfg80211_scan_done_callback
4847 * scanning callback function, called after finishing scan
4848 *
4849 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304850static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -07004851 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
4852{
4853 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304854 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004855 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004856 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4857 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07004858 struct cfg80211_scan_request *req = NULL;
4859 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05304860 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304861 long waitRet = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004862
4863 ENTER();
4864
4865 hddLog(VOS_TRACE_LEVEL_INFO,
4866 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -08004867 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004868 __func__, halHandle, pContext, (int) scanId, (int) status);
4869
Kiet Lamac06e2c2013-10-23 16:25:07 +05304870 pScanInfo->mScanPendingCounter = 0;
4871
Jeff Johnson295189b2012-06-20 16:38:30 -07004872 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304873 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -07004874 &pScanInfo->scan_req_completion_event,
4875 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304876 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004877 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304878 hddLog(VOS_TRACE_LEVEL_ERROR,
4879 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -07004880 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004881 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004882 }
4883
Yue Maef608272013-04-08 23:09:17 -07004884 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004885 {
4886 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004887 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004888 }
4889
4890 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304891 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -07004892 {
4893 hddLog(VOS_TRACE_LEVEL_INFO,
4894 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004895 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004896 (int) scanId);
4897 }
4898
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304899 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004900 pAdapter);
4901
4902 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304903 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004904
4905
4906 /* If any client wait scan result through WEXT
4907 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004908 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07004909 {
4910 /* The other scan request waiting for current scan finish
4911 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004912 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004913 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004914 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07004915 }
4916 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004917 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004918 {
4919 struct net_device *dev = pAdapter->dev;
4920 union iwreq_data wrqu;
4921 int we_event;
4922 char *msg;
4923
4924 memset(&wrqu, '\0', sizeof(wrqu));
4925 we_event = SIOCGIWSCAN;
4926 msg = NULL;
4927 wireless_send_event(dev, we_event, &wrqu, msg);
4928 }
4929 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004930 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004931
4932 /* Get the Scan Req */
4933 req = pAdapter->request;
4934
4935 if (!req)
4936 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004937 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004938 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004939 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004940 }
4941
4942 /*
4943 * setting up 0, just in case.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304944 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004945 req->n_ssids = 0;
4946 req->n_channels = 0;
4947 req->ie = 0;
4948
Jeff Johnson295189b2012-06-20 16:38:30 -07004949 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07004950 /* Scan is no longer pending */
4951 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004952
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -07004953 /*
4954 * cfg80211_scan_done informing NL80211 about completion
4955 * of scanning
4956 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05304957 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
4958 {
4959 aborted = true;
4960 }
4961 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08004962 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07004963
Jeff Johnsone7245742012-09-05 17:12:55 -07004964allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004965 /* release the wake lock at the end of the scan*/
4966 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07004967
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004968 /* Acquire wakelock to handle the case where APP's tries to suspend
4969 * immediatly after the driver gets connect request(i.e after scan)
4970 * from supplicant, this result in app's is suspending and not able
4971 * to process the connect request to AP */
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05304972 hdd_prevent_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004973
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004974#ifdef FEATURE_WLAN_TDLS
4975 wlan_hdd_tdls_scan_done_callback(pAdapter);
4976#endif
4977
Jeff Johnson295189b2012-06-20 16:38:30 -07004978 EXIT();
4979 return 0;
4980}
4981
4982/*
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004983 * FUNCTION: hdd_isScanAllowed
4984 * Go through each adapter and check if scan allowed
4985 *
4986 */
4987v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx )
4988{
4989 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
4990 hdd_station_ctx_t *pHddStaCtx = NULL;
4991 hdd_adapter_t *pAdapter = NULL;
4992 VOS_STATUS status = 0;
4993 v_U8_t staId = 0;
4994 v_U8_t *staMac = NULL;
4995
c_hpothu9b781ba2013-12-30 20:57:45 +05304996 if (TRUE == pHddCtx->btCoexModeSet)
4997 {
4998 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4999 FL("BTCoex Mode operation in progress, Do not allow scan"));
5000 return VOS_FALSE;
5001 }
5002
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005003 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
5004
5005 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
5006 {
5007 pAdapter = pAdapterNode->pAdapter;
5008
5009 if( pAdapter )
5010 {
5011 hddLog(VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305012 "%s: Adapter with device mode %d exists",
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005013 __func__, pAdapter->device_mode);
5014 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
5015 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
5016 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
5017 {
5018 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5019 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
5020 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
5021 {
5022 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
5023 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08005024 "%s: client " MAC_ADDRESS_STR
5025 " is in the middle of WPS/EAPOL exchange.", __func__,
5026 MAC_ADDR_ARRAY(staMac));
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005027 return VOS_FALSE;
5028 }
5029 }
5030 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
5031 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
5032 {
5033 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
5034 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305035 if ((pAdapter->aStaInfo[staId].isUsed) &&
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005036 (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState))
5037 {
5038 staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
5039
5040 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08005041 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
5042 "middle of WPS/EAPOL exchange.", __func__,
5043 MAC_ADDR_ARRAY(staMac));
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005044 return VOS_FALSE;
5045 }
5046 }
5047 }
5048 }
5049 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
5050 pAdapterNode = pNext;
5051 }
5052 hddLog(VOS_TRACE_LEVEL_INFO,
5053 "%s: Scan allowed", __func__);
5054 return VOS_TRUE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305055}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005056
5057/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005058 * FUNCTION: wlan_hdd_cfg80211_scan
5059 * this scan respond to scan trigger and update cfg80211 scan database
5060 * later, scan dump command can be used to recieve scan results
5061 */
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08005062int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
5063#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
5064 struct net_device *dev,
5065#endif
5066 struct cfg80211_scan_request *request)
5067{
5068#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
5069 struct net_device *dev = request->wdev->netdev;
5070#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305071 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07005072 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5073 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305074 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005075 tCsrScanRequest scanRequest;
5076 tANI_U8 *channelList = NULL, i;
5077 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305078 int status;
5079 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005080 v_U8_t* pP2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005081
5082 ENTER();
5083
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305084 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
5085 TRACE_CODE_HDD_CFG80211_SCAN,
5086 pAdapter->sessionId, request->n_channels));
5087
Arif Hussain6d2a3322013-11-17 19:50:10 -08005088 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005089 __func__,pAdapter->device_mode);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005090
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305091 status = wlan_hdd_validate_context(pHddCtx);
5092
5093 if (0 != status)
5094 {
5095 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5096 "%s: HDD context is not valid", __func__);
5097 return status;
5098 }
5099
5100 cfg_param = pHddCtx->cfg_ini;
5101 pScanInfo = &pHddCtx->scan_info;
5102
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005103 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005104 (eConnectionState_Connecting ==
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005105 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005106 {
5107 hddLog(VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005108 "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \
5109 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005110 return -EBUSY;
5111 }
5112
Jeff Johnson295189b2012-06-20 16:38:30 -07005113#ifdef WLAN_BTAMP_FEATURE
5114 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005115 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -07005116 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005117 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005118 "%s: No scanning when AMP is on", __func__);
5119 return -EOPNOTSUPP;
5120 }
5121#endif
5122 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005123 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07005124 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005125 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005126 "%s: Not scanning on device_mode = %d",
5127 __func__, pAdapter->device_mode);
5128 return -EOPNOTSUPP;
5129 }
5130
5131 if (TRUE == pScanInfo->mScanPending)
5132 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05305133 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
5134 {
5135 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
5136 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005137 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005138 }
5139
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305140 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -07005141 //Channel and action frame is pending
5142 //Otherwise Cancel Remain On Channel and allow Scan
5143 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005144 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -07005145 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05305146 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -07005147 return -EBUSY;
5148 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005149#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07005150 /* if tdls disagree scan right now, return immediately.
5151 tdls will schedule the scan when scan is allowed. (return SUCCESS)
5152 or will reject the scan if any TDLS is in progress. (return -EBUSY)
5153 */
5154 status = wlan_hdd_tdls_scan_callback (pAdapter,
5155 wiphy,
5156#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
5157 dev,
Gopichand Nakkalac3c42b92013-03-20 19:42:34 -07005158#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07005159 request);
5160 if(status <= 0)
5161 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05305162 if(!status)
5163 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
5164 "scan rejected %d", __func__, status);
5165 else
5166 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
5167 __func__, status);
5168
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07005169 return status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005170 }
5171#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07005172
Jeff Johnson295189b2012-06-20 16:38:30 -07005173 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
5174 {
5175 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -08005176 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005177 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305178 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005179 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
5180 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05305181 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005182 "%s: MAX TM Level Scan not allowed", __func__);
5183 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305184 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005185 }
5186 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
5187
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005188 /* Check if scan is allowed at this point of time.
5189 */
5190 if (!hdd_isScanAllowed(pHddCtx))
5191 {
5192 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
5193 return -EBUSY;
5194 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305195
Jeff Johnson295189b2012-06-20 16:38:30 -07005196 vos_mem_zero( &scanRequest, sizeof(scanRequest));
5197
5198 if (NULL != request)
5199 {
5200 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305201 (int)request->n_ssids);
Jeff Johnson295189b2012-06-20 16:38:30 -07005202
5203 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
5204 * Becasue of this, driver is assuming that this is not wildcard scan and so
5205 * is not aging out the scan results.
5206 */
Jeff Johnson32d95a32012-09-10 13:15:23 -07005207 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07005208 {
5209 request->n_ssids = 0;
5210 }
5211
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07005212 if ((request->ssids) && (0 < request->n_ssids))
Jeff Johnson295189b2012-06-20 16:38:30 -07005213 {
5214 tCsrSSIDInfo *SsidInfo;
5215 int j;
5216 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
5217 /* Allocate num_ssid tCsrSSIDInfo structure */
5218 SsidInfo = scanRequest.SSIDs.SSIDList =
5219 ( tCsrSSIDInfo *)vos_mem_malloc(
5220 request->n_ssids*sizeof(tCsrSSIDInfo));
5221
5222 if(NULL == scanRequest.SSIDs.SSIDList)
5223 {
5224 hddLog(VOS_TRACE_LEVEL_ERROR,
Nirav Shah20ac06f2013-12-12 18:14:06 +05305225 "%s: memory alloc failed SSIDInfo buffer", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005226 return -ENOMEM;
5227 }
5228
5229 /* copy all the ssid's and their length */
5230 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
5231 {
5232 /* get the ssid length */
5233 SsidInfo->SSID.length = request->ssids[j].ssid_len;
5234 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
5235 SsidInfo->SSID.length);
5236 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
Nirav Shah20ac06f2013-12-12 18:14:06 +05305237 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005238 j, SsidInfo->SSID.ssId);
5239 }
5240 /* set the scan type to active */
5241 scanRequest.scanType = eSIR_ACTIVE_SCAN;
5242 }
5243 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
5244 {
5245 /* set the scan type to active */
5246 scanRequest.scanType = eSIR_ACTIVE_SCAN;
5247 }
5248 else
5249 {
5250 /*Set the scan type to default type, in this case it is ACTIVE*/
5251 scanRequest.scanType = pScanInfo->scan_mode;
5252 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305253 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07005254 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
5255 }
5256 else
5257 {
5258 /* set the scan type to active */
5259 scanRequest.scanType = eSIR_ACTIVE_SCAN;
5260 vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff );
5261
5262 /* set min and max channel time to zero */
5263 scanRequest.minChnTime = 0;
5264 scanRequest.maxChnTime = 0;
5265 }
5266
5267 /* set BSSType to default type */
5268 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
5269
5270 /*TODO: scan the requested channels only*/
5271
5272 /*Right now scanning all the channels */
5273 if( request )
5274 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05305275 hddLog(VOS_TRACE_LEVEL_INFO,
5276 "No of Scan Channels: %d", request->n_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07005277 if( request->n_channels )
5278 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05305279 char chList [(request->n_channels*5)+1];
5280 int len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005281 channelList = vos_mem_malloc( request->n_channels );
5282 if( NULL == channelList )
5283 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305284 hddLog(VOS_TRACE_LEVEL_ERROR,
Nirav Shah20ac06f2013-12-12 18:14:06 +05305285 "%s: memory alloc failed channelList", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005286 status = -ENOMEM;
5287 goto free_mem;
5288 }
5289
Nirav Shah20ac06f2013-12-12 18:14:06 +05305290 for( i = 0, len = 0; i < request->n_channels ; i++ )
5291 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005292 channelList[i] = request->channels[i]->hw_value;
Nirav Shah20ac06f2013-12-12 18:14:06 +05305293 len += snprintf(chList+len, 5, "%d ", channelList[i]);
5294 }
5295
5296 hddLog(VOS_TRACE_LEVEL_INFO,
5297 "Channel-List: %s ", chList);
Jeff Johnson295189b2012-06-20 16:38:30 -07005298 }
5299
5300 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
5301 scanRequest.ChannelInfo.ChannelList = channelList;
5302
5303 /* set requestType to full scan */
5304 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305305
5306 /* Flush the scan results(only p2p beacons) for STA scan and P2P
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08005307 * search (Flush on both full scan and social scan but not on single
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305308 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08005309 */
5310
5311 /* Supplicant does single channel scan after 8-way handshake
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305312 * and in that case driver shoudnt flush scan results. If
5313 * driver flushes the scan results here and unfortunately if
5314 * the AP doesnt respond to our probe req then association
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08005315 * fails which is not desired
5316 */
5317
5318 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
5319 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05305320 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08005321 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
5322 pAdapter->sessionId );
5323 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005324
5325 if( request->ie_len )
5326 {
5327 /* save this for future association (join requires this) */
Agarwal Ashish4f616132013-12-30 23:32:50 +05305328 /*TODO: Array needs to be converted to dynamic allocation,
5329 * as multiple ie.s can be sent in cfg80211_scan_request structure
5330 * CR 597966
5331 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005332 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
5333 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
5334 pScanInfo->scanAddIE.length = request->ie_len;
5335
Agarwal Ashish4f616132013-12-30 23:32:50 +05305336 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07005337 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
Agarwal Ashish4f616132013-12-30 23:32:50 +05305338 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07005339 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05305340 if ( request->ie_len <= SIR_MAC_MAX_IE_LENGTH)
5341 {
5342 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
5343 memcpy( pwextBuf->roamProfile.addIEScan,
5344 request->ie, request->ie_len);
5345 }
5346 else
5347 {
5348 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
5349 "%d", request->ie_len);
5350 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005351
Agarwal Ashish4f616132013-12-30 23:32:50 +05305352 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005353 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
5354 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
5355
Jeff Johnson295189b2012-06-20 16:38:30 -07005356 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
5357 request->ie_len);
5358 if (pP2pIe != NULL)
5359 {
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07005360#ifdef WLAN_FEATURE_P2P_DEBUG
5361 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
5362 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
5363 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5364 {
5365 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
5366 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
5367 "Go nego completed to Connection is started");
5368 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
5369 "for 8way Handshake");
5370 }
5371 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
5372 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5373 {
5374 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
5375 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
5376 "Disconnected state to Connection is started");
5377 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
5378 "for 4way Handshake");
5379 }
5380#endif
5381
Jeff Johnsone7245742012-09-05 17:12:55 -07005382 /* no_cck will be set during p2p find to disable 11b rates */
5383 if(TRUE == request->no_cck)
Jeff Johnson295189b2012-06-20 16:38:30 -07005384 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005385 hddLog(VOS_TRACE_LEVEL_INFO,
5386 "%s: This is a P2P Search", __func__);
5387 scanRequest.p2pSearch = 1;
Jeff Johnsone7245742012-09-05 17:12:55 -07005388
Jeff Johnsone7245742012-09-05 17:12:55 -07005389 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
5390 {
Madan Mohan Koyyalamudi1b1d9e82012-10-21 11:38:33 -07005391 /* set requestType to P2P Discovery */
5392 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
Jeff Johnsone7245742012-09-05 17:12:55 -07005393 }
5394
5395 /*
5396 Skip Dfs Channel in case of P2P Search
5397 if it is set in ini file
5398 */
5399 if(cfg_param->skipDfsChnlInP2pSearch)
5400 {
5401 scanRequest.skipDfsChnlInP2pSearch = 1;
5402 }
5403 else
5404 {
5405 scanRequest.skipDfsChnlInP2pSearch = 0;
5406 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005407
Jeff Johnson295189b2012-06-20 16:38:30 -07005408 }
5409 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005410 }
5411 }
5412
5413 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
5414
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07005415 /* acquire the wakelock to avoid the apps suspend during the scan. To
5416 * address the following issues.
5417 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
5418 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
5419 * for long time, this result in apps running at full power for long time.
5420 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
5421 * be stuck in full power because of resume BMPS
5422 */
5423 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07005424
Nirav Shah20ac06f2013-12-12 18:14:06 +05305425 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5426 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
5427 "p2pSearch %d, skipDfsChnlInP2pSearch %d", scanRequest.requestType,
5428 scanRequest.scanType, scanRequest.minChnTime, scanRequest.maxChnTime,
5429 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
5430
Jeff Johnsone7245742012-09-05 17:12:55 -07005431 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005432 pAdapter->sessionId, &scanRequest, &scanId,
5433 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -07005434
Jeff Johnson295189b2012-06-20 16:38:30 -07005435 if (eHAL_STATUS_SUCCESS != status)
5436 {
5437 hddLog(VOS_TRACE_LEVEL_ERROR,
5438 "%s: sme_ScanRequest returned error %d", __func__, status);
5439 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07005440 if(eHAL_STATUS_RESOURCES == status)
5441 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05305442 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
5443 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07005444 status = -EBUSY;
5445 } else {
5446 status = -EIO;
5447 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07005448 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07005449 goto free_mem;
5450 }
5451
5452 pScanInfo->mScanPending = TRUE;
5453 pAdapter->request = request;
5454 pScanInfo->scanId = scanId;
5455
5456 complete(&pScanInfo->scan_req_completion_event);
5457
5458free_mem:
5459 if( scanRequest.SSIDs.SSIDList )
5460 {
5461 vos_mem_free(scanRequest.SSIDs.SSIDList);
5462 }
5463
5464 if( channelList )
5465 vos_mem_free( channelList );
5466
5467 EXIT();
5468
5469 return status;
5470}
5471
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005472
5473void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
5474{
5475 v_U8_t iniDot11Mode =
5476 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
5477 eHddDot11Mode hddDot11Mode = iniDot11Mode;
5478
5479 switch ( iniDot11Mode )
5480 {
5481 case eHDD_DOT11_MODE_AUTO:
5482 case eHDD_DOT11_MODE_11ac:
5483 case eHDD_DOT11_MODE_11ac_ONLY:
5484#ifdef WLAN_FEATURE_11AC
5485 hddDot11Mode = eHDD_DOT11_MODE_11ac;
5486#else
5487 hddDot11Mode = eHDD_DOT11_MODE_11n;
5488#endif
5489 break;
5490 case eHDD_DOT11_MODE_11n:
5491 case eHDD_DOT11_MODE_11n_ONLY:
5492 hddDot11Mode = eHDD_DOT11_MODE_11n;
5493 break;
5494 default:
5495 hddDot11Mode = iniDot11Mode;
5496 break;
5497 }
5498 /* This call decides required channel bonding mode */
5499 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
5500 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
5501 operationChannel);
5502}
5503
Jeff Johnson295189b2012-06-20 16:38:30 -07005504/*
5505 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305506 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -07005507 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305508int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -07005509 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07005510{
5511 int status = 0;
5512 hdd_wext_state_t *pWextState;
5513 v_U32_t roamId;
5514 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005515 eCsrAuthType RSNAuthType;
5516
5517 ENTER();
5518
5519 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305520
Jeff Johnson295189b2012-06-20 16:38:30 -07005521 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
5522 {
5523 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
5524 return -EINVAL;
5525 }
5526
5527 pRoamProfile = &pWextState->roamProfile;
5528
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305529 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07005530 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005531 hdd_station_ctx_t *pHddStaCtx;
5532 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005533
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305534 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07005535 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
5536 {
5537 /*QoS not enabled in cfg file*/
5538 pRoamProfile->uapsd_mask = 0;
5539 }
5540 else
5541 {
5542 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305543 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -07005544 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
5545 }
5546
5547 pRoamProfile->SSIDs.numOfSSIDs = 1;
5548 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
5549 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305550 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005551 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
5552 ssid, ssid_len);
5553
5554 if (bssid)
5555 {
5556 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
5557 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
5558 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305559 /* Save BSSID in seperate variable as well, as RoamProfile
5560 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -07005561 case of join failure we should send valid BSSID to supplicant
5562 */
5563 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
5564 WNI_CFG_BSSID_LEN);
5565 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07005566 else
5567 {
5568 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
5569 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005570
5571 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
5572 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305573 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005574 /*set gen ie*/
5575 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
5576 /*set auth*/
5577 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5578 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005579#ifdef FEATURE_WLAN_WAPI
5580 if (pAdapter->wapi_info.nWapiMode)
5581 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005582 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005583 switch (pAdapter->wapi_info.wapiAuthMode)
5584 {
5585 case WAPI_AUTH_MODE_PSK:
5586 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005587 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005588 pAdapter->wapi_info.wapiAuthMode);
5589 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5590 break;
5591 }
5592 case WAPI_AUTH_MODE_CERT:
5593 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005594 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005595 pAdapter->wapi_info.wapiAuthMode);
5596 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5597 break;
5598 }
5599 } // End of switch
5600 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5601 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
5602 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005603 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005604 pRoamProfile->AuthType.numEntries = 1;
5605 pRoamProfile->EncryptionType.numEntries = 1;
5606 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5607 pRoamProfile->mcEncryptionType.numEntries = 1;
5608 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5609 }
5610 }
5611#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305612#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305613 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305614 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
5615 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5616 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305617 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
5618 sizeof (tSirGtkOffloadParams));
5619 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305620 }
5621#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005622 pRoamProfile->csrPersona = pAdapter->device_mode;
5623
Jeff Johnson32d95a32012-09-10 13:15:23 -07005624 if( operatingChannel )
5625 {
5626 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
5627 pRoamProfile->ChannelInfo.numOfChannels = 1;
5628 }
Chet Lanctot186b5732013-03-18 10:26:30 -07005629 else
5630 {
5631 pRoamProfile->ChannelInfo.ChannelList = NULL;
5632 pRoamProfile->ChannelInfo.numOfChannels = 0;
5633 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005634 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
5635 {
5636 hdd_select_cbmode(pAdapter,operatingChannel);
5637 }
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005638 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
5639 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305640 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005641 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005642 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
5643 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305644 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5645 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005646 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5647 eConnectionState_Connecting);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305648
5649 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005650 pAdapter->sessionId, pRoamProfile, &roamId);
5651
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305652 if ((eHAL_STATUS_SUCCESS != status) &&
5653 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5654 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305655
5656 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005657 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
5658 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
5659 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305660 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005661 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305662 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005663
5664 pRoamProfile->ChannelInfo.ChannelList = NULL;
5665 pRoamProfile->ChannelInfo.numOfChannels = 0;
5666
Jeff Johnson295189b2012-06-20 16:38:30 -07005667 }
5668 else
5669 {
5670 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
5671 return -EINVAL;
5672 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005673 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005674 return status;
5675}
5676
5677/*
5678 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
5679 * This function is used to set the authentication type (OPEN/SHARED).
5680 *
5681 */
5682static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
5683 enum nl80211_auth_type auth_type)
5684{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305685 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005686 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5687
5688 ENTER();
5689
5690 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305691 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -07005692 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005693 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305694 hddLog(VOS_TRACE_LEVEL_INFO,
5695 "%s: set authentication type to AUTOSWITCH", __func__);
5696 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
5697 break;
5698
5699 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07005700#ifdef WLAN_FEATURE_VOWIFI_11R
5701 case NL80211_AUTHTYPE_FT:
5702#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305703 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005704 "%s: set authentication type to OPEN", __func__);
5705 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5706 break;
5707
5708 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305709 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005710 "%s: set authentication type to SHARED", __func__);
5711 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
5712 break;
5713#ifdef FEATURE_WLAN_CCX
5714 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305715 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005716 "%s: set authentication type to CCKM WPA", __func__);
5717 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
5718 break;
5719#endif
5720
5721
5722 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305723 hddLog(VOS_TRACE_LEVEL_ERROR,
5724 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005725 auth_type);
5726 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
5727 return -EINVAL;
5728 }
5729
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305730 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005731 pHddStaCtx->conn_info.authType;
5732 return 0;
5733}
5734
5735/*
5736 * FUNCTION: wlan_hdd_set_akm_suite
5737 * This function is used to set the key mgmt type(PSK/8021x).
5738 *
5739 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305740static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005741 u32 key_mgmt
5742 )
5743{
5744 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5745 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305746
Jeff Johnson295189b2012-06-20 16:38:30 -07005747 /*set key mgmt type*/
5748 switch(key_mgmt)
5749 {
5750 case WLAN_AKM_SUITE_PSK:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305751#ifdef WLAN_FEATURE_VOWIFI_11R
5752 case WLAN_AKM_SUITE_FT_PSK:
5753#endif
5754 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -07005755 __func__);
5756 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5757 break;
5758
5759 case WLAN_AKM_SUITE_8021X:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305760#ifdef WLAN_FEATURE_VOWIFI_11R
5761 case WLAN_AKM_SUITE_FT_8021X:
5762#endif
5763 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -07005764 __func__);
5765 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5766 break;
5767#ifdef FEATURE_WLAN_CCX
5768#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
5769#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5770 case WLAN_AKM_SUITE_CCKM:
5771 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
5772 __func__);
5773 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
5774 break;
5775#endif
5776
5777 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305778 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005779 __func__, key_mgmt);
5780 return -EINVAL;
5781
5782 }
5783 return 0;
5784}
5785
5786/*
5787 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305788 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -07005789 * (NONE/WEP40/WEP104/TKIP/CCMP).
5790 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305791static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
5792 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -07005793 bool ucast
5794 )
5795{
5796 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305797 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005798 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5799
5800 ENTER();
5801
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305802 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005803 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305804 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -07005805 __func__, cipher);
5806 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5807 }
5808 else
5809 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305810
Jeff Johnson295189b2012-06-20 16:38:30 -07005811 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305812 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005813 {
5814 case IW_AUTH_CIPHER_NONE:
5815 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5816 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305817
Jeff Johnson295189b2012-06-20 16:38:30 -07005818 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305819 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07005820 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305821
Jeff Johnson295189b2012-06-20 16:38:30 -07005822 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305823 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -07005824 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305825
Jeff Johnson295189b2012-06-20 16:38:30 -07005826 case WLAN_CIPHER_SUITE_TKIP:
5827 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5828 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305829
Jeff Johnson295189b2012-06-20 16:38:30 -07005830 case WLAN_CIPHER_SUITE_CCMP:
5831 encryptionType = eCSR_ENCRYPT_TYPE_AES;
5832 break;
5833#ifdef FEATURE_WLAN_WAPI
5834 case WLAN_CIPHER_SUITE_SMS4:
5835 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
5836 break;
5837#endif
5838
5839#ifdef FEATURE_WLAN_CCX
5840 case WLAN_CIPHER_SUITE_KRK:
5841 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
5842 break;
5843#endif
5844 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305845 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005846 __func__, cipher);
5847 return -EOPNOTSUPP;
5848 }
5849 }
5850
5851 if (ucast)
5852 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305853 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005854 __func__, encryptionType);
5855 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
5856 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305857 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005858 encryptionType;
5859 }
5860 else
5861 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305862 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005863 __func__, encryptionType);
5864 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
5865 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5866 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
5867 }
5868
5869 return 0;
5870}
5871
5872
5873/*
5874 * FUNCTION: wlan_hdd_cfg80211_set_ie
5875 * This function is used to parse WPA/RSN IE's.
5876 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305877int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
5878 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -07005879 size_t ie_len
5880 )
5881{
5882 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5883 u8 *genie = ie;
5884 v_U16_t remLen = ie_len;
5885#ifdef FEATURE_WLAN_WAPI
5886 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
5887 u16 *tmp;
5888 v_U16_t akmsuiteCount;
5889 int *akmlist;
5890#endif
5891 ENTER();
5892
5893 /* clear previous assocAddIE */
5894 pWextState->assocAddIE.length = 0;
5895 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
5896
5897 while (remLen >= 2)
5898 {
5899 v_U16_t eLen = 0;
5900 v_U8_t elementId;
5901 elementId = *genie++;
5902 eLen = *genie++;
5903 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305904
Arif Hussain6d2a3322013-11-17 19:50:10 -08005905 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07005906 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305907
5908 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -07005909 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305910 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005911 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 -07005912 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305913 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005914 "%s: Invalid WPA IE", __func__);
5915 return -EINVAL;
5916 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305917 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -07005918 {
5919 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305920 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005921 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305922
Jeff Johnson295189b2012-06-20 16:38:30 -07005923 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5924 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005925 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
5926 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005927 VOS_ASSERT(0);
5928 return -ENOMEM;
5929 }
5930 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5931 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5932 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305933
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
5935 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5936 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5937 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305938 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
5939 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005940 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
5941 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5942 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
5943 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
5944 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
5945 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305946 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +05305947 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -07005948 {
5949 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305950 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005951 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305952
Jeff Johnson295189b2012-06-20 16:38:30 -07005953 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5954 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005955 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5956 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005957 VOS_ASSERT(0);
5958 return -ENOMEM;
5959 }
5960 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5961 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5962 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305963
Jeff Johnson295189b2012-06-20 16:38:30 -07005964 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5965 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5966 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005967#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305968 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
5969 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005970 /*Consider WFD IE, only for P2P Client */
5971 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5972 {
5973 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305974 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005975 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305976
Jeff Johnson295189b2012-06-20 16:38:30 -07005977 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5978 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005979 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5980 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005981 VOS_ASSERT(0);
5982 return -ENOMEM;
5983 }
5984 // WFD IE is saved to Additional IE ; it should be accumulated to handle
5985 // WPS IE + P2P IE + WFD IE
5986 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5987 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305988
Jeff Johnson295189b2012-06-20 16:38:30 -07005989 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5990 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5991 }
5992#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005993 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305994 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005995 HS20_OUI_TYPE_SIZE)) )
5996 {
5997 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305998 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005999 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006000
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006001 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
6002 {
Jeff Johnson902c9832012-12-10 14:28:09 -08006003 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
6004 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006005 VOS_ASSERT(0);
6006 return -ENOMEM;
6007 }
6008 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
6009 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006010
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006011 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
6012 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
6013 }
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006014
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -07006015 if (WLAN_HDD_IBSS == pAdapter->device_mode) {
6016
6017 /* populating as ADDIE in beacon frames */
6018 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
6019 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
6020 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
6021 {
6022 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
6023 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
6024 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6025 {
6026 hddLog(LOGE,
6027 "Coldn't pass "
6028 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
6029 }
6030 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
6031 else
6032 hddLog(LOGE,
6033 "Could not pass on "
6034 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
6035
6036 /* IBSS mode doesn't contain params->proberesp_ies still
6037 beaconIE's need to be populated in probe response frames */
6038 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
6039 {
6040 u16 rem_probe_resp_ie_len = eLen + 2;
6041 u8 probe_rsp_ie_len[3] = {0};
6042 u8 counter = 0;
6043
6044 /* Check Probe Resp Length if it is greater then 255 then
6045 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
6046 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
6047 not able Store More then 255 bytes into One Variable */
6048
6049 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
6050 {
6051 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
6052 {
6053 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
6054 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
6055 }
6056 else
6057 {
6058 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
6059 rem_probe_resp_ie_len = 0;
6060 }
6061 }
6062
6063 rem_probe_resp_ie_len = 0;
6064
6065 if (probe_rsp_ie_len[0] > 0)
6066 {
6067 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
6068 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
6069 (tANI_U8*)(genie - 2),
6070 probe_rsp_ie_len[0], NULL,
6071 eANI_BOOLEAN_FALSE)
6072 == eHAL_STATUS_FAILURE)
6073 {
6074 hddLog(LOGE,
6075 "Could not pass"
6076 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
6077 }
6078 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
6079 }
6080
6081 if (probe_rsp_ie_len[1] > 0)
6082 {
6083 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
6084 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
6085 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
6086 probe_rsp_ie_len[1], NULL,
6087 eANI_BOOLEAN_FALSE)
6088 == eHAL_STATUS_FAILURE)
6089 {
6090 hddLog(LOGE,
6091 "Could not pass"
6092 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
6093 }
6094 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
6095 }
6096
6097 if (probe_rsp_ie_len[2] > 0)
6098 {
6099 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
6100 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
6101 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
6102 probe_rsp_ie_len[2], NULL,
6103 eANI_BOOLEAN_FALSE)
6104 == eHAL_STATUS_FAILURE)
6105 {
6106 hddLog(LOGE,
6107 "Could not pass"
6108 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
6109 }
6110 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
6111 }
6112
6113 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
6114 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
6115 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6116 {
6117 hddLog(LOGE,
6118 "Could not pass"
6119 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
6120 }
6121 }
6122 else
6123 {
6124 // Reset WNI_CFG_PROBE_RSP Flags
6125 wlan_hdd_reset_prob_rspies(pAdapter);
6126
6127 hddLog(VOS_TRACE_LEVEL_INFO,
6128 "%s: No Probe Response IE received in set beacon",
6129 __func__);
6130 }
6131 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -07006132 break;
6133 case DOT11F_EID_RSN:
6134 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
6135 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
6136 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
6137 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
6138 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
6139 break;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006140 /* Appending Extended Capabilities with Interworking bit set in Assoc Req */
6141 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306142 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006143 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306144 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006145 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306146
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006147 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
6148 {
Jeff Johnson902c9832012-12-10 14:28:09 -08006149 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
6150 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006151 VOS_ASSERT(0);
6152 return -ENOMEM;
6153 }
6154 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
6155 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306156
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006157 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
6158 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
6159 break;
6160 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006161#ifdef FEATURE_WLAN_WAPI
6162 case WLAN_EID_WAPI:
6163 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006164 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07006165 pAdapter->wapi_info.nWapiMode);
6166 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306167 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -07006168 akmsuiteCount = WPA_GET_LE16(tmp);
6169 tmp = tmp + 1;
6170 akmlist = (int *)(tmp);
6171 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
6172 {
6173 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
6174 }
6175 else
6176 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006177 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -07006178 VOS_ASSERT(0);
6179 return -EINVAL;
6180 }
6181
6182 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
6183 {
6184 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006185 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006186 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306187 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006188 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306189 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006190 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006191 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006192 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
6193 }
6194 break;
6195#endif
6196 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306197 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006198 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006199 /* when Unknown IE is received we should break and continue
6200 * to the next IE in the buffer instead we were returning
6201 * so changing this to break */
6202 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006203 }
6204 genie += eLen;
6205 remLen -= eLen;
6206 }
6207 EXIT();
6208 return 0;
6209}
6210
6211/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +05306212 * FUNCTION: hdd_isWPAIEPresent
6213 * Parse the received IE to find the WPA IE
6214 *
6215 */
6216static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
6217{
6218 v_U8_t eLen = 0;
6219 v_U16_t remLen = ie_len;
6220 v_U8_t elementId = 0;
6221
6222 while (remLen >= 2)
6223 {
6224 elementId = *ie++;
6225 eLen = *ie++;
6226 remLen -= 2;
6227 if (eLen > remLen)
6228 {
6229 hddLog(VOS_TRACE_LEVEL_ERROR,
6230 "%s: IE length is wrong %d", __func__, eLen);
6231 return FALSE;
6232 }
6233 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
6234 {
6235 /* OUI - 0x00 0X50 0XF2
6236 WPA Information Element - 0x01
6237 WPA version - 0x01*/
6238 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
6239 return TRUE;
6240 }
6241 ie += eLen;
6242 remLen -= eLen;
6243 }
6244 return FALSE;
6245}
6246
6247/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006248 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306249 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006250 * parameters during connect operation.
6251 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306252int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006253 struct cfg80211_connect_params *req
6254 )
6255{
6256 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306257 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006258 ENTER();
6259
6260 /*set wpa version*/
6261 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
6262
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306263 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07006264 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +05306265 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 {
6267 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
6268 }
6269 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
6270 {
6271 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
6272 }
6273 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306274
6275 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006276 pWextState->wpaVersion);
6277
6278 /*set authentication type*/
6279 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
6280
6281 if (0 > status)
6282 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306283 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006284 "%s: failed to set authentication type ", __func__);
6285 return status;
6286 }
6287
6288 /*set key mgmt type*/
6289 if (req->crypto.n_akm_suites)
6290 {
6291 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
6292 if (0 > status)
6293 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306294 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 __func__);
6296 return status;
6297 }
6298 }
6299
6300 /*set pairwise cipher type*/
6301 if (req->crypto.n_ciphers_pairwise)
6302 {
6303 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
6304 req->crypto.ciphers_pairwise[0], true);
6305 if (0 > status)
6306 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306307 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006308 "%s: failed to set unicast cipher type", __func__);
6309 return status;
6310 }
6311 }
6312 else
6313 {
6314 /*Reset previous cipher suite to none*/
6315 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
6316 if (0 > status)
6317 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306318 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006319 "%s: failed to set unicast cipher type", __func__);
6320 return status;
6321 }
6322 }
6323
6324 /*set group cipher type*/
6325 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
6326 false);
6327
6328 if (0 > status)
6329 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306330 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -07006331 __func__);
6332 return status;
6333 }
6334
Chet Lanctot186b5732013-03-18 10:26:30 -07006335#ifdef WLAN_FEATURE_11W
6336 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
6337#endif
6338
Jeff Johnson295189b2012-06-20 16:38:30 -07006339 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
6340 if (req->ie_len)
6341 {
6342 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
6343 if ( 0 > status)
6344 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306345 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006346 __func__);
6347 return status;
6348 }
6349 }
6350
6351 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306352 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006353 {
6354 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
6355 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
6356 )
6357 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306358 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -07006359 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
6360 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306361 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07006362 __func__);
6363 return -EOPNOTSUPP;
6364 }
6365 else
6366 {
6367 u8 key_len = req->key_len;
6368 u8 key_idx = req->key_idx;
6369
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306370 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006371 && (CSR_MAX_NUM_KEY > key_idx)
6372 )
6373 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306374 hddLog(VOS_TRACE_LEVEL_INFO,
6375 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006376 __func__, key_idx, key_len);
6377 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306378 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07006379 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306380 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -07006381 (u8)key_len;
6382 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
6383 }
6384 }
6385 }
6386 }
6387
6388 return status;
6389}
6390
6391/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +05306392 * FUNCTION: wlan_hdd_try_disconnect
6393 * This function is used to disconnect from previous
6394 * connection
6395 */
6396static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
6397{
6398 long ret = 0;
6399 hdd_station_ctx_t *pHddStaCtx;
6400 eMib_dot11DesiredBssType connectedBssType;
6401
6402 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6403
6404 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
6405
6406 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
6407 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
6408 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
6409 {
6410 /* Issue disconnect to CSR */
6411 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6412 if( eHAL_STATUS_SUCCESS ==
6413 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
6414 pAdapter->sessionId,
6415 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
6416 {
6417 ret = wait_for_completion_interruptible_timeout(
6418 &pAdapter->disconnect_comp_var,
6419 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6420 if (0 >= ret)
6421 {
6422 hddLog(LOGE, FL("Failed to receive disconnect event"));
6423 return -EALREADY;
6424 }
6425 }
6426 }
6427 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
6428 {
6429 ret = wait_for_completion_interruptible_timeout(
6430 &pAdapter->disconnect_comp_var,
6431 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6432 if (0 >= ret)
6433 {
6434 hddLog(LOGE, FL("Failed to receive disconnect event"));
6435 return -EALREADY;
6436 }
6437 }
6438
6439 return 0;
6440}
6441
6442/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006443 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306444 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006445 * parameters during connect operation.
6446 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306447static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006448 struct net_device *ndev,
6449 struct cfg80211_connect_params *req
6450 )
6451{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306452 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306453 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006454 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -08006455 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006456
6457 ENTER();
6458
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306459 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6460 TRACE_CODE_HDD_CFG80211_CONNECT,
6461 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306462 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006463 "%s: device_mode = %d",__func__,pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006464
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306465 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08006466 if (!pHddCtx)
6467 {
6468 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6469 "%s: HDD context is null", __func__);
6470 return VOS_STATUS_E_FAILURE;
6471 }
6472
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306473 status = wlan_hdd_validate_context(pHddCtx);
6474
6475 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006476 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306477 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6478 "%s: HDD context is not valid", __func__);
6479 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006480 }
6481
6482#ifdef WLAN_BTAMP_FEATURE
6483 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306484 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -07006485 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306486 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006487 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08006488 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -07006489 }
6490#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +05306491
6492 //If Device Mode is Station Concurrent Sessions Exit BMps
6493 //P2P Mode will be taken care in Open/close adapter
6494 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
6495 (vos_concurrent_sessions_running()))
6496 {
6497 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
6498 }
6499
6500 /*Try disconnecting if already in connected state*/
6501 status = wlan_hdd_try_disconnect(pAdapter);
6502 if ( 0 > status)
6503 {
6504 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
6505 " connection"));
6506 return -EALREADY;
6507 }
6508
Jeff Johnson295189b2012-06-20 16:38:30 -07006509 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306510 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -07006511
6512 if ( 0 > status)
6513 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306514 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -07006515 __func__);
6516 return status;
6517 }
6518
Mohit Khanna765234a2012-09-11 15:08:35 -07006519 if ( req->channel )
6520 {
6521 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
6522 req->ssid_len, req->bssid,
6523 req->channel->hw_value);
6524 }
6525 else
6526 {
6527 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306528 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -07006529 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006530
6531 if (0 > status)
6532 {
6533 //ReEnable BMPS if disabled
6534 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
6535 (NULL != pHddCtx))
6536 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306537 if (pHddCtx->hdd_wlan_suspended)
6538 {
6539 hdd_set_pwrparams(pHddCtx);
6540 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006541 //ReEnable Bmps and Imps back
6542 hdd_enable_bmps_imps(pHddCtx);
6543 }
6544
6545 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6546 return status;
6547 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306548 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006549 EXIT();
6550 return status;
6551}
6552
6553
6554/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306555 * FUNCTION: wlan_hdd_disconnect
6556 * This function is used to issue a disconnect request to SME
6557 */
6558int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
6559{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306560 int status;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306561 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306562 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6563
6564 status = wlan_hdd_validate_context(pHddCtx);
6565
6566 if (0 != status)
6567 {
6568 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6569 "%s: HDD context is not valid", __func__);
6570 return status;
6571 }
6572
6573 pHddCtx->isAmpAllowed = VOS_TRUE;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306574 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306575 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306576
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306577 /*issue disconnect*/
6578 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
6579 pAdapter->sessionId, reason);
6580
6581 if ( 0 != status )
6582 {
6583 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006584 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306585 __func__, (int)status );
6586 return -EINVAL;
6587 }
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05306588 status = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306589 &pAdapter->disconnect_comp_var,
6590 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05306591 if (!status)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306592 {
6593 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05306594 "%s: Failed to disconnect, timed out", __func__);
6595 return -ETIMEDOUT;
6596 }
6597 else if (status == -ERESTARTSYS)
6598 {
6599 hddLog(VOS_TRACE_LEVEL_ERROR,
6600 "%s: Failed to disconnect, wait interrupted", __func__);
6601 return status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306602 }
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306603 /*stop tx queues*/
6604 netif_tx_disable(pAdapter->dev);
6605 netif_carrier_off(pAdapter->dev);
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05306606 return 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306607}
6608
6609
6610/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 * FUNCTION: wlan_hdd_cfg80211_disconnect
6612 * This function is used to issue a disconnect request to SME
6613 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306614static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006615 struct net_device *dev,
6616 u16 reason
6617 )
6618{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306619 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6620 tCsrRoamProfile *pRoamProfile =
Jeff Johnson295189b2012-06-20 16:38:30 -07006621 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306622 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006623 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006624 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306625#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006626 tANI_U8 staIdx;
6627#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306628
Jeff Johnson295189b2012-06-20 16:38:30 -07006629 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306630
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306631 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6632 TRACE_CODE_HDD_CFG80211_DISCONNECT,
6633 pAdapter->sessionId, reason));
6634 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006635 __func__,pAdapter->device_mode);
6636
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306637 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
6638 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006639
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306640 status = wlan_hdd_validate_context(pHddCtx);
6641
6642 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006643 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306644 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6645 "%s: HDD context is not valid", __func__);
6646 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006647 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306648
Jeff Johnson295189b2012-06-20 16:38:30 -07006649 if (NULL != pRoamProfile)
6650 {
6651 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +05306652 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
6653 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -07006654 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306655 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07006656 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306657 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07006658 switch(reason)
6659 {
6660 case WLAN_REASON_MIC_FAILURE:
6661 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
6662 break;
6663
6664 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
6665 case WLAN_REASON_DISASSOC_AP_BUSY:
6666 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
6667 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
6668 break;
6669
6670 case WLAN_REASON_PREV_AUTH_NOT_VALID:
6671 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
6672 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
6673 break;
6674
6675 case WLAN_REASON_DEAUTH_LEAVING:
6676 default:
6677 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
6678 break;
6679 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306680 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
6681 pScanInfo = &pHddCtx->scan_info;
6682 if (pScanInfo->mScanPending)
6683 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306684 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306685 "Aborting Scan");
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306686 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
6687 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306688 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006689
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006690#ifdef FEATURE_WLAN_TDLS
6691 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006692 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006693 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006694 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
6695 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006696 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006697 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006698 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006699 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006700 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006701 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006702 MAC_ADDR_ARRAY(mac));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006703 sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006704 pAdapter->sessionId,
6705 mac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006706 }
6707 }
6708#endif
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306709 status = wlan_hdd_disconnect(pAdapter, reasonCode);
6710 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -07006711 {
6712 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006713 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006714 __func__, (int)status );
6715 return -EINVAL;
6716 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006717 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +05306718 else
6719 {
6720 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
6721 "called while in %d state", __func__,
6722 pHddStaCtx->conn_info.connState);
6723 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006724 }
6725 else
6726 {
6727 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
6728 }
6729
6730 return status;
6731}
6732
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306733
Jeff Johnson295189b2012-06-20 16:38:30 -07006734/*
6735 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306736 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006737 * settings in IBSS mode.
6738 */
6739static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306740 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006741 struct cfg80211_ibss_params *params
6742 )
6743{
6744 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306745 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006746 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6747 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306748
Jeff Johnson295189b2012-06-20 16:38:30 -07006749 ENTER();
6750
6751 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -07006752 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006753
6754 if (params->ie_len && ( NULL != params->ie) )
6755 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006756 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6757 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006758 {
6759 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
6760 encryptionType = eCSR_ENCRYPT_TYPE_AES;
6761 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006762 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006763 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006764 tDot11fIEWPA dot11WPAIE;
6765 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006766 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006767
Wilson Yang00256342013-10-10 23:13:38 -07006768 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006769 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6770 params->ie_len, DOT11F_EID_WPA);
6771 if ( NULL != ie )
6772 {
6773 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
6774 // Unpack the WPA IE
6775 //Skip past the EID byte and length byte - and four byte WiFi OUI
6776 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
6777 &ie[2+4],
6778 ie[1] - 4,
6779 &dot11WPAIE);
6780 /*Extract the multicast cipher, the encType for unicast
6781 cipher for wpa-none is none*/
6782 encryptionType =
6783 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
6784 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006785 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006786
Jeff Johnson295189b2012-06-20 16:38:30 -07006787 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
6788
6789 if (0 > status)
6790 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306791 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006792 __func__);
6793 return status;
6794 }
6795 }
6796
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306797 pWextState->roamProfile.AuthType.authType[0] =
6798 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -07006799 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6800
6801 if (params->privacy)
6802 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306803 /* Security enabled IBSS, At this time there is no information available
6804 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -07006805 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306806 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -07006807 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306808 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -07006809 *enable privacy bit in beacons */
6810
6811 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6812 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006813 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
6814 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07006815 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
6816 pWextState->roamProfile.EncryptionType.numEntries = 1;
6817 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07006818 return status;
6819}
6820
6821/*
6822 * FUNCTION: wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306823 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006824 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306825static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006826 struct net_device *dev,
6827 struct cfg80211_ibss_params *params
6828 )
6829{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306830 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006831 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6832 tCsrRoamProfile *pRoamProfile;
6833 int status;
krunal sonie9002db2013-11-25 14:24:17 -08006834 bool alloc_bssid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006835 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306836 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006837
6838 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306839
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306840 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6841 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
6842 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306843 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006844 "%s: device_mode = %d",__func__,pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006845
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306846 status = wlan_hdd_validate_context(pHddCtx);
6847
6848 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006849 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306850 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6851 "%s: HDD context is not valid", __func__);
6852 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006853 }
6854
6855 if (NULL == pWextState)
6856 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006857 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -07006858 __func__);
6859 return -EIO;
6860 }
6861
Vinay Krishna Eranna21042322014-01-08 19:21:39 +05306862 /*Try disconnecting if already in connected state*/
6863 status = wlan_hdd_try_disconnect(pAdapter);
6864 if ( 0 > status)
6865 {
6866 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
6867 " IBSS connection"));
6868 return -EALREADY;
6869 }
6870
Jeff Johnson295189b2012-06-20 16:38:30 -07006871 pRoamProfile = &pWextState->roamProfile;
6872
6873 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
6874 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306875 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006876 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006877 return -EINVAL;
6878 }
6879
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -07006880 /* BSSID is provided by upper layers hence no need to AUTO generate */
6881 if (NULL != params->bssid) {
6882 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
6883 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
6884 hddLog (VOS_TRACE_LEVEL_ERROR,
6885 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
6886 return -EIO;
6887 }
6888 }
krunal sonie9002db2013-11-25 14:24:17 -08006889 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
6890 {
6891 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
6892 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
6893 {
6894 hddLog (VOS_TRACE_LEVEL_ERROR,
6895 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
6896 return -EIO;
6897 }
6898 params->bssid = vos_mem_malloc(sizeof(VOS_MAC_ADDR_SIZE));
6899 if (!params->bssid)
6900 {
6901 hddLog (VOS_TRACE_LEVEL_ERROR,
6902 "%s:Failed memory allocation", __func__);
6903 return -EIO;
6904 }
6905 vos_mem_copy((v_U8_t *)params->bssid,
6906 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
6907 VOS_MAC_ADDR_SIZE);
6908 alloc_bssid = VOS_TRUE;
6909 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -07006910
Jeff Johnson295189b2012-06-20 16:38:30 -07006911 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -07006912 if (NULL !=
6913#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6914 params->chandef.chan)
6915#else
6916 params->channel)
6917#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006918 {
6919 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006920 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6921 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6922 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6923 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006924
6925 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306926 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -07006927 ieee80211_frequency_to_channel(
6928#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6929 params->chandef.chan->center_freq);
6930#else
6931 params->channel->center_freq);
6932#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006933
6934 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6935 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -07006936 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006937 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
6938 __func__);
6939 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -07006940 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006941
6942 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006943 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006944 if (channelNum == validChan[indx])
6945 {
6946 break;
6947 }
6948 }
6949 if (indx >= numChans)
6950 {
6951 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006952 __func__, channelNum);
6953 return -EINVAL;
6954 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006955 /* Set the Operational Channel */
6956 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
6957 channelNum);
6958 pRoamProfile->ChannelInfo.numOfChannels = 1;
6959 pHddStaCtx->conn_info.operationChannel = channelNum;
6960 pRoamProfile->ChannelInfo.ChannelList =
6961 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006962 }
6963
6964 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306965 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -07006966 if (status < 0)
6967 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306968 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -07006969 __func__);
6970 return status;
6971 }
6972
6973 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306974 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006975 params->ssid_len, params->bssid,
6976 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006977
6978 if (0 > status)
6979 {
6980 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6981 return status;
6982 }
6983
krunal sonie9002db2013-11-25 14:24:17 -08006984 if (NULL != params->bssid &&
6985 pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 &&
6986 alloc_bssid == VOS_TRUE)
6987 {
6988 vos_mem_free(params->bssid);
6989 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006990 return 0;
6991}
6992
6993/*
6994 * FUNCTION: wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306995 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006996 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306997static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006998 struct net_device *dev
6999 )
7000{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307001 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07007002 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7003 tCsrRoamProfile *pRoamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307004 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7005 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007006
7007 ENTER();
7008
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307009 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7010 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
7011 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307012 status = wlan_hdd_validate_context(pHddCtx);
7013
7014 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007015 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307016 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7017 "%s: HDD context is not valid", __func__);
7018 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007019 }
7020
Arif Hussain6d2a3322013-11-17 19:50:10 -08007021 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",__func__,pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007022 if (NULL == pWextState)
7023 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007024 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -07007025 __func__);
7026 return -EIO;
7027 }
7028
7029 pRoamProfile = &pWextState->roamProfile;
7030
7031 /* Issue disconnect only if interface type is set to IBSS */
7032 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
7033 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307034 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -07007035 __func__);
7036 return -EINVAL;
7037 }
7038
7039 /* Issue Disconnect request */
7040 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7041 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
7042 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
7043
7044 return 0;
7045}
7046
7047/*
7048 * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params
7049 * This function is used to set the phy parameters
7050 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
7051 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307052static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007053 u32 changed)
7054{
7055 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7056 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307057 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007058
7059 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307060 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7061 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
7062 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307063 status = wlan_hdd_validate_context(pHddCtx);
7064
7065 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007066 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307067 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7068 "%s: HDD context is not valid", __func__);
7069 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007070 }
7071
Jeff Johnson295189b2012-06-20 16:38:30 -07007072 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
7073 {
7074 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
7075 WNI_CFG_RTS_THRESHOLD_STAMAX :
7076 wiphy->rts_threshold;
7077
7078 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307079 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -07007080 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307081 hddLog(VOS_TRACE_LEVEL_ERROR,
7082 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007083 __func__, rts_threshold);
7084 return -EINVAL;
7085 }
7086
7087 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
7088 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307089 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07007090 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307091 hddLog(VOS_TRACE_LEVEL_ERROR,
7092 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007093 __func__, rts_threshold);
7094 return -EIO;
7095 }
7096
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307097 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007098 rts_threshold);
7099 }
7100
7101 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
7102 {
7103 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
7104 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
7105 wiphy->frag_threshold;
7106
7107 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307108 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007109 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307110 hddLog(VOS_TRACE_LEVEL_ERROR,
7111 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007112 frag_threshold);
7113 return -EINVAL;
7114 }
7115
7116 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
7117 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307118 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07007119 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307120 hddLog(VOS_TRACE_LEVEL_ERROR,
7121 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007122 __func__, frag_threshold);
7123 return -EIO;
7124 }
7125
7126 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
7127 frag_threshold);
7128 }
7129
7130 if ((changed & WIPHY_PARAM_RETRY_SHORT)
7131 || (changed & WIPHY_PARAM_RETRY_LONG))
7132 {
7133 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
7134 wiphy->retry_short :
7135 wiphy->retry_long;
7136
7137 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
7138 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
7139 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307140 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007141 __func__, retry_value);
7142 return -EINVAL;
7143 }
7144
7145 if (changed & WIPHY_PARAM_RETRY_SHORT)
7146 {
7147 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
7148 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307149 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07007150 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307151 hddLog(VOS_TRACE_LEVEL_ERROR,
7152 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007153 __func__, retry_value);
7154 return -EIO;
7155 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307156 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007157 __func__, retry_value);
7158 }
7159 else if (changed & WIPHY_PARAM_RETRY_SHORT)
7160 {
7161 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
7162 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307163 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07007164 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307165 hddLog(VOS_TRACE_LEVEL_ERROR,
7166 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007167 __func__, retry_value);
7168 return -EIO;
7169 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307170 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007171 __func__, retry_value);
7172 }
7173 }
7174
7175 return 0;
7176}
7177
7178/*
7179 * FUNCTION: wlan_hdd_cfg80211_set_txpower
7180 * This function is used to set the txpower
7181 */
7182static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07007183#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
7184 struct wireless_dev *wdev,
7185#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007186#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307187 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07007188#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307189 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07007190#endif
7191 int dbm)
7192{
7193 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307194 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007195 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
7196 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307197 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007198
7199 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307200 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7201 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
7202 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307203 status = wlan_hdd_validate_context(pHddCtx);
7204
7205 if (0 != status)
7206 {
7207 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7208 "%s: HDD context is not valid", __func__);
7209 return status;
7210 }
7211
7212 hHal = pHddCtx->hHal;
7213
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307214 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
7215 dbm, ccmCfgSetCallback,
7216 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07007217 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307218 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007219 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
7220 return -EIO;
7221 }
7222
7223 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
7224 dbm);
7225
7226 switch(type)
7227 {
7228 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
7229 /* Fall through */
7230 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
7231 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
7232 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307233 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
7234 __func__);
7235 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07007236 }
7237 break;
7238 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307239 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07007240 __func__);
7241 return -EOPNOTSUPP;
7242 break;
7243 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307244 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
7245 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -07007246 return -EIO;
7247 }
7248
7249 return 0;
7250}
7251
7252/*
7253 * FUNCTION: wlan_hdd_cfg80211_get_txpower
7254 * This function is used to read the txpower
7255 */
Yue Maf49ba872013-08-19 12:04:25 -07007256static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
7257#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
7258 struct wireless_dev *wdev,
7259#endif
7260 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -07007261{
7262
7263 hdd_adapter_t *pAdapter;
7264 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307265 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007266
Jeff Johnsone7245742012-09-05 17:12:55 -07007267 ENTER();
7268
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307269 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007270
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307271 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007272 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307273 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7274 "%s: HDD context is not valid", __func__);
7275 *dbm = 0;
7276 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007277 }
7278
Jeff Johnson295189b2012-06-20 16:38:30 -07007279 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
7280 if (NULL == pAdapter)
7281 {
7282 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
7283 return -ENOENT;
7284 }
7285
7286 wlan_hdd_get_classAstats(pAdapter);
7287 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
7288
Jeff Johnsone7245742012-09-05 17:12:55 -07007289 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007290 return 0;
7291}
7292
7293static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
7294 u8* mac, struct station_info *sinfo)
7295{
7296 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
7297 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7298 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
7299 tANI_U8 rate_flags;
7300
7301 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
7302 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07007303
7304 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
7305 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
7306 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
7307 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
7308 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
7309 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
7310 tANI_U16 maxRate = 0;
7311 tANI_U16 myRate;
7312 tANI_U16 currentRate = 0;
7313 tANI_U8 maxSpeedMCS = 0;
7314 tANI_U8 maxMCSIdx = 0;
7315 tANI_U8 rateFlag = 1;
7316 tANI_U8 i, j, rssidx;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07007317 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307318 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007319
Leo Chang6f8870f2013-03-26 18:11:36 -07007320#ifdef WLAN_FEATURE_11AC
7321 tANI_U32 vht_mcs_map;
7322 eDataRate11ACMaxMcs vhtMaxMcs;
7323#endif /* WLAN_FEATURE_11AC */
7324
Jeff Johnsone7245742012-09-05 17:12:55 -07007325 ENTER();
7326
Jeff Johnson295189b2012-06-20 16:38:30 -07007327 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
7328 (0 == ssidlen))
7329 {
7330 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
7331 " Invalid ssidlen, %d", __func__, ssidlen);
7332 /*To keep GUI happy*/
7333 return 0;
7334 }
7335
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307336 status = wlan_hdd_validate_context(pHddCtx);
7337
7338 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007339 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307340 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7341 "%s: HDD context is not valid", __func__);
7342 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007343 }
7344
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07007345 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007346 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
7347
Kiet Lam3b17fc82013-09-27 05:24:08 +05307348 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
7349 sinfo->filled |= STATION_INFO_SIGNAL;
7350
Jeff Johnson295189b2012-06-20 16:38:30 -07007351 //convert to the UI units of 100kbps
7352 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
7353
7354#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -07007355 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 -07007356 sinfo->signal,
7357 pCfg->reportMaxLinkSpeed,
7358 myRate,
7359 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007360 (int) pCfg->linkSpeedRssiMid,
7361 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -07007362 (int) rate_flags,
7363 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07007364#endif //LINKSPEED_DEBUG_ENABLED
7365
7366 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
7367 {
7368 // we do not want to necessarily report the current speed
7369 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
7370 {
7371 // report the max possible speed
7372 rssidx = 0;
7373 }
7374 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
7375 {
7376 // report the max possible speed with RSSI scaling
7377 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
7378 {
7379 // report the max possible speed
7380 rssidx = 0;
7381 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007382 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -07007383 {
7384 // report middle speed
7385 rssidx = 1;
7386 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007387 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
7388 {
7389 // report middle speed
7390 rssidx = 2;
7391 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007392 else
7393 {
7394 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007395 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07007396 }
7397 }
7398 else
7399 {
7400 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
7401 hddLog(VOS_TRACE_LEVEL_ERROR,
7402 "%s: Invalid value for reportMaxLinkSpeed: %u",
7403 __func__, pCfg->reportMaxLinkSpeed);
7404 rssidx = 0;
7405 }
7406
7407 maxRate = 0;
7408
7409 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05307410 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
7411 OperationalRates, &ORLeng))
7412 {
7413 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
7414 /*To keep GUI happy*/
7415 return 0;
7416 }
7417
Jeff Johnson295189b2012-06-20 16:38:30 -07007418 for (i = 0; i < ORLeng; i++)
7419 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007420 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07007421 {
7422 /* Validate Rate Set */
7423 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
7424 {
7425 currentRate = supported_data_rate[j].supported_rate[rssidx];
7426 break;
7427 }
7428 }
7429 /* Update MAX rate */
7430 maxRate = (currentRate > maxRate)?currentRate:maxRate;
7431 }
7432
7433 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05307434 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
7435 ExtendedRates, &ERLeng))
7436 {
7437 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
7438 /*To keep GUI happy*/
7439 return 0;
7440 }
7441
Jeff Johnson295189b2012-06-20 16:38:30 -07007442 for (i = 0; i < ERLeng; i++)
7443 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007444 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07007445 {
7446 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
7447 {
7448 currentRate = supported_data_rate[j].supported_rate[rssidx];
7449 break;
7450 }
7451 }
7452 /* Update MAX rate */
7453 maxRate = (currentRate > maxRate)?currentRate:maxRate;
7454 }
Kiet Lamb69f8dc2013-11-15 15:34:27 +05307455 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +05307456 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +05307457 if we have good rssi */
Kaushik, Sushantdc304d82014-01-22 10:58:37 +05307458 if ((0 == rssidx) ||
Kiet Lamb69f8dc2013-11-15 15:34:27 +05307459 (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed))
Jeff Johnson295189b2012-06-20 16:38:30 -07007460 {
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05307461 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
7462 MCSRates, &MCSLeng))
7463 {
7464 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
7465 /*To keep GUI happy*/
7466 return 0;
7467 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007468 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -07007469#ifdef WLAN_FEATURE_11AC
7470 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307471 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -07007472 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007473 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307474 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -07007475 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -07007476 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007477 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007478 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007479 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -07007480 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007481 maxMCSIdx = 7;
7482 }
7483 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
7484 {
7485 maxMCSIdx = 8;
7486 }
7487 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
7488 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307489 //VHT20 is supporting 0~8
7490 if (rate_flags & eHAL_TX_RATE_VHT20)
7491 maxMCSIdx = 8;
7492 else
7493 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -07007494 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307495
7496 if (rate_flags & eHAL_TX_RATE_VHT80)
7497 {
7498 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
7499 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
7500 }
7501 else if (rate_flags & eHAL_TX_RATE_VHT40)
7502 {
7503 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
7504 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
7505 }
7506 else if (rate_flags & eHAL_TX_RATE_VHT20)
7507 {
7508 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
7509 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
7510 }
7511
Leo Chang6f8870f2013-03-26 18:11:36 -07007512 maxSpeedMCS = 1;
7513 if (currentRate > maxRate)
7514 {
7515 maxRate = currentRate;
7516 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307517
Leo Chang6f8870f2013-03-26 18:11:36 -07007518 }
7519 else
7520#endif /* WLAN_FEATURE_11AC */
7521 {
7522 if (rate_flags & eHAL_TX_RATE_HT40)
7523 {
7524 rateFlag |= 1;
7525 }
7526 if (rate_flags & eHAL_TX_RATE_SGI)
7527 {
7528 rateFlag |= 2;
7529 }
7530
7531 for (i = 0; i < MCSLeng; i++)
7532 {
7533 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
7534 for (j = 0; j < temp; j++)
7535 {
7536 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
7537 {
7538 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
7539 break;
7540 }
7541 }
7542 if ((j < temp) && (currentRate > maxRate))
7543 {
7544 maxRate = currentRate;
7545 maxSpeedMCS = 1;
7546 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
7547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007548 }
7549 }
7550 }
7551
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307552 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
7553 {
7554 maxRate = myRate;
7555 maxSpeedMCS = 1;
7556 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
7557 }
7558
Jeff Johnson295189b2012-06-20 16:38:30 -07007559 // make sure we report a value at least as big as our current rate
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007560 if (((maxRate < myRate) && (0 == rssidx)) ||
7561 (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -07007562 {
7563 maxRate = myRate;
7564 if (rate_flags & eHAL_TX_RATE_LEGACY)
7565 {
7566 maxSpeedMCS = 0;
7567 }
7568 else
7569 {
7570 maxSpeedMCS = 1;
7571 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
7572 }
7573 }
7574
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307575 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -07007576 {
7577 sinfo->txrate.legacy = maxRate;
7578#ifdef LINKSPEED_DEBUG_ENABLED
7579 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
7580#endif //LINKSPEED_DEBUG_ENABLED
7581 }
7582 else
7583 {
7584 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -07007585#ifdef WLAN_FEATURE_11AC
7586 sinfo->txrate.nss = 1;
7587 if (rate_flags & eHAL_TX_RATE_VHT80)
7588 {
7589 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307590 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -07007591 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307592 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -07007593 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307594 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7595 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7596 }
7597 else if (rate_flags & eHAL_TX_RATE_VHT20)
7598 {
7599 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7600 }
7601#endif /* WLAN_FEATURE_11AC */
7602 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
7603 {
7604 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7605 if (rate_flags & eHAL_TX_RATE_HT40)
7606 {
7607 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7608 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007609 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007610 if (rate_flags & eHAL_TX_RATE_SGI)
7611 {
7612 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7613 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307614
Jeff Johnson295189b2012-06-20 16:38:30 -07007615#ifdef LINKSPEED_DEBUG_ENABLED
7616 pr_info("Reporting MCS rate %d flags %x\n",
7617 sinfo->txrate.mcs,
7618 sinfo->txrate.flags );
7619#endif //LINKSPEED_DEBUG_ENABLED
7620 }
7621 }
7622 else
7623 {
7624 // report current rate instead of max rate
7625
7626 if (rate_flags & eHAL_TX_RATE_LEGACY)
7627 {
7628 //provide to the UI in units of 100kbps
7629 sinfo->txrate.legacy = myRate;
7630#ifdef LINKSPEED_DEBUG_ENABLED
7631 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
7632#endif //LINKSPEED_DEBUG_ENABLED
7633 }
7634 else
7635 {
7636 //must be MCS
7637 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -07007638#ifdef WLAN_FEATURE_11AC
7639 sinfo->txrate.nss = 1;
7640 if (rate_flags & eHAL_TX_RATE_VHT80)
7641 {
7642 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7643 }
7644 else
7645#endif /* WLAN_FEATURE_11AC */
7646 {
7647 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7648 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007649 if (rate_flags & eHAL_TX_RATE_SGI)
7650 {
7651 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7652 }
7653 if (rate_flags & eHAL_TX_RATE_HT40)
7654 {
7655 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7656 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007657#ifdef WLAN_FEATURE_11AC
7658 else if (rate_flags & eHAL_TX_RATE_VHT80)
7659 {
7660 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
7661 }
7662#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -07007663#ifdef LINKSPEED_DEBUG_ENABLED
7664 pr_info("Reporting actual MCS rate %d flags %x\n",
7665 sinfo->txrate.mcs,
7666 sinfo->txrate.flags );
7667#endif //LINKSPEED_DEBUG_ENABLED
7668 }
7669 }
7670 sinfo->filled |= STATION_INFO_TX_BITRATE;
7671
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07007672 sinfo->tx_packets =
7673 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
7674 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
7675 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
7676 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
7677
7678 sinfo->tx_retries =
7679 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
7680 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
7681 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
7682 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
7683
7684 sinfo->tx_failed =
7685 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
7686 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
7687 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
7688 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
7689
7690 sinfo->filled |=
7691 STATION_INFO_TX_PACKETS |
7692 STATION_INFO_TX_RETRIES |
7693 STATION_INFO_TX_FAILED;
7694
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307695 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7696 TRACE_CODE_HDD_CFG80211_GET_STA,
7697 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07007698 EXIT();
7699 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007700}
7701
7702static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -07007703 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -07007704{
7705 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307706 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007707 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307708 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007709
Jeff Johnsone7245742012-09-05 17:12:55 -07007710 ENTER();
7711
Jeff Johnson295189b2012-06-20 16:38:30 -07007712 if (NULL == pAdapter)
7713 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007714 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007715 return -ENODEV;
7716 }
7717
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307718 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7719 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
7720 pAdapter->sessionId, timeout));
7721
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307722 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307723 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307724
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307725 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307726 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307727 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7728 "%s: HDD context is not valid", __func__);
7729 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307730 }
7731
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307732 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
7733 (TRUE == pHddCtx->hdd_wlan_suspended) &&
7734 (pHddCtx->cfg_ini->fhostArpOffload) &&
7735 (eConnectionState_Associated ==
7736 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
7737 {
Amar Singhald53568e2013-09-26 11:03:45 -07007738
7739 hddLog(VOS_TRACE_LEVEL_INFO,
7740 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307741 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307742 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7743 {
7744 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007745 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307746 __func__, vos_status);
7747 }
7748 }
7749
Jeff Johnson295189b2012-06-20 16:38:30 -07007750 /**The get power cmd from the supplicant gets updated by the nl only
7751 *on successful execution of the function call
7752 *we are oppositely mapped w.r.t mode in the driver
7753 **/
7754 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
7755
Jeff Johnsone7245742012-09-05 17:12:55 -07007756 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007757 if (VOS_STATUS_E_FAILURE == vos_status)
7758 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307759 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7760 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007761 return -EINVAL;
7762 }
7763 return 0;
7764}
7765
7766
7767#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7768static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
7769 struct net_device *netdev,
7770 u8 key_index)
7771{
Jeff Johnsone7245742012-09-05 17:12:55 -07007772 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007773 return 0;
7774}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307775#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -07007776
7777#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7778static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7779 struct net_device *dev,
7780 struct ieee80211_txq_params *params)
7781{
Jeff Johnsone7245742012-09-05 17:12:55 -07007782 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007783 return 0;
7784}
7785#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7786static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7787 struct ieee80211_txq_params *params)
7788{
Jeff Johnsone7245742012-09-05 17:12:55 -07007789 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007790 return 0;
7791}
7792#endif //LINUX_VERSION_CODE
7793
7794static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
7795 struct net_device *dev, u8 *mac)
7796{
7797 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307798 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007799 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307800 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007801 v_U8_t staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007802
Jeff Johnsone7245742012-09-05 17:12:55 -07007803 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307804
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307805 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -07007806 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307807 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007808 return -EINVAL;
7809 }
7810
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307811 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7812 TRACE_CODE_HDD_CFG80211_DEL_STA,
7813 pAdapter->sessionId, pAdapter->device_mode));
7814
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307815 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7816 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007817
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307818 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007819 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307820 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7821 "%s: HDD context is not valid", __func__);
7822 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007823 }
7824
Jeff Johnson295189b2012-06-20 16:38:30 -07007825 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007826 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007827 )
7828 {
7829 if( NULL == mac )
7830 {
7831 v_U16_t i;
7832 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
7833 {
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007834 if ((pAdapter->aStaInfo[i].isUsed) &&
7835 (!pAdapter->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -07007836 {
7837 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
7838 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007839 "%s: Delete STA with MAC::"
7840 MAC_ADDRESS_STR,
7841 __func__, MAC_ADDR_ARRAY(macAddr));
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007842 vos_status = hdd_softap_sta_deauth(pAdapter, macAddr);
7843 if (VOS_IS_STATUS_SUCCESS(vos_status))
7844 pAdapter->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007845 }
7846 }
7847 }
7848 else
7849 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007850
7851 vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId);
7852 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7853 {
7854 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007855 "%s: Skip this DEL STA as this is not used::"
7856 MAC_ADDRESS_STR,
7857 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007858 return -ENOENT;
7859 }
7860
7861 if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE)
7862 {
7863 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007864 "%s: Skip this DEL STA as deauth is in progress::"
7865 MAC_ADDRESS_STR,
7866 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007867 return -ENOENT;
7868 }
7869
7870 pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE;
7871
Jeff Johnson295189b2012-06-20 16:38:30 -07007872 hddLog(VOS_TRACE_LEVEL_INFO,
7873 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -08007874 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007875 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -08007876 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007877
7878 vos_status = hdd_softap_sta_deauth(pAdapter, mac);
7879 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7880 {
7881 pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE;
7882 hddLog(VOS_TRACE_LEVEL_INFO,
7883 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -08007884 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007885 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -08007886 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007887 return -ENOENT;
7888 }
7889
Jeff Johnson295189b2012-06-20 16:38:30 -07007890 }
7891 }
7892
7893 EXIT();
7894
7895 return 0;
7896}
7897
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007898static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
7899 struct net_device *dev, u8 *mac, struct station_parameters *params)
7900{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307901 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007902 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007903#ifdef FEATURE_WLAN_TDLS
7904 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007905 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307906
7907 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7908 TRACE_CODE_HDD_CFG80211_ADD_STA,
7909 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007910 mask = params->sta_flags_mask;
7911
7912 set = params->sta_flags_set;
7913
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007914#ifdef WLAN_FEATURE_TDLS_DEBUG
7915 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7916 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
7917 __func__, mask, set, MAC_ADDR_ARRAY(mac));
7918#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007919
7920 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
7921 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007922 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007923 }
7924 }
7925#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007926 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007927}
7928
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007929
7930#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -07007931#define MAX_PMKSAIDS_IN_CACHE 8
7932
7933static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD local cache
7934static tANI_U32 PMKIDCacheIndex; // HDD local Cache index
7935
7936
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007937static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07007938 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007939{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307940 tANI_U32 j=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007941 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7942 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307943 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307944 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007945 tANI_U8 BSSIDMatched = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307946 hdd_context_t *pHddCtx;
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007947 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
7948 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07007949
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307950 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307951 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007952 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307953 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007954 return -EINVAL;
7955 }
7956
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307957 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7958 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007959
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307960 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007961 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307962 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7963 "%s: HDD context is not valid", __func__);
7964 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007965 }
7966
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307967 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007968 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7969
Wilson Yang6507c4e2013-10-01 20:11:19 -07007970 for (j = 0; j < PMKIDCacheIndex; j++)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007971 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307972 if(vos_mem_compare(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007973 pmksa->bssid, WNI_CFG_BSSID_LEN))
7974 {
7975 /* BSSID matched previous entry. Overwrite it. */
7976 BSSIDMatched = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307977 vos_mem_copy(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007978 pmksa->bssid, WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307979 vos_mem_copy(PMKIDCache[j].PMKID,
7980 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007981 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307982 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007983 __func__, j );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007984 dump_bssid(pmksa->bssid);
7985 dump_pmkid(halHandle, pmksa->pmkid);
7986 break;
7987 }
7988 }
7989
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007990 /* Check we compared all entries,if then take the first slot now */
Wilson Yang6507c4e2013-10-01 20:11:19 -07007991 if(j == MAX_PMKSAIDS_IN_CACHE) PMKIDCacheIndex=0;
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007992
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007993 if (!BSSIDMatched)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307994 {
7995 // Now, we DON'T have a BSSID match, so take a new entry in the cache.
Wilson Yang6507c4e2013-10-01 20:11:19 -07007996 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].BSSID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307997 pmksa->bssid, ETHER_ADDR_LEN);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007998 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].PMKID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307999 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008000 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308001 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Adding a new cache entry %d.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07008002 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008003 dump_bssid(pmksa->bssid);
8004 dump_pmkid(halHandle, pmksa->pmkid);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308005 // Increment the HDD Local Cache index
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008006 // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME
Wilson Yang6507c4e2013-10-01 20:11:19 -07008007 if (PMKIDCacheIndex <= (MAX_PMKSAIDS_IN_CACHE-1)) PMKIDCacheIndex++; else PMKIDCacheIndex = 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008008 }
8009
8010
8011 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308012 //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008013 // __func__, i );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308014 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07008015 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008016 // Finally set the PMKSA ID Cache in CSR
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308017 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
8018 PMKIDCache,
Wilson Yang6507c4e2013-10-01 20:11:19 -07008019 PMKIDCacheIndex);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308020 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8021 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
8022 pAdapter->sessionId, result));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008023 return 0;
8024}
8025
8026
Wilson Yang6507c4e2013-10-01 20:11:19 -07008027
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008028static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -07008029 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008030{
Wilson Yang6507c4e2013-10-01 20:11:19 -07008031 tANI_U32 j=0;
8032 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8033 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008034 tANI_U8 BSSIDMatched = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008035 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -08008036 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008037
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008038 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
8039 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -07008040
8041 /* Validate pAdapter */
8042 if (NULL == pAdapter)
8043 {
8044 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
8045 return -EINVAL;
8046 }
8047
8048 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8049 status = wlan_hdd_validate_context(pHddCtx);
8050
8051 if (0 != status)
8052 {
8053 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8054 "%s: HDD context is not valid", __func__);
8055 return status;
8056 }
8057
8058 /*Retrieve halHandle*/
8059 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
8060
8061 /*in case index is 0,no entry to delete*/
8062 if (0 == PMKIDCacheIndex)
8063 {
8064 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" ,
8065 __func__);
8066 return -EINVAL;
8067 }
8068
8069 /*find the matching PMKSA entry from j=0 to (index-1),
8070 * and delete the matched one
8071 */
8072 for (j = 0; j<PMKIDCacheIndex; j++)
8073 {
8074 if (vos_mem_compare(PMKIDCache[j].BSSID,
8075 pmksa->bssid,
8076 WNI_CFG_BSSID_LEN))
8077 {
8078 /* BSSID matched entry */
8079 BSSIDMatched = 1;
8080
8081 if (j<PMKIDCacheIndex-1)
8082 {
8083 /*replace the matching entry with the last entry in HDD local cache*/
8084 vos_mem_copy(PMKIDCache[j].BSSID,
8085 PMKIDCache[PMKIDCacheIndex-1].BSSID,
8086 WNI_CFG_BSSID_LEN);
8087 vos_mem_copy(PMKIDCache[j].PMKID,
8088 PMKIDCache[PMKIDCacheIndex-1].PMKID,
8089 CSR_RSN_PMKID_SIZE);
8090 }
8091
8092 /*clear the last entry in HDD cache ---[index-1]*/
Wilson Yang6507c4e2013-10-01 20:11:19 -07008093 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].BSSID, WNI_CFG_BSSID_LEN);
8094 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].PMKID, CSR_RSN_PMKID_SIZE);
8095
8096 /*reduce the PMKID array index*/
8097 PMKIDCacheIndex--;
8098
8099 /*delete the last PMKID cache in CSR*/
Wilson Yangef657d32014-01-15 19:19:23 -08008100 if (eHAL_STATUS_SUCCESS !=
8101 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pmksa->bssid))
Wilson Yang6507c4e2013-10-01 20:11:19 -07008102 {
8103 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cannot delete PMKSA %d CONTENT.",
8104 __func__,PMKIDCacheIndex);
Wilson Yangef657d32014-01-15 19:19:23 -08008105 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008106 }
8107
8108 dump_bssid(pmksa->bssid);
8109 dump_pmkid(halHandle,pmksa->pmkid);
8110
8111 break;
8112 }
8113 }
8114
8115 /* we compare all entries,but cannot find matching entry */
8116 if (j == MAX_PMKSAIDS_IN_CACHE && !BSSIDMatched)
8117 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008118 hddLog(VOS_TRACE_LEVEL_FATAL,
8119 "%s: No such PMKSA entry existed " MAC_ADDRESS_STR,
8120 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -07008121 dump_bssid(pmksa->bssid);
8122 dump_pmkid(halHandle, pmksa->pmkid);
8123 return -EINVAL;
8124 }
Wilson Yangef657d32014-01-15 19:19:23 -08008125 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008126}
8127
Wilson Yang6507c4e2013-10-01 20:11:19 -07008128
8129
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008130static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
8131{
Wilson Yang6507c4e2013-10-01 20:11:19 -07008132 tANI_U32 j=0;
8133 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8134 tHalHandle halHandle;
8135 hdd_context_t *pHddCtx;
8136 tANI_U8 *pBSSId;
Wilson Yangef657d32014-01-15 19:19:23 -08008137 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008138
8139 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__);
8140
8141 /* Validate pAdapter */
8142 if (NULL == pAdapter)
8143 {
8144 hddLog(VOS_TRACE_LEVEL_ERROR,
8145 "%s: Invalid Adapter" ,__func__);
8146 return -EINVAL;
8147 }
8148
8149 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8150 status = wlan_hdd_validate_context(pHddCtx);
8151
8152 if (0 != status)
8153 {
8154 hddLog(VOS_TRACE_LEVEL_ERROR,
8155 "%s: HDD context is not valid", __func__);
8156 return status;
8157 }
8158
8159 /*Retrieve halHandle*/
8160 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
8161
8162 /*in case index is 0,no entry to delete*/
8163 if (0 == PMKIDCacheIndex)
8164 {
8165 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" ,
8166 __func__);
8167 return -EINVAL;
8168 }
8169
8170 /*delete all the PMKSA one by one */
8171 for (j = 0; j<PMKIDCacheIndex; j++)
8172 {
Wilson Yang6507c4e2013-10-01 20:11:19 -07008173 pBSSId =(tANI_U8 *)(PMKIDCache[j].BSSID);
Wilson Yang6507c4e2013-10-01 20:11:19 -07008174
8175 /*delete the PMKID in CSR*/
Wilson Yangef657d32014-01-15 19:19:23 -08008176 if (eHAL_STATUS_SUCCESS !=
8177 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId))
Wilson Yang6507c4e2013-10-01 20:11:19 -07008178 {
8179 hddLog(VOS_TRACE_LEVEL_ERROR ,"%s cannot flush PMKIDCache %d.",
8180 __func__,j);
Wilson Yangef657d32014-01-15 19:19:23 -08008181 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008182 }
Kiet Lam8d21d5b2013-10-31 17:18:29 +05308183 /*clear the entry in HDD cache 0--index-1 */
8184 vos_mem_zero(PMKIDCache[j].BSSID, WNI_CFG_BSSID_LEN);
8185 vos_mem_zero(PMKIDCache[j].PMKID, CSR_RSN_PMKID_SIZE);
Wilson Yang6507c4e2013-10-01 20:11:19 -07008186 }
8187
8188 PMKIDCacheIndex = 0;
Wilson Yangef657d32014-01-15 19:19:23 -08008189 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008190}
8191#endif
8192
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008193#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308194static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008195 struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie)
8196{
8197 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8198 hdd_station_ctx_t *pHddStaCtx;
8199
8200 if (NULL == pAdapter)
8201 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008202 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008203 return -ENODEV;
8204 }
8205
8206 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8207
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308208 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8209 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
8210 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008211 // Added for debug on reception of Re-assoc Req.
8212 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8213 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008214 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008215 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008216 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008217 }
8218
8219#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08008220 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008221 ftie->ie_len);
8222#endif
8223
8224 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +05308225 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
8226 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008227 ftie->ie_len);
8228 return 0;
8229}
8230#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008231
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308232#ifdef FEATURE_WLAN_SCAN_PNO
8233
8234void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
8235 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
8236{
8237 int ret;
8238 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
8239 hdd_context_t *pHddCtx;
8240
Nirav Shah80830bf2013-12-31 16:35:12 +05308241 ENTER();
8242
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308243 if (NULL == pAdapter)
8244 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05308245 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308246 "%s: HDD adapter is Null", __func__);
8247 return ;
8248 }
8249
8250 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8251 if (NULL == pHddCtx)
8252 {
8253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8254 "%s: HDD context is Null!!!", __func__);
8255 return ;
8256 }
8257
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308258 spin_lock(&pHddCtx->schedScan_lock);
8259 if (TRUE == pHddCtx->isWiphySuspended)
8260 {
8261 pHddCtx->isSchedScanUpdatePending = TRUE;
8262 spin_unlock(&pHddCtx->schedScan_lock);
8263 hddLog(VOS_TRACE_LEVEL_INFO,
8264 "%s: Update cfg80211 scan database after it resume", __func__);
8265 return ;
8266 }
8267 spin_unlock(&pHddCtx->schedScan_lock);
8268
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308269 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
8270
8271 if (0 > ret)
8272 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
8273
8274 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308275 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8276 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308277}
8278
8279/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308280 * FUNCTION: wlan_hdd_is_pno_allowed
8281 * To check is there any P2P GO/SAP or P2P Client/STA
8282 * session is active
8283 */
8284static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
8285{
8286 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
8287 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308288 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308289 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8290 int status = 0;
8291 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
8292
8293 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
8294 {
8295 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308296 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308297
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308298 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
8299 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
8300 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
8301 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
8302 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
8303 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308304 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308305 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308306 }
8307 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
8308 pAdapterNode = pNext;
8309 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308310 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308311}
8312
8313/*
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308314 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
8315 * NL interface to enable PNO
8316 */
8317static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
8318 struct net_device *dev, struct cfg80211_sched_scan_request *request)
8319{
8320 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8321 tpSirPNOScanReq pPnoRequest = NULL;
8322 hdd_context_t *pHddCtx;
8323 tHalHandle hHal;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05308324 v_U32_t i, indx, num_ch, tempInterval;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308325 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
8326 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN];
8327 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
8328 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308329 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308330
8331 if (NULL == pAdapter)
8332 {
8333 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8334 "%s: HDD adapter is Null", __func__);
8335 return -ENODEV;
8336 }
8337
8338 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308339 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308340
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308341 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308342 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308343 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8344 "%s: HDD context is not valid", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308345 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308346 }
8347
8348 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8349 if (NULL == hHal)
8350 {
8351 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8352 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308353 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308354 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308355
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308356 /* The current firmware design for PNO does not consider concurrent
8357 * active sessions.Hence , determine the concurrent active sessions
8358 * and return a failure to the framework on a request for schedule
8359 * scan.
8360 */
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308361 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308362 {
8363 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308364 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308365 return -EBUSY;
8366 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308367
8368 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
8369 if (NULL == pPnoRequest)
8370 {
8371 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8372 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308373 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308374 }
8375
Madan Mohan Koyyalamudic3f04352013-09-26 19:21:48 +05308376 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308377 pPnoRequest->enable = 1; /*Enable PNO */
8378 pPnoRequest->ucNetworksCount = request->n_match_sets;
8379
8380 if (( !pPnoRequest->ucNetworksCount ) ||
8381 ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
8382 {
8383 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +05308384 "%s: Network input is not correct %d",
8385 __func__, pPnoRequest->ucNetworksCount);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308386 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308387 goto error;
8388 }
8389
8390 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
8391 {
8392 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +05308393 "%s: Incorrect number of channels %d",
8394 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308395 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308396 goto error;
8397 }
8398
8399 /* Framework provides one set of channels(all)
8400 * common for all saved profile */
8401 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
8402 channels_allowed, &num_channels_allowed))
8403 {
8404 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8405 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308406 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308407 goto error;
8408 }
8409 /* Checking each channel against allowed channel list */
8410 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +05308411 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308412 {
Nirav Shah80830bf2013-12-31 16:35:12 +05308413 char chList [(request->n_channels*5)+1];
8414 int len;
8415 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308416 {
Nirav Shah80830bf2013-12-31 16:35:12 +05308417 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308418 {
Nirav Shah80830bf2013-12-31 16:35:12 +05308419 if (request->channels[i]->hw_value == channels_allowed[indx])
8420 {
8421 valid_ch[num_ch++] = request->channels[i]->hw_value;
8422 len += snprintf(chList+len, 5, "%d ",
8423 request->channels[i]->hw_value);
8424 break ;
8425 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308426 }
8427 }
Nirav Shah80830bf2013-12-31 16:35:12 +05308428 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
8429 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308430
8431 /* Filling per profile params */
8432 for (i = 0; i < pPnoRequest->ucNetworksCount; i++)
8433 {
8434 pPnoRequest->aNetworks[i].ssId.length =
8435 request->match_sets[i].ssid.ssid_len;
8436
8437 if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) ||
8438 ( pPnoRequest->aNetworks[i].ssId.length > 32 ) )
8439 {
8440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +05308441 "%s: SSID Len %d is not correct for network %d",
8442 __func__, pPnoRequest->aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308443 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308444 goto error;
8445 }
8446
8447 memcpy(pPnoRequest->aNetworks[i].ssId.ssId,
8448 request->match_sets[i].ssid.ssid,
8449 request->match_sets[i].ssid.ssid_len);
8450 pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
8451 pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/
8452 pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
8453
8454 /*Copying list of valid channel into request */
8455 memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch);
8456 pPnoRequest->aNetworks[i].ucChannelCount = num_ch;
8457
8458 pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value
8459 }
8460
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +05308461 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -08008462 "request->ie_len = %zu", request->ie_len);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +05308463 if ((0 < request->ie_len) && (NULL != request->ie))
8464 {
8465 pPnoRequest->us24GProbeTemplateLen = request->ie_len;
8466 memcpy(&pPnoRequest->p24GProbeTemplate, request->ie,
8467 pPnoRequest->us24GProbeTemplateLen);
8468
8469 pPnoRequest->us5GProbeTemplateLen = request->ie_len;
8470 memcpy(&pPnoRequest->p5GProbeTemplate, request->ie,
8471 pPnoRequest->us5GProbeTemplateLen);
8472 }
8473
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05308474 /* Driver gets only one time interval which is hardcoded in
8475 * supplicant for 10000ms. Taking power consumption into account 6 timers
8476 * will be used, Timervalue is increased exponentially i.e 10,20,40,
8477 * 80,160,320 secs. And number of scan cycle for each timer
8478 * is configurable through INI param gPNOScanTimerRepeatValue.
8479 * If it is set to 0 only one timer will be used and PNO scan cycle
8480 * will be repeated after each interval specified by supplicant
8481 * till PNO is disabled.
8482 */
8483 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
8484 pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
8485 else
8486 pPnoRequest->scanTimers.ucScanTimersCount =
8487 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
8488
8489 tempInterval = (request->interval)/1000;
8490 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8491 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
8492 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
8493 for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++)
8494 {
8495 pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat =
8496 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
8497 pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval;
8498 tempInterval *= 2;
8499 }
8500 //Repeat last timer until pno disabled.
8501 pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
8502
Madan Mohan Koyyalamudid206c7b2013-09-26 22:54:51 +05308503 pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308504
Nirav Shah80830bf2013-12-31 16:35:12 +05308505 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8506 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
8507 pAdapter->sessionId, pPnoRequest->enable, pPnoRequest->modePNO,
8508 pPnoRequest->scanTimers.ucScanTimersCount);
8509
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308510 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
8511 pPnoRequest, pAdapter->sessionId,
8512 hdd_cfg80211_sched_scan_done_callback, pAdapter);
8513 if (eHAL_STATUS_SUCCESS != status)
8514 {
8515 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +05308516 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308517 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308518 goto error;
8519 }
8520
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308521 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8522 "PNO scanRequest offloaded");
8523
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308524error:
8525 vos_mem_free(pPnoRequest);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308526 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308527}
8528
8529/*
8530 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
8531 * NL interface to disable PNO
8532 */
8533static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
8534 struct net_device *dev)
8535{
8536 eHalStatus status = eHAL_STATUS_FAILURE;
8537 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8538 hdd_context_t *pHddCtx;
8539 tHalHandle hHal;
8540 tpSirPNOScanReq pPnoRequest = NULL;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308541 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308542
8543 ENTER();
8544
8545 if (NULL == pAdapter)
8546 {
8547 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8548 "%s: HDD adapter is Null", __func__);
8549 return -ENODEV;
8550 }
8551
8552 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308553
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308554 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308555 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308556 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308557 "%s: HDD context is Null", __func__);
8558 return -ENODEV;
8559 }
8560
8561 /* The return 0 is intentional when isLogpInProgress and
8562 * isLoadUnloadInProgress. We did observe a crash due to a return of
8563 * failure in sched_scan_stop , especially for a case where the unload
8564 * of the happens at the same time. The function __cfg80211_stop_sched_scan
8565 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
8566 * success. If it returns a failure , then its next invocation due to the
8567 * clean up of the second interface will have the dev pointer corresponding
8568 * to the first one leading to a crash.
8569 */
8570 if (pHddCtx->isLogpInProgress)
8571 {
8572 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8573 "%s: LOGP in Progress. Ignore!!!", __func__);
8574 return ret;
8575 }
8576
8577 if (pHddCtx->isLoadUnloadInProgress)
8578 {
8579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8580 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
8581 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308582 }
8583
8584 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8585 if (NULL == hHal)
8586 {
8587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8588 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308589 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308590 }
8591
8592 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
8593 if (NULL == pPnoRequest)
8594 {
8595 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8596 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308597 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308598 }
8599
8600 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
8601 pPnoRequest->enable = 0; /* Disable PNO */
8602 pPnoRequest->ucNetworksCount = 0;
8603
8604 status = sme_SetPreferredNetworkList(hHal, pPnoRequest,
8605 pAdapter->sessionId,
8606 NULL, pAdapter);
8607 if (eHAL_STATUS_SUCCESS != status)
8608 {
8609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8610 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308611 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308612 }
8613
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308614 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8615 "%s: PNO scan disabled", __func__);
8616
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308617 vos_mem_free(pPnoRequest);
8618
8619 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308620 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308621}
8622
8623#endif /*FEATURE_WLAN_SCAN_PNO*/
8624
8625
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008626#ifdef FEATURE_WLAN_TDLS
8627static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
8628 u8 *peer, u8 action_code, u8 dialog_token,
8629 u16 status_code, const u8 *buf, size_t len)
8630{
8631
8632 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8633 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008634 u8 peerMac[6];
8635 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008636 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -08008637 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -07008638 long rc;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008639
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308640 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8641 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
8642 pAdapter->sessionId, action_code));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008643 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008644 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308645 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008646 "Invalid arguments");
8647 return -EINVAL;
8648 }
8649
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008650 if (pHddCtx->isLogpInProgress)
8651 {
8652 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8653 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008654 wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008655 return -EBUSY;
8656 }
8657
Hoonki Lee27511902013-03-14 18:19:06 -07008658 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008659 {
Hoonki Lee27511902013-03-14 18:19:06 -07008660 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8661 "%s: TDLS mode is disabled OR not enabled in FW."
8662 MAC_ADDRESS_STR " action %d declined.",
8663 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008664 return -ENOTSUPP;
8665 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008666
Hoonki Lee27511902013-03-14 18:19:06 -07008667 /* other than teardown frame, other mgmt frames are not sent if disabled */
8668 if (SIR_MAC_TDLS_TEARDOWN != action_code)
8669 {
8670 /* if tdls_mode is disabled to respond to peer's request */
8671 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
8672 {
8673 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8674 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008675 " TDLS mode is disabled. action %d declined.",
8676 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -07008677
8678 return -ENOTSUPP;
8679 }
8680 }
8681
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008682 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
8683 {
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308684 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008685 {
8686 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008687 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008688 " TDLS setup is ongoing. action %d declined.",
8689 __func__, MAC_ADDR_ARRAY(peer), action_code);
8690 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008691 }
8692 }
8693
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008694 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
8695 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -08008696 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008697 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
Lee Hoonkic1262f22013-01-24 21:59:00 -08008698 {
8699 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
8700 we return error code at 'add_station()'. Hence we have this
8701 check again in addtion to add_station().
8702 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008703 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -08008704 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008705 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8706 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008707 " TDLS Max peer already connected. action %d declined.",
8708 __func__, MAC_ADDR_ARRAY(peer), action_code);
Sunil Dutt388ac8f2013-11-28 18:06:52 +05308709 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -08008710 }
8711 else
8712 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008713 /* maximum reached. tweak to send error code to peer and return
8714 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -08008715 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008716 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8717 "%s: " MAC_ADDRESS_STR
8718 " TDLS Max peer already connected send response status %d",
8719 __func__, MAC_ADDR_ARRAY(peer), status_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008720 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008721 /* fall through to send setup resp with failure status
8722 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -08008723 }
8724 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008725 else
8726 {
8727 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308728 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008729 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008730 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008731 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008732 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
8733 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008734 return -EPERM;
8735 }
8736 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008737 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008738 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008739
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008740#ifdef WLAN_FEATURE_TDLS_DEBUG
8741 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008742 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d",
8743 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
8744 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008745#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008746
Hoonki Leea34dd892013-02-05 22:56:02 -08008747 /*Except teardown responder will not be used so just make 0*/
8748 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008749 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -08008750 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008751
8752 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308753 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008754
8755 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
8756 responder = pTdlsPeer->is_responder;
8757 else
Hoonki Leea34dd892013-02-05 22:56:02 -08008758 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008759 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8760 "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d",
8761 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
8762 dialog_token, status_code, len);
8763 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -08008764 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008765 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008766
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308767 /* For explicit trigger of DIS_REQ come out of BMPS for
8768 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -07008769 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308770 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
8771 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -07008772 {
8773 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
8774 {
8775 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308776 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Hoonki Lee14621352013-04-16 17:51:19 -07008777 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
8778 }
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308779 if (SIR_MAC_TDLS_DIS_REQ != action_code)
8780 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
Hoonki Lee14621352013-04-16 17:51:19 -07008781 }
8782
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008783 /* make sure doesn't call send_mgmt() while it is pending */
8784 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
8785 {
8786 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008787 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008788 __func__, MAC_ADDR_ARRAY(peer), action_code);
8789 return -EBUSY;
8790 }
8791
8792 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008793 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
8794
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008795 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Hoonki Leea34dd892013-02-05 22:56:02 -08008796 peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008797
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008798 if (VOS_STATUS_SUCCESS != status)
8799 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008800 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8801 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008802 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -07008803 wlan_hdd_tdls_check_bmps(pAdapter);
Sunil Dutt388ac8f2013-11-28 18:06:52 +05308804 return -EINVAL;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008805 }
8806
Hoonki Leed37cbb32013-04-20 00:31:14 -07008807 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
8808 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
8809
8810 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008811 {
Hoonki Leed37cbb32013-04-20 00:31:14 -07008812 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008813 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -07008814 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008815 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -08008816
8817 if (pHddCtx->isLogpInProgress)
8818 {
8819 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8820 "%s: LOGP in Progress. Ignore!!!", __func__);
8821 return -EAGAIN;
8822 }
8823
Hoonki Leed37cbb32013-04-20 00:31:14 -07008824 wlan_hdd_tdls_check_bmps(pAdapter);
Sunil Dutt388ac8f2013-11-28 18:06:52 +05308825 return -EINVAL;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008826 }
8827
Gopichand Nakkala05922802013-03-14 12:23:19 -07008828 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -07008829 {
8830 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008831 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -07008832 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008833
Hoonki Leea34dd892013-02-05 22:56:02 -08008834 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
8835 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008836 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -08008837 }
8838 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
8839 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008840 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -08008841 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008842
8843 return 0;
8844}
8845
8846static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
8847 u8 *peer, enum nl80211_tdls_operation oper)
8848{
8849 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8850 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308851 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008852 hddTdlsPeer_t *pTdlsPeer;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008853
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308854 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8855 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
8856 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308857 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008858 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008859 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07008860 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008861 return -EINVAL;
8862 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008863
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308864 status = wlan_hdd_validate_context(pHddCtx);
8865
8866 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008867 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308868 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8869 "%s: HDD context is not valid", __func__);
8870 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008871 }
8872
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008873
8874 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008875 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008876 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008877 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07008878 "TDLS Disabled in INI OR not enabled in FW. "
8879 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008880 return -ENOTSUPP;
8881 }
8882
8883 switch (oper) {
8884 case NL80211_TDLS_ENABLE_LINK:
8885 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008886 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308887 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308888 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008889
Sunil Dutt41de4e22013-11-14 18:09:02 +05308890 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
8891
8892 if ( NULL == pTdlsPeer ) {
8893 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
8894 " (oper %d) not exsting. ignored",
8895 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
8896 return -EINVAL;
8897 }
8898
8899 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8900 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
8901 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
8902 "NL80211_TDLS_ENABLE_LINK");
8903
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -07008904 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
8905 {
8906 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
8907 MAC_ADDRESS_STR " failed",
8908 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
8909 return -EINVAL;
8910 }
8911
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008912 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008913 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308914 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05308915
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308916 if (0 != wlan_hdd_tdls_get_link_establish_params(
8917 pAdapter, peer,&tdlsLinkEstablishParams)) {
8918 return -EINVAL;
8919 }
8920 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308921
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308922 sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter),
8923 pAdapter->sessionId, peer, &tdlsLinkEstablishParams);
8924 /* Send TDLS peer UAPSD capabilities to the firmware and
8925 * register with the TL on after the response for this operation
8926 * is received .
8927 */
8928 ret = wait_for_completion_interruptible_timeout(
8929 &pAdapter->tdls_link_establish_req_comp,
8930 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
8931 if (ret <= 0)
8932 {
8933 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8934 "%s: Link Establish Request Faled Status %ld",
8935 __func__, ret);
8936 return -EINVAL;
8937 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308938 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008939 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED);
Gopichand Nakkala471708b2013-06-04 20:03:01 +05308940 /* Mark TDLS client Authenticated .*/
8941 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
8942 pTdlsPeer->staId,
8943 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008944 if (VOS_STATUS_SUCCESS == status)
8945 {
Hoonki Lee14621352013-04-16 17:51:19 -07008946 if (pTdlsPeer->is_responder == 0)
8947 {
8948 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
8949
8950 wlan_hdd_tdls_timer_restart(pAdapter,
8951 &pTdlsPeer->initiatorWaitTimeoutTimer,
8952 WAIT_TIME_TDLS_INITIATOR);
8953 /* suspend initiator TX until it receives direct packet from the
8954 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
8955 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
8956 &staId, NULL);
8957 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008958 wlan_hdd_tdls_increment_peer_count(pAdapter);
8959 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008960 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308961
8962 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308963 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
8964 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308965 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308966 int ac;
8967 uint8 ucAc[4] = { WLANTL_AC_VO,
8968 WLANTL_AC_VI,
8969 WLANTL_AC_BK,
8970 WLANTL_AC_BE };
8971 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
8972 for(ac=0; ac < 4; ac++)
8973 {
8974 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
8975 pTdlsPeer->staId, ucAc[ac],
8976 tlTid[ac], tlTid[ac], 0, 0,
8977 WLANTL_BI_DIR );
8978 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308979 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008980 }
8981
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008982 }
8983 break;
8984 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -08008985 {
Sunil Dutt41de4e22013-11-14 18:09:02 +05308986 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
8987
8988 if ( NULL == pTdlsPeer ) {
8989 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
8990 " (oper %d) not exsting. ignored",
8991 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
8992 return -EINVAL;
8993 }
8994
8995 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8996 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
8997 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
8998 "NL80211_TDLS_DISABLE_LINK");
8999
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009000 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -08009001 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009002 long status;
9003
9004 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
9005
Lee Hoonkic1262f22013-01-24 21:59:00 -08009006 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
9007 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009008
9009 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
9010 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
9011 if (status <= 0)
9012 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009013 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009014 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9015 "%s: Del station failed status %ld",
9016 __func__, status);
9017 return -EPERM;
9018 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009019 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Lee Hoonkic1262f22013-01-24 21:59:00 -08009020 }
9021 else
9022 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009023 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9024 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -08009025 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08009026 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009027 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009028 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +05309029 {
9030 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9031 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
9032 __func__, MAC_ADDR_ARRAY(peer));
9033
9034 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
9035 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
9036
9037 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9038 " %s TDLS External control and Implicit Trigger not enabled ",
9039 __func__);
9040 return -ENOTSUPP;
9041 }
9042
Sunil Dutt41de4e22013-11-14 18:09:02 +05309043
9044 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
9045
9046 if ( NULL == pTdlsPeer ) {
9047 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
9048 " peer not exsting",
9049 __func__, MAC_ADDR_ARRAY(peer));
Naresh Jayaram937abdf2013-11-26 19:50:25 +05309050 return -EINVAL;
Sunil Dutt41de4e22013-11-14 18:09:02 +05309051 }
9052 else {
9053 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
9054 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
9055 }
Naresh Jayaram937abdf2013-11-26 19:50:25 +05309056
9057 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) )
9058 return -EINVAL;
Sunil Dutt41de4e22013-11-14 18:09:02 +05309059 break;
9060 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009061 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +05309062 {
Naresh Jayaramdb4514b2013-11-25 18:08:10 +05309063 hddTdlsPeer_t *pTdlsPeer;
Sunil Dutt41de4e22013-11-14 18:09:02 +05309064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9065 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
9066 __func__, MAC_ADDR_ARRAY(peer));
9067
9068 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
9069 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
9070
9071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9072 " %s TDLS External control and Implicit Trigger not enabled ",
9073 __func__);
9074 return -ENOTSUPP;
9075 }
9076
Naresh Jayaramdb4514b2013-11-25 18:08:10 +05309077 /* To cater the requirement of establishing the TDLS link
9078 * irrespective of the data traffic , get an entry of TDLS peer.
9079 */
9080 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
9081 if (pTdlsPeer == NULL) {
9082 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9083 "%s: peer " MAC_ADDRESS_STR " not existing",
9084 __func__, MAC_ADDR_ARRAY(peer));
9085 return -EINVAL;
9086 }
Naresh Jayaram937abdf2013-11-26 19:50:25 +05309087
9088 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
9089
9090 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9091 " %s TDLS Add Force Peer Failed",
9092 __func__);
9093 return -EINVAL;
9094 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +05309095 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +05309096 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009097 case NL80211_TDLS_DISCOVERY_REQ:
9098 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309099 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9100 "%s: We don't support in-driver setup/teardown/discovery "
9101 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009102 return -ENOTSUPP;
9103 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309104 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9105 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009106 return -ENOTSUPP;
9107 }
9108 return 0;
9109}
Chilam NG571c65a2013-01-19 12:27:36 +05309110
9111int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
9112 struct net_device *dev, u8 *peer)
9113{
Arif Hussaina7c8e412013-11-20 11:06:42 -08009114 hddLog(VOS_TRACE_LEVEL_INFO,
9115 "tdls send discover req: "MAC_ADDRESS_STR,
9116 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +05309117
9118 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
9119 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
9120}
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009121#endif
9122
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309123#ifdef WLAN_FEATURE_GTK_OFFLOAD
9124/*
9125 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
9126 * Callback rountine called upon receiving response for
9127 * get offload info
9128 */
9129void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
9130 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
9131{
9132
9133 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309134 tANI_U8 tempReplayCounter[8];
9135 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309136
9137 ENTER();
9138
9139 if (NULL == pAdapter)
9140 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309141 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309142 "%s: HDD adapter is Null", __func__);
9143 return ;
9144 }
9145
9146 if (NULL == pGtkOffloadGetInfoRsp)
9147 {
9148 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9149 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
9150 return ;
9151 }
9152
9153 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
9154 {
9155 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9156 "%s: wlan Failed to get replay counter value",
9157 __func__);
9158 return ;
9159 }
9160
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309161 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9162 /* Update replay counter */
9163 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
9164 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
9165
9166 {
9167 /* changing from little to big endian since supplicant
9168 * works on big endian format
9169 */
9170 int i;
9171 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
9172
9173 for (i = 0; i < 8; i++)
9174 {
9175 tempReplayCounter[7-i] = (tANI_U8)p[i];
9176 }
9177 }
9178
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309179 /* Update replay counter to NL */
9180 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309181 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309182}
9183
9184/*
9185 * FUNCTION: wlan_hdd_cfg80211_set_rekey_data
9186 * This function is used to offload GTK rekeying job to the firmware.
9187 */
9188int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
9189 struct cfg80211_gtk_rekey_data *data)
9190{
9191 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9192 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9193 hdd_station_ctx_t *pHddStaCtx;
9194 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309195 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309196 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309197 eHalStatus status = eHAL_STATUS_FAILURE;
9198
9199 ENTER();
9200
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309201
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309202 if (NULL == pAdapter)
9203 {
9204 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9205 "%s: HDD adapter is Null", __func__);
9206 return -ENODEV;
9207 }
9208
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309209 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9210 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
9211 pAdapter->sessionId, pAdapter->device_mode));
9212
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309213 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309214
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309215 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309216 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309217 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9218 "%s: HDD context is not valid", __func__);
9219 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309220 }
9221
9222 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9223 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9224 if (NULL == hHal)
9225 {
9226 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9227 "%s: HAL context is Null!!!", __func__);
9228 return -EAGAIN;
9229 }
9230
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309231 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
9232 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
9233 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
9234 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309235 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309236 {
9237 /* changing from big to little endian since driver
9238 * works on little endian format
9239 */
9240 tANI_U8 *p =
9241 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
9242 int i;
9243
9244 for (i = 0; i < 8; i++)
9245 {
9246 p[7-i] = data->replay_ctr[i];
9247 }
9248 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309249
9250 if (TRUE == pHddCtx->hdd_wlan_suspended)
9251 {
9252 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309253 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
9254 sizeof (tSirGtkOffloadParams));
9255 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309256 pAdapter->sessionId);
9257
9258 if (eHAL_STATUS_SUCCESS != status)
9259 {
9260 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9261 "%s: sme_SetGTKOffload failed, returned %d",
9262 __func__, status);
9263 return status;
9264 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9266 "%s: sme_SetGTKOffload successfull", __func__);
9267 }
9268 else
9269 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309270 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9271 "%s: wlan not suspended GTKOffload request is stored",
9272 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309273 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309274
9275 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309276}
9277#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
9278
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309279/*
9280 * FUNCTION: wlan_hdd_cfg80211_set_mac_acl
9281 * This function is used to set access control policy
9282 */
9283static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
9284 struct net_device *dev, const struct cfg80211_acl_data *params)
9285{
9286 int i;
9287 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9288 hdd_hostapd_state_t *pHostapdState;
9289 tsap_Config_t *pConfig;
9290 v_CONTEXT_t pVosContext = NULL;
9291 hdd_context_t *pHddCtx;
9292 int status;
9293
9294 ENTER();
9295
9296 if (NULL == pAdapter)
9297 {
9298 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9299 "%s: HDD adapter is Null", __func__);
9300 return -ENODEV;
9301 }
9302
9303 if (NULL == params)
9304 {
9305 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9306 "%s: params is Null", __func__);
9307 return -EINVAL;
9308 }
9309
9310 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9311 status = wlan_hdd_validate_context(pHddCtx);
9312
9313 if (0 != status)
9314 {
9315 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9316 "%s: HDD context is not valid", __func__);
9317 return status;
9318 }
9319
9320 pVosContext = pHddCtx->pvosContext;
9321 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
9322
9323 if (NULL == pHostapdState)
9324 {
9325 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9326 "%s: pHostapdState is Null", __func__);
9327 return -EINVAL;
9328 }
9329
9330 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
9331 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
9332
9333 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
9334 {
9335 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
9336
9337 /* default value */
9338 pConfig->num_accept_mac = 0;
9339 pConfig->num_deny_mac = 0;
9340
9341 /**
9342 * access control policy
9343 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
9344 * listed in hostapd.deny file.
9345 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
9346 * listed in hostapd.accept file.
9347 */
9348 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
9349 {
9350 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
9351 }
9352 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
9353 {
9354 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
9355 }
9356 else
9357 {
9358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9359 "%s:Acl Policy : %d is not supported",
9360 __func__, params->acl_policy);
9361 return -ENOTSUPP;
9362 }
9363
9364 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
9365 {
9366 pConfig->num_accept_mac = params->n_acl_entries;
9367 for (i = 0; i < params->n_acl_entries; i++)
9368 {
9369 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9370 "** Add ACL MAC entry %i in WhiletList :"
9371 MAC_ADDRESS_STR, i,
9372 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
9373
9374 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
9375 sizeof(qcmacaddr));
9376 }
9377 }
9378 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
9379 {
9380 pConfig->num_deny_mac = params->n_acl_entries;
9381 for (i = 0; i < params->n_acl_entries; i++)
9382 {
9383 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9384 "** Add ACL MAC entry %i in BlackList :"
9385 MAC_ADDRESS_STR, i,
9386 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
9387
9388 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
9389 sizeof(qcmacaddr));
9390 }
9391 }
9392
9393 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
9394 {
9395 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9396 "%s: SAP Set Mac Acl fail", __func__);
9397 return -EINVAL;
9398 }
9399 }
9400 else
9401 {
9402 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9403 "%s: Invalid device_mode = %d",
9404 __func__, pAdapter->device_mode);
9405 return -EINVAL;
9406 }
9407
9408 return 0;
9409}
9410
Leo Chang9056f462013-08-01 19:21:11 -07009411#ifdef WLAN_NL80211_TESTMODE
9412#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -07009413void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -07009414(
9415 void *pAdapter,
9416 void *indCont
9417)
9418{
Leo Changd9df8aa2013-09-26 13:32:26 -07009419 tSirLPHBInd *lphbInd;
9420 struct sk_buff *skb;
Leo Chang9056f462013-08-01 19:21:11 -07009421
9422 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07009423 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -07009424
9425 if (NULL == indCont)
9426 {
9427 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07009428 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -07009429 return;
9430 }
9431
Leo Changd9df8aa2013-09-26 13:32:26 -07009432 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -07009433 skb = cfg80211_testmode_alloc_event_skb(
9434 ((hdd_adapter_t *)pAdapter)->wdev.wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -07009435 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -07009436 GFP_ATOMIC);
9437 if (!skb)
9438 {
9439 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9440 "LPHB timeout, NL buffer alloc fail");
9441 return;
9442 }
9443
Leo Changac3ba772013-10-07 09:47:04 -07009444 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -07009445 {
9446 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9447 "WLAN_HDD_TM_ATTR_CMD put fail");
9448 goto nla_put_failure;
9449 }
Leo Changac3ba772013-10-07 09:47:04 -07009450 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -07009451 {
9452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9453 "WLAN_HDD_TM_ATTR_TYPE put fail");
9454 goto nla_put_failure;
9455 }
Leo Changac3ba772013-10-07 09:47:04 -07009456 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -07009457 sizeof(tSirLPHBInd), lphbInd))
9458 {
9459 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9460 "WLAN_HDD_TM_ATTR_DATA put fail");
9461 goto nla_put_failure;
9462 }
Leo Chang9056f462013-08-01 19:21:11 -07009463 cfg80211_testmode_event(skb, GFP_ATOMIC);
9464 return;
9465
9466nla_put_failure:
9467 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9468 "NLA Put fail");
9469 kfree_skb(skb);
9470
9471 return;
9472}
9473#endif /* FEATURE_WLAN_LPHB */
9474
9475static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
9476{
9477 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
9478 int err = 0;
9479#ifdef FEATURE_WLAN_LPHB
9480 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -07009481 eHalStatus smeStatus;
Leo Chang9056f462013-08-01 19:21:11 -07009482#endif /* FEATURE_WLAN_LPHB */
9483
9484 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
9485 if (err)
9486 {
9487 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9488 "%s Testmode INV ATTR", __func__);
9489 return err;
9490 }
9491
9492 if (!tb[WLAN_HDD_TM_ATTR_CMD])
9493 {
9494 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9495 "%s Testmode INV CMD", __func__);
9496 return -EINVAL;
9497 }
9498
9499 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
9500 {
9501#ifdef FEATURE_WLAN_LPHB
9502 /* Low Power Heartbeat configuration request */
9503 case WLAN_HDD_TM_CMD_WLAN_HB:
9504 {
9505 int buf_len;
9506 void *buf;
9507 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -08009508 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -07009509
9510 if (!tb[WLAN_HDD_TM_ATTR_DATA])
9511 {
9512 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9513 "%s Testmode INV DATA", __func__);
9514 return -EINVAL;
9515 }
9516
9517 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
9518 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -08009519
9520 hb_params_temp =(tSirLPHBReq *)buf;
9521 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
9522 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
9523 return -EINVAL;
9524
Leo Chang9056f462013-08-01 19:21:11 -07009525 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
9526 if (NULL == hb_params)
9527 {
9528 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9529 "%s Request Buffer Alloc Fail", __func__);
9530 return -EINVAL;
9531 }
9532
9533 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -07009534 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
9535 hb_params,
9536 wlan_hdd_cfg80211_lphb_ind_handler);
9537 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -07009538 {
Leo Changd9df8aa2013-09-26 13:32:26 -07009539 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9540 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -07009541 vos_mem_free(hb_params);
9542 }
Leo Chang9056f462013-08-01 19:21:11 -07009543 return 0;
9544 }
9545#endif /* FEATURE_WLAN_LPHB */
9546 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309547 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9548 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -07009549 return -EOPNOTSUPP;
9550 }
9551
9552 return err;
9553}
9554#endif /* CONFIG_NL80211_TESTMODE */
9555
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309556static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
9557 struct net_device *dev,
9558 int idx, struct survey_info *survey)
9559{
9560 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9561 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +05309562 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309563 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +05309564 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309565 v_S7_t snr,rssi;
9566 int status, i, j, filled = 0;
9567
9568 ENTER();
9569
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309570 if (NULL == pAdapter)
9571 {
9572 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9573 "%s: HDD adapter is Null", __func__);
9574 return -ENODEV;
9575 }
9576
9577 if (NULL == wiphy)
9578 {
9579 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9580 "%s: wiphy is Null", __func__);
9581 return -ENODEV;
9582 }
9583
9584 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9585 status = wlan_hdd_validate_context(pHddCtx);
9586
9587 if (0 != status)
9588 {
9589 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9590 "%s: HDD context is not valid", __func__);
9591 return status;
9592 }
9593
Mihir Sheted9072e02013-08-21 17:02:29 +05309594 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9595
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309596 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +05309597 0 != pAdapter->survey_idx ||
9598 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309599 {
9600 /* The survey dump ops when implemented completely is expected to
9601 * return a survey of all channels and the ops is called by the
9602 * kernel with incremental values of the argument 'idx' till it
9603 * returns -ENONET. But we can only support the survey for the
9604 * operating channel for now. survey_idx is used to track
9605 * that the ops is called only once and then return -ENONET for
9606 * the next iteration
9607 */
9608 pAdapter->survey_idx = 0;
9609 return -ENONET;
9610 }
9611
9612 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
9613
9614 wlan_hdd_get_snr(pAdapter, &snr);
9615 wlan_hdd_get_rssi(pAdapter, &rssi);
9616
9617 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
9618 hdd_wlan_get_freq(channel, &freq);
9619
9620
9621 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
9622 {
9623 if (NULL == wiphy->bands[i])
9624 {
9625 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9626 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
9627 continue;
9628 }
9629
9630 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
9631 {
9632 struct ieee80211_supported_band *band = wiphy->bands[i];
9633
9634 if (band->channels[j].center_freq == (v_U16_t)freq)
9635 {
9636 survey->channel = &band->channels[j];
9637 /* The Rx BDs contain SNR values in dB for the received frames
9638 * while the supplicant expects noise. So we calculate and
9639 * return the value of noise (dBm)
9640 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
9641 */
9642 survey->noise = rssi - snr;
9643 survey->filled = SURVEY_INFO_NOISE_DBM;
9644 filled = 1;
9645 }
9646 }
9647 }
9648
9649 if (filled)
9650 pAdapter->survey_idx = 1;
9651 else
9652 {
9653 pAdapter->survey_idx = 0;
9654 return -ENONET;
9655 }
9656
9657 return 0;
9658}
9659
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309660/*
9661 * FUNCTION: wlan_hdd_cfg80211_resume_wlan
9662 * this is called when cfg80211 driver resume
9663 * driver updates latest sched_scan scan result(if any) to cfg80211 database
9664 */
9665int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
9666{
9667 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9668 hdd_adapter_t *pAdapter;
9669 hdd_adapter_list_node_t *pAdapterNode, *pNext;
9670 VOS_STATUS status = VOS_STATUS_SUCCESS;
9671
9672 ENTER();
9673
9674 if ( NULL == pHddCtx )
9675 {
9676 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9677 "%s: HddCtx validation failed", __func__);
9678 return 0;
9679 }
9680
9681 if (pHddCtx->isLogpInProgress)
9682 {
9683 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9684 "%s: LOGP in Progress. Ignore!!!", __func__);
9685 return 0;
9686 }
9687
9688 if (pHddCtx->isLoadUnloadInProgress)
9689 {
9690 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9691 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
9692 return 0;
9693 }
9694
9695 spin_lock(&pHddCtx->schedScan_lock);
9696 pHddCtx->isWiphySuspended = FALSE;
9697 if (TRUE != pHddCtx->isSchedScanUpdatePending)
9698 {
9699 spin_unlock(&pHddCtx->schedScan_lock);
9700 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9701 "%s: Return resume is not due to PNO indication", __func__);
9702 return 0;
9703 }
9704 // Reset flag to avoid updatating cfg80211 data old results again
9705 pHddCtx->isSchedScanUpdatePending = FALSE;
9706 spin_unlock(&pHddCtx->schedScan_lock);
9707
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05309708
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309709 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
9710
9711 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
9712 {
9713 pAdapter = pAdapterNode->pAdapter;
9714 if ( (NULL != pAdapter) &&
9715 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
9716 {
9717 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05309718 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309719 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9720 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05309721 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309722 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05309723 {
9724 /* Acquire wakelock to handle the case where APP's tries to
9725 * suspend immediately after updating the scan results. Whis
9726 * results in app's is in suspended state and not able to
9727 * process the connect request to AP
9728 */
9729 hdd_prevent_suspend_timeout(2000);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309730 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05309731 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309732
9733 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9734 "%s : cfg80211 scan result database updated", __func__);
9735
9736 return 0;
9737
9738 }
9739 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
9740 pAdapterNode = pNext;
9741 }
9742
9743 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9744 "%s: Failed to find Adapter", __func__);
9745 return 0;
9746}
9747
9748/*
9749 * FUNCTION: wlan_hdd_cfg80211_suspend_wlan
9750 * this is called when cfg80211 driver suspends
9751 */
9752int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
9753 struct cfg80211_wowlan *wow)
9754{
9755 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9756
9757 ENTER();
9758 if (NULL == pHddCtx)
9759 {
9760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9761 "%s: HddCtx validation failed", __func__);
9762 return 0;
9763 }
9764
9765 pHddCtx->isWiphySuspended = TRUE;
9766
9767 EXIT();
9768
9769 return 0;
9770}
9771
Jeff Johnson295189b2012-06-20 16:38:30 -07009772/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309773static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -07009774{
9775 .add_virtual_intf = wlan_hdd_add_virtual_intf,
9776 .del_virtual_intf = wlan_hdd_del_virtual_intf,
9777 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
9778 .change_station = wlan_hdd_change_station,
9779#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9780 .add_beacon = wlan_hdd_cfg80211_add_beacon,
9781 .del_beacon = wlan_hdd_cfg80211_del_beacon,
9782 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009783#else
9784 .start_ap = wlan_hdd_cfg80211_start_ap,
9785 .change_beacon = wlan_hdd_cfg80211_change_beacon,
9786 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -07009787#endif
9788 .change_bss = wlan_hdd_cfg80211_change_bss,
9789 .add_key = wlan_hdd_cfg80211_add_key,
9790 .get_key = wlan_hdd_cfg80211_get_key,
9791 .del_key = wlan_hdd_cfg80211_del_key,
9792 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009793#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009794 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009795#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009796 .scan = wlan_hdd_cfg80211_scan,
9797 .connect = wlan_hdd_cfg80211_connect,
9798 .disconnect = wlan_hdd_cfg80211_disconnect,
9799 .join_ibss = wlan_hdd_cfg80211_join_ibss,
9800 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
9801 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
9802 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
9803 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -07009804 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
9805 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
9806 .mgmt_tx = wlan_hdd_action,
9807#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9808 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
9809 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
9810 .set_txq_params = wlan_hdd_set_txq_params,
9811#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009812 .get_station = wlan_hdd_cfg80211_get_station,
9813 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
9814 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009815 .add_station = wlan_hdd_cfg80211_add_station,
9816#ifdef FEATURE_WLAN_LFR
9817 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
9818 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
9819 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
9820#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009821#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
9822 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
9823#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009824#ifdef FEATURE_WLAN_TDLS
9825 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
9826 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
9827#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309828#ifdef WLAN_FEATURE_GTK_OFFLOAD
9829 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
9830#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309831#ifdef FEATURE_WLAN_SCAN_PNO
9832 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
9833 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
9834#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309835 .resume = wlan_hdd_cfg80211_resume_wlan,
9836 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309837 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -07009838#ifdef WLAN_NL80211_TESTMODE
9839 .testmode_cmd = wlan_hdd_cfg80211_testmode,
9840#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309841 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009842};
9843