blob: 96d4c95c685922bd1ed8e8ae22c1d73d32ec9ce4 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lamaa8e15a2014-02-11 23:30:06 -080023 * Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
24 * All Rights Reserved.
25 * Qualcomm Atheros Confidential and Proprietary.
Kiet Lam842dad02014-02-18 18:44:02 -080026 *
Kiet Lamaa8e15a2014-02-11 23:30:06 -080027 */
Kiet Lam842dad02014-02-18 18:44:02 -080028
29
Jeff Johnson295189b2012-06-20 16:38:30 -070030/**========================================================================
31
32 \file wlan_hdd_cfg80211.c
33
34 \brief WLAN Host Device Driver implementation
35
Jeff Johnson295189b2012-06-20 16:38:30 -070036 ========================================================================*/
37
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070038/**=========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070039
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070040 EDIT HISTORY FOR FILE
Jeff Johnson295189b2012-06-20 16:38:30 -070041
42
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070043 This section contains comments describing changes made to the module.
44 Notice that changes are listed in reverse chronological order.
Jeff Johnson295189b2012-06-20 16:38:30 -070045
46
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070047 $Header:$ $DateTime: $ $Author: $
Jeff Johnson295189b2012-06-20 16:38:30 -070048
49
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070050 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070051 -------- --- --------------------------------------------------------
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070052 21/12/09 Ashwani Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070053
54 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070055 Ganesh K
Jeff Johnson295189b2012-06-20 16:38:30 -070056 ==========================================================================*/
57
Jeff Johnson295189b2012-06-20 16:38:30 -070058
59#include <linux/version.h>
60#include <linux/module.h>
61#include <linux/kernel.h>
62#include <linux/init.h>
63#include <linux/wireless.h>
64#include <wlan_hdd_includes.h>
65#include <net/arp.h>
66#include <net/cfg80211.h>
67#include <linux/wireless.h>
68#include <wlan_hdd_wowl.h>
69#include <aniGlobal.h>
70#include "ccmApi.h"
71#include "sirParams.h"
72#include "dot11f.h"
73#include "wlan_hdd_assoc.h"
74#include "wlan_hdd_wext.h"
75#include "sme_Api.h"
76#include "wlan_hdd_p2p.h"
77#include "wlan_hdd_cfg80211.h"
78#include "wlan_hdd_hostapd.h"
79#include "sapInternal.h"
80#include "wlan_hdd_softap_tx_rx.h"
81#include "wlan_hdd_main.h"
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053082#include "wlan_hdd_assoc.h"
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053083#include "wlan_hdd_power.h"
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053084#include "wlan_hdd_trace.h"
85#include "vos_types.h"
86#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070087#ifdef WLAN_BTAMP_FEATURE
88#include "bap_hdd_misc.h"
89#endif
90#include <qc_sap_ioctl.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080091#ifdef FEATURE_WLAN_TDLS
92#include "wlan_hdd_tdls.h"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053093#include "wlan_hdd_wmm.h"
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053094#include "wlan_qct_wda.h"
Mohit Khanna698ba2a2012-12-04 15:08:18 -080095#endif
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053096#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070097#include "wlan_hdd_dev_pwr.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070098
99#define g_mode_rates_size (12)
100#define a_mode_rates_size (8)
101#define FREQ_BASE_80211G (2407)
102#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700103#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +0530104#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -0700105#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
krunal soni2a6a9062014-02-11 14:14:23 -0800106 ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700107
108#define HDD2GHZCHAN(freq, chan, flag) { \
109 .band = IEEE80211_BAND_2GHZ, \
110 .center_freq = (freq), \
111 .hw_value = (chan),\
112 .flags = (flag), \
113 .max_antenna_gain = 0 ,\
114 .max_power = 30, \
115}
116
117#define HDD5GHZCHAN(freq, chan, flag) { \
118 .band = IEEE80211_BAND_5GHZ, \
119 .center_freq = (freq), \
120 .hw_value = (chan),\
121 .flags = (flag), \
122 .max_antenna_gain = 0 ,\
123 .max_power = 30, \
124}
125
126#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
127{\
128 .bitrate = rate, \
129 .hw_value = rate_id, \
130 .flags = flag, \
131}
132
Lee Hoonkic1262f22013-01-24 21:59:00 -0800133#ifndef WLAN_FEATURE_TDLS_DEBUG
134#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_INFO
135#else
136#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_ERROR
137#endif
138
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530139#ifdef WLAN_FEATURE_VOWIFI_11R
140#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
141#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
142#endif
143
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530144#define HDD_CHANNEL_14 14
145
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530146static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700147{
148 WLAN_CIPHER_SUITE_WEP40,
149 WLAN_CIPHER_SUITE_WEP104,
150 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800151#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700152#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
153 WLAN_CIPHER_SUITE_KRK,
154 WLAN_CIPHER_SUITE_CCMP,
155#else
156 WLAN_CIPHER_SUITE_CCMP,
157#endif
158#ifdef FEATURE_WLAN_WAPI
159 WLAN_CIPHER_SUITE_SMS4,
160#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700161#ifdef WLAN_FEATURE_11W
162 WLAN_CIPHER_SUITE_AES_CMAC,
163#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700164};
165
166static inline int is_broadcast_ether_addr(const u8 *addr)
167{
168 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
169 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
170}
171
172static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530173{
Jeff Johnson295189b2012-06-20 16:38:30 -0700174 HDD2GHZCHAN(2412, 1, 0) ,
175 HDD2GHZCHAN(2417, 2, 0) ,
176 HDD2GHZCHAN(2422, 3, 0) ,
177 HDD2GHZCHAN(2427, 4, 0) ,
178 HDD2GHZCHAN(2432, 5, 0) ,
179 HDD2GHZCHAN(2437, 6, 0) ,
180 HDD2GHZCHAN(2442, 7, 0) ,
181 HDD2GHZCHAN(2447, 8, 0) ,
182 HDD2GHZCHAN(2452, 9, 0) ,
183 HDD2GHZCHAN(2457, 10, 0) ,
184 HDD2GHZCHAN(2462, 11, 0) ,
185 HDD2GHZCHAN(2467, 12, 0) ,
186 HDD2GHZCHAN(2472, 13, 0) ,
187 HDD2GHZCHAN(2484, 14, 0) ,
188};
189
Jeff Johnson295189b2012-06-20 16:38:30 -0700190static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
191{
192 HDD2GHZCHAN(2412, 1, 0) ,
193 HDD2GHZCHAN(2437, 6, 0) ,
194 HDD2GHZCHAN(2462, 11, 0) ,
195};
Jeff Johnson295189b2012-06-20 16:38:30 -0700196
197static struct ieee80211_channel hdd_channels_5_GHZ[] =
198{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700199 HDD5GHZCHAN(4920, 240, 0) ,
200 HDD5GHZCHAN(4940, 244, 0) ,
201 HDD5GHZCHAN(4960, 248, 0) ,
202 HDD5GHZCHAN(4980, 252, 0) ,
203 HDD5GHZCHAN(5040, 208, 0) ,
204 HDD5GHZCHAN(5060, 212, 0) ,
205 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700206 HDD5GHZCHAN(5180, 36, 0) ,
207 HDD5GHZCHAN(5200, 40, 0) ,
208 HDD5GHZCHAN(5220, 44, 0) ,
209 HDD5GHZCHAN(5240, 48, 0) ,
210 HDD5GHZCHAN(5260, 52, 0) ,
211 HDD5GHZCHAN(5280, 56, 0) ,
212 HDD5GHZCHAN(5300, 60, 0) ,
213 HDD5GHZCHAN(5320, 64, 0) ,
214 HDD5GHZCHAN(5500,100, 0) ,
215 HDD5GHZCHAN(5520,104, 0) ,
216 HDD5GHZCHAN(5540,108, 0) ,
217 HDD5GHZCHAN(5560,112, 0) ,
218 HDD5GHZCHAN(5580,116, 0) ,
219 HDD5GHZCHAN(5600,120, 0) ,
220 HDD5GHZCHAN(5620,124, 0) ,
221 HDD5GHZCHAN(5640,128, 0) ,
222 HDD5GHZCHAN(5660,132, 0) ,
223 HDD5GHZCHAN(5680,136, 0) ,
224 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800225#ifdef FEATURE_WLAN_CH144
226 HDD5GHZCHAN(5720,144, 0) ,
227#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700228 HDD5GHZCHAN(5745,149, 0) ,
229 HDD5GHZCHAN(5765,153, 0) ,
230 HDD5GHZCHAN(5785,157, 0) ,
231 HDD5GHZCHAN(5805,161, 0) ,
232 HDD5GHZCHAN(5825,165, 0) ,
233};
234
235static struct ieee80211_rate g_mode_rates[] =
236{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530237 HDD_G_MODE_RATETAB(10, 0x1, 0),
238 HDD_G_MODE_RATETAB(20, 0x2, 0),
239 HDD_G_MODE_RATETAB(55, 0x4, 0),
240 HDD_G_MODE_RATETAB(110, 0x8, 0),
241 HDD_G_MODE_RATETAB(60, 0x10, 0),
242 HDD_G_MODE_RATETAB(90, 0x20, 0),
243 HDD_G_MODE_RATETAB(120, 0x40, 0),
244 HDD_G_MODE_RATETAB(180, 0x80, 0),
245 HDD_G_MODE_RATETAB(240, 0x100, 0),
246 HDD_G_MODE_RATETAB(360, 0x200, 0),
247 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700248 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530249};
Jeff Johnson295189b2012-06-20 16:38:30 -0700250
251static struct ieee80211_rate a_mode_rates[] =
252{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530253 HDD_G_MODE_RATETAB(60, 0x10, 0),
254 HDD_G_MODE_RATETAB(90, 0x20, 0),
255 HDD_G_MODE_RATETAB(120, 0x40, 0),
256 HDD_G_MODE_RATETAB(180, 0x80, 0),
257 HDD_G_MODE_RATETAB(240, 0x100, 0),
258 HDD_G_MODE_RATETAB(360, 0x200, 0),
259 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700260 HDD_G_MODE_RATETAB(540, 0x800, 0),
261};
262
263static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
264{
265 .channels = hdd_channels_2_4_GHZ,
266 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
267 .band = IEEE80211_BAND_2GHZ,
268 .bitrates = g_mode_rates,
269 .n_bitrates = g_mode_rates_size,
270 .ht_cap.ht_supported = 1,
271 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
272 | IEEE80211_HT_CAP_GRN_FLD
273 | IEEE80211_HT_CAP_DSSSCCK40
274 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
275 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
276 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
277 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
278 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
279 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
280};
281
Jeff Johnson295189b2012-06-20 16:38:30 -0700282static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
283{
284 .channels = hdd_social_channels_2_4_GHZ,
285 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
286 .band = IEEE80211_BAND_2GHZ,
287 .bitrates = g_mode_rates,
288 .n_bitrates = g_mode_rates_size,
289 .ht_cap.ht_supported = 1,
290 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
291 | IEEE80211_HT_CAP_GRN_FLD
292 | IEEE80211_HT_CAP_DSSSCCK40
293 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
294 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
295 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
296 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
297 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
298 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
299};
Jeff Johnson295189b2012-06-20 16:38:30 -0700300
301static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
302{
303 .channels = hdd_channels_5_GHZ,
304 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
305 .band = IEEE80211_BAND_5GHZ,
306 .bitrates = a_mode_rates,
307 .n_bitrates = a_mode_rates_size,
308 .ht_cap.ht_supported = 1,
309 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
310 | IEEE80211_HT_CAP_GRN_FLD
311 | IEEE80211_HT_CAP_DSSSCCK40
312 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
313 | IEEE80211_HT_CAP_SGI_40
314 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
315 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
316 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
317 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
318 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
319 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
320};
321
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530322/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700323 TX/RX direction for each kind of interface */
324static const struct ieee80211_txrx_stypes
325wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
326 [NL80211_IFTYPE_STATION] = {
327 .tx = 0xffff,
328 .rx = BIT(SIR_MAC_MGMT_ACTION) |
329 BIT(SIR_MAC_MGMT_PROBE_REQ),
330 },
331 [NL80211_IFTYPE_AP] = {
332 .tx = 0xffff,
333 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
334 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
335 BIT(SIR_MAC_MGMT_PROBE_REQ) |
336 BIT(SIR_MAC_MGMT_DISASSOC) |
337 BIT(SIR_MAC_MGMT_AUTH) |
338 BIT(SIR_MAC_MGMT_DEAUTH) |
339 BIT(SIR_MAC_MGMT_ACTION),
340 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700341 [NL80211_IFTYPE_ADHOC] = {
342 .tx = 0xffff,
343 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
344 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
345 BIT(SIR_MAC_MGMT_PROBE_REQ) |
346 BIT(SIR_MAC_MGMT_DISASSOC) |
347 BIT(SIR_MAC_MGMT_AUTH) |
348 BIT(SIR_MAC_MGMT_DEAUTH) |
349 BIT(SIR_MAC_MGMT_ACTION),
350 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700351 [NL80211_IFTYPE_P2P_CLIENT] = {
352 .tx = 0xffff,
353 .rx = BIT(SIR_MAC_MGMT_ACTION) |
354 BIT(SIR_MAC_MGMT_PROBE_REQ),
355 },
356 [NL80211_IFTYPE_P2P_GO] = {
357 /* This is also same as for SoftAP */
358 .tx = 0xffff,
359 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
360 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
361 BIT(SIR_MAC_MGMT_PROBE_REQ) |
362 BIT(SIR_MAC_MGMT_DISASSOC) |
363 BIT(SIR_MAC_MGMT_AUTH) |
364 BIT(SIR_MAC_MGMT_DEAUTH) |
365 BIT(SIR_MAC_MGMT_ACTION),
366 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700367};
368
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800369#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800370static const struct ieee80211_iface_limit
371wlan_hdd_iface_limit[] = {
372 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800373 /* max = 3 ; Our driver create two interfaces during driver init
374 * wlan0 and p2p0 interfaces. p2p0 is considered as station
375 * interface until a group is formed. In JB architecture, once the
376 * group is formed, interface type of p2p0 is changed to P2P GO or
377 * Client.
378 * When supplicant remove the group, it first issue a set interface
379 * cmd to change the mode back to Station. In JB this works fine as
380 * we advertize two station type interface during driver init.
381 * Some vendors create separate interface for P2P GO/Client,
382 * after group formation(Third one). But while group remove
383 * supplicant first tries to change the mode(3rd interface) to STATION
384 * But as we advertized only two sta type interfaces nl80211 was
385 * returning error for the third one which was leading to failure in
386 * delete interface. Ideally while removing the group, supplicant
387 * should not try to change the 3rd interface mode to Station type.
388 * Till we get a fix in wpa_supplicant, we advertize max STA
389 * interface type to 3
390 */
391 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800392 .types = BIT(NL80211_IFTYPE_STATION),
393 },
394 {
395 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700396 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800397 },
398 {
399 .max = 1,
400 .types = BIT(NL80211_IFTYPE_P2P_GO) |
401 BIT(NL80211_IFTYPE_P2P_CLIENT),
402 },
403};
404
405/* By default, only single channel concurrency is allowed */
406static struct ieee80211_iface_combination
407wlan_hdd_iface_combination = {
408 .limits = wlan_hdd_iface_limit,
409 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800410 /*
411 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
412 * and p2p0 interfaces during driver init
413 * Some vendors create separate interface for P2P operations.
414 * wlan0: STA interface
415 * p2p0: P2P Device interface, action frames goes
416 * through this interface.
417 * p2p-xx: P2P interface, After GO negotiation this interface is
418 * created for p2p operations(GO/CLIENT interface).
419 */
420 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800421 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
422 .beacon_int_infra_match = false,
423};
424#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800425
Jeff Johnson295189b2012-06-20 16:38:30 -0700426static struct cfg80211_ops wlan_hdd_cfg80211_ops;
427
428/* Data rate 100KBPS based on IE Index */
429struct index_data_rate_type
430{
431 v_U8_t beacon_rate_index;
432 v_U16_t supported_rate[4];
433};
434
435/* 11B, 11G Rate table include Basic rate and Extended rate
436 The IDX field is the rate index
437 The HI field is the rate when RSSI is strong or being ignored
438 (in this case we report actual rate)
439 The MID field is the rate when RSSI is moderate
440 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
441 The LO field is the rate when RSSI is low
442 (in this case we don't report rates, actual current rate used)
443 */
444static const struct
445{
446 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700447 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700448} supported_data_rate[] =
449{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700450/* IDX HI HM LM LO (RSSI-based index */
451 {2, { 10, 10, 10, 0}},
452 {4, { 20, 20, 10, 0}},
453 {11, { 55, 20, 10, 0}},
454 {12, { 60, 55, 20, 0}},
455 {18, { 90, 55, 20, 0}},
456 {22, {110, 55, 20, 0}},
457 {24, {120, 90, 60, 0}},
458 {36, {180, 120, 60, 0}},
459 {44, {220, 180, 60, 0}},
460 {48, {240, 180, 90, 0}},
461 {66, {330, 180, 90, 0}},
462 {72, {360, 240, 90, 0}},
463 {96, {480, 240, 120, 0}},
464 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700465};
466
467/* MCS Based rate table */
468static struct index_data_rate_type supported_mcs_rate[] =
469{
470/* MCS L20 L40 S20 S40 */
471 {0, {65, 135, 72, 150}},
472 {1, {130, 270, 144, 300}},
473 {2, {195, 405, 217, 450}},
474 {3, {260, 540, 289, 600}},
475 {4, {390, 810, 433, 900}},
476 {5, {520, 1080, 578, 1200}},
477 {6, {585, 1215, 650, 1350}},
478 {7, {650, 1350, 722, 1500}}
479};
480
Leo Chang6f8870f2013-03-26 18:11:36 -0700481#ifdef WLAN_FEATURE_11AC
482
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530483#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700484
485struct index_vht_data_rate_type
486{
487 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530488 v_U16_t supported_VHT80_rate[2];
489 v_U16_t supported_VHT40_rate[2];
490 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700491};
492
493typedef enum
494{
495 DATA_RATE_11AC_MAX_MCS_7,
496 DATA_RATE_11AC_MAX_MCS_8,
497 DATA_RATE_11AC_MAX_MCS_9,
498 DATA_RATE_11AC_MAX_MCS_NA
499} eDataRate11ACMaxMcs;
500
501/* MCS Based VHT rate table */
502static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
503{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530504/* MCS L80 S80 L40 S40 L20 S40*/
505 {0, {293, 325}, {135, 150}, {65, 72}},
506 {1, {585, 650}, {270, 300}, {130, 144}},
507 {2, {878, 975}, {405, 450}, {195, 217}},
508 {3, {1170, 1300}, {540, 600}, {260, 289}},
509 {4, {1755, 1950}, {810, 900}, {390, 433}},
510 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
511 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
512 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
513 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
514 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700515};
516#endif /* WLAN_FEATURE_11AC */
517
Jeff Johnson295189b2012-06-20 16:38:30 -0700518extern struct net_device_ops net_ops_struct;
519
Leo Chang9056f462013-08-01 19:21:11 -0700520#ifdef WLAN_NL80211_TESTMODE
521enum wlan_hdd_tm_attr
522{
523 WLAN_HDD_TM_ATTR_INVALID = 0,
524 WLAN_HDD_TM_ATTR_CMD = 1,
525 WLAN_HDD_TM_ATTR_DATA = 2,
526 WLAN_HDD_TM_ATTR_TYPE = 3,
527 /* keep last */
528 WLAN_HDD_TM_ATTR_AFTER_LAST,
529 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
530};
531
532enum wlan_hdd_tm_cmd
533{
534 WLAN_HDD_TM_CMD_WLAN_HB = 1,
535};
536
537#define WLAN_HDD_TM_DATA_MAX_LEN 5000
538
539static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
540{
541 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
542 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
543 .len = WLAN_HDD_TM_DATA_MAX_LEN },
544};
545#endif /* WLAN_NL80211_TESTMODE */
546
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800547#ifdef FEATURE_WLAN_CH_AVOID
548/*
549 * FUNCTION: wlan_hdd_send_avoid_freq_event
550 * This is called when wlan driver needs to send vendor specific
551 * avoid frequency range event to userspace
552 */
553int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
554 tHddAvoidFreqList *pAvoidFreqList)
555{
556 struct sk_buff *vendor_event;
557
558 ENTER();
559
560 if (!pHddCtx)
561 {
562 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
563 "%s: HDD context is null", __func__);
564 return -1;
565 }
566
567 if (!pAvoidFreqList)
568 {
569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
570 "%s: pAvoidFreqList is null", __func__);
571 return -1;
572 }
573
574 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
575 sizeof(tHddAvoidFreqList),
576 QCOM_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
577 GFP_KERNEL);
578 if (!vendor_event)
579 {
580 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
581 "%s: cfg80211_vendor_event_alloc failed", __func__);
582 return -1;
583 }
584
585 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
586 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
587
588 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
589
590 EXIT();
591 return 0;
592}
593#endif /* FEATURE_WLAN_CH_AVOID */
594
595/* vendor specific events */
596static const struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
597{
598#ifdef FEATURE_WLAN_CH_AVOID
599 {
600 .vendor_id = QCOM_NL80211_VENDOR_ID,
601 .subcmd = QCOM_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
602 },
603#endif /* FEATURE_WLAN_CH_AVOID */
604};
605
Jeff Johnson295189b2012-06-20 16:38:30 -0700606/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530607 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530608 * This function is called by hdd_wlan_startup()
609 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530610 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -0700611 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530612struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -0700613{
614 struct wiphy *wiphy;
615 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530616 /*
617 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -0700618 */
619 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
620
621 if (!wiphy)
622 {
623 /* Print error and jump into err label and free the memory */
624 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
625 return NULL;
626 }
627
628 return wiphy;
629}
630
631/*
632 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530633 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 * private ioctl to change the band value
635 */
636int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
637{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530638 int i, j;
639 eNVChannelEnabledType channelEnabledState;
640
Jeff Johnsone7245742012-09-05 17:12:55 -0700641 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530642
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530643 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700644 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530645
646 if (NULL == wiphy->bands[i])
647 {
648 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
649 __func__, i);
650 continue;
651 }
652
653 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
654 {
655 struct ieee80211_supported_band *band = wiphy->bands[i];
656
657 channelEnabledState = vos_nv_getChannelEnabledState(
658 band->channels[j].hw_value);
659
660 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
661 {
662 // Enable Social channels for P2P
663 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq) &&
664 NV_CHANNEL_ENABLE == channelEnabledState)
665 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
666 else
667 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
668 continue;
669 }
670 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
671 {
672 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
673 continue;
674 }
675
676 if (NV_CHANNEL_DISABLE == channelEnabledState ||
677 NV_CHANNEL_INVALID == channelEnabledState)
678 {
679 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
680 }
681 else if (NV_CHANNEL_DFS == channelEnabledState)
682 {
683 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
684 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
685 }
686 else
687 {
688 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
689 |IEEE80211_CHAN_RADAR);
690 }
691 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700692 }
693 return 0;
694}
695/*
696 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530697 * This function is called by hdd_wlan_startup()
698 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -0700699 * This function is used to initialize and register wiphy structure.
700 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530701int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -0700702 struct wiphy *wiphy,
703 hdd_config_t *pCfg
704 )
705{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530706 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +0530707 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
708
Jeff Johnsone7245742012-09-05 17:12:55 -0700709 ENTER();
710
Jeff Johnson295189b2012-06-20 16:38:30 -0700711 /* Now bind the underlying wlan device with wiphy */
712 set_wiphy_dev(wiphy, dev);
713
714 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -0700715
Kiet Lam6c583332013-10-14 05:37:09 +0530716#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -0700717 /* the flag for the other case would be initialzed in
718 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -0700719 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +0530720#endif
Amar Singhala49cbc52013-10-08 18:37:44 -0700721
Amar Singhalfddc28c2013-09-05 13:03:40 -0700722 /* This will disable updating of NL channels from passive to
723 * active if a beacon is received on passive channel. */
724 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Amar Singhalf0073192013-09-20 12:34:56 -0700725
Amar Singhalfddc28c2013-09-05 13:03:40 -0700726
Amar Singhala49cbc52013-10-08 18:37:44 -0700727
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700728#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -0700729 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
730 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
731 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -0700732 | WIPHY_FLAG_OFFCHAN_TX;
Kiet Lam6c583332013-10-14 05:37:09 +0530733 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700734#endif
Amar Singhala49cbc52013-10-08 18:37:44 -0700735
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800736#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700737 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -0800738#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700739 || pCfg->isFastRoamIniFeatureEnabled
740#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800741#ifdef FEATURE_WLAN_ESE
742 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700743#endif
744 )
745 {
746 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
747 }
James Zmuda77fb5ae2013-01-29 08:00:17 -0800748#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800749#ifdef FEATURE_WLAN_TDLS
750 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
751 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
752#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530753#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +0530754 if (pCfg->configPNOScanSupport)
755 {
756 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
757 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
758 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
759 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
760 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530761#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800762
Amar Singhalfddc28c2013-09-05 13:03:40 -0700763#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700764 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
765 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -0700766 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700767 driver need to determine what to do with both
768 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -0700769
770 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -0700771#else
772 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -0700773#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700774
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530775 wiphy->max_scan_ssids = MAX_SCAN_SSID;
776
Madan Mohan Koyyalamudi6815b162013-07-19 17:17:46 +0530777 wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700778
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +0530779 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
780
Jeff Johnson295189b2012-06-20 16:38:30 -0700781 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530782 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -0700783 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -0700784 | BIT(NL80211_IFTYPE_P2P_CLIENT)
785 | BIT(NL80211_IFTYPE_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -0700786 | BIT(NL80211_IFTYPE_AP);
787
Rashmi Ramannabd3feb72014-02-25 16:14:48 +0530788 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800789 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +0530790#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
791 if( pCfg->enableMCC )
792 {
793 /* Currently, supports up to two channels */
794 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800795
Rashmi Ramannabd3feb72014-02-25 16:14:48 +0530796 if( !pCfg->allowMCCGODiffBI )
797 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800798
Rashmi Ramannabd3feb72014-02-25 16:14:48 +0530799 }
800 wiphy->iface_combinations = &wlan_hdd_iface_combination;
801 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800802#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +0530803 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800804
Jeff Johnson295189b2012-06-20 16:38:30 -0700805 /* Before registering we need to update the ht capabilitied based
806 * on ini values*/
807 if( !pCfg->ShortGI20MhzEnable )
808 {
809 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
810 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
811 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
812 }
813
814 if( !pCfg->ShortGI40MhzEnable )
815 {
816 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
817 }
818
819 if( !pCfg->nChannelBondingMode5GHz )
820 {
821 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
822 }
823
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530824 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +0530825 if (true == hdd_is_5g_supported(pHddCtx))
826 {
827 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
828 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530829
830 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
831 {
832
833 if (NULL == wiphy->bands[i])
834 {
835 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
836 __func__, i);
837 continue;
838 }
839
840 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
841 {
842 struct ieee80211_supported_band *band = wiphy->bands[i];
843
844 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
845 {
846 // Enable social channels for P2P
847 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
848 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
849 else
850 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
851 continue;
852 }
853 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
854 {
855 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
856 continue;
857 }
858 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 }
860 /*Initialise the supported cipher suite details*/
861 wiphy->cipher_suites = hdd_cipher_suites;
862 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
863
864 /*signal strength in mBm (100*dBm) */
865 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
866
867#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 wiphy->max_remain_on_channel_duration = 1000;
869#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700870
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800871 wiphy->n_vendor_commands = 0;
872 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
873 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
874
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530875 EXIT();
876 return 0;
877}
878
879/* In this function we are registering wiphy. */
880int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
881{
882 ENTER();
883 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700884 if (0 > wiphy_register(wiphy))
885 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530886 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -0700887 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
888 return -EIO;
889 }
890
891 EXIT();
892 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530893}
Jeff Johnson295189b2012-06-20 16:38:30 -0700894
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530895/* In this function we are updating channel list when,
896 regulatory domain is FCC and country code is US.
897 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
898 As per FCC smart phone is not a indoor device.
899 GO should not opeate on indoor channels */
900void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
901{
902 int j;
903 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
904 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
905 //Default counrtycode from NV at the time of wiphy initialization.
906 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
907 &defaultCountryCode[0]))
908 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700909 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530910 }
911 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
912 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530913 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
914 {
915 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
916 return;
917 }
918 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
919 {
920 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
921 // Mark UNII -1 band channel as passive
922 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
923 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
924 }
925 }
926}
927
Jeff Johnson295189b2012-06-20 16:38:30 -0700928/* In this function we will do all post VOS start initialization.
929 In this function we will register for all frame in which supplicant
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530930 is interested.
Jeff Johnson295189b2012-06-20 16:38:30 -0700931*/
932void wlan_hdd_cfg80211_post_voss_start(hdd_adapter_t* pAdapter)
933{
Jeff Johnson295189b2012-06-20 16:38:30 -0700934 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
935 /* Register for all P2P action, public action etc frames */
936 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
937
Jeff Johnsone7245742012-09-05 17:12:55 -0700938 ENTER();
939
Jeff Johnson295189b2012-06-20 16:38:30 -0700940 /* Right now we are registering these frame when driver is getting
941 initialized. Once we will move to 2.6.37 kernel, in which we have
942 frame register ops, we will move this code as a part of that */
943 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530944 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -0700945 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
946
947 /* GAS Initial Response */
948 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
949 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530950
Jeff Johnson295189b2012-06-20 16:38:30 -0700951 /* GAS Comeback Request */
952 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
953 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
954
955 /* GAS Comeback Response */
956 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
957 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
958
959 /* P2P Public Action */
960 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530961 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700962 P2P_PUBLIC_ACTION_FRAME_SIZE );
963
964 /* P2P Action */
965 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
966 (v_U8_t*)P2P_ACTION_FRAME,
967 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700968
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +0530969 /* WNM BSS Transition Request frame */
970 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
971 (v_U8_t*)WNM_BSS_ACTION_FRAME,
972 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -0700973
974 /* WNM-Notification */
975 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
976 (v_U8_t*)WNM_NOTIFICATION_FRAME,
977 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700978}
979
980void wlan_hdd_cfg80211_pre_voss_stop(hdd_adapter_t* pAdapter)
981{
Jeff Johnson295189b2012-06-20 16:38:30 -0700982 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
983 /* Register for all P2P action, public action etc frames */
984 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
985
Jeff Johnsone7245742012-09-05 17:12:55 -0700986 ENTER();
987
Jeff Johnson295189b2012-06-20 16:38:30 -0700988 /* Right now we are registering these frame when driver is getting
989 initialized. Once we will move to 2.6.37 kernel, in which we have
990 frame register ops, we will move this code as a part of that */
991 /* GAS Initial Request */
992
993 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
994 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
995
996 /* GAS Initial Response */
997 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
998 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530999
Jeff Johnson295189b2012-06-20 16:38:30 -07001000 /* GAS Comeback Request */
1001 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
1002 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
1003
1004 /* GAS Comeback Response */
1005 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
1006 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
1007
1008 /* P2P Public Action */
1009 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301010 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07001011 P2P_PUBLIC_ACTION_FRAME_SIZE );
1012
1013 /* P2P Action */
1014 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
1015 (v_U8_t*)P2P_ACTION_FRAME,
1016 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07001017 /* WNM-Notification */
1018 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
1019 (v_U8_t*)WNM_NOTIFICATION_FRAME,
1020 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07001021}
1022
1023#ifdef FEATURE_WLAN_WAPI
1024void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
1025 const u8 *mac_addr, u8 *key , int key_Len)
1026{
1027 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1028 tCsrRoamSetKey setKey;
1029 v_BOOL_t isConnected = TRUE;
1030 int status = 0;
1031 v_U32_t roamId= 0xFF;
1032 tANI_U8 *pKeyPtr = NULL;
1033 int n = 0;
1034
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05301035 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
1036 __func__, hdd_device_modetoString(pAdapter->device_mode),
1037 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001038
Gopichand Nakkalae7480202013-02-11 15:24:22 +05301039 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07001040 setKey.keyId = key_index; // Store Key ID
1041 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
1042 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
1043 setKey.paeRole = 0 ; // the PAE role
1044 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
1045 {
1046 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
1047 }
1048 else
1049 {
1050 isConnected = hdd_connIsConnected(pHddStaCtx);
1051 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
1052 }
1053 setKey.keyLength = key_Len;
1054 pKeyPtr = setKey.Key;
1055 memcpy( pKeyPtr, key, key_Len);
1056
Arif Hussain6d2a3322013-11-17 19:50:10 -08001057 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07001058 __func__, key_Len);
1059 for (n = 0 ; n < key_Len; n++)
1060 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
1061 __func__,n,setKey.Key[n]);
1062
1063 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
1064 if ( isConnected )
1065 {
1066 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
1067 pAdapter->sessionId, &setKey, &roamId );
1068 }
1069 if ( status != 0 )
1070 {
1071 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1072 "[%4d] sme_RoamSetKey returned ERROR status= %d",
1073 __LINE__, status );
1074 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1075 }
1076}
1077#endif /* FEATURE_WLAN_WAPI*/
1078
1079#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301080int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001081 beacon_data_t **ppBeacon,
1082 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001083#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301084int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001085 beacon_data_t **ppBeacon,
1086 struct cfg80211_beacon_data *params,
1087 int dtim_period)
1088#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301089{
Jeff Johnson295189b2012-06-20 16:38:30 -07001090 int size;
1091 beacon_data_t *beacon = NULL;
1092 beacon_data_t *old = NULL;
1093 int head_len,tail_len;
1094
Jeff Johnsone7245742012-09-05 17:12:55 -07001095 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001096 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301097 {
1098 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1099 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001100 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301101 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001102
1103 old = pAdapter->sessionCtx.ap.beacon;
1104
1105 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301106 {
1107 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1108 FL("session(%d) old and new heads points to NULL"),
1109 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001110 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301111 }
1112
1113 if (params->tail && !params->tail_len)
1114 {
1115 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1116 FL("tail_len is zero but tail is not NULL"));
1117 return -EINVAL;
1118 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001119
Jeff Johnson295189b2012-06-20 16:38:30 -07001120#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
1121 /* Kernel 3.0 is not updating dtim_period for set beacon */
1122 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301123 {
1124 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1125 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001126 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301127 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001128#endif
1129
1130 if(params->head)
1131 head_len = params->head_len;
1132 else
1133 head_len = old->head_len;
1134
1135 if(params->tail || !old)
1136 tail_len = params->tail_len;
1137 else
1138 tail_len = old->tail_len;
1139
1140 size = sizeof(beacon_data_t) + head_len + tail_len;
1141
1142 beacon = kzalloc(size, GFP_KERNEL);
1143
1144 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301145 {
1146 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1147 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001148 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301149 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001150
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001151#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001152 if(params->dtim_period || !old )
1153 beacon->dtim_period = params->dtim_period;
1154 else
1155 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001156#else
1157 if(dtim_period || !old )
1158 beacon->dtim_period = dtim_period;
1159 else
1160 beacon->dtim_period = old->dtim_period;
1161#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301162
Jeff Johnson295189b2012-06-20 16:38:30 -07001163 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
1164 beacon->tail = beacon->head + head_len;
1165 beacon->head_len = head_len;
1166 beacon->tail_len = tail_len;
1167
1168 if(params->head) {
1169 memcpy (beacon->head,params->head,beacon->head_len);
1170 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301171 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001172 if(old)
1173 memcpy (beacon->head,old->head,beacon->head_len);
1174 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301175
Jeff Johnson295189b2012-06-20 16:38:30 -07001176 if(params->tail) {
1177 memcpy (beacon->tail,params->tail,beacon->tail_len);
1178 }
1179 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301180 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07001181 memcpy (beacon->tail,old->tail,beacon->tail_len);
1182 }
1183
1184 *ppBeacon = beacon;
1185
1186 kfree(old);
1187
1188 return 0;
1189
1190}
Jeff Johnson295189b2012-06-20 16:38:30 -07001191
1192v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
1193{
1194 int left = length;
1195 v_U8_t *ptr = pIes;
1196 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301197
Jeff Johnson295189b2012-06-20 16:38:30 -07001198 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301199 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001200 elem_id = ptr[0];
1201 elem_len = ptr[1];
1202 left -= 2;
1203 if(elem_len > left)
1204 {
1205 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001206 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001207 eid,elem_len,left);
1208 return NULL;
1209 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301210 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07001211 {
1212 return ptr;
1213 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301214
Jeff Johnson295189b2012-06-20 16:38:30 -07001215 left -= elem_len;
1216 ptr += (elem_len + 2);
1217 }
1218 return NULL;
1219}
1220
Jeff Johnson295189b2012-06-20 16:38:30 -07001221/* Check if rate is 11g rate or not */
1222static int wlan_hdd_rate_is_11g(u8 rate)
1223{
Sanjay Devnani28322e22013-06-21 16:13:40 -07001224 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001225 u8 i;
1226 for (i = 0; i < 8; i++)
1227 {
1228 if(rate == gRateArray[i])
1229 return TRUE;
1230 }
1231 return FALSE;
1232}
1233
1234/* Check for 11g rate and set proper 11g only mode */
1235static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
1236 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
1237{
1238 u8 i, num_rates = pIe[0];
1239
1240 pIe += 1;
1241 for ( i = 0; i < num_rates; i++)
1242 {
1243 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
1244 {
1245 /* If rate set have 11g rate than change the mode to 11G */
1246 *pSapHw_mode = eSAP_DOT11_MODE_11g;
1247 if (pIe[i] & BASIC_RATE_MASK)
1248 {
1249 /* If we have 11g rate as basic rate, it means mode
1250 is 11g only mode.
1251 */
1252 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
1253 *pCheckRatesfor11g = FALSE;
1254 }
1255 }
1256 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
1257 {
1258 *require_ht = TRUE;
1259 }
1260 }
1261 return;
1262}
1263
1264static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
1265{
1266 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1267 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1268 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1269 u8 checkRatesfor11g = TRUE;
1270 u8 require_ht = FALSE;
1271 u8 *pIe=NULL;
1272
1273 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
1274
1275 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
1276 pBeacon->head_len, WLAN_EID_SUPP_RATES);
1277 if (pIe != NULL)
1278 {
1279 pIe += 1;
1280 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1281 &pConfig->SapHw_mode);
1282 }
1283
1284 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1285 WLAN_EID_EXT_SUPP_RATES);
1286 if (pIe != NULL)
1287 {
1288
1289 pIe += 1;
1290 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1291 &pConfig->SapHw_mode);
1292 }
1293
1294 if( pConfig->channel > 14 )
1295 {
1296 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
1297 }
1298
1299 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1300 WLAN_EID_HT_CAPABILITY);
1301
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301302 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001303 {
1304 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
1305 if(require_ht)
1306 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
1307 }
1308}
1309
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301310static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
1311 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
1312{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001313 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301314 v_U8_t *pIe = NULL;
1315 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1316
1317 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
1318 pBeacon->tail, pBeacon->tail_len);
1319
1320 if (pIe)
1321 {
1322 ielen = pIe[1] + 2;
1323 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1324 {
1325 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
1326 }
1327 else
1328 {
1329 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
1330 return -EINVAL;
1331 }
1332 *total_ielen += ielen;
1333 }
1334 return 0;
1335}
1336
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001337static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
1338 v_U8_t *genie, v_U8_t *total_ielen)
1339{
1340 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1341 int left = pBeacon->tail_len;
1342 v_U8_t *ptr = pBeacon->tail;
1343 v_U8_t elem_id, elem_len;
1344 v_U16_t ielen = 0;
1345
1346 if ( NULL == ptr || 0 == left )
1347 return;
1348
1349 while (left >= 2)
1350 {
1351 elem_id = ptr[0];
1352 elem_len = ptr[1];
1353 left -= 2;
1354 if (elem_len > left)
1355 {
1356 hddLog( VOS_TRACE_LEVEL_ERROR,
1357 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
1358 elem_id, elem_len, left);
1359 return;
1360 }
1361 if (IE_EID_VENDOR == elem_id)
1362 {
1363 /* skipping the VSIE's which we don't want to include or
1364 * it will be included by existing code
1365 */
1366 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
1367#ifdef WLAN_FEATURE_WFD
1368 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
1369#endif
1370 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1371 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1372 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
1373 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1374 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
1375 {
1376 ielen = ptr[1] + 2;
1377 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1378 {
1379 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
1380 *total_ielen += ielen;
1381 }
1382 else
1383 {
1384 hddLog( VOS_TRACE_LEVEL_ERROR,
1385 "IE Length is too big "
1386 "IEs eid=%d elem_len=%d total_ie_lent=%d",
1387 elem_id, elem_len, *total_ielen);
1388 }
1389 }
1390 }
1391
1392 left -= elem_len;
1393 ptr += (elem_len + 2);
1394 }
1395 return;
1396}
1397
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001398#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001399static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1400 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001401#else
1402static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1403 struct cfg80211_beacon_data *params)
1404#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001405{
1406 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301407 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001408 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07001409 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001410
1411 genie = vos_mem_malloc(MAX_GENIE_LEN);
1412
1413 if(genie == NULL) {
1414
1415 return -ENOMEM;
1416 }
1417
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301418 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1419 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001420 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301421 hddLog(LOGE,
1422 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301423 ret = -EINVAL;
1424 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001425 }
1426
1427#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301428 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1429 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
1430 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301431 hddLog(LOGE,
1432 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301433 ret = -EINVAL;
1434 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001435 }
1436#endif
1437
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301438 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1439 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001440 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301441 hddLog(LOGE,
1442 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301443 ret = -EINVAL;
1444 goto done;
1445 }
1446
1447 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
1448 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001449 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001450 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001451
1452 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1453 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
1454 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
1455 {
1456 hddLog(LOGE,
1457 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001458 ret = -EINVAL;
1459 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001460 }
1461
1462 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1463 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
1464 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1465 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1466 ==eHAL_STATUS_FAILURE)
1467 {
1468 hddLog(LOGE,
1469 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001470 ret = -EINVAL;
1471 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001472 }
1473
1474 // Added for ProResp IE
1475 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
1476 {
1477 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
1478 u8 probe_rsp_ie_len[3] = {0};
1479 u8 counter = 0;
1480 /* Check Probe Resp Length if it is greater then 255 then Store
1481 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
1482 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
1483 Store More then 255 bytes into One Variable.
1484 */
1485 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
1486 {
1487 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
1488 {
1489 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
1490 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
1491 }
1492 else
1493 {
1494 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
1495 rem_probe_resp_ie_len = 0;
1496 }
1497 }
1498
1499 rem_probe_resp_ie_len = 0;
1500
1501 if (probe_rsp_ie_len[0] > 0)
1502 {
1503 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1504 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
1505 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1506 probe_rsp_ie_len[0], NULL,
1507 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1508 {
1509 hddLog(LOGE,
1510 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001511 ret = -EINVAL;
1512 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001513 }
1514 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
1515 }
1516
1517 if (probe_rsp_ie_len[1] > 0)
1518 {
1519 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1520 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
1521 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1522 probe_rsp_ie_len[1], NULL,
1523 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1524 {
1525 hddLog(LOGE,
1526 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001527 ret = -EINVAL;
1528 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001529 }
1530 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
1531 }
1532
1533 if (probe_rsp_ie_len[2] > 0)
1534 {
1535 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1536 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
1537 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1538 probe_rsp_ie_len[2], NULL,
1539 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1540 {
1541 hddLog(LOGE,
1542 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001543 ret = -EINVAL;
1544 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001545 }
1546 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
1547 }
1548
1549 if (probe_rsp_ie_len[1] == 0 )
1550 {
1551 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1552 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
1553 eANI_BOOLEAN_FALSE) )
1554 {
1555 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001556 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 }
1558 }
1559
1560 if (probe_rsp_ie_len[2] == 0 )
1561 {
1562 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1563 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
1564 eANI_BOOLEAN_FALSE) )
1565 {
1566 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001567 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07001568 }
1569 }
1570
1571 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1572 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
1573 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1574 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1575 == eHAL_STATUS_FAILURE)
1576 {
1577 hddLog(LOGE,
1578 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001579 ret = -EINVAL;
1580 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001581 }
1582 }
1583 else
1584 {
1585 // Reset WNI_CFG_PROBE_RSP Flags
1586 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
1587
1588 hddLog(VOS_TRACE_LEVEL_INFO,
1589 "%s: No Probe Response IE received in set beacon",
1590 __func__);
1591 }
1592
1593 // Added for AssocResp IE
1594 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
1595 {
1596 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1597 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
1598 params->assocresp_ies_len, NULL,
1599 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1600 {
1601 hddLog(LOGE,
1602 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001603 ret = -EINVAL;
1604 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001605 }
1606
1607 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1608 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
1609 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1610 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1611 == eHAL_STATUS_FAILURE)
1612 {
1613 hddLog(LOGE,
1614 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001615 ret = -EINVAL;
1616 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001617 }
1618 }
1619 else
1620 {
1621 hddLog(VOS_TRACE_LEVEL_INFO,
1622 "%s: No Assoc Response IE received in set beacon",
1623 __func__);
1624
1625 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1626 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
1627 eANI_BOOLEAN_FALSE) )
1628 {
1629 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001630 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07001631 }
1632 }
1633
Jeff Johnsone7245742012-09-05 17:12:55 -07001634done:
Jeff Johnson295189b2012-06-20 16:38:30 -07001635 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301636 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001637}
Jeff Johnson295189b2012-06-20 16:38:30 -07001638
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301639/*
Jeff Johnson295189b2012-06-20 16:38:30 -07001640 * FUNCTION: wlan_hdd_validate_operation_channel
1641 * called by wlan_hdd_cfg80211_start_bss() and
1642 * wlan_hdd_cfg80211_set_channel()
1643 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301644 * channel list.
1645 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001646VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001647{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301648
Jeff Johnson295189b2012-06-20 16:38:30 -07001649 v_U32_t num_ch = 0;
1650 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1651 u32 indx = 0;
1652 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301653 v_U8_t fValidChannel = FALSE, count = 0;
1654 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301655
Jeff Johnson295189b2012-06-20 16:38:30 -07001656 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1657
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301658 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001659 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301660 /* Validate the channel */
1661 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001662 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301663 if ( channel == rfChannels[count].channelNum )
1664 {
1665 fValidChannel = TRUE;
1666 break;
1667 }
1668 }
1669 if (fValidChannel != TRUE)
1670 {
1671 hddLog(VOS_TRACE_LEVEL_ERROR,
1672 "%s: Invalid Channel [%d]", __func__, channel);
1673 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001674 }
1675 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301676 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001677 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301678 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1679 valid_ch, &num_ch))
1680 {
1681 hddLog(VOS_TRACE_LEVEL_ERROR,
1682 "%s: failed to get valid channel list", __func__);
1683 return VOS_STATUS_E_FAILURE;
1684 }
1685 for (indx = 0; indx < num_ch; indx++)
1686 {
1687 if (channel == valid_ch[indx])
1688 {
1689 break;
1690 }
1691 }
1692
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05301693 if (indx >= num_ch)
1694 {
1695 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
1696 {
1697 eCsrBand band;
1698 unsigned int freq;
1699
1700 sme_GetFreqBand(hHal, &band);
1701
1702 if (eCSR_BAND_5G == band)
1703 {
1704#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
1705 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
1706 {
1707 freq = ieee80211_channel_to_frequency(channel,
1708 IEEE80211_BAND_2GHZ);
1709 }
1710 else
1711 {
1712 freq = ieee80211_channel_to_frequency(channel,
1713 IEEE80211_BAND_5GHZ);
1714 }
1715#else
1716 freq = ieee80211_channel_to_frequency(channel);
1717#endif
1718 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
1719 return VOS_STATUS_SUCCESS;
1720 }
1721 }
1722
1723 hddLog(VOS_TRACE_LEVEL_ERROR,
1724 "%s: Invalid Channel [%d]", __func__, channel);
1725 return VOS_STATUS_E_FAILURE;
1726 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001727 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05301728
Jeff Johnson295189b2012-06-20 16:38:30 -07001729 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301730
Jeff Johnson295189b2012-06-20 16:38:30 -07001731}
1732
Viral Modi3a32cc52013-02-08 11:14:52 -08001733/**
1734 * FUNCTION: wlan_hdd_cfg80211_set_channel
1735 * This function is used to set the channel number
1736 */
1737static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
1738 struct ieee80211_channel *chan,
1739 enum nl80211_channel_type channel_type
1740 )
1741{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05301742 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08001743 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07001744 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08001745 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301746 hdd_context_t *pHddCtx;
1747 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001748
1749 ENTER();
1750
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05301751
Viral Modi3a32cc52013-02-08 11:14:52 -08001752 if( NULL == dev )
1753 {
1754 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001755 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08001756 return -ENODEV;
1757 }
1758 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
1759
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05301760 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
1761 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
1762 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08001763 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05301764 "%s: device_mode = %s (%d) freq = %d", __func__,
1765 hdd_device_modetoString(pAdapter->device_mode),
1766 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301767
1768 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1769 status = wlan_hdd_validate_context(pHddCtx);
1770
1771 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08001772 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301773 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1774 "%s: HDD context is not valid", __func__);
1775 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001776 }
1777
1778 /*
1779 * Do freq to chan conversion
1780 * TODO: for 11a
1781 */
1782
1783 channel = ieee80211_frequency_to_channel(freq);
1784
1785 /* Check freq range */
1786 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
1787 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
1788 {
1789 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001790 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08001791 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
1792 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1793 return -EINVAL;
1794 }
1795
1796 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1797
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05301798 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
1799 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08001800 {
1801 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
1802 {
1803 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001804 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08001805 return -EINVAL;
1806 }
1807 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1808 "%s: set channel to [%d] for device mode =%d",
1809 __func__, channel,pAdapter->device_mode);
1810 }
1811 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08001812 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08001813 )
1814 {
1815 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1816 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
1817 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1818
1819 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
1820 {
1821 /* Link is up then return cant set channel*/
1822 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001823 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08001824 return -EINVAL;
1825 }
1826
1827 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
1828 pHddStaCtx->conn_info.operationChannel = channel;
1829 pRoamProfile->ChannelInfo.ChannelList =
1830 &pHddStaCtx->conn_info.operationChannel;
1831 }
1832 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08001833 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08001834 )
1835 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301836 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
1837 {
1838 if(VOS_STATUS_SUCCESS !=
1839 wlan_hdd_validate_operation_channel(pAdapter,channel))
1840 {
1841 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001842 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301843 return -EINVAL;
1844 }
1845 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1846 }
1847 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08001848 {
1849 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1850
1851 /* If auto channel selection is configured as enable/ 1 then ignore
1852 channel set by supplicant
1853 */
1854 if ( cfg_param->apAutoChannelSelection )
1855 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301856 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
1857 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08001858 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05301859 "%s: set channel to auto channel (0) for device mode =%s (%d)",
1860 __func__, hdd_device_modetoString(pAdapter->device_mode),
1861 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08001862 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301863 else
1864 {
1865 if(VOS_STATUS_SUCCESS !=
1866 wlan_hdd_validate_operation_channel(pAdapter,channel))
1867 {
1868 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001869 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301870 return -EINVAL;
1871 }
1872 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1873 }
Viral Modi3a32cc52013-02-08 11:14:52 -08001874 }
1875 }
1876 else
1877 {
1878 hddLog(VOS_TRACE_LEVEL_FATAL,
1879 "%s: Invalid device mode failed to set valid channel", __func__);
1880 return -EINVAL;
1881 }
1882 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301883 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001884}
1885
Jeff Johnson295189b2012-06-20 16:38:30 -07001886#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
1887static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1888 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001889#else
1890static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1891 struct cfg80211_beacon_data *params,
1892 const u8 *ssid, size_t ssid_len,
1893 enum nl80211_hidden_ssid hidden_ssid)
1894#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001895{
1896 tsap_Config_t *pConfig;
1897 beacon_data_t *pBeacon = NULL;
1898 struct ieee80211_mgmt *pMgmt_frame;
1899 v_U8_t *pIe=NULL;
1900 v_U16_t capab_info;
1901 eCsrAuthType RSNAuthType;
1902 eCsrEncryptionType RSNEncryptType;
1903 eCsrEncryptionType mcRSNEncryptType;
1904 int status = VOS_STATUS_SUCCESS;
1905 tpWLAN_SAPEventCB pSapEventCallback;
1906 hdd_hostapd_state_t *pHostapdState;
1907 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
1908 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301909 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001910 struct qc_mac_acl_entry *acl_entry = NULL;
1911 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08001912 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Chet Lanctot8cecea22014-02-11 19:09:36 -08001913 v_BOOL_t MFPCapable;
1914 v_BOOL_t MFPRequired;
Abhishek Singhf0ac1752014-03-05 17:47:09 +05301915 eHddDot11Mode sapDot11Mode =
1916 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001917
1918 ENTER();
1919
1920 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
1921
1922 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1923
1924 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1925
1926 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1927
1928 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
1929
1930 //channel is already set in the set_channel Call back
1931 //pConfig->channel = pCommitConfig->channel;
1932
1933 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301934 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07001935 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
1936
1937 pConfig->dtim_period = pBeacon->dtim_period;
1938
Arif Hussain6d2a3322013-11-17 19:50:10 -08001939 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07001940 pConfig->dtim_period);
1941
1942
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08001943 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07001944 {
1945 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001946 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05301947 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
1948 {
1949 tANI_BOOLEAN restartNeeded;
1950 pConfig->ieee80211d = 1;
1951 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
1952 sme_setRegInfo(hHal, pConfig->countryCode);
1953 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
1954 }
1955 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001956 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07001957 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07001958 pConfig->ieee80211d = 1;
1959 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
1960 sme_setRegInfo(hHal, pConfig->countryCode);
1961 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07001962 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001963 else
1964 {
1965 pConfig->ieee80211d = 0;
1966 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301967 /*
1968 * If auto channel is configured i.e. channel is 0,
1969 * so skip channel validation.
1970 */
1971 if( AUTO_CHANNEL_SELECT != pConfig->channel )
1972 {
1973 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
1974 {
1975 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001976 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301977 return -EINVAL;
1978 }
1979 }
1980 else
1981 {
1982 if(1 != pHddCtx->is_dynamic_channel_range_set)
1983 {
1984 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
1985 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
1986 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
1987 }
1988 pHddCtx->is_dynamic_channel_range_set = 0;
1989 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001990 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001991 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001992 {
1993 pConfig->ieee80211d = 0;
1994 }
1995 pConfig->authType = eSAP_AUTO_SWITCH;
1996
1997 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301998
1999 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07002000 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
2001
2002 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
2003
2004 /*Set wps station to configured*/
2005 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
2006
2007 if(pIe)
2008 {
2009 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
2010 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002011 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07002012 return -EINVAL;
2013 }
2014 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
2015 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002016 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07002017 /* Check 15 bit of WPS IE as it contain information for wps state
2018 * WPS state
2019 */
2020 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
2021 {
2022 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
2023 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
2024 {
2025 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
2026 }
2027 }
2028 }
2029 else
2030 {
2031 pConfig->wps_state = SAP_WPS_DISABLED;
2032 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302033 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07002034
2035 pConfig->RSNWPAReqIELength = 0;
2036 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302037 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07002038 WLAN_EID_RSN);
2039 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302040 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002041 pConfig->RSNWPAReqIELength = pIe[1] + 2;
2042 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
2043 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302044 /* The actual processing may eventually be more extensive than
2045 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07002046 * by the app.
2047 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302048 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07002049 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
2050 &RSNEncryptType,
2051 &mcRSNEncryptType,
2052 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08002053 &MFPCapable,
2054 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07002055 pConfig->pRSNWPAReqIE[1]+2,
2056 pConfig->pRSNWPAReqIE );
2057
2058 if( VOS_STATUS_SUCCESS == status )
2059 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302060 /* Now copy over all the security attributes you have
2061 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07002062 * */
2063 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
2064 pConfig->mcRSNEncryptType = mcRSNEncryptType;
2065 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
2066 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05302067 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002068 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002069 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
2070 }
2071 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302072
Jeff Johnson295189b2012-06-20 16:38:30 -07002073 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
2074 pBeacon->tail, pBeacon->tail_len);
2075
2076 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
2077 {
2078 if (pConfig->pRSNWPAReqIE)
2079 {
2080 /*Mixed mode WPA/WPA2*/
2081 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
2082 pConfig->RSNWPAReqIELength += pIe[1] + 2;
2083 }
2084 else
2085 {
2086 pConfig->RSNWPAReqIELength = pIe[1] + 2;
2087 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
2088 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302089 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07002090 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
2091 &RSNEncryptType,
2092 &mcRSNEncryptType,
2093 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08002094 &MFPCapable,
2095 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07002096 pConfig->pRSNWPAReqIE[1]+2,
2097 pConfig->pRSNWPAReqIE );
2098
2099 if( VOS_STATUS_SUCCESS == status )
2100 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302101 /* Now copy over all the security attributes you have
2102 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07002103 * */
2104 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
2105 pConfig->mcRSNEncryptType = mcRSNEncryptType;
2106 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
2107 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05302108 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002109 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002110 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
2111 }
2112 }
2113 }
2114
Jeff Johnson4416a782013-03-25 14:17:50 -07002115 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
2116 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
2117 return -EINVAL;
2118 }
2119
Jeff Johnson295189b2012-06-20 16:38:30 -07002120 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
2121
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002122#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002123 if (params->ssid != NULL)
2124 {
2125 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
2126 pConfig->SSIDinfo.ssid.length = params->ssid_len;
2127 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
2128 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
2129 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002130#else
2131 if (ssid != NULL)
2132 {
2133 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
2134 pConfig->SSIDinfo.ssid.length = ssid_len;
2135 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
2136 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
2137 }
2138#endif
2139
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302140 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07002141 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302142
Jeff Johnson295189b2012-06-20 16:38:30 -07002143 /* default value */
2144 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
2145 pConfig->num_accept_mac = 0;
2146 pConfig->num_deny_mac = 0;
2147
2148 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
2149 pBeacon->tail, pBeacon->tail_len);
2150
2151 /* pIe for black list is following form:
2152 type : 1 byte
2153 length : 1 byte
2154 OUI : 4 bytes
2155 acl type : 1 byte
2156 no of mac addr in black list: 1 byte
2157 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302158 */
2159 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002160 {
2161 pConfig->SapMacaddr_acl = pIe[6];
2162 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08002163 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002164 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302165 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
2166 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002167 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
2168 for (i = 0; i < pConfig->num_deny_mac; i++)
2169 {
2170 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
2171 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302172 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002173 }
2174 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
2175 pBeacon->tail, pBeacon->tail_len);
2176
2177 /* pIe for white list is following form:
2178 type : 1 byte
2179 length : 1 byte
2180 OUI : 4 bytes
2181 acl type : 1 byte
2182 no of mac addr in white list: 1 byte
2183 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302184 */
2185 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002186 {
2187 pConfig->SapMacaddr_acl = pIe[6];
2188 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08002189 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002190 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302191 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
2192 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002193 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
2194 for (i = 0; i < pConfig->num_accept_mac; i++)
2195 {
2196 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
2197 acl_entry++;
2198 }
2199 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302200
Jeff Johnson295189b2012-06-20 16:38:30 -07002201 wlan_hdd_set_sapHwmode(pHostapdAdapter);
2202
Jeff Johnsone7245742012-09-05 17:12:55 -07002203#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002204 /* Overwrite the hostapd setting for HW mode only for 11ac.
Kiet Lam0f320422013-11-21 19:29:17 +05302205 * This is valid only if mode is set to 11n in hostapd, either AUTO or
2206 * 11ac in .ini and 11ac is supported by both host and firmware.
2207 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
2208 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002209 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
2210 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Abhishek Singhf0ac1752014-03-05 17:47:09 +05302211 (( sapDot11Mode == eHDD_DOT11_MODE_AUTO ) ||
2212 ( sapDot11Mode == eHDD_DOT11_MODE_11ac ) ||
2213 ( sapDot11Mode == eHDD_DOT11_MODE_11ac_ONLY ) ) &&
2214 (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
2215 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07002216 {
2217 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07002218
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05302219 /* Disable VHT support in 2.4 GHz and */
Ravi Joshi83bfaa12013-05-28 22:12:08 -07002220 if (pConfig->channel <= 14 &&
2221 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->enableVhtFor24GHzBand == FALSE)
2222 {
2223 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
2224 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002225 }
2226#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302227
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07002228 if ( AUTO_CHANNEL_SELECT != pConfig->channel )
2229 {
2230 sme_SelectCBMode(hHal,
2231 sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode),
2232 pConfig->channel);
2233 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002234 // ht_capab is not what the name conveys,this is used for protection bitmap
2235 pConfig->ht_capab =
2236 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
2237
2238 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
2239 {
2240 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
2241 return -EINVAL;
2242 }
2243
2244 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302245 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07002246 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
2247 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302248 pConfig->obssProtEnabled =
2249 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07002250
Chet Lanctot8cecea22014-02-11 19:09:36 -08002251#ifdef WLAN_FEATURE_11W
2252 pConfig->mfpCapable = MFPCapable;
2253 pConfig->mfpRequired = MFPRequired;
2254 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
2255 pConfig->mfpCapable, pConfig->mfpRequired);
2256#endif
2257
Arif Hussain6d2a3322013-11-17 19:50:10 -08002258 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07002259 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08002260 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
2261 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
2262 (int)pConfig->channel);
2263 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
2264 pConfig->SapHw_mode, pConfig->privacy,
2265 pConfig->authType);
2266 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
2267 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
2268 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
2269 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07002270
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302271 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07002272 {
2273 //Bss already started. just return.
2274 //TODO Probably it should update some beacon params.
2275 hddLog( LOGE, "Bss Already started...Ignore the request");
2276 EXIT();
2277 return 0;
2278 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302279
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 pConfig->persona = pHostapdAdapter->device_mode;
2281
2282 pSapEventCallback = hdd_hostapd_SAPEventCB;
2283 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
2284 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
2285 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002286 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002287 return -EINVAL;
2288 }
2289
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302290 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002291 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
2292
2293 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302294
Jeff Johnson295189b2012-06-20 16:38:30 -07002295 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302296 {
2297 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002298 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07002299 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002300 VOS_ASSERT(0);
2301 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302302
Jeff Johnson295189b2012-06-20 16:38:30 -07002303 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
2304
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002305#ifdef WLAN_FEATURE_P2P_DEBUG
2306 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
2307 {
2308 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
2309 {
2310 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2311 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002312 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002313 }
2314 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
2315 {
2316 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2317 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002318 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002319 }
2320 }
2321#endif
2322
Jeff Johnson295189b2012-06-20 16:38:30 -07002323 pHostapdState->bCommit = TRUE;
2324 EXIT();
2325
2326 return 0;
2327}
2328
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002329#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302330static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
2331 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002332 struct beacon_parameters *params)
2333{
2334 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302335 hdd_context_t *pHddCtx;
2336 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002337
2338 ENTER();
2339
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302340 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2341 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
2342 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05302343 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
2344 hdd_device_modetoString(pAdapter->device_mode),
2345 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002346
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302347 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2348 status = wlan_hdd_validate_context(pHddCtx);
2349
2350 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002351 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302352 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2353 "%s: HDD context is not valid", __func__);
2354 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002355 }
2356
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302357 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002358 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002359 )
2360 {
2361 beacon_data_t *old,*new;
2362
2363 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302364
Jeff Johnson295189b2012-06-20 16:38:30 -07002365 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302366 {
2367 hddLog(VOS_TRACE_LEVEL_WARN,
2368 FL("already beacon info added to session(%d)"),
2369 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002370 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302371 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002372
2373 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2374
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302375 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002376 {
2377 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002378 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002379 return -EINVAL;
2380 }
2381
2382 pAdapter->sessionCtx.ap.beacon = new;
2383
2384 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2385 }
2386
2387 EXIT();
2388 return status;
2389}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302390
2391static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07002392 struct net_device *dev,
2393 struct beacon_parameters *params)
2394{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302395 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302396 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302397 hdd_context_t *pHddCtx;
2398 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002399
2400 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302401 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2402 TRACE_CODE_HDD_CFG80211_SET_BEACON,
2403 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05302404 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
2405 __func__, hdd_device_modetoString(pAdapter->device_mode),
2406 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002407
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302408 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2409 status = wlan_hdd_validate_context(pHddCtx);
2410
2411 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002412 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302413 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2414 "%s: HDD context is not valid", __func__);
2415 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002416 }
2417
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302418 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002419 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302420 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002421 {
2422 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302423
Jeff Johnson295189b2012-06-20 16:38:30 -07002424 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302425
Jeff Johnson295189b2012-06-20 16:38:30 -07002426 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302427 {
2428 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2429 FL("session(%d) old and new heads points to NULL"),
2430 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002431 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302432 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002433
2434 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2435
2436 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302437 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002438 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002439 return -EINVAL;
2440 }
2441
2442 pAdapter->sessionCtx.ap.beacon = new;
2443
2444 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2445 }
2446
2447 EXIT();
2448 return status;
2449}
2450
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002451#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
2452
2453#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002454static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
2455 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002456#else
2457static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
2458 struct net_device *dev)
2459#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002460{
2461 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07002462 hdd_context_t *pHddCtx = NULL;
2463 hdd_scaninfo_t *pScanInfo = NULL;
2464 hdd_adapter_t *staAdapter = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302465 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002466
2467 ENTER();
2468
2469 if (NULL == pAdapter)
2470 {
2471 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002472 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002473 return -ENODEV;
2474 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002475
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302476 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2477 TRACE_CODE_HDD_CFG80211_STOP_AP,
2478 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302479 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2480 status = wlan_hdd_validate_context(pHddCtx);
2481
2482 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002483 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302484 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2485 "%s: HDD context is not valid", __func__);
2486 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07002487 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002488
2489 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
2490 if (NULL == staAdapter)
2491 {
2492 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
2493 if (NULL == staAdapter)
2494 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002495 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2496 "%s: HDD adapter context for STA/P2P-CLI is Null",
2497 __func__);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002498 }
2499 }
2500
2501 pScanInfo = &pHddCtx->scan_info;
2502
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05302503 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
2504 __func__, hdd_device_modetoString(pAdapter->device_mode),
2505 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002506
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002507 if ((pScanInfo != NULL) && pScanInfo->mScanPending && staAdapter)
Jeff Johnsone7245742012-09-05 17:12:55 -07002508 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302509 long ret;
2510
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002511 INIT_COMPLETION(pScanInfo->abortscan_event_var);
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05302512 hdd_abort_mac_scan(staAdapter->pHddCtx, pAdapter->sessionId,
2513 eCSR_SCAN_ABORT_DEFAULT);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302514 ret = wait_for_completion_interruptible_timeout(
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002515 &pScanInfo->abortscan_event_var,
Jeff Johnsone7245742012-09-05 17:12:55 -07002516 msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302517 if (ret <= 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07002518 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002519 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302520 FL("Timeout occurred while waiting for abortscan %ld"),
2521 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08002522
2523 if (pHddCtx->isLogpInProgress)
2524 {
2525 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2526 "%s: LOGP in Progress. Ignore!!!", __func__);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302527
2528 VOS_ASSERT(pScanInfo->mScanPending);
Yue Ma4f55ef32014-01-23 16:45:33 -08002529 return -EAGAIN;
2530 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002531 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07002532 }
2533 }
2534
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05302535 hdd_hostapd_stop(dev);
2536
Jeff Johnson295189b2012-06-20 16:38:30 -07002537 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002538 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002539 )
2540 {
2541 beacon_data_t *old;
2542
2543 old = pAdapter->sessionCtx.ap.beacon;
2544
2545 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302546 {
2547 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2548 FL("session(%d) beacon data points to NULL"),
2549 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002550 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302551 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002552
Jeff Johnson295189b2012-06-20 16:38:30 -07002553 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002554
2555 mutex_lock(&pHddCtx->sap_lock);
2556 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
2557 {
Jeff Johnson4416a782013-03-25 14:17:50 -07002558 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002559 {
2560 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
2561
2562 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
2563
2564 if (!VOS_IS_STATUS_SUCCESS(status))
2565 {
2566 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002567 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002568 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302569 }
2570 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002571 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
2572 }
2573 mutex_unlock(&pHddCtx->sap_lock);
2574
2575 if(status != VOS_STATUS_SUCCESS)
2576 {
2577 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002578 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002579 return -EINVAL;
2580 }
2581
Jeff Johnson4416a782013-03-25 14:17:50 -07002582 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002583 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
2584 ==eHAL_STATUS_FAILURE)
2585 {
2586 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002587 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07002588 }
2589
Jeff Johnson4416a782013-03-25 14:17:50 -07002590 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002591 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
2592 eANI_BOOLEAN_FALSE) )
2593 {
2594 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002595 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07002596 }
2597
2598 // Reset WNI_CFG_PROBE_RSP Flags
2599 wlan_hdd_reset_prob_rspies(pAdapter);
2600
2601 pAdapter->sessionCtx.ap.beacon = NULL;
2602 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002603#ifdef WLAN_FEATURE_P2P_DEBUG
2604 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
2605 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
2606 {
2607 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
2608 "GO got removed");
2609 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
2610 }
2611#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002612 }
2613 EXIT();
2614 return status;
2615}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002616
2617#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2618
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302619static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
2620 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002621 struct cfg80211_ap_settings *params)
2622{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302623 hdd_adapter_t *pAdapter;
2624 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302625 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002626
2627 ENTER();
2628
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302629 if (NULL == dev)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002630 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302631 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302632 "%s: Device is Null", __func__);
2633 return -ENODEV;
2634 }
2635
2636 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2637 if (NULL == pAdapter)
2638 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302639 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302640 "%s: HDD adapter is Null", __func__);
2641 return -ENODEV;
2642 }
2643
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302644 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2645 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
2646 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302647 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
2648 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302649 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302650 "%s: HDD adapter magic is invalid", __func__);
2651 return -ENODEV;
2652 }
2653
2654 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302655 status = wlan_hdd_validate_context(pHddCtx);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302656
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302657 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302658 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302659 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2660 "%s: HDD context is not valid", __func__);
2661 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302662 }
2663
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05302664 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
2665 __func__, hdd_device_modetoString(pAdapter->device_mode),
2666 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302667
2668 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002669 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002670 )
2671 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302672 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002673
2674 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302675
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002676 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302677 {
2678 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2679 FL("already beacon info added to session(%d)"),
2680 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002681 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302682 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002683
2684 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, &params->beacon, params->dtim_period);
2685
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302686 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002687 {
2688 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302689 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002690 return -EINVAL;
2691 }
2692 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08002693#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07002694 wlan_hdd_cfg80211_set_channel(wiphy, dev,
2695#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
2696 params->channel, params->channel_type);
2697#else
2698 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
2699#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08002700#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002701 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
2702 params->ssid_len, params->hidden_ssid);
2703 }
2704
2705 EXIT();
2706 return status;
2707}
2708
2709
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302710static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002711 struct net_device *dev,
2712 struct cfg80211_beacon_data *params)
2713{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302714 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302715 hdd_context_t *pHddCtx;
2716 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002717
2718 ENTER();
2719
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302720 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2721 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
2722 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08002723 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002724 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302725
2726 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2727 status = wlan_hdd_validate_context(pHddCtx);
2728
2729 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002730 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302731 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2732 "%s: HDD context is not valid", __func__);
2733 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002734 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002735
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302736 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002737 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302738 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002739 {
2740 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302741
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002742 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302743
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002744 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302745 {
2746 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2747 FL("session(%d) beacon data points to NULL"),
2748 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002749 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302750 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002751
2752 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
2753
2754 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302755 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002756 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002757 return -EINVAL;
2758 }
2759
2760 pAdapter->sessionCtx.ap.beacon = new;
2761
2762 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
2763 }
2764
2765 EXIT();
2766 return status;
2767}
2768
2769#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2770
Jeff Johnson295189b2012-06-20 16:38:30 -07002771
2772static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
2773 struct net_device *dev,
2774 struct bss_parameters *params)
2775{
2776 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2777
2778 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302779
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302780 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2781 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
2782 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05302783 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
2784 __func__, hdd_device_modetoString(pAdapter->device_mode),
2785 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002786
2787 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002788 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302789 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002790 {
2791 /* ap_isolate == -1 means that in change bss, upper layer doesn't
2792 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302793 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07002794 {
2795 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302796 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002797 }
2798
2799 EXIT();
2800 return 0;
2801}
2802
Kiet Lam10841362013-11-01 11:36:50 +05302803/* FUNCTION: wlan_hdd_change_country_code_cd
2804* to wait for contry code completion
2805*/
2806void* wlan_hdd_change_country_code_cb(void *pAdapter)
2807{
2808 hdd_adapter_t *call_back_pAdapter = pAdapter;
2809 complete(&call_back_pAdapter->change_country_code);
2810 return NULL;
2811}
2812
Jeff Johnson295189b2012-06-20 16:38:30 -07002813/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05302814 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07002815 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
2816 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05302817int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07002818 struct net_device *ndev,
2819 enum nl80211_iftype type,
2820 u32 *flags,
2821 struct vif_params *params
2822 )
2823{
2824 struct wireless_dev *wdev;
2825 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002826 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07002827 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002828 tCsrRoamProfile *pRoamProfile = NULL;
2829 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302830 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002831 eMib_dot11DesiredBssType connectedBssType;
2832 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302833 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002834
2835 ENTER();
2836
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302837 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002838 {
2839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2840 "%s: Adapter context is null", __func__);
2841 return VOS_STATUS_E_FAILURE;
2842 }
2843
2844 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2845 if (!pHddCtx)
2846 {
2847 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2848 "%s: HDD context is null", __func__);
2849 return VOS_STATUS_E_FAILURE;
2850 }
2851
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302852 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2853 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
2854 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302855 status = wlan_hdd_validate_context(pHddCtx);
2856
2857 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002858 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302859 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2860 "%s: HDD context is not valid", __func__);
2861 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002862 }
2863
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05302864 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
2865 __func__, hdd_device_modetoString(pAdapter->device_mode),
2866 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002867
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302868 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07002869 wdev = ndev->ieee80211_ptr;
2870
2871#ifdef WLAN_BTAMP_FEATURE
2872 if((NL80211_IFTYPE_P2P_CLIENT == type)||
2873 (NL80211_IFTYPE_ADHOC == type)||
2874 (NL80211_IFTYPE_AP == type)||
2875 (NL80211_IFTYPE_P2P_GO == type))
2876 {
2877 pHddCtx->isAmpAllowed = VOS_FALSE;
2878 // stop AMP traffic
2879 status = WLANBAP_StopAmp();
2880 if(VOS_STATUS_SUCCESS != status )
2881 {
2882 pHddCtx->isAmpAllowed = VOS_TRUE;
2883 hddLog(VOS_TRACE_LEVEL_FATAL,
2884 "%s: Failed to stop AMP", __func__);
2885 return -EINVAL;
2886 }
2887 }
2888#endif //WLAN_BTAMP_FEATURE
2889 /* Reset the current device mode bit mask*/
2890 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
2891
2892 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07002893 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07002894 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002895 )
2896 {
2897 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002898 if (!pWextState)
2899 {
2900 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2901 "%s: pWextState is null", __func__);
2902 return VOS_STATUS_E_FAILURE;
2903 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002904 pRoamProfile = &pWextState->roamProfile;
2905 LastBSSType = pRoamProfile->BSSType;
2906
2907 switch (type)
2908 {
2909 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002910 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002911 hddLog(VOS_TRACE_LEVEL_INFO,
2912 "%s: setting interface Type to INFRASTRUCTURE", __func__);
2913 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002914#ifdef WLAN_FEATURE_11AC
2915 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
2916 {
2917 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
2918 }
2919#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302920 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07002921 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002922 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002923 //Check for sub-string p2p to confirm its a p2p interface
2924 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302925 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002926 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2927 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2928 }
2929 else
2930 {
2931 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002932 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002933 }
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05302934#ifdef FEATURE_WLAN_TDLS
2935 /* The open adapter for the p2p shall skip initializations in
2936 * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for
2937 * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke
2938 * tdls_init when the change_iface sets the device mode to
2939 * WLAN_HDD_P2P_CLIENT.
2940 */
2941
2942 if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2943 {
2944 if (0 != wlan_hdd_tdls_init (pAdapter))
2945 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302946 hddLog(VOS_TRACE_LEVEL_ERROR,
2947 "%s: tdls initialization failed", __func__);
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05302948 return -EINVAL;
2949 }
2950 }
2951#endif
2952
Jeff Johnson295189b2012-06-20 16:38:30 -07002953 break;
2954 case NL80211_IFTYPE_ADHOC:
2955 hddLog(VOS_TRACE_LEVEL_INFO,
2956 "%s: setting interface Type to ADHOC", __func__);
2957 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2958 pRoamProfile->phyMode =
2959 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002960 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002961 wdev->iftype = type;
2962 break;
2963
2964 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002965 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002966 {
2967 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2968 "%s: setting interface Type to %s", __func__,
2969 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
2970
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002971 //Cancel any remain on channel for GO mode
2972 if (NL80211_IFTYPE_P2P_GO == type)
2973 {
2974 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
2975 }
Mohit Khanna0f232092012-09-11 14:46:08 -07002976 if (NL80211_IFTYPE_AP == type)
2977 {
2978 /* As Loading WLAN Driver one interface being created for p2p device
2979 * address. This will take one HW STA and the max number of clients
2980 * that can connect to softAP will be reduced by one. so while changing
2981 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
2982 * interface as it is not required in SoftAP mode.
2983 */
2984
2985 // Get P2P Adapter
2986 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
2987
2988 if (pP2pAdapter)
2989 {
2990 hdd_stop_adapter(pHddCtx, pP2pAdapter);
2991 hdd_deinit_adapter(pHddCtx, pP2pAdapter);
2992 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
2993 }
2994 }
Swaroop Goltia2e32212014-04-09 23:37:33 +05302995 //Disable IMPS & BMPS for SAP/GO
2996 if(VOS_STATUS_E_FAILURE ==
2997 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
2998 {
2999 //Fail to Exit BMPS
3000 VOS_ASSERT(0);
3001 }
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303002#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07003003
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303004 /* A Mutex Lock is introduced while changing the mode to
3005 * protect the concurrent access for the Adapters by TDLS
3006 * module.
3007 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05303008 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303009#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003010 //De-init the adapter.
3011 hdd_stop_adapter( pHddCtx, pAdapter );
3012 hdd_deinit_adapter( pHddCtx, pAdapter );
3013 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07003014 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
3015 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303016#ifdef FEATURE_WLAN_TDLS
3017 mutex_unlock(&pHddCtx->tdls_lock);
3018#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07003019 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
3020 (pConfig->apRandomBssidEnabled))
3021 {
3022 /* To meet Android requirements create a randomized
3023 MAC address of the form 02:1A:11:Fx:xx:xx */
3024 get_random_bytes(&ndev->dev_addr[3], 3);
3025 ndev->dev_addr[0] = 0x02;
3026 ndev->dev_addr[1] = 0x1A;
3027 ndev->dev_addr[2] = 0x11;
3028 ndev->dev_addr[3] |= 0xF0;
3029 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
3030 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08003031 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
3032 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07003033 }
3034
Jeff Johnson295189b2012-06-20 16:38:30 -07003035 hdd_set_ap_ops( pAdapter->dev );
3036
Kiet Lam10841362013-11-01 11:36:50 +05303037 /* This is for only SAP mode where users can
3038 * control country through ini.
3039 * P2P GO follows station country code
3040 * acquired during the STA scanning. */
3041 if((NL80211_IFTYPE_AP == type) &&
3042 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
3043 {
3044 int status = 0;
3045 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
3046 "%s: setting country code from INI ", __func__);
3047 init_completion(&pAdapter->change_country_code);
3048 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
3049 (void *)(tSmeChangeCountryCallback)
3050 wlan_hdd_change_country_code_cb,
3051 pConfig->apCntryCode, pAdapter,
3052 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05303053 eSIR_FALSE,
3054 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05303055 if (eHAL_STATUS_SUCCESS == status)
3056 {
3057 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303058 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05303059 &pAdapter->change_country_code,
3060 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303061 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05303062 {
3063 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303064 FL("SME Timed out while setting country code %ld"),
3065 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08003066
3067 if (pHddCtx->isLogpInProgress)
3068 {
3069 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3070 "%s: LOGP in Progress. Ignore!!!", __func__);
3071 return -EAGAIN;
3072 }
Kiet Lam10841362013-11-01 11:36:50 +05303073 }
3074 }
3075 else
3076 {
3077 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003078 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05303079 return -EINVAL;
3080 }
3081 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003082 status = hdd_init_ap_mode(pAdapter);
3083 if(status != VOS_STATUS_SUCCESS)
3084 {
3085 hddLog(VOS_TRACE_LEVEL_FATAL,
3086 "%s: Error initializing the ap mode", __func__);
3087 return -EINVAL;
3088 }
3089 hdd_set_conparam(1);
3090
Jeff Johnson295189b2012-06-20 16:38:30 -07003091 /*interface type changed update in wiphy structure*/
3092 if(wdev)
3093 {
3094 wdev->iftype = type;
3095 pHddCtx->change_iface = type;
3096 }
3097 else
3098 {
3099 hddLog(VOS_TRACE_LEVEL_ERROR,
3100 "%s: ERROR !!!! Wireless dev is NULL", __func__);
3101 return -EINVAL;
3102 }
3103 goto done;
3104 }
3105
3106 default:
3107 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
3108 __func__);
3109 return -EOPNOTSUPP;
3110 }
3111 }
3112 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07003113 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07003114 )
3115 {
3116 switch(type)
3117 {
3118 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07003119 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07003120 case NL80211_IFTYPE_ADHOC:
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303121#ifdef FEATURE_WLAN_TDLS
3122
3123 /* A Mutex Lock is introduced while changing the mode to
3124 * protect the concurrent access for the Adapters by TDLS
3125 * module.
3126 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05303127 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303128#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07003129 hdd_stop_adapter( pHddCtx, pAdapter );
3130 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08003132 //Check for sub-string p2p to confirm its a p2p interface
3133 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08003134 {
3135 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
3136 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
3137 }
3138 else
3139 {
3140 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07003141 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08003142 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003143 hdd_set_conparam(0);
3144 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07003145 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
3146 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303147#ifdef FEATURE_WLAN_TDLS
3148 mutex_unlock(&pHddCtx->tdls_lock);
3149#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05303150 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07003151 if( VOS_STATUS_SUCCESS != status )
3152 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07003153 /* In case of JB, for P2P-GO, only change interface will be called,
3154 * This is the right place to enable back bmps_imps()
3155 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05303156 if (pHddCtx->hdd_wlan_suspended)
3157 {
3158 hdd_set_pwrparams(pHddCtx);
3159 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003160 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07003161 goto done;
3162 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07003163 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07003164 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07003165 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
3166 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003167 goto done;
3168 default:
3169 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
3170 __func__);
3171 return -EOPNOTSUPP;
3172
3173 }
3174
3175 }
3176 else
3177 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05303178 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
3179 __func__, hdd_device_modetoString(pAdapter->device_mode),
3180 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003181 return -EOPNOTSUPP;
3182 }
3183
3184
3185 if(pRoamProfile)
3186 {
3187 if ( LastBSSType != pRoamProfile->BSSType )
3188 {
3189 /*interface type changed update in wiphy structure*/
3190 wdev->iftype = type;
3191
3192 /*the BSS mode changed, We need to issue disconnect
3193 if connected or in IBSS disconnect state*/
3194 if ( hdd_connGetConnectedBssType(
3195 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
3196 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
3197 {
3198 /*need to issue a disconnect to CSR.*/
3199 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3200 if( eHAL_STATUS_SUCCESS ==
3201 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
3202 pAdapter->sessionId,
3203 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
3204 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303205 ret = wait_for_completion_interruptible_timeout(
3206 &pAdapter->disconnect_comp_var,
3207 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3208 if (ret <= 0)
3209 {
3210 hddLog(VOS_TRACE_LEVEL_ERROR,
3211 FL("wait on disconnect_comp_var failed %ld"), ret);
3212 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003213 }
3214 }
3215 }
3216 }
3217
3218done:
3219 /*set bitmask based on updated value*/
3220 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07003221
3222 /* Only STA mode support TM now
3223 * all other mode, TM feature should be disabled */
3224 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
3225 (~VOS_STA & pHddCtx->concurrency_mode) )
3226 {
3227 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
3228 }
3229
Jeff Johnson295189b2012-06-20 16:38:30 -07003230#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303231 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003232 (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
3233 {
3234 //we are ok to do AMP
3235 pHddCtx->isAmpAllowed = VOS_TRUE;
3236 }
3237#endif //WLAN_BTAMP_FEATURE
3238 EXIT();
3239 return 0;
3240}
3241
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05303242/*
3243 * FUNCTION: wlan_hdd_cfg80211_change_iface
3244 * wrapper function to protect the actual implementation from SSR.
3245 */
3246int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
3247 struct net_device *ndev,
3248 enum nl80211_iftype type,
3249 u32 *flags,
3250 struct vif_params *params
3251 )
3252{
3253 int ret;
3254
3255 vos_ssr_protect(__func__);
3256 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
3257 vos_ssr_unprotect(__func__);
3258
3259 return ret;
3260}
3261
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003262#ifdef FEATURE_WLAN_TDLS
3263static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
3264 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
3265{
3266 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3267 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3268 VOS_STATUS status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003269 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303270 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05303271 tANI_U16 numCurrTdlsPeers;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003272
3273 ENTER();
3274
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303275 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003276 {
3277 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3278 "Invalid arguments");
3279 return -EINVAL;
3280 }
Hoonki Lee27511902013-03-14 18:19:06 -07003281
3282 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
3283 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
3284 {
3285 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3286 "%s: TDLS mode is disabled OR not enabled in FW."
3287 MAC_ADDRESS_STR " Request declined.",
3288 __func__, MAC_ADDR_ARRAY(mac));
3289 return -ENOTSUPP;
3290 }
3291
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003292 if (pHddCtx->isLogpInProgress)
3293 {
3294 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3295 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07003296 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003297 return -EBUSY;
3298 }
3299
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05303300 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003301
3302 if ( NULL == pTdlsPeer ) {
3303 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3304 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
3305 __func__, MAC_ADDR_ARRAY(mac), update);
3306 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003307 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003308
3309 /* in add station, we accept existing valid staId if there is */
3310 if ((0 == update) &&
3311 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
3312 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003313 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003314 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003315 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003316 " link_status %d. staId %d. add station ignored.",
3317 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
3318 return 0;
3319 }
3320 /* in change station, we accept only when staId is valid */
3321 if ((1 == update) &&
3322 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
3323 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
3324 {
3325 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3326 "%s: " MAC_ADDRESS_STR
3327 " link status %d. staId %d. change station %s.",
3328 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
3329 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
3330 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003331 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003332
3333 /* when others are on-going, we want to change link_status to idle */
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303334 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003335 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003336 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3337 "%s: " MAC_ADDRESS_STR
3338 " TDLS setup is ongoing. Request declined.",
3339 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07003340 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003341 }
3342
3343 /* first to check if we reached to maximum supported TDLS peer.
3344 TODO: for now, return -EPERM looks working fine,
3345 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05303346 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
3347 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003348 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003349 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3350 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05303351 " TDLS Max peer already connected. Request declined."
3352 " Num of peers (%d), Max allowed (%d).",
3353 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
3354 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07003355 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003356 }
3357 else
3358 {
3359 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303360 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003361 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003362 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003363 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3364 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
3365 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003366 return -EPERM;
3367 }
3368 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003369 if (0 == update)
3370 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003371
Jeff Johnsond75fe012013-04-06 10:53:06 -07003372 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303373 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003374 {
3375 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3376 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003377 if(StaParams->htcap_present)
3378 {
3379 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3380 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
3381 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3382 "ht_capa->extended_capabilities: %0x",
3383 StaParams->HTCap.extendedHtCapInfo);
3384 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003385 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3386 "params->capability: %0x",StaParams->capability);
3387 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003388 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003389 if(StaParams->vhtcap_present)
3390 {
3391 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3392 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
3393 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
3394 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
3395 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003396 {
3397 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003398 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003399 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
3400 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3401 "[%d]: %x ", i, StaParams->supported_rates[i]);
3402 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07003403 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303404 else if ((1 == update) && (NULL == StaParams))
3405 {
3406 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3407 "%s : update is true, but staParams is NULL. Error!", __func__);
3408 return -EPERM;
3409 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003410
3411 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
3412
3413 if (!update)
3414 {
3415 status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3416 pAdapter->sessionId, mac);
3417 }
3418 else
3419 {
3420 status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3421 pAdapter->sessionId, mac, StaParams);
3422 }
3423
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303424 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003425 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
3426
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303427 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003428 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003429 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303430 "%s: timeout waiting for tdls add station indication %ld",
3431 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003432 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003433 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303434
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003435 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
3436 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003437 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003438 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003439 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003440 }
3441
3442 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07003443
3444error:
3445 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
3446 return -EPERM;
3447
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003448}
3449#endif
3450
Jeff Johnson295189b2012-06-20 16:38:30 -07003451static int wlan_hdd_change_station(struct wiphy *wiphy,
3452 struct net_device *dev,
3453 u8 *mac,
3454 struct station_parameters *params)
3455{
3456 VOS_STATUS status = VOS_STATUS_SUCCESS;
3457 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkala29149562013-05-10 21:43:41 +05303458 hdd_context_t *pHddCtx;
3459 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003460 v_MACADDR_t STAMacAddress;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003461#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003462 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003463 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05303464 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003465#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003466 ENTER();
3467
Gopichand Nakkala29149562013-05-10 21:43:41 +05303468 if ((NULL == pAdapter))
3469 {
3470 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3471 "invalid adapter ");
3472 return -EINVAL;
3473 }
3474
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303475 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
3476 TRACE_CODE_HDD_CHANGE_STATION,
3477 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05303478 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3479 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3480
3481 if ((NULL == pHddCtx) || (NULL == pHddStaCtx))
3482 {
3483 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3484 "invalid HDD state or HDD station context");
3485 return -EINVAL;
3486 }
3487
3488 if (pHddCtx->isLogpInProgress)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003489 {
3490 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3491 "%s:LOGP in Progress. Ignore!!!", __func__);
3492 return -EAGAIN;
3493 }
3494
Jeff Johnson295189b2012-06-20 16:38:30 -07003495 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
3496
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003497 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
3498 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07003499 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003500 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07003501 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303502 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07003503 WLANTL_STA_AUTHENTICATED);
3504
Gopichand Nakkala29149562013-05-10 21:43:41 +05303505 if (status != VOS_STATUS_SUCCESS)
3506 {
3507 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3508 "%s: Not able to change TL state to AUTHENTICATED", __func__);
3509 return -EINVAL;
3510 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003511 }
3512 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07003513 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
3514 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303515#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003516 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
3517 StaParams.capability = params->capability;
3518 StaParams.uapsd_queues = params->uapsd_queues;
3519 StaParams.max_sp = params->max_sp;
3520
Naresh Jayaram3180aa42014-02-12 21:47:26 +05303521 /* Convert (first channel , number of channels) tuple to
3522 * the total list of channels. This goes with the assumption
3523 * that if the first channel is < 14, then the next channels
3524 * are an incremental of 1 else an incremental of 4 till the number
3525 * of channels.
3526 */
3527 if (0 != params->supported_channels_len) {
3528 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
3529 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
3530 {
3531 int wifi_chan_index;
3532 StaParams.supported_channels[j] = params->supported_channels[i];
3533 wifi_chan_index =
3534 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
3535 no_of_channels = params->supported_channels[i+1];
3536 for(k=1; k <= no_of_channels; k++)
3537 {
3538 StaParams.supported_channels[j+1] =
3539 StaParams.supported_channels[j] + wifi_chan_index;
3540 j+=1;
3541 }
3542 }
3543 StaParams.supported_channels_len = j;
3544 }
3545 vos_mem_copy(StaParams.supported_oper_classes,
3546 params->supported_oper_classes,
3547 params->supported_oper_classes_len);
3548 StaParams.supported_oper_classes_len =
3549 params->supported_oper_classes_len;
3550
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003551 if (0 != params->ext_capab_len)
3552 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
3553 sizeof(StaParams.extn_capability));
3554
3555 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003556 {
3557 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003558 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003559 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003560
3561 StaParams.supported_rates_len = params->supported_rates_len;
3562
3563 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
3564 * The supported_rates array , for all the structures propogating till Add Sta
3565 * to the firmware has to be modified , if the supplicant (ieee80211) is
3566 * modified to send more rates.
3567 */
3568
3569 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
3570 */
3571 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
3572 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
3573
3574 if (0 != StaParams.supported_rates_len) {
3575 int i = 0;
3576 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
3577 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003578 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003579 "Supported Rates with Length %d", StaParams.supported_rates_len);
3580 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003581 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003582 "[%d]: %0x", i, StaParams.supported_rates[i]);
3583 }
3584
3585 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003586 {
3587 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003588 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003589 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003590
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003591 if (0 != params->ext_capab_len ) {
3592 /*Define A Macro : TODO Sunil*/
3593 if ((1<<4) & StaParams.extn_capability[3]) {
3594 isBufSta = 1;
3595 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05303596 /* TDLS Channel Switching Support */
3597 if ((1<<6) & StaParams.extn_capability[3]) {
3598 isOffChannelSupported = 1;
3599 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003600 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05303601 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
3602 &StaParams, isBufSta,
3603 isOffChannelSupported);
3604
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303605 if (VOS_STATUS_SUCCESS != status) {
3606 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3607 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
3608 return -EINVAL;
3609 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003610 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
3611
3612 if (VOS_STATUS_SUCCESS != status) {
3613 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3614 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
3615 return -EINVAL;
3616 }
3617 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003618#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05303619 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003620 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003621 return status;
3622}
3623
3624/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003625 * FUNCTION: wlan_hdd_cfg80211_add_key
3626 * This function is used to initialize the key information
3627 */
3628#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003629static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003630 struct net_device *ndev,
3631 u8 key_index, bool pairwise,
3632 const u8 *mac_addr,
3633 struct key_params *params
3634 )
3635#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003636static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003637 struct net_device *ndev,
3638 u8 key_index, const u8 *mac_addr,
3639 struct key_params *params
3640 )
3641#endif
3642{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003643 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003644 tCsrRoamSetKey setKey;
3645 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303646 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003647 v_U32_t roamId= 0xFF;
3648 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 hdd_hostapd_state_t *pHostapdState;
3650 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003651 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303652 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003653
3654 ENTER();
3655
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303656 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
3657 TRACE_CODE_HDD_CFG80211_ADD_KEY,
3658 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303659 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3660 status = wlan_hdd_validate_context(pHddCtx);
3661
3662 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003663 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303664 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3665 "%s: HDD context is not valid", __func__);
3666 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003667 }
3668
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05303669 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
3670 __func__, hdd_device_modetoString(pAdapter->device_mode),
3671 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003672
3673 if (CSR_MAX_NUM_KEY <= key_index)
3674 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003675 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003676 key_index);
3677
3678 return -EINVAL;
3679 }
3680
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003681 if (CSR_MAX_KEY_LEN < params->key_len)
3682 {
3683 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
3684 params->key_len);
3685
3686 return -EINVAL;
3687 }
3688
3689 hddLog(VOS_TRACE_LEVEL_INFO,
3690 "%s: called with key index = %d & key length %d",
3691 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003692
3693 /*extract key idx, key len and key*/
3694 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3695 setKey.keyId = key_index;
3696 setKey.keyLength = params->key_len;
3697 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
3698
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003699 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07003700 {
3701 case WLAN_CIPHER_SUITE_WEP40:
3702 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3703 break;
3704
3705 case WLAN_CIPHER_SUITE_WEP104:
3706 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3707 break;
3708
3709 case WLAN_CIPHER_SUITE_TKIP:
3710 {
3711 u8 *pKey = &setKey.Key[0];
3712 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3713
3714 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3715
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003716 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07003717
3718 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003719 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003720 |--------------|----------|----------|
3721 <---16bytes---><--8bytes--><--8bytes-->
3722
3723 */
3724 /*Sme expects the 32 bytes key to be in the below order
3725
3726 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003727 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003728 |--------------|----------|----------|
3729 <---16bytes---><--8bytes--><--8bytes-->
3730 */
3731 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003732 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07003733
3734 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003735 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003736
3737 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003738 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003739
3740
3741 break;
3742 }
3743
3744 case WLAN_CIPHER_SUITE_CCMP:
3745 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3746 break;
3747
3748#ifdef FEATURE_WLAN_WAPI
3749 case WLAN_CIPHER_SUITE_SMS4:
3750 {
3751 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3752 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
3753 params->key, params->key_len);
3754 return 0;
3755 }
3756#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003757
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003758#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003759 case WLAN_CIPHER_SUITE_KRK:
3760 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3761 break;
3762#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003763
3764#ifdef WLAN_FEATURE_11W
3765 case WLAN_CIPHER_SUITE_AES_CMAC:
3766 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07003767 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07003768#endif
3769
Jeff Johnson295189b2012-06-20 16:38:30 -07003770 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003771 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07003772 __func__, params->cipher);
3773 return -EOPNOTSUPP;
3774 }
3775
3776 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
3777 __func__, setKey.encType);
3778
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003779 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07003780#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3781 (!pairwise)
3782#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003783 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07003784#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003785 )
3786 {
3787 /* set group key*/
3788 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3789 "%s- %d: setting Broadcast key",
3790 __func__, __LINE__);
3791 setKey.keyDirection = eSIR_RX_ONLY;
3792 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3793 }
3794 else
3795 {
3796 /* set pairwise key*/
3797 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3798 "%s- %d: setting pairwise key",
3799 __func__, __LINE__);
3800 setKey.keyDirection = eSIR_TX_RX;
3801 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3802 }
3803 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
3804 {
3805 setKey.keyDirection = eSIR_TX_RX;
3806 /*Set the group key*/
3807 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3808 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003809
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003810 if ( 0 != status )
3811 {
3812 hddLog(VOS_TRACE_LEVEL_ERROR,
3813 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3814 return -EINVAL;
3815 }
3816 /*Save the keys here and call sme_RoamSetKey for setting
3817 the PTK after peer joins the IBSS network*/
3818 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
3819 &setKey, sizeof(tCsrRoamSetKey));
3820 return status;
3821 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05303822 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
3823 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
3824 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003825 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003826 if( pHostapdState->bssState == BSS_START )
3827 {
c_hpothu7c55da62014-01-23 18:34:02 +05303828 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3829 vos_status = wlan_hdd_check_ula_done(pAdapter);
3830
3831 if ( vos_status != VOS_STATUS_SUCCESS )
3832 {
3833 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3834 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3835 __LINE__, vos_status );
3836
3837 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3838
3839 return -EINVAL;
3840 }
3841
Jeff Johnson295189b2012-06-20 16:38:30 -07003842 status = WLANSAP_SetKeySta( pVosContext, &setKey);
3843
3844 if ( status != eHAL_STATUS_SUCCESS )
3845 {
3846 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3847 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3848 __LINE__, status );
3849 }
3850 }
3851
3852 /* Saving WEP keys */
3853 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
3854 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
3855 {
3856 //Save the wep key in ap context. Issue setkey after the BSS is started.
3857 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3858 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
3859 }
3860 else
3861 {
3862 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003863 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003864 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
3865 }
3866 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003867 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
3868 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003869 {
3870 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3871 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3872
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303873#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3874 if (!pairwise)
3875#else
3876 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
3877#endif
3878 {
3879 /* set group key*/
3880 if (pHddStaCtx->roam_info.deferKeyComplete)
3881 {
3882 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3883 "%s- %d: Perform Set key Complete",
3884 __func__, __LINE__);
3885 hdd_PerformRoamSetKeyComplete(pAdapter);
3886 }
3887 }
3888
Jeff Johnson295189b2012-06-20 16:38:30 -07003889 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
3890
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08003891 pWextState->roamProfile.Keys.defaultIndex = key_index;
3892
3893
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003894 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003895 params->key, params->key_len);
3896
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303897
Jeff Johnson295189b2012-06-20 16:38:30 -07003898 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3899
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303900 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003901 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303902 __func__, setKey.peerMac[0], setKey.peerMac[1],
3903 setKey.peerMac[2], setKey.peerMac[3],
3904 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003905 setKey.keyDirection);
3906
3907 vos_status = wlan_hdd_check_ula_done(pAdapter);
3908
3909 if ( vos_status != VOS_STATUS_SUCCESS )
3910 {
3911 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3912 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3913 __LINE__, vos_status );
3914
3915 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3916
3917 return -EINVAL;
3918
3919 }
3920
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003921#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303922 /* The supplicant may attempt to set the PTK once pre-authentication
3923 is done. Save the key in the UMAC and include it in the ADD BSS
3924 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003925 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303926 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003927 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303928 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3929 "%s: Update PreAuth Key success", __func__);
3930 return 0;
3931 }
3932 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3933 {
3934 hddLog(VOS_TRACE_LEVEL_ERROR,
3935 "%s: Update PreAuth Key failed", __func__);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05303936 return -EINVAL;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003937 }
3938#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07003939
3940 /* issue set key request to SME*/
3941 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3942 pAdapter->sessionId, &setKey, &roamId );
3943
3944 if ( 0 != status )
3945 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303946 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3948 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3949 return -EINVAL;
3950 }
3951
3952
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303953 /* in case of IBSS as there was no information available about WEP keys during
3954 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07003955 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303956 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
3957 !( ( IW_AUTH_KEY_MGMT_802_1X
3958 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003959 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
3960 )
3961 &&
3962 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
3963 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
3964 )
3965 )
3966 {
3967 setKey.keyDirection = eSIR_RX_ONLY;
3968 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3969
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303970 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003971 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303972 __func__, setKey.peerMac[0], setKey.peerMac[1],
3973 setKey.peerMac[2], setKey.peerMac[3],
3974 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003975 setKey.keyDirection);
3976
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303977 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003978 pAdapter->sessionId, &setKey, &roamId );
3979
3980 if ( 0 != status )
3981 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303982 hddLog(VOS_TRACE_LEVEL_ERROR,
3983 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003984 __func__, status);
3985 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3986 return -EINVAL;
3987 }
3988 }
3989 }
3990
3991 return 0;
3992}
3993
3994/*
3995 * FUNCTION: wlan_hdd_cfg80211_get_key
3996 * This function is used to get the key information
3997 */
3998#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303999static int wlan_hdd_cfg80211_get_key(
4000 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004001 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304002 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07004003 const u8 *mac_addr, void *cookie,
4004 void (*callback)(void *cookie, struct key_params*)
4005 )
4006#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304007static int wlan_hdd_cfg80211_get_key(
4008 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004009 struct net_device *ndev,
4010 u8 key_index, const u8 *mac_addr, void *cookie,
4011 void (*callback)(void *cookie, struct key_params*)
4012 )
4013#endif
4014{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304015 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07004016 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4017 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
4018 struct key_params params;
4019
4020 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304021
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304022 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
4023 TRACE_CODE_HDD_CFG80211_GET_KEY,
4024 pAdapter->sessionId, params.cipher));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05304025 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
4026 __func__, hdd_device_modetoString(pAdapter->device_mode),
4027 pAdapter->device_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304028
Jeff Johnson295189b2012-06-20 16:38:30 -07004029 memset(&params, 0, sizeof(params));
4030
4031 if (CSR_MAX_NUM_KEY <= key_index)
4032 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304033 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07004034 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304035 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004036
4037 switch(pRoamProfile->EncryptionType.encryptionType[0])
4038 {
4039 case eCSR_ENCRYPT_TYPE_NONE:
4040 params.cipher = IW_AUTH_CIPHER_NONE;
4041 break;
4042
4043 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4044 case eCSR_ENCRYPT_TYPE_WEP40:
4045 params.cipher = WLAN_CIPHER_SUITE_WEP40;
4046 break;
4047
4048 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4049 case eCSR_ENCRYPT_TYPE_WEP104:
4050 params.cipher = WLAN_CIPHER_SUITE_WEP104;
4051 break;
4052
4053 case eCSR_ENCRYPT_TYPE_TKIP:
4054 params.cipher = WLAN_CIPHER_SUITE_TKIP;
4055 break;
4056
4057 case eCSR_ENCRYPT_TYPE_AES:
4058 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
4059 break;
4060
4061 default:
4062 params.cipher = IW_AUTH_CIPHER_NONE;
4063 break;
4064 }
4065
4066 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
4067 params.seq_len = 0;
4068 params.seq = NULL;
4069 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
4070 callback(cookie, &params);
4071 return 0;
4072}
4073
4074/*
4075 * FUNCTION: wlan_hdd_cfg80211_del_key
4076 * This function is used to delete the key information
4077 */
4078#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304079static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004080 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304081 u8 key_index,
4082 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07004083 const u8 *mac_addr
4084 )
4085#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304086static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004087 struct net_device *ndev,
4088 u8 key_index,
4089 const u8 *mac_addr
4090 )
4091#endif
4092{
4093 int status = 0;
4094
4095 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304096 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07004097 //it is observed that this is invalidating peer
4098 //key index whenever re-key is done. This is affecting data link.
4099 //It should be ok to ignore del_key.
4100#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304101 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
4102 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004103 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4104 tCsrRoamSetKey setKey;
4105 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304106
Jeff Johnson295189b2012-06-20 16:38:30 -07004107 ENTER();
4108
4109 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
4110 __func__,pAdapter->device_mode);
4111
4112 if (CSR_MAX_NUM_KEY <= key_index)
4113 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304114 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 key_index);
4116
4117 return -EINVAL;
4118 }
4119
4120 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4121 setKey.keyId = key_index;
4122
4123 if (mac_addr)
4124 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
4125 else
4126 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
4127
4128 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4129
4130 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07004131 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304132 )
4133 {
4134
4135 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07004136 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
4137 if( pHostapdState->bssState == BSS_START)
4138 {
4139 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304140
Jeff Johnson295189b2012-06-20 16:38:30 -07004141 if ( status != eHAL_STATUS_SUCCESS )
4142 {
4143 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4144 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
4145 __LINE__, status );
4146 }
4147 }
4148 }
4149 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304150 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07004151 )
4152 {
4153 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4154
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304155 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
4156
4157 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07004158 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304159 __func__, setKey.peerMac[0], setKey.peerMac[1],
4160 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07004161 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304162 if(pAdapter->sessionCtx.station.conn_info.connState ==
4163 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07004164 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304165 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07004166 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304167
Jeff Johnson295189b2012-06-20 16:38:30 -07004168 if ( 0 != status )
4169 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304170 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004171 "%s: sme_RoamSetKey failure, returned %d",
4172 __func__, status);
4173 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4174 return -EINVAL;
4175 }
4176 }
4177 }
4178#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07004179 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004180 return status;
4181}
4182
4183/*
4184 * FUNCTION: wlan_hdd_cfg80211_set_default_key
4185 * This function is used to set the default tx key index
4186 */
4187#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
4188static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
4189 struct net_device *ndev,
4190 u8 key_index,
4191 bool unicast, bool multicast)
4192#else
4193static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
4194 struct net_device *ndev,
4195 u8 key_index)
4196#endif
4197{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304198 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304199 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05304200 hdd_wext_state_t *pWextState;
4201 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304202 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004203
4204 ENTER();
4205
Gopichand Nakkala29149562013-05-10 21:43:41 +05304206 if ((NULL == pAdapter))
4207 {
4208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4209 "invalid adapter");
4210 return -EINVAL;
4211 }
4212
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304213 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
4214 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
4215 pAdapter->sessionId, key_index));
4216
Gopichand Nakkala29149562013-05-10 21:43:41 +05304217 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4218 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4219
4220 if ((NULL == pWextState) || (NULL == pHddStaCtx))
4221 {
4222 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4223 "invalid Wext state or HDD context");
4224 return -EINVAL;
4225 }
4226
Arif Hussain6d2a3322013-11-17 19:50:10 -08004227 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004228 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304229
Jeff Johnson295189b2012-06-20 16:38:30 -07004230 if (CSR_MAX_NUM_KEY <= key_index)
4231 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304232 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004233 key_index);
4234
4235 return -EINVAL;
4236 }
4237
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304238 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4239 status = wlan_hdd_validate_context(pHddCtx);
4240
4241 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004242 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304243 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4244 "%s: HDD context is not valid", __func__);
4245 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004246 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304247
Jeff Johnson295189b2012-06-20 16:38:30 -07004248 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07004249 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304250 )
Jeff Johnson295189b2012-06-20 16:38:30 -07004251 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05304252 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08004253 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304254 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08004255 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07004256 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304257 {
4258 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07004259 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304260
Jeff Johnson295189b2012-06-20 16:38:30 -07004261 tCsrRoamSetKey setKey;
4262 v_U32_t roamId= 0xFF;
4263 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304264
4265 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004266 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304267
Jeff Johnson295189b2012-06-20 16:38:30 -07004268 Keys->defaultIndex = (u8)key_index;
4269 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4270 setKey.keyId = key_index;
4271 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304272
4273 vos_mem_copy(&setKey.Key[0],
4274 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07004275 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304276
Gopichand Nakkala29149562013-05-10 21:43:41 +05304277 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304278
4279 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07004280 &pHddStaCtx->conn_info.bssId[0],
4281 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304282
Gopichand Nakkala29149562013-05-10 21:43:41 +05304283 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
4284 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
4285 eCSR_ENCRYPT_TYPE_WEP104)
4286 {
4287 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
4288 even though ap is configured for WEP-40 encryption. In this canse the key length
4289 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
4290 type(104) and switching encryption type to 40*/
4291 pWextState->roamProfile.EncryptionType.encryptionType[0] =
4292 eCSR_ENCRYPT_TYPE_WEP40;
4293 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
4294 eCSR_ENCRYPT_TYPE_WEP40;
4295 }
4296
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304297 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07004298 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304299
Jeff Johnson295189b2012-06-20 16:38:30 -07004300 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304301 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07004302 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304303
Jeff Johnson295189b2012-06-20 16:38:30 -07004304 if ( 0 != status )
4305 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304306 hddLog(VOS_TRACE_LEVEL_ERROR,
4307 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004308 status);
4309 return -EINVAL;
4310 }
4311 }
4312 }
4313
4314 /* In SoftAp mode setting key direction for default mode */
4315 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
4316 {
4317 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
4318 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
4319 (eCSR_ENCRYPT_TYPE_AES !=
4320 pWextState->roamProfile.EncryptionType.encryptionType[0])
4321 )
4322 {
4323 /* Saving key direction for default key index to TX default */
4324 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
4325 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
4326 }
4327 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304328
Jeff Johnson295189b2012-06-20 16:38:30 -07004329 return status;
4330}
4331
Jeff Johnson295189b2012-06-20 16:38:30 -07004332/*
4333 * FUNCTION: wlan_hdd_cfg80211_inform_bss
4334 * This function is used to inform the BSS details to nl80211 interface.
4335 */
4336static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
4337 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
4338{
4339 struct net_device *dev = pAdapter->dev;
4340 struct wireless_dev *wdev = dev->ieee80211_ptr;
4341 struct wiphy *wiphy = wdev->wiphy;
4342 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
4343 int chan_no;
4344 int ie_length;
4345 const char *ie;
4346 unsigned int freq;
4347 struct ieee80211_channel *chan;
4348 int rssi = 0;
4349 struct cfg80211_bss *bss = NULL;
4350
4351 ENTER();
4352
4353 if( NULL == pBssDesc )
4354 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004355 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004356 return bss;
4357 }
4358
4359 chan_no = pBssDesc->channelId;
4360 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
4361 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
4362
4363 if( NULL == ie )
4364 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004365 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004366 return bss;
4367 }
4368
4369#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
4370 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
4371 {
4372 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4373 }
4374 else
4375 {
4376 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4377 }
4378#else
4379 freq = ieee80211_channel_to_frequency(chan_no);
4380#endif
4381
4382 chan = __ieee80211_get_channel(wiphy, freq);
4383
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +05304384 if (!chan) {
4385 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
4386 return NULL;
4387 }
4388
Jeff Johnson295189b2012-06-20 16:38:30 -07004389 bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId,
4390 &roamProfile->SSID.ssId[0], roamProfile->SSID.length,
4391 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
4392 if (bss == NULL)
4393 {
4394 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
4395
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304396 return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
4397 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07004398 pBssDesc->capabilityInfo,
4399 pBssDesc->beaconInterval, ie, ie_length,
4400 rssi, GFP_KERNEL ));
4401}
4402 else
4403 {
4404 return bss;
4405 }
4406}
4407
4408
4409
4410/*
4411 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
4412 * This function is used to inform the BSS details to nl80211 interface.
4413 */
4414struct cfg80211_bss*
4415wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
4416 tSirBssDescription *bss_desc
4417 )
4418{
4419 /*
4420 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
4421 already exists in bss data base of cfg80211 for that particular BSS ID.
4422 Using cfg80211_inform_bss_frame to update the bss entry instead of
4423 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
4424 now there is no possibility to get the mgmt(probe response) frame from PE,
4425 converting bss_desc to ieee80211_mgmt(probe response) and passing to
4426 cfg80211_inform_bss_frame.
4427 */
4428 struct net_device *dev = pAdapter->dev;
4429 struct wireless_dev *wdev = dev->ieee80211_ptr;
4430 struct wiphy *wiphy = wdev->wiphy;
4431 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004432#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4433 qcom_ie_age *qie_age = NULL;
4434 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
4435#else
Jeff Johnson295189b2012-06-20 16:38:30 -07004436 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004437#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004438 const char *ie =
4439 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
4440 unsigned int freq;
4441 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05304442 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004443 struct cfg80211_bss *bss_status = NULL;
4444 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
4445 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07004446 hdd_context_t *pHddCtx;
4447 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07004448#ifdef WLAN_OPEN_SOURCE
4449 struct timespec ts;
4450#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004451
Wilson Yangf80a0542013-10-07 13:02:37 -07004452 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4453 status = wlan_hdd_validate_context(pHddCtx);
4454
4455 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +05304456 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -07004457 {
4458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4459 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
4460 return NULL;
4461 }
4462
4463
4464 if (0 != status)
4465 {
4466 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4467 "%s: HDD context is not valid", __func__);
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07004468 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07004469 }
4470
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05304471 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -07004472 if (!mgmt)
4473 {
4474 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4475 "%s: memory allocation failed ", __func__);
4476 return NULL;
4477 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07004478
Jeff Johnson295189b2012-06-20 16:38:30 -07004479 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07004480
4481#ifdef WLAN_OPEN_SOURCE
4482 /* Android does not want the timestamp from the frame.
4483 Instead it wants a monotonic increasing value */
4484 get_monotonic_boottime(&ts);
4485 mgmt->u.probe_resp.timestamp =
4486 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
4487#else
4488 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07004489 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
4490 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07004491
4492#endif
4493
Jeff Johnson295189b2012-06-20 16:38:30 -07004494 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
4495 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004496
4497#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4498 /* GPS Requirement: need age ie per entry. Using vendor specific. */
4499 /* Assuming this is the last IE, copy at the end */
4500 ie_length -=sizeof(qcom_ie_age);
4501 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
4502 qie_age->element_id = QCOM_VENDOR_IE_ID;
4503 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
4504 qie_age->oui_1 = QCOM_OUI1;
4505 qie_age->oui_2 = QCOM_OUI2;
4506 qie_age->oui_3 = QCOM_OUI3;
4507 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
4508 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
4509#endif
4510
Jeff Johnson295189b2012-06-20 16:38:30 -07004511 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05304512 if (bss_desc->fProbeRsp)
4513 {
4514 mgmt->frame_control |=
4515 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
4516 }
4517 else
4518 {
4519 mgmt->frame_control |=
4520 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
4521 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004522
4523#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304524 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004525 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
4526 {
4527 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4528 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304529 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004530 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
4531
4532 {
4533 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4534 }
4535 else
4536 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05304537 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
4538 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -07004539 kfree(mgmt);
4540 return NULL;
4541 }
4542#else
4543 freq = ieee80211_channel_to_frequency(chan_no);
4544#endif
4545 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004546 /*when the band is changed on the fly using the GUI, three things are done
4547 * 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)
4548 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
4549 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
4550 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
4551 * and discards the channels correponding to previous band and calls back with zero bss results.
4552 * 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
4553 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
4554 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
4555 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
4556 * So drop the bss and continue to next bss.
4557 */
4558 if(chan == NULL)
4559 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05304560 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07004561 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004562 return NULL;
4563 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004564 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304565 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07004566 * */
4567 if (( eConnectionState_Associated ==
4568 pAdapter->sessionCtx.station.conn_info.connState ) &&
4569 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
4570 pAdapter->sessionCtx.station.conn_info.bssId,
4571 WNI_CFG_BSSID_LEN)))
4572 {
4573 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
4574 rssi = (pAdapter->rssi * 100);
4575 }
4576 else
4577 {
4578 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
4579 }
4580
Nirav Shah20ac06f2013-12-12 18:14:06 +05304581 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
4582 "RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
4583 chan->center_freq, (int)(rssi/100));
4584
Jeff Johnson295189b2012-06-20 16:38:30 -07004585 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
4586 frame_len, rssi, GFP_KERNEL);
4587 kfree(mgmt);
4588 return bss_status;
4589}
4590
4591/*
4592 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
4593 * This function is used to update the BSS data base of CFG8011
4594 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304595struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004596 tCsrRoamInfo *pRoamInfo
4597 )
4598{
4599 tCsrRoamConnectedProfile roamProfile;
4600 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4601 struct cfg80211_bss *bss = NULL;
4602
4603 ENTER();
4604
4605 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
4606 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
4607
4608 if (NULL != roamProfile.pBssDesc)
4609 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304610 bss = wlan_hdd_cfg80211_inform_bss(pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004611 &roamProfile);
4612
4613 if (NULL == bss)
4614 {
4615 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
4616 __func__);
4617 }
4618
4619 sme_RoamFreeConnectProfile(hHal, &roamProfile);
4620 }
4621 else
4622 {
4623 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
4624 __func__);
4625 }
4626 return bss;
4627}
4628
4629/*
4630 * FUNCTION: wlan_hdd_cfg80211_update_bss
4631 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304632static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
4633 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304635{
Jeff Johnson295189b2012-06-20 16:38:30 -07004636 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4637 tCsrScanResultInfo *pScanResult;
4638 eHalStatus status = 0;
4639 tScanResultHandle pResult;
4640 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07004641 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004642
4643 ENTER();
4644
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304645 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
4646 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
4647 NO_SESSION, pAdapter->sessionId));
4648
Wilson Yangf80a0542013-10-07 13:02:37 -07004649 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4650
4651 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -07004652 {
Wilson Yangf80a0542013-10-07 13:02:37 -07004653 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4654 "%s:LOGP in Progress. Ignore!!!",__func__);
4655 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004656 }
4657
Wilson Yangf80a0542013-10-07 13:02:37 -07004658
4659 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +05304660 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -07004661 {
4662 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4663 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
4664 return VOS_STATUS_E_PERM;
4665 }
4666
4667
Jeff Johnson295189b2012-06-20 16:38:30 -07004668 /*
4669 * start getting scan results and populate cgf80211 BSS database
4670 */
4671 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
4672
4673 /* no scan results */
4674 if (NULL == pResult)
4675 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05304676 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
4677 __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004678 return status;
4679 }
4680
4681 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
4682
4683 while (pScanResult)
4684 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304685 /*
4686 * cfg80211_inform_bss() is not updating ie field of bss entry, if
4687 * entry already exists in bss data base of cfg80211 for that
4688 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
4689 * bss entry instead of cfg80211_inform_bss, But this call expects
4690 * mgmt packet as input. As of now there is no possibility to get
4691 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07004692 * ieee80211_mgmt(probe response) and passing to c
4693 * fg80211_inform_bss_frame.
4694 * */
4695
4696 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
4697 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304698
Jeff Johnson295189b2012-06-20 16:38:30 -07004699
4700 if (NULL == bss_status)
4701 {
4702 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004703 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004704 }
4705 else
4706 {
Yue Maf49ba872013-08-19 12:04:25 -07004707 cfg80211_put_bss(
4708#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
4709 wiphy,
4710#endif
4711 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004712 }
4713
4714 pScanResult = sme_ScanResultGetNext(hHal, pResult);
4715 }
4716
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304717 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07004718
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304719 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004720}
4721
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004722void
4723hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
4724{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304725 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -08004726 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004727} /****** end hddPrintMacAddr() ******/
4728
4729void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004730hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004731{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304732 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004733 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004734 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
4735 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
4736 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004737} /****** end hddPrintPmkId() ******/
4738
4739//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
4740//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
4741
4742//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
4743//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
4744
4745#define dump_bssid(bssid) \
4746 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004747 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
4748 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004749 }
4750
4751#define dump_pmkid(pMac, pmkid) \
4752 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004753 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
4754 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004755 }
4756
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004757#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004758/*
4759 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
4760 * This function is used to notify the supplicant of a new PMKSA candidate.
4761 */
4762int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304763 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004764 int index, bool preauth )
4765{
Jeff Johnsone7245742012-09-05 17:12:55 -07004766#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004767 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004768 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004769
4770 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07004771 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004772
4773 if( NULL == pRoamInfo )
4774 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004775 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004776 return -EINVAL;
4777 }
4778
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004779 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
4780 {
4781 dump_bssid(pRoamInfo->bssid);
4782 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004783 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004784 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004785#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304786 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004787}
4788#endif //FEATURE_WLAN_LFR
4789
Yue Maef608272013-04-08 23:09:17 -07004790#ifdef FEATURE_WLAN_LFR_METRICS
4791/*
4792 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
4793 * 802.11r/LFR metrics reporting function to report preauth initiation
4794 *
4795 */
4796#define MAX_LFR_METRICS_EVENT_LENGTH 100
4797VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
4798 tCsrRoamInfo *pRoamInfo)
4799{
4800 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4801 union iwreq_data wrqu;
4802
4803 ENTER();
4804
4805 if (NULL == pAdapter)
4806 {
4807 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4808 return VOS_STATUS_E_FAILURE;
4809 }
4810
4811 /* create the event */
4812 memset(&wrqu, 0, sizeof(wrqu));
4813 memset(metrics_notification, 0, sizeof(metrics_notification));
4814
4815 wrqu.data.pointer = metrics_notification;
4816 wrqu.data.length = scnprintf(metrics_notification,
4817 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
4818 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
4819
4820 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4821
4822 EXIT();
4823
4824 return VOS_STATUS_SUCCESS;
4825}
4826
4827/*
4828 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
4829 * 802.11r/LFR metrics reporting function to report preauth completion
4830 * or failure
4831 */
4832VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
4833 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
4834{
4835 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4836 union iwreq_data wrqu;
4837
4838 ENTER();
4839
4840 if (NULL == pAdapter)
4841 {
4842 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4843 return VOS_STATUS_E_FAILURE;
4844 }
4845
4846 /* create the event */
4847 memset(&wrqu, 0, sizeof(wrqu));
4848 memset(metrics_notification, 0, sizeof(metrics_notification));
4849
4850 scnprintf(metrics_notification, sizeof(metrics_notification),
4851 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
4852 MAC_ADDR_ARRAY(pRoamInfo->bssid));
4853
4854 if (1 == preauth_status)
4855 strncat(metrics_notification, " TRUE", 5);
4856 else
4857 strncat(metrics_notification, " FALSE", 6);
4858
4859 wrqu.data.pointer = metrics_notification;
4860 wrqu.data.length = strlen(metrics_notification);
4861
4862 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4863
4864 EXIT();
4865
4866 return VOS_STATUS_SUCCESS;
4867}
4868
4869/*
4870 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
4871 * 802.11r/LFR metrics reporting function to report handover initiation
4872 *
4873 */
4874VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
4875 tCsrRoamInfo *pRoamInfo)
4876{
4877 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4878 union iwreq_data wrqu;
4879
4880 ENTER();
4881
4882 if (NULL == pAdapter)
4883 {
4884 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4885 return VOS_STATUS_E_FAILURE;
4886 }
4887
4888 /* create the event */
4889 memset(&wrqu, 0, sizeof(wrqu));
4890 memset(metrics_notification, 0, sizeof(metrics_notification));
4891
4892 wrqu.data.pointer = metrics_notification;
4893 wrqu.data.length = scnprintf(metrics_notification,
4894 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
4895 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
4896
4897 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4898
4899 EXIT();
4900
4901 return VOS_STATUS_SUCCESS;
4902}
4903#endif
4904
Jeff Johnson295189b2012-06-20 16:38:30 -07004905/*
4906 * FUNCTION: hdd_cfg80211_scan_done_callback
4907 * scanning callback function, called after finishing scan
4908 *
4909 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304910static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -07004911 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
4912{
4913 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304914 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004915 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004916 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4917 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07004918 struct cfg80211_scan_request *req = NULL;
4919 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05304920 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304921 long waitRet = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004922
4923 ENTER();
4924
4925 hddLog(VOS_TRACE_LEVEL_INFO,
4926 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -08004927 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004928 __func__, halHandle, pContext, (int) scanId, (int) status);
4929
Kiet Lamac06e2c2013-10-23 16:25:07 +05304930 pScanInfo->mScanPendingCounter = 0;
4931
Jeff Johnson295189b2012-06-20 16:38:30 -07004932 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304933 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -07004934 &pScanInfo->scan_req_completion_event,
4935 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304936 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004937 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304938 hddLog(VOS_TRACE_LEVEL_ERROR,
4939 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -07004940 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004941 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004942 }
4943
Yue Maef608272013-04-08 23:09:17 -07004944 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004945 {
4946 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004947 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004948 }
4949
4950 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304951 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -07004952 {
4953 hddLog(VOS_TRACE_LEVEL_INFO,
4954 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004955 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004956 (int) scanId);
4957 }
4958
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304959 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004960 pAdapter);
4961
4962 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304963 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004964
4965
4966 /* If any client wait scan result through WEXT
4967 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004968 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07004969 {
4970 /* The other scan request waiting for current scan finish
4971 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004972 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004973 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004974 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07004975 }
4976 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004977 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004978 {
4979 struct net_device *dev = pAdapter->dev;
4980 union iwreq_data wrqu;
4981 int we_event;
4982 char *msg;
4983
4984 memset(&wrqu, '\0', sizeof(wrqu));
4985 we_event = SIOCGIWSCAN;
4986 msg = NULL;
4987 wireless_send_event(dev, we_event, &wrqu, msg);
4988 }
4989 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004990 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004991
4992 /* Get the Scan Req */
4993 req = pAdapter->request;
4994
4995 if (!req)
4996 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004997 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004998 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004999 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07005000 }
5001
5002 /*
5003 * setting up 0, just in case.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305004 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005005 req->n_ssids = 0;
5006 req->n_channels = 0;
5007 req->ie = 0;
5008
Jeff Johnson295189b2012-06-20 16:38:30 -07005009 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07005010 /* Scan is no longer pending */
5011 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005012
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -07005013 /*
5014 * cfg80211_scan_done informing NL80211 about completion
5015 * of scanning
5016 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05305017 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
5018 {
5019 aborted = true;
5020 }
5021 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08005022 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07005023
Jeff Johnsone7245742012-09-05 17:12:55 -07005024allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07005025 /* release the wake lock at the end of the scan*/
5026 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07005027
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07005028 /* Acquire wakelock to handle the case where APP's tries to suspend
5029 * immediatly after the driver gets connect request(i.e after scan)
5030 * from supplicant, this result in app's is suspending and not able
5031 * to process the connect request to AP */
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05305032 hdd_prevent_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07005033
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07005034#ifdef FEATURE_WLAN_TDLS
5035 wlan_hdd_tdls_scan_done_callback(pAdapter);
5036#endif
5037
Jeff Johnson295189b2012-06-20 16:38:30 -07005038 EXIT();
5039 return 0;
5040}
5041
5042/*
Rashmi Ramannab1429032014-04-26 14:59:09 +05305043 * FUNCTION: hdd_isConnectionInProgress
5044 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005045 *
5046 */
Rashmi Ramannab1429032014-04-26 14:59:09 +05305047v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx )
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005048{
5049 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
5050 hdd_station_ctx_t *pHddStaCtx = NULL;
5051 hdd_adapter_t *pAdapter = NULL;
5052 VOS_STATUS status = 0;
5053 v_U8_t staId = 0;
5054 v_U8_t *staMac = NULL;
5055
c_hpothu9b781ba2013-12-30 20:57:45 +05305056 if (TRUE == pHddCtx->btCoexModeSet)
5057 {
5058 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +05305059 FL("BTCoex Mode operation in progress"));
5060 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +05305061 }
5062
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005063 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
5064
5065 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
5066 {
5067 pAdapter = pAdapterNode->pAdapter;
5068
5069 if( pAdapter )
5070 {
5071 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305072 "%s: Adapter with device mode %s (%d) exists",
5073 __func__, hdd_device_modetoString(pAdapter->device_mode),
5074 pAdapter->device_mode);
Rashmi Ramannab1429032014-04-26 14:59:09 +05305075 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
5076 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
5077 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
5078 (eConnectionState_Connecting ==
5079 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
5080 {
5081 hddLog(VOS_TRACE_LEVEL_ERROR,
5082 "%s: %p(%d) Connection is in progress", __func__,
5083 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
5084 return VOS_TRUE;
5085 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005086 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305087 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
5088 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005089 {
5090 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5091 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305092 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005093 {
5094 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
5095 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08005096 "%s: client " MAC_ADDRESS_STR
5097 " is in the middle of WPS/EAPOL exchange.", __func__,
5098 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +05305099 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005100 }
5101 }
5102 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
5103 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
5104 {
5105 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
5106 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305107 if ((pAdapter->aStaInfo[staId].isUsed) &&
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005108 (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState))
5109 {
5110 staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
5111
5112 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08005113 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
5114 "middle of WPS/EAPOL exchange.", __func__,
5115 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +05305116 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005117 }
5118 }
5119 }
5120 }
5121 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
5122 pAdapterNode = pNext;
5123 }
Rashmi Ramannab1429032014-04-26 14:59:09 +05305124 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305125}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005126
5127/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005128 * FUNCTION: wlan_hdd_cfg80211_scan
5129 * this scan respond to scan trigger and update cfg80211 scan database
5130 * later, scan dump command can be used to recieve scan results
5131 */
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08005132int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
5133#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
5134 struct net_device *dev,
5135#endif
5136 struct cfg80211_scan_request *request)
5137{
5138#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
5139 struct net_device *dev = request->wdev->netdev;
5140#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305141 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07005142 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5143 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305144 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005145 tCsrScanRequest scanRequest;
5146 tANI_U8 *channelList = NULL, i;
5147 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305148 int status;
5149 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005150 v_U8_t* pP2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005151
5152 ENTER();
5153
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305154 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
5155 TRACE_CODE_HDD_CFG80211_SCAN,
5156 pAdapter->sessionId, request->n_channels));
5157
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305158 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
5159 __func__, hdd_device_modetoString(pAdapter->device_mode),
5160 pAdapter->device_mode);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005161
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305162 status = wlan_hdd_validate_context(pHddCtx);
5163
5164 if (0 != status)
5165 {
5166 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5167 "%s: HDD context is not valid", __func__);
5168 return status;
5169 }
5170
5171 cfg_param = pHddCtx->cfg_ini;
5172 pScanInfo = &pHddCtx->scan_info;
5173
Jeff Johnson295189b2012-06-20 16:38:30 -07005174#ifdef WLAN_BTAMP_FEATURE
5175 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005176 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -07005177 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005178 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005179 "%s: No scanning when AMP is on", __func__);
5180 return -EOPNOTSUPP;
5181 }
5182#endif
5183 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005184 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07005185 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005186 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305187 "%s: Not scanning on device_mode = %s (%d)",
5188 __func__, hdd_device_modetoString(pAdapter->device_mode),
5189 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005190 return -EOPNOTSUPP;
5191 }
5192
5193 if (TRUE == pScanInfo->mScanPending)
5194 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05305195 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
5196 {
5197 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
5198 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005199 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005200 }
5201
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305202 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -07005203 //Channel and action frame is pending
5204 //Otherwise Cancel Remain On Channel and allow Scan
5205 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005206 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -07005207 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05305208 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -07005209 return -EBUSY;
5210 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005211#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07005212 /* if tdls disagree scan right now, return immediately.
5213 tdls will schedule the scan when scan is allowed. (return SUCCESS)
5214 or will reject the scan if any TDLS is in progress. (return -EBUSY)
5215 */
5216 status = wlan_hdd_tdls_scan_callback (pAdapter,
5217 wiphy,
5218#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
5219 dev,
Gopichand Nakkalac3c42b92013-03-20 19:42:34 -07005220#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07005221 request);
5222 if(status <= 0)
5223 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05305224 if(!status)
5225 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
5226 "scan rejected %d", __func__, status);
5227 else
5228 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
5229 __func__, status);
5230
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07005231 return status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005232 }
5233#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07005234
Jeff Johnson295189b2012-06-20 16:38:30 -07005235 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
5236 {
5237 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -08005238 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005239 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305240 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005241 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
5242 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05305243 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005244 "%s: MAX TM Level Scan not allowed", __func__);
5245 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305246 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005247 }
5248 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
5249
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005250 /* Check if scan is allowed at this point of time.
5251 */
Rashmi Ramannab1429032014-04-26 14:59:09 +05305252 if (hdd_isConnectionInProgress(pHddCtx))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005253 {
5254 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
5255 return -EBUSY;
5256 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305257
Jeff Johnson295189b2012-06-20 16:38:30 -07005258 vos_mem_zero( &scanRequest, sizeof(scanRequest));
5259
5260 if (NULL != request)
5261 {
5262 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305263 (int)request->n_ssids);
Jeff Johnson295189b2012-06-20 16:38:30 -07005264
5265 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
5266 * Becasue of this, driver is assuming that this is not wildcard scan and so
5267 * is not aging out the scan results.
5268 */
Jeff Johnson32d95a32012-09-10 13:15:23 -07005269 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07005270 {
5271 request->n_ssids = 0;
5272 }
5273
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07005274 if ((request->ssids) && (0 < request->n_ssids))
Jeff Johnson295189b2012-06-20 16:38:30 -07005275 {
5276 tCsrSSIDInfo *SsidInfo;
5277 int j;
5278 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
5279 /* Allocate num_ssid tCsrSSIDInfo structure */
5280 SsidInfo = scanRequest.SSIDs.SSIDList =
5281 ( tCsrSSIDInfo *)vos_mem_malloc(
5282 request->n_ssids*sizeof(tCsrSSIDInfo));
5283
5284 if(NULL == scanRequest.SSIDs.SSIDList)
5285 {
5286 hddLog(VOS_TRACE_LEVEL_ERROR,
Nirav Shah20ac06f2013-12-12 18:14:06 +05305287 "%s: memory alloc failed SSIDInfo buffer", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005288 return -ENOMEM;
5289 }
5290
5291 /* copy all the ssid's and their length */
5292 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
5293 {
5294 /* get the ssid length */
5295 SsidInfo->SSID.length = request->ssids[j].ssid_len;
5296 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
5297 SsidInfo->SSID.length);
5298 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
Nirav Shah20ac06f2013-12-12 18:14:06 +05305299 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005300 j, SsidInfo->SSID.ssId);
5301 }
5302 /* set the scan type to active */
5303 scanRequest.scanType = eSIR_ACTIVE_SCAN;
5304 }
5305 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
5306 {
5307 /* set the scan type to active */
5308 scanRequest.scanType = eSIR_ACTIVE_SCAN;
5309 }
5310 else
5311 {
5312 /*Set the scan type to default type, in this case it is ACTIVE*/
5313 scanRequest.scanType = pScanInfo->scan_mode;
5314 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305315 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07005316 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
5317 }
5318 else
5319 {
5320 /* set the scan type to active */
5321 scanRequest.scanType = eSIR_ACTIVE_SCAN;
5322 vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff );
5323
5324 /* set min and max channel time to zero */
5325 scanRequest.minChnTime = 0;
5326 scanRequest.maxChnTime = 0;
5327 }
5328
5329 /* set BSSType to default type */
5330 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
5331
5332 /*TODO: scan the requested channels only*/
5333
5334 /*Right now scanning all the channels */
5335 if( request )
5336 {
c_hpothu53512302014-04-15 18:49:53 +05305337 if (MAX_CHANNEL < request->n_channels)
5338 {
5339 hddLog(VOS_TRACE_LEVEL_WARN,
5340 "No of Scan Channels exceeded limit: %d", request->n_channels);
5341 request->n_channels = MAX_CHANNEL;
5342 }
Nirav Shah20ac06f2013-12-12 18:14:06 +05305343 hddLog(VOS_TRACE_LEVEL_INFO,
5344 "No of Scan Channels: %d", request->n_channels);
c_hpothu53512302014-04-15 18:49:53 +05305345
Jeff Johnson295189b2012-06-20 16:38:30 -07005346 if( request->n_channels )
5347 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05305348 char chList [(request->n_channels*5)+1];
5349 int len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005350 channelList = vos_mem_malloc( request->n_channels );
5351 if( NULL == channelList )
5352 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305353 hddLog(VOS_TRACE_LEVEL_ERROR,
Nirav Shah20ac06f2013-12-12 18:14:06 +05305354 "%s: memory alloc failed channelList", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005355 status = -ENOMEM;
5356 goto free_mem;
5357 }
5358
Nirav Shah20ac06f2013-12-12 18:14:06 +05305359 for( i = 0, len = 0; i < request->n_channels ; i++ )
5360 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005361 channelList[i] = request->channels[i]->hw_value;
Nirav Shah20ac06f2013-12-12 18:14:06 +05305362 len += snprintf(chList+len, 5, "%d ", channelList[i]);
5363 }
5364
5365 hddLog(VOS_TRACE_LEVEL_INFO,
5366 "Channel-List: %s ", chList);
Jeff Johnson295189b2012-06-20 16:38:30 -07005367 }
5368
5369 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
5370 scanRequest.ChannelInfo.ChannelList = channelList;
5371
5372 /* set requestType to full scan */
5373 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305374
5375 /* Flush the scan results(only p2p beacons) for STA scan and P2P
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08005376 * search (Flush on both full scan and social scan but not on single
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305377 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08005378 */
5379
5380 /* Supplicant does single channel scan after 8-way handshake
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305381 * and in that case driver shoudnt flush scan results. If
5382 * driver flushes the scan results here and unfortunately if
5383 * the AP doesnt respond to our probe req then association
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08005384 * fails which is not desired
5385 */
5386
5387 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
5388 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05305389 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08005390 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
5391 pAdapter->sessionId );
5392 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005393
5394 if( request->ie_len )
5395 {
5396 /* save this for future association (join requires this) */
Agarwal Ashish4f616132013-12-30 23:32:50 +05305397 /*TODO: Array needs to be converted to dynamic allocation,
5398 * as multiple ie.s can be sent in cfg80211_scan_request structure
5399 * CR 597966
5400 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005401 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
5402 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
5403 pScanInfo->scanAddIE.length = request->ie_len;
5404
Agarwal Ashish4f616132013-12-30 23:32:50 +05305405 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07005406 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
Agarwal Ashish4f616132013-12-30 23:32:50 +05305407 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07005408 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05305409 if ( request->ie_len <= SIR_MAC_MAX_IE_LENGTH)
5410 {
5411 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
5412 memcpy( pwextBuf->roamProfile.addIEScan,
5413 request->ie, request->ie_len);
5414 }
5415 else
5416 {
5417 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
Arun Kumar Khandavalli75eeb122014-03-27 21:43:12 +05305418 "%zu", request->ie_len);
Agarwal Ashish4f616132013-12-30 23:32:50 +05305419 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005420
Agarwal Ashish4f616132013-12-30 23:32:50 +05305421 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005422 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
5423 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
5424
Jeff Johnson295189b2012-06-20 16:38:30 -07005425 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
5426 request->ie_len);
5427 if (pP2pIe != NULL)
5428 {
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07005429#ifdef WLAN_FEATURE_P2P_DEBUG
5430 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
5431 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
5432 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5433 {
5434 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
5435 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
5436 "Go nego completed to Connection is started");
5437 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
5438 "for 8way Handshake");
5439 }
5440 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
5441 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5442 {
5443 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
5444 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
5445 "Disconnected state to Connection is started");
5446 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
5447 "for 4way Handshake");
5448 }
5449#endif
5450
Jeff Johnsone7245742012-09-05 17:12:55 -07005451 /* no_cck will be set during p2p find to disable 11b rates */
5452 if(TRUE == request->no_cck)
Jeff Johnson295189b2012-06-20 16:38:30 -07005453 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005454 hddLog(VOS_TRACE_LEVEL_INFO,
5455 "%s: This is a P2P Search", __func__);
5456 scanRequest.p2pSearch = 1;
Jeff Johnsone7245742012-09-05 17:12:55 -07005457
Jeff Johnsone7245742012-09-05 17:12:55 -07005458 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
5459 {
Madan Mohan Koyyalamudi1b1d9e82012-10-21 11:38:33 -07005460 /* set requestType to P2P Discovery */
5461 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
Jeff Johnsone7245742012-09-05 17:12:55 -07005462 }
5463
5464 /*
5465 Skip Dfs Channel in case of P2P Search
5466 if it is set in ini file
5467 */
5468 if(cfg_param->skipDfsChnlInP2pSearch)
5469 {
5470 scanRequest.skipDfsChnlInP2pSearch = 1;
5471 }
5472 else
5473 {
5474 scanRequest.skipDfsChnlInP2pSearch = 0;
5475 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005476
Jeff Johnson295189b2012-06-20 16:38:30 -07005477 }
5478 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005479 }
5480 }
5481
5482 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
5483
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07005484 /* acquire the wakelock to avoid the apps suspend during the scan. To
5485 * address the following issues.
5486 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
5487 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
5488 * for long time, this result in apps running at full power for long time.
5489 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
5490 * be stuck in full power because of resume BMPS
5491 */
5492 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07005493
Nirav Shah20ac06f2013-12-12 18:14:06 +05305494 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5495 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305496 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
5497 scanRequest.requestType, scanRequest.scanType,
5498 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +05305499 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
5500
Jeff Johnsone7245742012-09-05 17:12:55 -07005501 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005502 pAdapter->sessionId, &scanRequest, &scanId,
5503 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -07005504
Jeff Johnson295189b2012-06-20 16:38:30 -07005505 if (eHAL_STATUS_SUCCESS != status)
5506 {
5507 hddLog(VOS_TRACE_LEVEL_ERROR,
5508 "%s: sme_ScanRequest returned error %d", __func__, status);
5509 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07005510 if(eHAL_STATUS_RESOURCES == status)
5511 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05305512 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
5513 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07005514 status = -EBUSY;
5515 } else {
5516 status = -EIO;
5517 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07005518 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07005519 goto free_mem;
5520 }
5521
5522 pScanInfo->mScanPending = TRUE;
5523 pAdapter->request = request;
5524 pScanInfo->scanId = scanId;
5525
5526 complete(&pScanInfo->scan_req_completion_event);
5527
5528free_mem:
5529 if( scanRequest.SSIDs.SSIDList )
5530 {
5531 vos_mem_free(scanRequest.SSIDs.SSIDList);
5532 }
5533
5534 if( channelList )
5535 vos_mem_free( channelList );
5536
5537 EXIT();
5538
5539 return status;
5540}
5541
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005542
5543void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
5544{
5545 v_U8_t iniDot11Mode =
5546 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
5547 eHddDot11Mode hddDot11Mode = iniDot11Mode;
5548
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05305549 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
5550 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005551 switch ( iniDot11Mode )
5552 {
5553 case eHDD_DOT11_MODE_AUTO:
5554 case eHDD_DOT11_MODE_11ac:
5555 case eHDD_DOT11_MODE_11ac_ONLY:
5556#ifdef WLAN_FEATURE_11AC
5557 hddDot11Mode = eHDD_DOT11_MODE_11ac;
5558#else
5559 hddDot11Mode = eHDD_DOT11_MODE_11n;
5560#endif
5561 break;
5562 case eHDD_DOT11_MODE_11n:
5563 case eHDD_DOT11_MODE_11n_ONLY:
5564 hddDot11Mode = eHDD_DOT11_MODE_11n;
5565 break;
5566 default:
5567 hddDot11Mode = iniDot11Mode;
5568 break;
5569 }
5570 /* This call decides required channel bonding mode */
5571 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
5572 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
5573 operationChannel);
5574}
5575
Jeff Johnson295189b2012-06-20 16:38:30 -07005576/*
5577 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305578 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -07005579 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305580int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -07005581 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07005582{
5583 int status = 0;
5584 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -08005585 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005586 v_U32_t roamId;
5587 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005588 eCsrAuthType RSNAuthType;
5589
5590 ENTER();
5591
5592 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -08005593 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5594
5595 status = wlan_hdd_validate_context(pHddCtx);
5596 if (status)
5597 {
5598 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5599 "%s: HDD context is not valid!", __func__);
5600 return status;
5601 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305602
Jeff Johnson295189b2012-06-20 16:38:30 -07005603 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
5604 {
5605 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
5606 return -EINVAL;
5607 }
5608
5609 pRoamProfile = &pWextState->roamProfile;
5610
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305611 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07005612 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005613 hdd_station_ctx_t *pHddStaCtx;
5614 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005615
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305616 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07005617 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
5618 {
5619 /*QoS not enabled in cfg file*/
5620 pRoamProfile->uapsd_mask = 0;
5621 }
5622 else
5623 {
5624 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305625 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -07005626 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
5627 }
5628
5629 pRoamProfile->SSIDs.numOfSSIDs = 1;
5630 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
5631 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305632 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005633 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
5634 ssid, ssid_len);
5635
5636 if (bssid)
5637 {
5638 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
5639 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
5640 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305641 /* Save BSSID in seperate variable as well, as RoamProfile
5642 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -07005643 case of join failure we should send valid BSSID to supplicant
5644 */
5645 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
5646 WNI_CFG_BSSID_LEN);
5647 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07005648 else
5649 {
5650 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
5651 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005652
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05305653 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
5654 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07005655 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
5656 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305657 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 /*set gen ie*/
5659 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
5660 /*set auth*/
5661 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5662 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005663#ifdef FEATURE_WLAN_WAPI
5664 if (pAdapter->wapi_info.nWapiMode)
5665 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005666 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005667 switch (pAdapter->wapi_info.wapiAuthMode)
5668 {
5669 case WAPI_AUTH_MODE_PSK:
5670 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005671 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005672 pAdapter->wapi_info.wapiAuthMode);
5673 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5674 break;
5675 }
5676 case WAPI_AUTH_MODE_CERT:
5677 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005678 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005679 pAdapter->wapi_info.wapiAuthMode);
5680 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5681 break;
5682 }
5683 } // End of switch
5684 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5685 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
5686 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005687 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005688 pRoamProfile->AuthType.numEntries = 1;
5689 pRoamProfile->EncryptionType.numEntries = 1;
5690 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5691 pRoamProfile->mcEncryptionType.numEntries = 1;
5692 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5693 }
5694 }
5695#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305696#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305697 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305698 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
5699 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5700 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305701 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
5702 sizeof (tSirGtkOffloadParams));
5703 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305704 }
5705#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005706 pRoamProfile->csrPersona = pAdapter->device_mode;
5707
Jeff Johnson32d95a32012-09-10 13:15:23 -07005708 if( operatingChannel )
5709 {
5710 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
5711 pRoamProfile->ChannelInfo.numOfChannels = 1;
5712 }
Chet Lanctot186b5732013-03-18 10:26:30 -07005713 else
5714 {
5715 pRoamProfile->ChannelInfo.ChannelList = NULL;
5716 pRoamProfile->ChannelInfo.numOfChannels = 0;
5717 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005718 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
5719 {
5720 hdd_select_cbmode(pAdapter,operatingChannel);
5721 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05305722
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005723 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
5724 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305725 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005726 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005727 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
5728 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305729 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5730 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005731 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5732 eConnectionState_Connecting);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305733
5734 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005735 pAdapter->sessionId, pRoamProfile, &roamId);
5736
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305737 if ((eHAL_STATUS_SUCCESS != status) &&
5738 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5739 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305740
5741 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005742 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
5743 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
5744 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305745 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005746 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305747 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005748
5749 pRoamProfile->ChannelInfo.ChannelList = NULL;
5750 pRoamProfile->ChannelInfo.numOfChannels = 0;
5751
Jeff Johnson295189b2012-06-20 16:38:30 -07005752 }
5753 else
5754 {
5755 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
5756 return -EINVAL;
5757 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005758 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005759 return status;
5760}
5761
5762/*
5763 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
5764 * This function is used to set the authentication type (OPEN/SHARED).
5765 *
5766 */
5767static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
5768 enum nl80211_auth_type auth_type)
5769{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305770 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005771 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5772
5773 ENTER();
5774
5775 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305776 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -07005777 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005778 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305779 hddLog(VOS_TRACE_LEVEL_INFO,
5780 "%s: set authentication type to AUTOSWITCH", __func__);
5781 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
5782 break;
5783
5784 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07005785#ifdef WLAN_FEATURE_VOWIFI_11R
5786 case NL80211_AUTHTYPE_FT:
5787#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305788 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005789 "%s: set authentication type to OPEN", __func__);
5790 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5791 break;
5792
5793 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305794 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005795 "%s: set authentication type to SHARED", __func__);
5796 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
5797 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005798#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005799 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305800 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005801 "%s: set authentication type to CCKM WPA", __func__);
5802 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
5803 break;
5804#endif
5805
5806
5807 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305808 hddLog(VOS_TRACE_LEVEL_ERROR,
5809 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005810 auth_type);
5811 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
5812 return -EINVAL;
5813 }
5814
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305815 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005816 pHddStaCtx->conn_info.authType;
5817 return 0;
5818}
5819
5820/*
5821 * FUNCTION: wlan_hdd_set_akm_suite
5822 * This function is used to set the key mgmt type(PSK/8021x).
5823 *
5824 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305825static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005826 u32 key_mgmt
5827 )
5828{
5829 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5830 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305831
Jeff Johnson295189b2012-06-20 16:38:30 -07005832 /*set key mgmt type*/
5833 switch(key_mgmt)
5834 {
5835 case WLAN_AKM_SUITE_PSK:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305836#ifdef WLAN_FEATURE_VOWIFI_11R
5837 case WLAN_AKM_SUITE_FT_PSK:
5838#endif
5839 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -07005840 __func__);
5841 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5842 break;
5843
5844 case WLAN_AKM_SUITE_8021X:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305845#ifdef WLAN_FEATURE_VOWIFI_11R
5846 case WLAN_AKM_SUITE_FT_8021X:
5847#endif
5848 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -07005849 __func__);
5850 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5851 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005852#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005853#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
5854#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5855 case WLAN_AKM_SUITE_CCKM:
5856 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
5857 __func__);
5858 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
5859 break;
5860#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07005861#ifndef WLAN_AKM_SUITE_OSEN
5862#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
5863 case WLAN_AKM_SUITE_OSEN:
5864 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
5865 __func__);
5866 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5867 break;
5868#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005869
5870 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305871 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005872 __func__, key_mgmt);
5873 return -EINVAL;
5874
5875 }
5876 return 0;
5877}
5878
5879/*
5880 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305881 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -07005882 * (NONE/WEP40/WEP104/TKIP/CCMP).
5883 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305884static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
5885 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -07005886 bool ucast
5887 )
5888{
5889 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305890 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005891 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5892
5893 ENTER();
5894
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305895 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005896 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305897 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -07005898 __func__, cipher);
5899 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5900 }
5901 else
5902 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305903
Jeff Johnson295189b2012-06-20 16:38:30 -07005904 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305905 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005906 {
5907 case IW_AUTH_CIPHER_NONE:
5908 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5909 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305910
Jeff Johnson295189b2012-06-20 16:38:30 -07005911 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305912 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07005913 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305914
Jeff Johnson295189b2012-06-20 16:38:30 -07005915 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305916 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -07005917 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305918
Jeff Johnson295189b2012-06-20 16:38:30 -07005919 case WLAN_CIPHER_SUITE_TKIP:
5920 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5921 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305922
Jeff Johnson295189b2012-06-20 16:38:30 -07005923 case WLAN_CIPHER_SUITE_CCMP:
5924 encryptionType = eCSR_ENCRYPT_TYPE_AES;
5925 break;
5926#ifdef FEATURE_WLAN_WAPI
5927 case WLAN_CIPHER_SUITE_SMS4:
5928 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
5929 break;
5930#endif
5931
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005932#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005933 case WLAN_CIPHER_SUITE_KRK:
5934 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
5935 break;
5936#endif
5937 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305938 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005939 __func__, cipher);
5940 return -EOPNOTSUPP;
5941 }
5942 }
5943
5944 if (ucast)
5945 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305946 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005947 __func__, encryptionType);
5948 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
5949 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305950 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005951 encryptionType;
5952 }
5953 else
5954 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305955 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005956 __func__, encryptionType);
5957 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
5958 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5959 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
5960 }
5961
5962 return 0;
5963}
5964
5965
5966/*
5967 * FUNCTION: wlan_hdd_cfg80211_set_ie
5968 * This function is used to parse WPA/RSN IE's.
5969 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305970int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
5971 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -07005972 size_t ie_len
5973 )
5974{
5975 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5976 u8 *genie = ie;
5977 v_U16_t remLen = ie_len;
5978#ifdef FEATURE_WLAN_WAPI
5979 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
5980 u16 *tmp;
5981 v_U16_t akmsuiteCount;
5982 int *akmlist;
5983#endif
5984 ENTER();
5985
5986 /* clear previous assocAddIE */
5987 pWextState->assocAddIE.length = 0;
5988 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07005989 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005990
5991 while (remLen >= 2)
5992 {
5993 v_U16_t eLen = 0;
5994 v_U8_t elementId;
5995 elementId = *genie++;
5996 eLen = *genie++;
5997 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305998
Arif Hussain6d2a3322013-11-17 19:50:10 -08005999 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07006000 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306001
6002 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -07006003 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306004 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006005 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 -07006006 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306007 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006008 "%s: Invalid WPA IE", __func__);
6009 return -EINVAL;
6010 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306011 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -07006012 {
6013 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306014 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07006015 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306016
Jeff Johnson295189b2012-06-20 16:38:30 -07006017 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
6018 {
Jeff Johnson902c9832012-12-10 14:28:09 -08006019 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
6020 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07006021 VOS_ASSERT(0);
6022 return -ENOMEM;
6023 }
6024 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
6025 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
6026 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306027
Jeff Johnson295189b2012-06-20 16:38:30 -07006028 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
6029 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
6030 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
6031 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306032 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
6033 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006034 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
6035 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
6036 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
6037 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
6038 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
6039 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306040 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +05306041 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006042 {
6043 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306044 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07006045 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306046
Jeff Johnson295189b2012-06-20 16:38:30 -07006047 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
6048 {
Jeff Johnson902c9832012-12-10 14:28:09 -08006049 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
6050 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07006051 VOS_ASSERT(0);
6052 return -ENOMEM;
6053 }
6054 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
6055 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
6056 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306057
Jeff Johnson295189b2012-06-20 16:38:30 -07006058 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
6059 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
6060 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006061#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306062 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
6063 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006064 /*Consider WFD IE, only for P2P Client */
6065 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
6066 {
6067 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306068 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07006069 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306070
Jeff Johnson295189b2012-06-20 16:38:30 -07006071 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
6072 {
Jeff Johnson902c9832012-12-10 14:28:09 -08006073 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
6074 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07006075 VOS_ASSERT(0);
6076 return -ENOMEM;
6077 }
6078 // WFD IE is saved to Additional IE ; it should be accumulated to handle
6079 // WPS IE + P2P IE + WFD IE
6080 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
6081 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306082
Jeff Johnson295189b2012-06-20 16:38:30 -07006083 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
6084 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
6085 }
6086#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006087 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306088 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006089 HS20_OUI_TYPE_SIZE)) )
6090 {
6091 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306092 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006093 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006094
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006095 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
6096 {
Jeff Johnson902c9832012-12-10 14:28:09 -08006097 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
6098 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006099 VOS_ASSERT(0);
6100 return -ENOMEM;
6101 }
6102 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
6103 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006104
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006105 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
6106 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
6107 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006108 /* Appending OSEN Information Element in Assiciation Request */
6109 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
6110 OSEN_OUI_TYPE_SIZE)) )
6111 {
6112 v_U16_t curAddIELen = pWextState->assocAddIE.length;
6113 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
6114 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006115
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006116 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
6117 {
6118 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
6119 "Need bigger buffer space");
6120 VOS_ASSERT(0);
6121 return -ENOMEM;
6122 }
6123 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
6124 pWextState->assocAddIE.length += eLen + 2;
6125
6126 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
6127 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
6128 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
6129 }
6130
6131 break;
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -07006132 if (WLAN_HDD_IBSS == pAdapter->device_mode) {
6133
6134 /* populating as ADDIE in beacon frames */
6135 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
6136 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
6137 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
6138 {
6139 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
6140 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
6141 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6142 {
6143 hddLog(LOGE,
6144 "Coldn't pass "
6145 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
6146 }
6147 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
6148 else
6149 hddLog(LOGE,
6150 "Could not pass on "
6151 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
6152
6153 /* IBSS mode doesn't contain params->proberesp_ies still
6154 beaconIE's need to be populated in probe response frames */
6155 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
6156 {
6157 u16 rem_probe_resp_ie_len = eLen + 2;
6158 u8 probe_rsp_ie_len[3] = {0};
6159 u8 counter = 0;
6160
6161 /* Check Probe Resp Length if it is greater then 255 then
6162 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
6163 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
6164 not able Store More then 255 bytes into One Variable */
6165
6166 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
6167 {
6168 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
6169 {
6170 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
6171 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
6172 }
6173 else
6174 {
6175 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
6176 rem_probe_resp_ie_len = 0;
6177 }
6178 }
6179
6180 rem_probe_resp_ie_len = 0;
6181
6182 if (probe_rsp_ie_len[0] > 0)
6183 {
6184 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
6185 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
6186 (tANI_U8*)(genie - 2),
6187 probe_rsp_ie_len[0], NULL,
6188 eANI_BOOLEAN_FALSE)
6189 == eHAL_STATUS_FAILURE)
6190 {
6191 hddLog(LOGE,
6192 "Could not pass"
6193 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
6194 }
6195 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
6196 }
6197
6198 if (probe_rsp_ie_len[1] > 0)
6199 {
6200 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
6201 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
6202 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
6203 probe_rsp_ie_len[1], NULL,
6204 eANI_BOOLEAN_FALSE)
6205 == eHAL_STATUS_FAILURE)
6206 {
6207 hddLog(LOGE,
6208 "Could not pass"
6209 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
6210 }
6211 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
6212 }
6213
6214 if (probe_rsp_ie_len[2] > 0)
6215 {
6216 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
6217 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
6218 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
6219 probe_rsp_ie_len[2], NULL,
6220 eANI_BOOLEAN_FALSE)
6221 == eHAL_STATUS_FAILURE)
6222 {
6223 hddLog(LOGE,
6224 "Could not pass"
6225 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
6226 }
6227 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
6228 }
6229
6230 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
6231 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
6232 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6233 {
6234 hddLog(LOGE,
6235 "Could not pass"
6236 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
6237 }
6238 }
6239 else
6240 {
6241 // Reset WNI_CFG_PROBE_RSP Flags
6242 wlan_hdd_reset_prob_rspies(pAdapter);
6243
6244 hddLog(VOS_TRACE_LEVEL_INFO,
6245 "%s: No Probe Response IE received in set beacon",
6246 __func__);
6247 }
6248 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -07006249 break;
6250 case DOT11F_EID_RSN:
6251 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
6252 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
6253 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
6254 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
6255 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
6256 break;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006257 /* Appending Extended Capabilities with Interworking bit set in Assoc Req */
6258 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306259 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006260 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306261 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006262 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306263
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006264 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
6265 {
Jeff Johnson902c9832012-12-10 14:28:09 -08006266 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
6267 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006268 VOS_ASSERT(0);
6269 return -ENOMEM;
6270 }
6271 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
6272 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306273
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006274 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
6275 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
6276 break;
6277 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006278#ifdef FEATURE_WLAN_WAPI
6279 case WLAN_EID_WAPI:
6280 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006281 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07006282 pAdapter->wapi_info.nWapiMode);
6283 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306284 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -07006285 akmsuiteCount = WPA_GET_LE16(tmp);
6286 tmp = tmp + 1;
6287 akmlist = (int *)(tmp);
6288 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
6289 {
6290 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
6291 }
6292 else
6293 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006294 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 VOS_ASSERT(0);
6296 return -EINVAL;
6297 }
6298
6299 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
6300 {
6301 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006302 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006303 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306304 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006305 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306306 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006307 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006308 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006309 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
6310 }
6311 break;
6312#endif
6313 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306314 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006315 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006316 /* when Unknown IE is received we should break and continue
6317 * to the next IE in the buffer instead we were returning
6318 * so changing this to break */
6319 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006320 }
6321 genie += eLen;
6322 remLen -= eLen;
6323 }
6324 EXIT();
6325 return 0;
6326}
6327
6328/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +05306329 * FUNCTION: hdd_isWPAIEPresent
6330 * Parse the received IE to find the WPA IE
6331 *
6332 */
6333static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
6334{
6335 v_U8_t eLen = 0;
6336 v_U16_t remLen = ie_len;
6337 v_U8_t elementId = 0;
6338
6339 while (remLen >= 2)
6340 {
6341 elementId = *ie++;
6342 eLen = *ie++;
6343 remLen -= 2;
6344 if (eLen > remLen)
6345 {
6346 hddLog(VOS_TRACE_LEVEL_ERROR,
6347 "%s: IE length is wrong %d", __func__, eLen);
6348 return FALSE;
6349 }
6350 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
6351 {
6352 /* OUI - 0x00 0X50 0XF2
6353 WPA Information Element - 0x01
6354 WPA version - 0x01*/
6355 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
6356 return TRUE;
6357 }
6358 ie += eLen;
6359 remLen -= eLen;
6360 }
6361 return FALSE;
6362}
6363
6364/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006365 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306366 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006367 * parameters during connect operation.
6368 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306369int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006370 struct cfg80211_connect_params *req
6371 )
6372{
6373 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306374 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006375 ENTER();
6376
6377 /*set wpa version*/
6378 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
6379
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306380 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07006381 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +05306382 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07006383 {
6384 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
6385 }
6386 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
6387 {
6388 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
6389 }
6390 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306391
6392 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006393 pWextState->wpaVersion);
6394
6395 /*set authentication type*/
6396 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
6397
6398 if (0 > status)
6399 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306400 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006401 "%s: failed to set authentication type ", __func__);
6402 return status;
6403 }
6404
6405 /*set key mgmt type*/
6406 if (req->crypto.n_akm_suites)
6407 {
6408 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
6409 if (0 > status)
6410 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306411 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -07006412 __func__);
6413 return status;
6414 }
6415 }
6416
6417 /*set pairwise cipher type*/
6418 if (req->crypto.n_ciphers_pairwise)
6419 {
6420 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
6421 req->crypto.ciphers_pairwise[0], true);
6422 if (0 > status)
6423 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306424 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006425 "%s: failed to set unicast cipher type", __func__);
6426 return status;
6427 }
6428 }
6429 else
6430 {
6431 /*Reset previous cipher suite to none*/
6432 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
6433 if (0 > status)
6434 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306435 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006436 "%s: failed to set unicast cipher type", __func__);
6437 return status;
6438 }
6439 }
6440
6441 /*set group cipher type*/
6442 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
6443 false);
6444
6445 if (0 > status)
6446 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306447 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -07006448 __func__);
6449 return status;
6450 }
6451
Chet Lanctot186b5732013-03-18 10:26:30 -07006452#ifdef WLAN_FEATURE_11W
6453 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
6454#endif
6455
Jeff Johnson295189b2012-06-20 16:38:30 -07006456 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
6457 if (req->ie_len)
6458 {
6459 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
6460 if ( 0 > status)
6461 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306462 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006463 __func__);
6464 return status;
6465 }
6466 }
6467
6468 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306469 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006470 {
6471 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
6472 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
6473 )
6474 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306475 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -07006476 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
6477 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306478 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07006479 __func__);
6480 return -EOPNOTSUPP;
6481 }
6482 else
6483 {
6484 u8 key_len = req->key_len;
6485 u8 key_idx = req->key_idx;
6486
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306487 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006488 && (CSR_MAX_NUM_KEY > key_idx)
6489 )
6490 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306491 hddLog(VOS_TRACE_LEVEL_INFO,
6492 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006493 __func__, key_idx, key_len);
6494 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306495 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07006496 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306497 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -07006498 (u8)key_len;
6499 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
6500 }
6501 }
6502 }
6503 }
6504
6505 return status;
6506}
6507
6508/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +05306509 * FUNCTION: wlan_hdd_try_disconnect
6510 * This function is used to disconnect from previous
6511 * connection
6512 */
6513static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
6514{
6515 long ret = 0;
6516 hdd_station_ctx_t *pHddStaCtx;
6517 eMib_dot11DesiredBssType connectedBssType;
6518
6519 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6520
6521 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
6522
6523 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
6524 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
6525 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
6526 {
6527 /* Issue disconnect to CSR */
6528 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6529 if( eHAL_STATUS_SUCCESS ==
6530 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
6531 pAdapter->sessionId,
6532 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
6533 {
6534 ret = wait_for_completion_interruptible_timeout(
6535 &pAdapter->disconnect_comp_var,
6536 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6537 if (0 >= ret)
6538 {
6539 hddLog(LOGE, FL("Failed to receive disconnect event"));
6540 return -EALREADY;
6541 }
6542 }
6543 }
6544 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
6545 {
6546 ret = wait_for_completion_interruptible_timeout(
6547 &pAdapter->disconnect_comp_var,
6548 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6549 if (0 >= ret)
6550 {
6551 hddLog(LOGE, FL("Failed to receive disconnect event"));
6552 return -EALREADY;
6553 }
6554 }
6555
6556 return 0;
6557}
6558
6559/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006560 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306561 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006562 * parameters during connect operation.
6563 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306564static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006565 struct net_device *ndev,
6566 struct cfg80211_connect_params *req
6567 )
6568{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306569 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306570 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006571 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -08006572 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006573
6574 ENTER();
6575
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306576 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6577 TRACE_CODE_HDD_CFG80211_CONNECT,
6578 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306579 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306580 "%s: device_mode = %s (%d)", __func__,
6581 hdd_device_modetoString(pAdapter->device_mode),
6582 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006583
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306584 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08006585 if (!pHddCtx)
6586 {
6587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6588 "%s: HDD context is null", __func__);
6589 return VOS_STATUS_E_FAILURE;
6590 }
6591
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306592 status = wlan_hdd_validate_context(pHddCtx);
6593
6594 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006595 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306596 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6597 "%s: HDD context is not valid", __func__);
6598 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006599 }
6600
6601#ifdef WLAN_BTAMP_FEATURE
6602 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306603 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -07006604 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306605 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006606 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08006607 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -07006608 }
6609#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +05306610
6611 //If Device Mode is Station Concurrent Sessions Exit BMps
6612 //P2P Mode will be taken care in Open/close adapter
6613 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
6614 (vos_concurrent_sessions_running()))
6615 {
6616 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
6617 }
6618
6619 /*Try disconnecting if already in connected state*/
6620 status = wlan_hdd_try_disconnect(pAdapter);
6621 if ( 0 > status)
6622 {
6623 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
6624 " connection"));
6625 return -EALREADY;
6626 }
6627
Jeff Johnson295189b2012-06-20 16:38:30 -07006628 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306629 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -07006630
6631 if ( 0 > status)
6632 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306633 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -07006634 __func__);
6635 return status;
6636 }
6637
Mohit Khanna765234a2012-09-11 15:08:35 -07006638 if ( req->channel )
6639 {
6640 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
6641 req->ssid_len, req->bssid,
6642 req->channel->hw_value);
6643 }
6644 else
6645 {
6646 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306647 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -07006648 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006649
6650 if (0 > status)
6651 {
6652 //ReEnable BMPS if disabled
6653 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
6654 (NULL != pHddCtx))
6655 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306656 if (pHddCtx->hdd_wlan_suspended)
6657 {
6658 hdd_set_pwrparams(pHddCtx);
6659 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006660 //ReEnable Bmps and Imps back
6661 hdd_enable_bmps_imps(pHddCtx);
6662 }
6663
6664 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6665 return status;
6666 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306667 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006668 EXIT();
6669 return status;
6670}
6671
6672
6673/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306674 * FUNCTION: wlan_hdd_disconnect
6675 * This function is used to issue a disconnect request to SME
6676 */
6677int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
6678{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306679 int status;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306680 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306681 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6682
6683 status = wlan_hdd_validate_context(pHddCtx);
6684
6685 if (0 != status)
6686 {
6687 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6688 "%s: HDD context is not valid", __func__);
6689 return status;
6690 }
6691
6692 pHddCtx->isAmpAllowed = VOS_TRUE;
Vinay Krishna Erannab09d3e72014-03-26 21:23:55 +05306693 pHddStaCtx->conn_info.connState = eConnectionState_Disconnecting;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306694 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306695
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306696 /*issue disconnect*/
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05306697
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306698 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
6699 pAdapter->sessionId, reason);
6700
6701 if ( 0 != status )
6702 {
6703 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006704 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306705 __func__, (int)status );
6706 return -EINVAL;
6707 }
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05306708 status = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306709 &pAdapter->disconnect_comp_var,
6710 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05306711 if (!status)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306712 {
6713 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05306714 "%s: Failed to disconnect, timed out", __func__);
6715 return -ETIMEDOUT;
6716 }
6717 else if (status == -ERESTARTSYS)
6718 {
6719 hddLog(VOS_TRACE_LEVEL_ERROR,
6720 "%s: Failed to disconnect, wait interrupted", __func__);
6721 return status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306722 }
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306723 /*stop tx queues*/
6724 netif_tx_disable(pAdapter->dev);
6725 netif_carrier_off(pAdapter->dev);
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05306726 return 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306727}
6728
6729
6730/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006731 * FUNCTION: wlan_hdd_cfg80211_disconnect
6732 * This function is used to issue a disconnect request to SME
6733 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306734static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006735 struct net_device *dev,
6736 u16 reason
6737 )
6738{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306739 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6740 tCsrRoamProfile *pRoamProfile =
Jeff Johnson295189b2012-06-20 16:38:30 -07006741 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306742 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006743 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006744 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306745#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006746 tANI_U8 staIdx;
6747#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306748
Jeff Johnson295189b2012-06-20 16:38:30 -07006749 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306750
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306751 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6752 TRACE_CODE_HDD_CFG80211_DISCONNECT,
6753 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306754 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
6755 __func__, hdd_device_modetoString(pAdapter->device_mode),
6756 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006757
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306758 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
6759 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006760
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306761 status = wlan_hdd_validate_context(pHddCtx);
6762
6763 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006764 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306765 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6766 "%s: HDD context is not valid", __func__);
6767 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006768 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306769
Jeff Johnson295189b2012-06-20 16:38:30 -07006770 if (NULL != pRoamProfile)
6771 {
6772 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +05306773 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
6774 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -07006775 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306776 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07006777 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306778 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07006779 switch(reason)
6780 {
6781 case WLAN_REASON_MIC_FAILURE:
6782 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
6783 break;
6784
6785 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
6786 case WLAN_REASON_DISASSOC_AP_BUSY:
6787 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
6788 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
6789 break;
6790
6791 case WLAN_REASON_PREV_AUTH_NOT_VALID:
6792 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
6793 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
6794 break;
6795
6796 case WLAN_REASON_DEAUTH_LEAVING:
6797 default:
6798 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
6799 break;
6800 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306801 pScanInfo = &pHddCtx->scan_info;
6802 if (pScanInfo->mScanPending)
6803 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306804 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306805 "Aborting Scan");
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306806 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
6807 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306808 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006809
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006810#ifdef FEATURE_WLAN_TDLS
6811 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006812 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006813 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006814 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
6815 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006816 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006817 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006818 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006819 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006820 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006821 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006822 MAC_ADDR_ARRAY(mac));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006823 sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006824 pAdapter->sessionId,
6825 mac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006826 }
6827 }
6828#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05306829 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306830 status = wlan_hdd_disconnect(pAdapter, reasonCode);
6831 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -07006832 {
6833 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006834 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006835 __func__, (int)status );
6836 return -EINVAL;
6837 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006838 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +05306839 else
6840 {
6841 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
6842 "called while in %d state", __func__,
6843 pHddStaCtx->conn_info.connState);
6844 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006845 }
6846 else
6847 {
6848 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
6849 }
6850
6851 return status;
6852}
6853
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306854
Jeff Johnson295189b2012-06-20 16:38:30 -07006855/*
6856 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306857 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006858 * settings in IBSS mode.
6859 */
6860static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306861 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006862 struct cfg80211_ibss_params *params
6863 )
6864{
6865 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306866 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006867 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6868 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306869
Jeff Johnson295189b2012-06-20 16:38:30 -07006870 ENTER();
6871
6872 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -07006873 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006874
6875 if (params->ie_len && ( NULL != params->ie) )
6876 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006877 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6878 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006879 {
6880 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
6881 encryptionType = eCSR_ENCRYPT_TYPE_AES;
6882 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006883 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006884 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006885 tDot11fIEWPA dot11WPAIE;
6886 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006887 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006888
Wilson Yang00256342013-10-10 23:13:38 -07006889 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006890 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6891 params->ie_len, DOT11F_EID_WPA);
6892 if ( NULL != ie )
6893 {
6894 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
6895 // Unpack the WPA IE
6896 //Skip past the EID byte and length byte - and four byte WiFi OUI
6897 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
6898 &ie[2+4],
6899 ie[1] - 4,
6900 &dot11WPAIE);
6901 /*Extract the multicast cipher, the encType for unicast
6902 cipher for wpa-none is none*/
6903 encryptionType =
6904 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
6905 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006906 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006907
Jeff Johnson295189b2012-06-20 16:38:30 -07006908 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
6909
6910 if (0 > status)
6911 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306912 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006913 __func__);
6914 return status;
6915 }
6916 }
6917
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306918 pWextState->roamProfile.AuthType.authType[0] =
6919 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -07006920 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6921
6922 if (params->privacy)
6923 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306924 /* Security enabled IBSS, At this time there is no information available
6925 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -07006926 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306927 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -07006928 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306929 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -07006930 *enable privacy bit in beacons */
6931
6932 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6933 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006934 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
6935 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07006936 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
6937 pWextState->roamProfile.EncryptionType.numEntries = 1;
6938 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07006939 return status;
6940}
6941
6942/*
6943 * FUNCTION: wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306944 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006945 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306946static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006947 struct net_device *dev,
6948 struct cfg80211_ibss_params *params
6949 )
6950{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306951 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006952 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6953 tCsrRoamProfile *pRoamProfile;
6954 int status;
krunal sonie9002db2013-11-25 14:24:17 -08006955 bool alloc_bssid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006956 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306957 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006958
6959 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306960
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306961 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6962 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
6963 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306964 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306965 "%s: device_mode = %s (%d)", __func__,
6966 hdd_device_modetoString(pAdapter->device_mode),
6967 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006968
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306969 status = wlan_hdd_validate_context(pHddCtx);
6970
6971 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006972 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306973 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6974 "%s: HDD context is not valid", __func__);
6975 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006976 }
6977
6978 if (NULL == pWextState)
6979 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006980 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -07006981 __func__);
6982 return -EIO;
6983 }
6984
Vinay Krishna Eranna21042322014-01-08 19:21:39 +05306985 /*Try disconnecting if already in connected state*/
6986 status = wlan_hdd_try_disconnect(pAdapter);
6987 if ( 0 > status)
6988 {
6989 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
6990 " IBSS connection"));
6991 return -EALREADY;
6992 }
6993
Jeff Johnson295189b2012-06-20 16:38:30 -07006994 pRoamProfile = &pWextState->roamProfile;
6995
6996 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
6997 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306998 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006999 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007000 return -EINVAL;
7001 }
7002
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -07007003 /* BSSID is provided by upper layers hence no need to AUTO generate */
7004 if (NULL != params->bssid) {
7005 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
7006 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
7007 hddLog (VOS_TRACE_LEVEL_ERROR,
7008 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
7009 return -EIO;
7010 }
7011 }
krunal sonie9002db2013-11-25 14:24:17 -08007012 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
7013 {
7014 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
7015 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
7016 {
7017 hddLog (VOS_TRACE_LEVEL_ERROR,
7018 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
7019 return -EIO;
7020 }
7021 params->bssid = vos_mem_malloc(sizeof(VOS_MAC_ADDR_SIZE));
7022 if (!params->bssid)
7023 {
7024 hddLog (VOS_TRACE_LEVEL_ERROR,
7025 "%s:Failed memory allocation", __func__);
7026 return -EIO;
7027 }
7028 vos_mem_copy((v_U8_t *)params->bssid,
7029 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
7030 VOS_MAC_ADDR_SIZE);
7031 alloc_bssid = VOS_TRUE;
7032 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -07007033
Jeff Johnson295189b2012-06-20 16:38:30 -07007034 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -07007035 if (NULL !=
7036#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
7037 params->chandef.chan)
7038#else
7039 params->channel)
7040#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007041 {
7042 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07007043 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
7044 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7045 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7046 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007047
7048 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307049 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -07007050 ieee80211_frequency_to_channel(
7051#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
7052 params->chandef.chan->center_freq);
7053#else
7054 params->channel->center_freq);
7055#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07007056
7057 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
7058 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -07007059 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07007060 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
7061 __func__);
7062 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -07007063 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07007064
7065 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -07007066 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07007067 if (channelNum == validChan[indx])
7068 {
7069 break;
7070 }
7071 }
7072 if (indx >= numChans)
7073 {
7074 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007075 __func__, channelNum);
7076 return -EINVAL;
7077 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07007078 /* Set the Operational Channel */
7079 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
7080 channelNum);
7081 pRoamProfile->ChannelInfo.numOfChannels = 1;
7082 pHddStaCtx->conn_info.operationChannel = channelNum;
7083 pRoamProfile->ChannelInfo.ChannelList =
7084 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07007085 }
7086
7087 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307088 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -07007089 if (status < 0)
7090 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307091 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -07007092 __func__);
7093 return status;
7094 }
7095
7096 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307097 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07007098 params->ssid_len, params->bssid,
7099 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07007100
7101 if (0 > status)
7102 {
7103 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
7104 return status;
7105 }
7106
krunal sonie9002db2013-11-25 14:24:17 -08007107 if (NULL != params->bssid &&
7108 pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 &&
7109 alloc_bssid == VOS_TRUE)
7110 {
7111 vos_mem_free(params->bssid);
7112 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007113 return 0;
7114}
7115
7116/*
7117 * FUNCTION: wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307118 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07007119 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307120static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007121 struct net_device *dev
7122 )
7123{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307124 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07007125 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7126 tCsrRoamProfile *pRoamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307127 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7128 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007129
7130 ENTER();
7131
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307132 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7133 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
7134 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307135 status = wlan_hdd_validate_context(pHddCtx);
7136
7137 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007138 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307139 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7140 "%s: HDD context is not valid", __func__);
7141 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007142 }
7143
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307144 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
7145 hdd_device_modetoString(pAdapter->device_mode),
7146 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007147 if (NULL == pWextState)
7148 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007149 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -07007150 __func__);
7151 return -EIO;
7152 }
7153
7154 pRoamProfile = &pWextState->roamProfile;
7155
7156 /* Issue disconnect only if interface type is set to IBSS */
7157 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
7158 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307159 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -07007160 __func__);
7161 return -EINVAL;
7162 }
7163
7164 /* Issue Disconnect request */
7165 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7166 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
7167 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
7168
7169 return 0;
7170}
7171
7172/*
7173 * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params
7174 * This function is used to set the phy parameters
7175 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
7176 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307177static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007178 u32 changed)
7179{
7180 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7181 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307182 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007183
7184 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307185 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7186 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
7187 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307188 status = wlan_hdd_validate_context(pHddCtx);
7189
7190 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007191 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307192 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7193 "%s: HDD context is not valid", __func__);
7194 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007195 }
7196
Jeff Johnson295189b2012-06-20 16:38:30 -07007197 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
7198 {
7199 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
7200 WNI_CFG_RTS_THRESHOLD_STAMAX :
7201 wiphy->rts_threshold;
7202
7203 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307204 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -07007205 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307206 hddLog(VOS_TRACE_LEVEL_ERROR,
7207 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007208 __func__, rts_threshold);
7209 return -EINVAL;
7210 }
7211
7212 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
7213 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307214 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07007215 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307216 hddLog(VOS_TRACE_LEVEL_ERROR,
7217 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007218 __func__, rts_threshold);
7219 return -EIO;
7220 }
7221
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307222 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007223 rts_threshold);
7224 }
7225
7226 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
7227 {
7228 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
7229 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
7230 wiphy->frag_threshold;
7231
7232 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307233 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007234 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307235 hddLog(VOS_TRACE_LEVEL_ERROR,
7236 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007237 frag_threshold);
7238 return -EINVAL;
7239 }
7240
7241 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
7242 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307243 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07007244 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307245 hddLog(VOS_TRACE_LEVEL_ERROR,
7246 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007247 __func__, frag_threshold);
7248 return -EIO;
7249 }
7250
7251 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
7252 frag_threshold);
7253 }
7254
7255 if ((changed & WIPHY_PARAM_RETRY_SHORT)
7256 || (changed & WIPHY_PARAM_RETRY_LONG))
7257 {
7258 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
7259 wiphy->retry_short :
7260 wiphy->retry_long;
7261
7262 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
7263 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
7264 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307265 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007266 __func__, retry_value);
7267 return -EINVAL;
7268 }
7269
7270 if (changed & WIPHY_PARAM_RETRY_SHORT)
7271 {
7272 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
7273 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307274 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07007275 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307276 hddLog(VOS_TRACE_LEVEL_ERROR,
7277 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007278 __func__, retry_value);
7279 return -EIO;
7280 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307281 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007282 __func__, retry_value);
7283 }
7284 else if (changed & WIPHY_PARAM_RETRY_SHORT)
7285 {
7286 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
7287 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307288 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07007289 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307290 hddLog(VOS_TRACE_LEVEL_ERROR,
7291 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007292 __func__, retry_value);
7293 return -EIO;
7294 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307295 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007296 __func__, retry_value);
7297 }
7298 }
7299
7300 return 0;
7301}
7302
7303/*
7304 * FUNCTION: wlan_hdd_cfg80211_set_txpower
7305 * This function is used to set the txpower
7306 */
7307static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07007308#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
7309 struct wireless_dev *wdev,
7310#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007311#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307312 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07007313#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307314 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07007315#endif
7316 int dbm)
7317{
7318 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307319 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007320 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
7321 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307322 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007323
7324 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307325 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7326 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
7327 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307328 status = wlan_hdd_validate_context(pHddCtx);
7329
7330 if (0 != status)
7331 {
7332 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7333 "%s: HDD context is not valid", __func__);
7334 return status;
7335 }
7336
7337 hHal = pHddCtx->hHal;
7338
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307339 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
7340 dbm, ccmCfgSetCallback,
7341 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07007342 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307343 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007344 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
7345 return -EIO;
7346 }
7347
7348 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
7349 dbm);
7350
7351 switch(type)
7352 {
7353 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
7354 /* Fall through */
7355 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
7356 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
7357 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307358 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
7359 __func__);
7360 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07007361 }
7362 break;
7363 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307364 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07007365 __func__);
7366 return -EOPNOTSUPP;
7367 break;
7368 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307369 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
7370 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -07007371 return -EIO;
7372 }
7373
7374 return 0;
7375}
7376
7377/*
7378 * FUNCTION: wlan_hdd_cfg80211_get_txpower
7379 * This function is used to read the txpower
7380 */
Yue Maf49ba872013-08-19 12:04:25 -07007381static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
7382#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
7383 struct wireless_dev *wdev,
7384#endif
7385 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -07007386{
7387
7388 hdd_adapter_t *pAdapter;
7389 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307390 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007391
Jeff Johnsone7245742012-09-05 17:12:55 -07007392 ENTER();
7393
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307394 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007395
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307396 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007397 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307398 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7399 "%s: HDD context is not valid", __func__);
7400 *dbm = 0;
7401 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007402 }
7403
Jeff Johnson295189b2012-06-20 16:38:30 -07007404 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
7405 if (NULL == pAdapter)
7406 {
7407 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
7408 return -ENOENT;
7409 }
7410
7411 wlan_hdd_get_classAstats(pAdapter);
7412 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
7413
Jeff Johnsone7245742012-09-05 17:12:55 -07007414 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007415 return 0;
7416}
7417
7418static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
7419 u8* mac, struct station_info *sinfo)
7420{
7421 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
7422 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7423 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +05307424 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -07007425
7426 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
7427 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07007428
7429 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
7430 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
7431 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
7432 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
7433 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
7434 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
7435 tANI_U16 maxRate = 0;
7436 tANI_U16 myRate;
7437 tANI_U16 currentRate = 0;
7438 tANI_U8 maxSpeedMCS = 0;
7439 tANI_U8 maxMCSIdx = 0;
7440 tANI_U8 rateFlag = 1;
7441 tANI_U8 i, j, rssidx;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07007442 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307443 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007444
Leo Chang6f8870f2013-03-26 18:11:36 -07007445#ifdef WLAN_FEATURE_11AC
7446 tANI_U32 vht_mcs_map;
7447 eDataRate11ACMaxMcs vhtMaxMcs;
7448#endif /* WLAN_FEATURE_11AC */
7449
Jeff Johnsone7245742012-09-05 17:12:55 -07007450 ENTER();
7451
Jeff Johnson295189b2012-06-20 16:38:30 -07007452 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
7453 (0 == ssidlen))
7454 {
7455 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
7456 " Invalid ssidlen, %d", __func__, ssidlen);
7457 /*To keep GUI happy*/
7458 return 0;
7459 }
7460
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307461 status = wlan_hdd_validate_context(pHddCtx);
7462
7463 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007464 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307465 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7466 "%s: HDD context is not valid", __func__);
7467 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007468 }
7469
Jeff Johnson295189b2012-06-20 16:38:30 -07007470
Kiet Lam3b17fc82013-09-27 05:24:08 +05307471 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
7472 sinfo->filled |= STATION_INFO_SIGNAL;
7473
c_hpothu44ff4e02014-05-08 00:13:57 +05307474 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
7475 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
7476 sinfo->signal >= pCfg->linkSpeedRssiHigh))
7477 {
7478 rate_flags = pAdapter->maxRateFlags;
7479 }
7480 else
7481 {
7482 wlan_hdd_get_station_stats(pAdapter);
7483 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
7484 }
7485
Jeff Johnson295189b2012-06-20 16:38:30 -07007486 //convert to the UI units of 100kbps
7487 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
7488
7489#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -07007490 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 -07007491 sinfo->signal,
7492 pCfg->reportMaxLinkSpeed,
7493 myRate,
7494 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007495 (int) pCfg->linkSpeedRssiMid,
7496 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -07007497 (int) rate_flags,
7498 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07007499#endif //LINKSPEED_DEBUG_ENABLED
7500
7501 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
7502 {
7503 // we do not want to necessarily report the current speed
7504 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
7505 {
7506 // report the max possible speed
7507 rssidx = 0;
7508 }
7509 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
7510 {
7511 // report the max possible speed with RSSI scaling
7512 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
7513 {
7514 // report the max possible speed
7515 rssidx = 0;
7516 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007517 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -07007518 {
7519 // report middle speed
7520 rssidx = 1;
7521 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007522 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
7523 {
7524 // report middle speed
7525 rssidx = 2;
7526 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007527 else
7528 {
7529 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007530 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07007531 }
7532 }
7533 else
7534 {
7535 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
7536 hddLog(VOS_TRACE_LEVEL_ERROR,
7537 "%s: Invalid value for reportMaxLinkSpeed: %u",
7538 __func__, pCfg->reportMaxLinkSpeed);
7539 rssidx = 0;
7540 }
7541
7542 maxRate = 0;
7543
7544 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05307545 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
7546 OperationalRates, &ORLeng))
7547 {
7548 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
7549 /*To keep GUI happy*/
7550 return 0;
7551 }
7552
Jeff Johnson295189b2012-06-20 16:38:30 -07007553 for (i = 0; i < ORLeng; i++)
7554 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007555 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07007556 {
7557 /* Validate Rate Set */
7558 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
7559 {
7560 currentRate = supported_data_rate[j].supported_rate[rssidx];
7561 break;
7562 }
7563 }
7564 /* Update MAX rate */
7565 maxRate = (currentRate > maxRate)?currentRate:maxRate;
7566 }
7567
7568 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05307569 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
7570 ExtendedRates, &ERLeng))
7571 {
7572 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
7573 /*To keep GUI happy*/
7574 return 0;
7575 }
7576
Jeff Johnson295189b2012-06-20 16:38:30 -07007577 for (i = 0; i < ERLeng; i++)
7578 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007579 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07007580 {
7581 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
7582 {
7583 currentRate = supported_data_rate[j].supported_rate[rssidx];
7584 break;
7585 }
7586 }
7587 /* Update MAX rate */
7588 maxRate = (currentRate > maxRate)?currentRate:maxRate;
7589 }
Kiet Lamb69f8dc2013-11-15 15:34:27 +05307590 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +05307591 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +05307592 if we have good rssi */
Kaushik, Sushantdc304d82014-01-22 10:58:37 +05307593 if ((0 == rssidx) ||
Kiet Lamb69f8dc2013-11-15 15:34:27 +05307594 (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed))
Jeff Johnson295189b2012-06-20 16:38:30 -07007595 {
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05307596 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
7597 MCSRates, &MCSLeng))
7598 {
7599 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
7600 /*To keep GUI happy*/
7601 return 0;
7602 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007603 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -07007604#ifdef WLAN_FEATURE_11AC
7605 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307606 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -07007607 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007608 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307609 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -07007610 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -07007611 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007612 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007613 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007614 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -07007615 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007616 maxMCSIdx = 7;
7617 }
7618 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
7619 {
7620 maxMCSIdx = 8;
7621 }
7622 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
7623 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307624 //VHT20 is supporting 0~8
7625 if (rate_flags & eHAL_TX_RATE_VHT20)
7626 maxMCSIdx = 8;
7627 else
7628 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -07007629 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307630
7631 if (rate_flags & eHAL_TX_RATE_VHT80)
7632 {
7633 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
7634 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
7635 }
7636 else if (rate_flags & eHAL_TX_RATE_VHT40)
7637 {
7638 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
7639 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
7640 }
7641 else if (rate_flags & eHAL_TX_RATE_VHT20)
7642 {
7643 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
7644 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
7645 }
7646
Leo Chang6f8870f2013-03-26 18:11:36 -07007647 maxSpeedMCS = 1;
7648 if (currentRate > maxRate)
7649 {
7650 maxRate = currentRate;
7651 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307652
Leo Chang6f8870f2013-03-26 18:11:36 -07007653 }
7654 else
7655#endif /* WLAN_FEATURE_11AC */
7656 {
7657 if (rate_flags & eHAL_TX_RATE_HT40)
7658 {
7659 rateFlag |= 1;
7660 }
7661 if (rate_flags & eHAL_TX_RATE_SGI)
7662 {
7663 rateFlag |= 2;
7664 }
7665
7666 for (i = 0; i < MCSLeng; i++)
7667 {
7668 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
7669 for (j = 0; j < temp; j++)
7670 {
7671 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
7672 {
7673 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
7674 break;
7675 }
7676 }
7677 if ((j < temp) && (currentRate > maxRate))
7678 {
7679 maxRate = currentRate;
7680 maxSpeedMCS = 1;
7681 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
7682 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007683 }
7684 }
7685 }
7686
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307687 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
7688 {
7689 maxRate = myRate;
7690 maxSpeedMCS = 1;
7691 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
7692 }
7693
Jeff Johnson295189b2012-06-20 16:38:30 -07007694 // make sure we report a value at least as big as our current rate
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007695 if (((maxRate < myRate) && (0 == rssidx)) ||
7696 (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -07007697 {
7698 maxRate = myRate;
7699 if (rate_flags & eHAL_TX_RATE_LEGACY)
7700 {
7701 maxSpeedMCS = 0;
7702 }
7703 else
7704 {
7705 maxSpeedMCS = 1;
7706 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
7707 }
7708 }
7709
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307710 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -07007711 {
7712 sinfo->txrate.legacy = maxRate;
7713#ifdef LINKSPEED_DEBUG_ENABLED
7714 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
7715#endif //LINKSPEED_DEBUG_ENABLED
7716 }
7717 else
7718 {
7719 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -07007720#ifdef WLAN_FEATURE_11AC
7721 sinfo->txrate.nss = 1;
7722 if (rate_flags & eHAL_TX_RATE_VHT80)
7723 {
7724 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307725 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -07007726 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307727 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -07007728 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307729 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7730 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7731 }
7732 else if (rate_flags & eHAL_TX_RATE_VHT20)
7733 {
7734 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7735 }
7736#endif /* WLAN_FEATURE_11AC */
7737 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
7738 {
7739 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7740 if (rate_flags & eHAL_TX_RATE_HT40)
7741 {
7742 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7743 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007744 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007745 if (rate_flags & eHAL_TX_RATE_SGI)
7746 {
7747 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7748 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307749
Jeff Johnson295189b2012-06-20 16:38:30 -07007750#ifdef LINKSPEED_DEBUG_ENABLED
7751 pr_info("Reporting MCS rate %d flags %x\n",
7752 sinfo->txrate.mcs,
7753 sinfo->txrate.flags );
7754#endif //LINKSPEED_DEBUG_ENABLED
7755 }
7756 }
7757 else
7758 {
7759 // report current rate instead of max rate
7760
7761 if (rate_flags & eHAL_TX_RATE_LEGACY)
7762 {
7763 //provide to the UI in units of 100kbps
7764 sinfo->txrate.legacy = myRate;
7765#ifdef LINKSPEED_DEBUG_ENABLED
7766 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
7767#endif //LINKSPEED_DEBUG_ENABLED
7768 }
7769 else
7770 {
7771 //must be MCS
7772 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -07007773#ifdef WLAN_FEATURE_11AC
7774 sinfo->txrate.nss = 1;
7775 if (rate_flags & eHAL_TX_RATE_VHT80)
7776 {
7777 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7778 }
7779 else
7780#endif /* WLAN_FEATURE_11AC */
7781 {
7782 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7783 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007784 if (rate_flags & eHAL_TX_RATE_SGI)
7785 {
7786 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7787 }
7788 if (rate_flags & eHAL_TX_RATE_HT40)
7789 {
7790 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7791 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007792#ifdef WLAN_FEATURE_11AC
7793 else if (rate_flags & eHAL_TX_RATE_VHT80)
7794 {
7795 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
7796 }
7797#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -07007798#ifdef LINKSPEED_DEBUG_ENABLED
7799 pr_info("Reporting actual MCS rate %d flags %x\n",
7800 sinfo->txrate.mcs,
7801 sinfo->txrate.flags );
7802#endif //LINKSPEED_DEBUG_ENABLED
7803 }
7804 }
7805 sinfo->filled |= STATION_INFO_TX_BITRATE;
7806
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07007807 sinfo->tx_packets =
7808 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
7809 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
7810 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
7811 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
7812
7813 sinfo->tx_retries =
7814 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
7815 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
7816 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
7817 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
7818
7819 sinfo->tx_failed =
7820 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
7821 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
7822 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
7823 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
7824
7825 sinfo->filled |=
7826 STATION_INFO_TX_PACKETS |
7827 STATION_INFO_TX_RETRIES |
7828 STATION_INFO_TX_FAILED;
7829
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307830 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7831 TRACE_CODE_HDD_CFG80211_GET_STA,
7832 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07007833 EXIT();
7834 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007835}
7836
7837static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -07007838 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -07007839{
7840 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307841 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007842 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307843 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007844
Jeff Johnsone7245742012-09-05 17:12:55 -07007845 ENTER();
7846
Jeff Johnson295189b2012-06-20 16:38:30 -07007847 if (NULL == pAdapter)
7848 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007849 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007850 return -ENODEV;
7851 }
7852
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307853 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7854 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
7855 pAdapter->sessionId, timeout));
7856
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307857 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307858 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307859
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307860 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307861 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307862 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7863 "%s: HDD context is not valid", __func__);
7864 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307865 }
7866
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307867 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
7868 (TRUE == pHddCtx->hdd_wlan_suspended) &&
7869 (pHddCtx->cfg_ini->fhostArpOffload) &&
7870 (eConnectionState_Associated ==
7871 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
7872 {
Amar Singhald53568e2013-09-26 11:03:45 -07007873
7874 hddLog(VOS_TRACE_LEVEL_INFO,
7875 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307876 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307877 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7878 {
7879 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007880 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307881 __func__, vos_status);
7882 }
7883 }
7884
Jeff Johnson295189b2012-06-20 16:38:30 -07007885 /**The get power cmd from the supplicant gets updated by the nl only
7886 *on successful execution of the function call
7887 *we are oppositely mapped w.r.t mode in the driver
7888 **/
7889 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
7890
Jeff Johnsone7245742012-09-05 17:12:55 -07007891 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007892 if (VOS_STATUS_E_FAILURE == vos_status)
7893 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307894 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7895 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007896 return -EINVAL;
7897 }
7898 return 0;
7899}
7900
7901
7902#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7903static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
7904 struct net_device *netdev,
7905 u8 key_index)
7906{
Jeff Johnsone7245742012-09-05 17:12:55 -07007907 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007908 return 0;
7909}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307910#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -07007911
7912#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7913static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7914 struct net_device *dev,
7915 struct ieee80211_txq_params *params)
7916{
Jeff Johnsone7245742012-09-05 17:12:55 -07007917 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007918 return 0;
7919}
7920#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7921static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7922 struct ieee80211_txq_params *params)
7923{
Jeff Johnsone7245742012-09-05 17:12:55 -07007924 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007925 return 0;
7926}
7927#endif //LINUX_VERSION_CODE
7928
7929static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
7930 struct net_device *dev, u8 *mac)
7931{
7932 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307933 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007934 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307935 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007936 v_U8_t staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007937
Jeff Johnsone7245742012-09-05 17:12:55 -07007938 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307939
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307940 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -07007941 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307942 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007943 return -EINVAL;
7944 }
7945
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307946 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7947 TRACE_CODE_HDD_CFG80211_DEL_STA,
7948 pAdapter->sessionId, pAdapter->device_mode));
7949
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307950 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7951 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007952
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307953 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007954 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307955 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7956 "%s: HDD context is not valid", __func__);
7957 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007958 }
7959
Jeff Johnson295189b2012-06-20 16:38:30 -07007960 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007961 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007962 )
7963 {
7964 if( NULL == mac )
7965 {
7966 v_U16_t i;
7967 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
7968 {
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007969 if ((pAdapter->aStaInfo[i].isUsed) &&
7970 (!pAdapter->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -07007971 {
7972 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
7973 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007974 "%s: Delete STA with MAC::"
7975 MAC_ADDRESS_STR,
7976 __func__, MAC_ADDR_ARRAY(macAddr));
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007977 vos_status = hdd_softap_sta_deauth(pAdapter, macAddr);
7978 if (VOS_IS_STATUS_SUCCESS(vos_status))
7979 pAdapter->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007980 }
7981 }
7982 }
7983 else
7984 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007985
7986 vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId);
7987 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7988 {
7989 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007990 "%s: Skip this DEL STA as this is not used::"
7991 MAC_ADDRESS_STR,
7992 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007993 return -ENOENT;
7994 }
7995
7996 if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE)
7997 {
7998 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007999 "%s: Skip this DEL STA as deauth is in progress::"
8000 MAC_ADDRESS_STR,
8001 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008002 return -ENOENT;
8003 }
8004
8005 pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE;
8006
Jeff Johnson295189b2012-06-20 16:38:30 -07008007 hddLog(VOS_TRACE_LEVEL_INFO,
8008 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -08008009 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -07008010 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -08008011 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008012
8013 vos_status = hdd_softap_sta_deauth(pAdapter, mac);
8014 if (!VOS_IS_STATUS_SUCCESS(vos_status))
8015 {
8016 pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE;
8017 hddLog(VOS_TRACE_LEVEL_INFO,
8018 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -08008019 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008020 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -08008021 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008022 return -ENOENT;
8023 }
8024
Jeff Johnson295189b2012-06-20 16:38:30 -07008025 }
8026 }
8027
8028 EXIT();
8029
8030 return 0;
8031}
8032
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008033static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
8034 struct net_device *dev, u8 *mac, struct station_parameters *params)
8035{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308036 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008037 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008038#ifdef FEATURE_WLAN_TDLS
8039 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008040 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308041
8042 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8043 TRACE_CODE_HDD_CFG80211_ADD_STA,
8044 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008045 mask = params->sta_flags_mask;
8046
8047 set = params->sta_flags_set;
8048
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008049#ifdef WLAN_FEATURE_TDLS_DEBUG
8050 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8051 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
8052 __func__, mask, set, MAC_ADDR_ARRAY(mac));
8053#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008054
8055 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
8056 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008057 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008058 }
8059 }
8060#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008061 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008062}
8063
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008064
8065#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -07008066#define MAX_PMKSAIDS_IN_CACHE 8
8067
8068static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD local cache
8069static tANI_U32 PMKIDCacheIndex; // HDD local Cache index
8070
8071
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008072static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07008073 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008074{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308075 tANI_U32 j=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008076 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8077 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308078 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308079 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008080 tANI_U8 BSSIDMatched = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308081 hdd_context_t *pHddCtx;
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008082 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
8083 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07008084
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308085 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308086 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008087 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308088 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008089 return -EINVAL;
8090 }
8091
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308092 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8093 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008094
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308095 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008096 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308097 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8098 "%s: HDD context is not valid", __func__);
8099 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008100 }
8101
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308102 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008103 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
8104
Wilson Yang6507c4e2013-10-01 20:11:19 -07008105 for (j = 0; j < PMKIDCacheIndex; j++)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008106 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308107 if(vos_mem_compare(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008108 pmksa->bssid, WNI_CFG_BSSID_LEN))
8109 {
8110 /* BSSID matched previous entry. Overwrite it. */
8111 BSSIDMatched = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308112 vos_mem_copy(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008113 pmksa->bssid, WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308114 vos_mem_copy(PMKIDCache[j].PMKID,
8115 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008116 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308117 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008118 __func__, j );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008119 dump_bssid(pmksa->bssid);
8120 dump_pmkid(halHandle, pmksa->pmkid);
8121 break;
8122 }
8123 }
8124
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07008125 /* Check we compared all entries,if then take the first slot now */
Wilson Yang6507c4e2013-10-01 20:11:19 -07008126 if(j == MAX_PMKSAIDS_IN_CACHE) PMKIDCacheIndex=0;
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07008127
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008128 if (!BSSIDMatched)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308129 {
8130 // Now, we DON'T have a BSSID match, so take a new entry in the cache.
Wilson Yang6507c4e2013-10-01 20:11:19 -07008131 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].BSSID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308132 pmksa->bssid, ETHER_ADDR_LEN);
Wilson Yang6507c4e2013-10-01 20:11:19 -07008133 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].PMKID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308134 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008135 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308136 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Adding a new cache entry %d.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07008137 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008138 dump_bssid(pmksa->bssid);
8139 dump_pmkid(halHandle, pmksa->pmkid);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308140 // Increment the HDD Local Cache index
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008141 // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME
Wilson Yang6507c4e2013-10-01 20:11:19 -07008142 if (PMKIDCacheIndex <= (MAX_PMKSAIDS_IN_CACHE-1)) PMKIDCacheIndex++; else PMKIDCacheIndex = 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008143 }
8144
8145
8146 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308147 //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008148 // __func__, i );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308149 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07008150 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008151 // Finally set the PMKSA ID Cache in CSR
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308152 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
8153 PMKIDCache,
Wilson Yang6507c4e2013-10-01 20:11:19 -07008154 PMKIDCacheIndex);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308155 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8156 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
8157 pAdapter->sessionId, result));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008158 return 0;
8159}
8160
8161
Wilson Yang6507c4e2013-10-01 20:11:19 -07008162
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008163static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -07008164 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008165{
Wilson Yang6507c4e2013-10-01 20:11:19 -07008166 tANI_U32 j=0;
8167 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8168 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008169 tANI_U8 BSSIDMatched = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008170 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -08008171 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008172
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008173 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
8174 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -07008175
8176 /* Validate pAdapter */
8177 if (NULL == pAdapter)
8178 {
8179 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
8180 return -EINVAL;
8181 }
8182
8183 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8184 status = wlan_hdd_validate_context(pHddCtx);
8185
8186 if (0 != status)
8187 {
8188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8189 "%s: HDD context is not valid", __func__);
8190 return status;
8191 }
8192
8193 /*Retrieve halHandle*/
8194 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
8195
8196 /*in case index is 0,no entry to delete*/
8197 if (0 == PMKIDCacheIndex)
8198 {
8199 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" ,
8200 __func__);
8201 return -EINVAL;
8202 }
8203
8204 /*find the matching PMKSA entry from j=0 to (index-1),
8205 * and delete the matched one
8206 */
8207 for (j = 0; j<PMKIDCacheIndex; j++)
8208 {
8209 if (vos_mem_compare(PMKIDCache[j].BSSID,
8210 pmksa->bssid,
8211 WNI_CFG_BSSID_LEN))
8212 {
8213 /* BSSID matched entry */
8214 BSSIDMatched = 1;
8215
8216 if (j<PMKIDCacheIndex-1)
8217 {
8218 /*replace the matching entry with the last entry in HDD local cache*/
8219 vos_mem_copy(PMKIDCache[j].BSSID,
8220 PMKIDCache[PMKIDCacheIndex-1].BSSID,
8221 WNI_CFG_BSSID_LEN);
8222 vos_mem_copy(PMKIDCache[j].PMKID,
8223 PMKIDCache[PMKIDCacheIndex-1].PMKID,
8224 CSR_RSN_PMKID_SIZE);
8225 }
8226
8227 /*clear the last entry in HDD cache ---[index-1]*/
Wilson Yang6507c4e2013-10-01 20:11:19 -07008228 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].BSSID, WNI_CFG_BSSID_LEN);
8229 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].PMKID, CSR_RSN_PMKID_SIZE);
8230
8231 /*reduce the PMKID array index*/
8232 PMKIDCacheIndex--;
8233
8234 /*delete the last PMKID cache in CSR*/
Wilson Yangef657d32014-01-15 19:19:23 -08008235 if (eHAL_STATUS_SUCCESS !=
8236 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pmksa->bssid))
Wilson Yang6507c4e2013-10-01 20:11:19 -07008237 {
8238 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cannot delete PMKSA %d CONTENT.",
8239 __func__,PMKIDCacheIndex);
Wilson Yangef657d32014-01-15 19:19:23 -08008240 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008241 }
8242
8243 dump_bssid(pmksa->bssid);
8244 dump_pmkid(halHandle,pmksa->pmkid);
8245
8246 break;
8247 }
8248 }
8249
8250 /* we compare all entries,but cannot find matching entry */
8251 if (j == MAX_PMKSAIDS_IN_CACHE && !BSSIDMatched)
8252 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008253 hddLog(VOS_TRACE_LEVEL_FATAL,
8254 "%s: No such PMKSA entry existed " MAC_ADDRESS_STR,
8255 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -07008256 dump_bssid(pmksa->bssid);
8257 dump_pmkid(halHandle, pmksa->pmkid);
8258 return -EINVAL;
8259 }
Wilson Yangef657d32014-01-15 19:19:23 -08008260 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008261}
8262
Wilson Yang6507c4e2013-10-01 20:11:19 -07008263
8264
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008265static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
8266{
Wilson Yang6507c4e2013-10-01 20:11:19 -07008267 tANI_U32 j=0;
8268 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8269 tHalHandle halHandle;
8270 hdd_context_t *pHddCtx;
8271 tANI_U8 *pBSSId;
Wilson Yangef657d32014-01-15 19:19:23 -08008272 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008273
8274 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__);
8275
8276 /* Validate pAdapter */
8277 if (NULL == pAdapter)
8278 {
8279 hddLog(VOS_TRACE_LEVEL_ERROR,
8280 "%s: Invalid Adapter" ,__func__);
8281 return -EINVAL;
8282 }
8283
8284 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8285 status = wlan_hdd_validate_context(pHddCtx);
8286
8287 if (0 != status)
8288 {
8289 hddLog(VOS_TRACE_LEVEL_ERROR,
8290 "%s: HDD context is not valid", __func__);
8291 return status;
8292 }
8293
8294 /*Retrieve halHandle*/
8295 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
8296
8297 /*in case index is 0,no entry to delete*/
8298 if (0 == PMKIDCacheIndex)
8299 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +05308300 hddLog(VOS_TRACE_LEVEL_ERROR, FL("No entries to flush"));
Wilson Yang6507c4e2013-10-01 20:11:19 -07008301 return -EINVAL;
8302 }
8303
8304 /*delete all the PMKSA one by one */
8305 for (j = 0; j<PMKIDCacheIndex; j++)
8306 {
Wilson Yang6507c4e2013-10-01 20:11:19 -07008307 pBSSId =(tANI_U8 *)(PMKIDCache[j].BSSID);
Wilson Yang6507c4e2013-10-01 20:11:19 -07008308
8309 /*delete the PMKID in CSR*/
Wilson Yangef657d32014-01-15 19:19:23 -08008310 if (eHAL_STATUS_SUCCESS !=
8311 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId))
Wilson Yang6507c4e2013-10-01 20:11:19 -07008312 {
8313 hddLog(VOS_TRACE_LEVEL_ERROR ,"%s cannot flush PMKIDCache %d.",
8314 __func__,j);
Wilson Yangef657d32014-01-15 19:19:23 -08008315 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008316 }
Kiet Lam8d21d5b2013-10-31 17:18:29 +05308317 /*clear the entry in HDD cache 0--index-1 */
8318 vos_mem_zero(PMKIDCache[j].BSSID, WNI_CFG_BSSID_LEN);
8319 vos_mem_zero(PMKIDCache[j].PMKID, CSR_RSN_PMKID_SIZE);
Wilson Yang6507c4e2013-10-01 20:11:19 -07008320 }
8321
8322 PMKIDCacheIndex = 0;
Wilson Yangef657d32014-01-15 19:19:23 -08008323 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008324}
8325#endif
8326
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008327#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308328static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008329 struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie)
8330{
8331 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8332 hdd_station_ctx_t *pHddStaCtx;
8333
8334 if (NULL == pAdapter)
8335 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008336 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008337 return -ENODEV;
8338 }
8339
8340 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8341
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308342 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8343 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
8344 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008345 // Added for debug on reception of Re-assoc Req.
8346 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8347 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008348 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008349 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008350 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008351 }
8352
8353#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08008354 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008355 ftie->ie_len);
8356#endif
8357
8358 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +05308359 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
8360 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008361 ftie->ie_len);
8362 return 0;
8363}
8364#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008365
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308366#ifdef FEATURE_WLAN_SCAN_PNO
8367
8368void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
8369 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
8370{
8371 int ret;
8372 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
8373 hdd_context_t *pHddCtx;
8374
Nirav Shah80830bf2013-12-31 16:35:12 +05308375 ENTER();
8376
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308377 if (NULL == pAdapter)
8378 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05308379 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308380 "%s: HDD adapter is Null", __func__);
8381 return ;
8382 }
8383
8384 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8385 if (NULL == pHddCtx)
8386 {
8387 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8388 "%s: HDD context is Null!!!", __func__);
8389 return ;
8390 }
8391
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308392 spin_lock(&pHddCtx->schedScan_lock);
8393 if (TRUE == pHddCtx->isWiphySuspended)
8394 {
8395 pHddCtx->isSchedScanUpdatePending = TRUE;
8396 spin_unlock(&pHddCtx->schedScan_lock);
8397 hddLog(VOS_TRACE_LEVEL_INFO,
8398 "%s: Update cfg80211 scan database after it resume", __func__);
8399 return ;
8400 }
8401 spin_unlock(&pHddCtx->schedScan_lock);
8402
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308403 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
8404
8405 if (0 > ret)
8406 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
8407
8408 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308409 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8410 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308411}
8412
8413/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308414 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +05308415 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308416 */
8417static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
8418{
8419 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
8420 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308421 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308422 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8423 int status = 0;
8424 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
8425
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +05308426 /* The current firmware design does not allow PNO during any
8427 * active sessions. Hence, determine the active sessions
8428 * and return a failure.
8429 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308430 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
8431 {
8432 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308433 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308434
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308435 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
8436 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
8437 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
8438 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
8439 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
8440 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308441 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308442 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308443 }
8444 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
8445 pAdapterNode = pNext;
8446 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308447 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308448}
8449
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +05308450void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
8451{
8452 hdd_adapter_t *pAdapter = callbackContext;
8453 hdd_context_t *pHddCtx;
8454
8455 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
8456 {
8457 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8458 FL("Invalid adapter or adapter has invalid magic"));
8459 return;
8460 }
8461
8462 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8463 if (0 != wlan_hdd_validate_context(pHddCtx))
8464 {
8465 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8466 FL("HDD context is not valid"));
8467 return;
8468 }
8469
8470 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8471 FL("PNO enable response status = %d"), status);
8472
8473 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
8474 complete(&pAdapter->pno_comp_var);
8475}
8476
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308477/*
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308478 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
8479 * NL interface to enable PNO
8480 */
8481static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
8482 struct net_device *dev, struct cfg80211_sched_scan_request *request)
8483{
8484 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8485 tpSirPNOScanReq pPnoRequest = NULL;
8486 hdd_context_t *pHddCtx;
8487 tHalHandle hHal;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05308488 v_U32_t i, indx, num_ch, tempInterval;
Sushant Kaushikd62d9782014-02-19 15:39:40 +05308489 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
8490 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308491 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
8492 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308493 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308494
8495 if (NULL == pAdapter)
8496 {
8497 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8498 "%s: HDD adapter is Null", __func__);
8499 return -ENODEV;
8500 }
8501
8502 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308503 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308504
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308505 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308506 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308507 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8508 "%s: HDD context is not valid", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308509 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308510 }
8511
8512 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8513 if (NULL == hHal)
8514 {
8515 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8516 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308517 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308518 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308519
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308520 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308521 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +05308522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308523 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308524 return -EBUSY;
8525 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308526
c_hpothu37f21312014-04-09 21:49:54 +05308527 if (TRUE == pHddCtx->isPnoEnable)
8528 {
8529 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8530 FL("already PNO is enabled"));
8531 return -EBUSY;
8532 }
8533 pHddCtx->isPnoEnable = TRUE;
8534
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308535 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
8536 if (NULL == pPnoRequest)
8537 {
8538 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8539 "%s: vos_mem_malloc failed", __func__);
c_hpothu37f21312014-04-09 21:49:54 +05308540 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308541 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308542 }
8543
Madan Mohan Koyyalamudic3f04352013-09-26 19:21:48 +05308544 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308545 pPnoRequest->enable = 1; /*Enable PNO */
8546 pPnoRequest->ucNetworksCount = request->n_match_sets;
8547
8548 if (( !pPnoRequest->ucNetworksCount ) ||
8549 ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
8550 {
8551 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +05308552 "%s: Network input is not correct %d",
8553 __func__, pPnoRequest->ucNetworksCount);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308554 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308555 goto error;
8556 }
8557
8558 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
8559 {
8560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +05308561 "%s: Incorrect number of channels %d",
8562 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308563 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308564 goto error;
8565 }
8566
8567 /* Framework provides one set of channels(all)
8568 * common for all saved profile */
8569 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
8570 channels_allowed, &num_channels_allowed))
8571 {
8572 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8573 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308574 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308575 goto error;
8576 }
8577 /* Checking each channel against allowed channel list */
8578 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +05308579 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308580 {
Nirav Shah80830bf2013-12-31 16:35:12 +05308581 char chList [(request->n_channels*5)+1];
8582 int len;
8583 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308584 {
Nirav Shah80830bf2013-12-31 16:35:12 +05308585 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308586 {
Nirav Shah80830bf2013-12-31 16:35:12 +05308587 if (request->channels[i]->hw_value == channels_allowed[indx])
8588 {
8589 valid_ch[num_ch++] = request->channels[i]->hw_value;
8590 len += snprintf(chList+len, 5, "%d ",
8591 request->channels[i]->hw_value);
8592 break ;
8593 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308594 }
8595 }
Nirav Shah80830bf2013-12-31 16:35:12 +05308596 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
8597 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308598
8599 /* Filling per profile params */
8600 for (i = 0; i < pPnoRequest->ucNetworksCount; i++)
8601 {
8602 pPnoRequest->aNetworks[i].ssId.length =
8603 request->match_sets[i].ssid.ssid_len;
8604
8605 if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) ||
8606 ( pPnoRequest->aNetworks[i].ssId.length > 32 ) )
8607 {
8608 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +05308609 "%s: SSID Len %d is not correct for network %d",
8610 __func__, pPnoRequest->aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308611 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308612 goto error;
8613 }
8614
8615 memcpy(pPnoRequest->aNetworks[i].ssId.ssId,
8616 request->match_sets[i].ssid.ssid,
8617 request->match_sets[i].ssid.ssid_len);
8618 pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
8619 pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/
8620 pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
8621
8622 /*Copying list of valid channel into request */
8623 memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch);
8624 pPnoRequest->aNetworks[i].ucChannelCount = num_ch;
8625
8626 pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value
8627 }
8628
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +05308629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -08008630 "request->ie_len = %zu", request->ie_len);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +05308631 if ((0 < request->ie_len) && (NULL != request->ie))
8632 {
8633 pPnoRequest->us24GProbeTemplateLen = request->ie_len;
8634 memcpy(&pPnoRequest->p24GProbeTemplate, request->ie,
8635 pPnoRequest->us24GProbeTemplateLen);
8636
8637 pPnoRequest->us5GProbeTemplateLen = request->ie_len;
8638 memcpy(&pPnoRequest->p5GProbeTemplate, request->ie,
8639 pPnoRequest->us5GProbeTemplateLen);
8640 }
8641
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05308642 /* Driver gets only one time interval which is hardcoded in
8643 * supplicant for 10000ms. Taking power consumption into account 6 timers
8644 * will be used, Timervalue is increased exponentially i.e 10,20,40,
8645 * 80,160,320 secs. And number of scan cycle for each timer
8646 * is configurable through INI param gPNOScanTimerRepeatValue.
8647 * If it is set to 0 only one timer will be used and PNO scan cycle
8648 * will be repeated after each interval specified by supplicant
8649 * till PNO is disabled.
8650 */
8651 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
8652 pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
8653 else
8654 pPnoRequest->scanTimers.ucScanTimersCount =
8655 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
8656
8657 tempInterval = (request->interval)/1000;
8658 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8659 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
8660 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
8661 for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++)
8662 {
8663 pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat =
8664 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
8665 pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval;
8666 tempInterval *= 2;
8667 }
8668 //Repeat last timer until pno disabled.
8669 pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
8670
Madan Mohan Koyyalamudid206c7b2013-09-26 22:54:51 +05308671 pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308672
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +05308673 INIT_COMPLETION(pAdapter->pno_comp_var);
8674 pPnoRequest->statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
8675 pPnoRequest->callbackContext = pAdapter;
8676 pAdapter->pno_req_status = 0;
8677
Nirav Shah80830bf2013-12-31 16:35:12 +05308678 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8679 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
8680 pAdapter->sessionId, pPnoRequest->enable, pPnoRequest->modePNO,
8681 pPnoRequest->scanTimers.ucScanTimersCount);
8682
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308683 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
8684 pPnoRequest, pAdapter->sessionId,
8685 hdd_cfg80211_sched_scan_done_callback, pAdapter);
8686 if (eHAL_STATUS_SUCCESS != status)
8687 {
8688 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +05308689 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308690 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308691 goto error;
8692 }
8693
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +05308694 ret = wait_for_completion_timeout(
8695 &pAdapter->pno_comp_var,
8696 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
8697 if (0 >= ret)
8698 {
8699 // Did not receive the response for PNO enable in time.
8700 // Assuming the PNO enable was success.
8701 // Returning error from here, because we timeout, results
8702 // in side effect of Wifi (Wifi Setting) not to work.
8703 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8704 FL("Timed out waiting for PNO to be Enabled"));
8705 ret = 0;
8706 goto error;
8707 }
8708
8709 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +05308710 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308711
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308712error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +05308713 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8714 FL("PNO scanRequest offloaded ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308715 vos_mem_free(pPnoRequest);
c_hpothu37f21312014-04-09 21:49:54 +05308716 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308717 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308718}
8719
8720/*
8721 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
8722 * NL interface to disable PNO
8723 */
8724static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
8725 struct net_device *dev)
8726{
8727 eHalStatus status = eHAL_STATUS_FAILURE;
8728 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8729 hdd_context_t *pHddCtx;
8730 tHalHandle hHal;
8731 tpSirPNOScanReq pPnoRequest = NULL;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308732 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308733
8734 ENTER();
8735
8736 if (NULL == pAdapter)
8737 {
8738 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8739 "%s: HDD adapter is Null", __func__);
8740 return -ENODEV;
8741 }
8742
8743 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308744
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308745 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308746 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308747 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308748 "%s: HDD context is Null", __func__);
8749 return -ENODEV;
8750 }
8751
8752 /* The return 0 is intentional when isLogpInProgress and
8753 * isLoadUnloadInProgress. We did observe a crash due to a return of
8754 * failure in sched_scan_stop , especially for a case where the unload
8755 * of the happens at the same time. The function __cfg80211_stop_sched_scan
8756 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
8757 * success. If it returns a failure , then its next invocation due to the
8758 * clean up of the second interface will have the dev pointer corresponding
8759 * to the first one leading to a crash.
8760 */
8761 if (pHddCtx->isLogpInProgress)
8762 {
8763 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8764 "%s: LOGP in Progress. Ignore!!!", __func__);
8765 return ret;
8766 }
8767
Mihir Shete18156292014-03-11 15:38:30 +05308768 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308769 {
8770 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8771 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
8772 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308773 }
8774
8775 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8776 if (NULL == hHal)
8777 {
8778 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8779 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308780 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308781 }
8782
8783 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
8784 if (NULL == pPnoRequest)
8785 {
8786 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8787 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308788 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308789 }
8790
8791 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
8792 pPnoRequest->enable = 0; /* Disable PNO */
8793 pPnoRequest->ucNetworksCount = 0;
8794
8795 status = sme_SetPreferredNetworkList(hHal, pPnoRequest,
8796 pAdapter->sessionId,
8797 NULL, pAdapter);
8798 if (eHAL_STATUS_SUCCESS != status)
8799 {
8800 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8801 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308802 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +05308803 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308804 }
c_hpothu37f21312014-04-09 21:49:54 +05308805 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308806
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +05308807error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308808 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +05308809 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308810 vos_mem_free(pPnoRequest);
8811
8812 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308813 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308814}
8815
8816#endif /*FEATURE_WLAN_SCAN_PNO*/
8817
8818
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008819#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +05308820#if TDLS_MGMT_VERSION2
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008821static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
8822 u8 *peer, u8 action_code, u8 dialog_token,
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +05308823 u16 status_code, u32 peer_capability, const u8 *buf, size_t len)
8824#else
8825static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
8826 u8 *peer, u8 action_code, u8 dialog_token,
8827 u16 status_code, const u8 *buf, size_t len)
8828#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008829{
8830
8831 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8832 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008833 u8 peerMac[6];
8834 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008835 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -08008836 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -07008837 long rc;
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +05308838#if !(TDLS_MGMT_VERSION2)
8839 u32 peer_capability = 0;
8840#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308841 tANI_U16 numCurrTdlsPeers;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008842
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308843 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8844 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
8845 pAdapter->sessionId, action_code));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008846 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008847 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308848 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008849 "Invalid arguments");
8850 return -EINVAL;
8851 }
8852
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008853 if (pHddCtx->isLogpInProgress)
8854 {
8855 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8856 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008857 wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008858 return -EBUSY;
8859 }
8860
Hoonki Lee27511902013-03-14 18:19:06 -07008861 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008862 {
Hoonki Lee27511902013-03-14 18:19:06 -07008863 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8864 "%s: TDLS mode is disabled OR not enabled in FW."
8865 MAC_ADDRESS_STR " action %d declined.",
8866 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008867 return -ENOTSUPP;
8868 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008869
Hoonki Lee27511902013-03-14 18:19:06 -07008870 /* other than teardown frame, other mgmt frames are not sent if disabled */
8871 if (SIR_MAC_TDLS_TEARDOWN != action_code)
8872 {
8873 /* if tdls_mode is disabled to respond to peer's request */
8874 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
8875 {
8876 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8877 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008878 " TDLS mode is disabled. action %d declined.",
8879 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -07008880
8881 return -ENOTSUPP;
8882 }
8883 }
8884
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008885 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
8886 {
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308887 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008888 {
8889 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008890 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008891 " TDLS setup is ongoing. action %d declined.",
8892 __func__, MAC_ADDR_ARRAY(peer), action_code);
8893 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008894 }
8895 }
8896
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008897 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
8898 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -08008899 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308900 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
8901 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -08008902 {
8903 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
8904 we return error code at 'add_station()'. Hence we have this
8905 check again in addtion to add_station().
8906 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008907 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -08008908 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008909 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8910 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308911 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
8912 __func__, MAC_ADDR_ARRAY(peer), action_code,
8913 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +05308914 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -08008915 }
8916 else
8917 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008918 /* maximum reached. tweak to send error code to peer and return
8919 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -08008920 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008921 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8922 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308923 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
8924 __func__, MAC_ADDR_ARRAY(peer), status_code,
8925 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008926 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008927 /* fall through to send setup resp with failure status
8928 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -08008929 }
8930 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008931 else
8932 {
8933 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308934 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008935 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008936 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008937 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008938 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
8939 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008940 return -EPERM;
8941 }
8942 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008943 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008944 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008945
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008946#ifdef WLAN_FEATURE_TDLS_DEBUG
8947 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +05308948 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008949 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
8950 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008951#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008952
Hoonki Leea34dd892013-02-05 22:56:02 -08008953 /*Except teardown responder will not be used so just make 0*/
8954 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008955 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -08008956 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008957
8958 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308959 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008960
8961 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
8962 responder = pTdlsPeer->is_responder;
8963 else
Hoonki Leea34dd892013-02-05 22:56:02 -08008964 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008965 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +05308966 "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %zu",
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008967 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
8968 dialog_token, status_code, len);
8969 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -08008970 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008971 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008972
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308973 /* For explicit trigger of DIS_REQ come out of BMPS for
8974 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -07008975 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308976 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
8977 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -07008978 {
8979 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
8980 {
8981 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308982 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Hoonki Lee14621352013-04-16 17:51:19 -07008983 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
8984 }
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308985 if (SIR_MAC_TDLS_DIS_REQ != action_code)
8986 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
Hoonki Lee14621352013-04-16 17:51:19 -07008987 }
8988
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008989 /* make sure doesn't call send_mgmt() while it is pending */
8990 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
8991 {
8992 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008993 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008994 __func__, MAC_ADDR_ARRAY(peer), action_code);
8995 return -EBUSY;
8996 }
8997
8998 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008999 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
9000
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009001 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05309002 peerMac, action_code, dialog_token, status_code, peer_capability, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009003
Gopichand Nakkalab977a972013-02-18 19:15:09 -08009004 if (VOS_STATUS_SUCCESS != status)
9005 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009006 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9007 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009008 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -07009009 wlan_hdd_tdls_check_bmps(pAdapter);
Sunil Dutt388ac8f2013-11-28 18:06:52 +05309010 return -EINVAL;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009011 }
9012
Hoonki Leed37cbb32013-04-20 00:31:14 -07009013 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
9014 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
9015
9016 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08009017 {
Hoonki Leed37cbb32013-04-20 00:31:14 -07009018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009019 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -07009020 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009021 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -08009022
9023 if (pHddCtx->isLogpInProgress)
9024 {
9025 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9026 "%s: LOGP in Progress. Ignore!!!", __func__);
9027 return -EAGAIN;
9028 }
9029
Hoonki Leed37cbb32013-04-20 00:31:14 -07009030 wlan_hdd_tdls_check_bmps(pAdapter);
Sunil Dutt388ac8f2013-11-28 18:06:52 +05309031 return -EINVAL;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08009032 }
9033
Gopichand Nakkala05922802013-03-14 12:23:19 -07009034 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -07009035 {
9036 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -07009037 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -07009038 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08009039
Hoonki Leea34dd892013-02-05 22:56:02 -08009040 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
9041 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08009042 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -08009043 }
9044 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
9045 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08009046 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -08009047 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009048
9049 return 0;
9050}
9051
9052static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
9053 u8 *peer, enum nl80211_tdls_operation oper)
9054{
9055 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9056 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309057 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009058 hddTdlsPeer_t *pTdlsPeer;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009059
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309060 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9061 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
9062 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309063 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009064 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08009065 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07009066 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009067 return -EINVAL;
9068 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -08009069
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309070 status = wlan_hdd_validate_context(pHddCtx);
9071
9072 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009073 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309074 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9075 "%s: HDD context is not valid", __func__);
9076 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009077 }
9078
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009079
9080 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -08009081 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009082 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -08009083 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07009084 "TDLS Disabled in INI OR not enabled in FW. "
9085 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009086 return -ENOTSUPP;
9087 }
9088
9089 switch (oper) {
9090 case NL80211_TDLS_ENABLE_LINK:
9091 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009092 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309093 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05309094 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009095
Sunil Dutt41de4e22013-11-14 18:09:02 +05309096 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
9097
9098 if ( NULL == pTdlsPeer ) {
9099 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
9100 " (oper %d) not exsting. ignored",
9101 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
9102 return -EINVAL;
9103 }
9104
9105 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9106 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
9107 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
9108 "NL80211_TDLS_ENABLE_LINK");
9109
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -07009110 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
9111 {
9112 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
9113 MAC_ADDRESS_STR " failed",
9114 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
9115 return -EINVAL;
9116 }
9117
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009118 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009119 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05309120 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05309121
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05309122 if (0 != wlan_hdd_tdls_get_link_establish_params(
9123 pAdapter, peer,&tdlsLinkEstablishParams)) {
9124 return -EINVAL;
9125 }
9126 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05309127
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05309128 sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter),
9129 pAdapter->sessionId, peer, &tdlsLinkEstablishParams);
9130 /* Send TDLS peer UAPSD capabilities to the firmware and
9131 * register with the TL on after the response for this operation
9132 * is received .
9133 */
9134 ret = wait_for_completion_interruptible_timeout(
9135 &pAdapter->tdls_link_establish_req_comp,
9136 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
9137 if (ret <= 0)
9138 {
9139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9140 "%s: Link Establish Request Faled Status %ld",
9141 __func__, ret);
9142 return -EINVAL;
9143 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05309144 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07009145 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED);
Gopichand Nakkala471708b2013-06-04 20:03:01 +05309146 /* Mark TDLS client Authenticated .*/
9147 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
9148 pTdlsPeer->staId,
9149 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07009150 if (VOS_STATUS_SUCCESS == status)
9151 {
Hoonki Lee14621352013-04-16 17:51:19 -07009152 if (pTdlsPeer->is_responder == 0)
9153 {
9154 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
9155
9156 wlan_hdd_tdls_timer_restart(pAdapter,
9157 &pTdlsPeer->initiatorWaitTimeoutTimer,
9158 WAIT_TIME_TDLS_INITIATOR);
9159 /* suspend initiator TX until it receives direct packet from the
9160 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
9161 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9162 &staId, NULL);
9163 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07009164 wlan_hdd_tdls_increment_peer_count(pAdapter);
9165 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009166 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05309167
9168 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05309169 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
9170 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05309171 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05309172 int ac;
9173 uint8 ucAc[4] = { WLANTL_AC_VO,
9174 WLANTL_AC_VI,
9175 WLANTL_AC_BK,
9176 WLANTL_AC_BE };
9177 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
9178 for(ac=0; ac < 4; ac++)
9179 {
9180 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9181 pTdlsPeer->staId, ucAc[ac],
9182 tlTid[ac], tlTid[ac], 0, 0,
9183 WLANTL_BI_DIR );
9184 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05309185 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009186 }
9187
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009188 }
9189 break;
9190 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -08009191 {
Sunil Dutt41de4e22013-11-14 18:09:02 +05309192 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
9193
9194 if ( NULL == pTdlsPeer ) {
9195 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
9196 " (oper %d) not exsting. ignored",
9197 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
9198 return -EINVAL;
9199 }
9200
9201 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9202 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
9203 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
9204 "NL80211_TDLS_DISABLE_LINK");
9205
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009206 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -08009207 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009208 long status;
9209
9210 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
9211
Lee Hoonkic1262f22013-01-24 21:59:00 -08009212 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
9213 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009214
9215 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
9216 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
9217 if (status <= 0)
9218 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009219 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009220 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9221 "%s: Del station failed status %ld",
9222 __func__, status);
9223 return -EPERM;
9224 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009225 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Lee Hoonkic1262f22013-01-24 21:59:00 -08009226 }
9227 else
9228 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009229 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9230 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -08009231 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08009232 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009233 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009234 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +05309235 {
9236 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9237 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
9238 __func__, MAC_ADDR_ARRAY(peer));
9239
9240 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
9241 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
9242
9243 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9244 " %s TDLS External control and Implicit Trigger not enabled ",
9245 __func__);
9246 return -ENOTSUPP;
9247 }
9248
Sunil Dutt41de4e22013-11-14 18:09:02 +05309249
9250 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
9251
9252 if ( NULL == pTdlsPeer ) {
9253 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
9254 " peer not exsting",
9255 __func__, MAC_ADDR_ARRAY(peer));
Naresh Jayaram937abdf2013-11-26 19:50:25 +05309256 return -EINVAL;
Sunil Dutt41de4e22013-11-14 18:09:02 +05309257 }
9258 else {
9259 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
9260 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
9261 }
Naresh Jayaram937abdf2013-11-26 19:50:25 +05309262
9263 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) )
9264 return -EINVAL;
Sunil Dutt41de4e22013-11-14 18:09:02 +05309265 break;
9266 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009267 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +05309268 {
Naresh Jayaramdb4514b2013-11-25 18:08:10 +05309269 hddTdlsPeer_t *pTdlsPeer;
Sunil Dutt41de4e22013-11-14 18:09:02 +05309270 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9271 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
9272 __func__, MAC_ADDR_ARRAY(peer));
9273
9274 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
9275 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
9276
9277 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9278 " %s TDLS External control and Implicit Trigger not enabled ",
9279 __func__);
9280 return -ENOTSUPP;
9281 }
9282
Naresh Jayaramdb4514b2013-11-25 18:08:10 +05309283 /* To cater the requirement of establishing the TDLS link
9284 * irrespective of the data traffic , get an entry of TDLS peer.
9285 */
9286 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
9287 if (pTdlsPeer == NULL) {
9288 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9289 "%s: peer " MAC_ADDRESS_STR " not existing",
9290 __func__, MAC_ADDR_ARRAY(peer));
9291 return -EINVAL;
9292 }
Naresh Jayaram937abdf2013-11-26 19:50:25 +05309293
9294 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
9295
9296 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9297 " %s TDLS Add Force Peer Failed",
9298 __func__);
9299 return -EINVAL;
9300 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +05309301 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +05309302 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009303 case NL80211_TDLS_DISCOVERY_REQ:
9304 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309305 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9306 "%s: We don't support in-driver setup/teardown/discovery "
9307 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009308 return -ENOTSUPP;
9309 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309310 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9311 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009312 return -ENOTSUPP;
9313 }
9314 return 0;
9315}
Chilam NG571c65a2013-01-19 12:27:36 +05309316
9317int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
9318 struct net_device *dev, u8 *peer)
9319{
Arif Hussaina7c8e412013-11-20 11:06:42 -08009320 hddLog(VOS_TRACE_LEVEL_INFO,
9321 "tdls send discover req: "MAC_ADDRESS_STR,
9322 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +05309323
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +05309324#if TDLS_MGMT_VERSION2
9325 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
9326 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
9327#else
Chilam NG571c65a2013-01-19 12:27:36 +05309328 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
9329 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +05309330#endif
Chilam NG571c65a2013-01-19 12:27:36 +05309331}
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009332#endif
9333
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309334#ifdef WLAN_FEATURE_GTK_OFFLOAD
9335/*
9336 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
9337 * Callback rountine called upon receiving response for
9338 * get offload info
9339 */
9340void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
9341 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
9342{
9343
9344 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309345 tANI_U8 tempReplayCounter[8];
9346 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309347
9348 ENTER();
9349
9350 if (NULL == pAdapter)
9351 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309352 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309353 "%s: HDD adapter is Null", __func__);
9354 return ;
9355 }
9356
9357 if (NULL == pGtkOffloadGetInfoRsp)
9358 {
9359 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9360 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
9361 return ;
9362 }
9363
9364 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
9365 {
9366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9367 "%s: wlan Failed to get replay counter value",
9368 __func__);
9369 return ;
9370 }
9371
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309372 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9373 /* Update replay counter */
9374 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
9375 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
9376
9377 {
9378 /* changing from little to big endian since supplicant
9379 * works on big endian format
9380 */
9381 int i;
9382 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
9383
9384 for (i = 0; i < 8; i++)
9385 {
9386 tempReplayCounter[7-i] = (tANI_U8)p[i];
9387 }
9388 }
9389
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309390 /* Update replay counter to NL */
9391 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309392 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309393}
9394
9395/*
9396 * FUNCTION: wlan_hdd_cfg80211_set_rekey_data
9397 * This function is used to offload GTK rekeying job to the firmware.
9398 */
9399int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
9400 struct cfg80211_gtk_rekey_data *data)
9401{
9402 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9403 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9404 hdd_station_ctx_t *pHddStaCtx;
9405 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309406 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309407 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309408 eHalStatus status = eHAL_STATUS_FAILURE;
9409
9410 ENTER();
9411
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309412
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309413 if (NULL == pAdapter)
9414 {
9415 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9416 "%s: HDD adapter is Null", __func__);
9417 return -ENODEV;
9418 }
9419
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309420 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9421 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
9422 pAdapter->sessionId, pAdapter->device_mode));
9423
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309424 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309425
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309426 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309427 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309428 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9429 "%s: HDD context is not valid", __func__);
9430 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309431 }
9432
9433 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9434 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9435 if (NULL == hHal)
9436 {
9437 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9438 "%s: HAL context is Null!!!", __func__);
9439 return -EAGAIN;
9440 }
9441
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309442 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
9443 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
9444 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
9445 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309446 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309447 {
9448 /* changing from big to little endian since driver
9449 * works on little endian format
9450 */
9451 tANI_U8 *p =
9452 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
9453 int i;
9454
9455 for (i = 0; i < 8; i++)
9456 {
9457 p[7-i] = data->replay_ctr[i];
9458 }
9459 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309460
9461 if (TRUE == pHddCtx->hdd_wlan_suspended)
9462 {
9463 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309464 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
9465 sizeof (tSirGtkOffloadParams));
9466 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309467 pAdapter->sessionId);
9468
9469 if (eHAL_STATUS_SUCCESS != status)
9470 {
9471 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9472 "%s: sme_SetGTKOffload failed, returned %d",
9473 __func__, status);
9474 return status;
9475 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309476 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9477 "%s: sme_SetGTKOffload successfull", __func__);
9478 }
9479 else
9480 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309481 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9482 "%s: wlan not suspended GTKOffload request is stored",
9483 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309484 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309485
9486 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309487}
9488#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
9489
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309490/*
9491 * FUNCTION: wlan_hdd_cfg80211_set_mac_acl
9492 * This function is used to set access control policy
9493 */
9494static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
9495 struct net_device *dev, const struct cfg80211_acl_data *params)
9496{
9497 int i;
9498 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9499 hdd_hostapd_state_t *pHostapdState;
9500 tsap_Config_t *pConfig;
9501 v_CONTEXT_t pVosContext = NULL;
9502 hdd_context_t *pHddCtx;
9503 int status;
9504
9505 ENTER();
9506
9507 if (NULL == pAdapter)
9508 {
9509 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9510 "%s: HDD adapter is Null", __func__);
9511 return -ENODEV;
9512 }
9513
9514 if (NULL == params)
9515 {
9516 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9517 "%s: params is Null", __func__);
9518 return -EINVAL;
9519 }
9520
9521 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9522 status = wlan_hdd_validate_context(pHddCtx);
9523
9524 if (0 != status)
9525 {
9526 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9527 "%s: HDD context is not valid", __func__);
9528 return status;
9529 }
9530
9531 pVosContext = pHddCtx->pvosContext;
9532 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
9533
9534 if (NULL == pHostapdState)
9535 {
9536 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9537 "%s: pHostapdState is Null", __func__);
9538 return -EINVAL;
9539 }
9540
9541 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
9542 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
9543
9544 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
9545 {
9546 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
9547
9548 /* default value */
9549 pConfig->num_accept_mac = 0;
9550 pConfig->num_deny_mac = 0;
9551
9552 /**
9553 * access control policy
9554 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
9555 * listed in hostapd.deny file.
9556 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
9557 * listed in hostapd.accept file.
9558 */
9559 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
9560 {
9561 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
9562 }
9563 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
9564 {
9565 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
9566 }
9567 else
9568 {
9569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9570 "%s:Acl Policy : %d is not supported",
9571 __func__, params->acl_policy);
9572 return -ENOTSUPP;
9573 }
9574
9575 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
9576 {
9577 pConfig->num_accept_mac = params->n_acl_entries;
9578 for (i = 0; i < params->n_acl_entries; i++)
9579 {
9580 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9581 "** Add ACL MAC entry %i in WhiletList :"
9582 MAC_ADDRESS_STR, i,
9583 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
9584
9585 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
9586 sizeof(qcmacaddr));
9587 }
9588 }
9589 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
9590 {
9591 pConfig->num_deny_mac = params->n_acl_entries;
9592 for (i = 0; i < params->n_acl_entries; i++)
9593 {
9594 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9595 "** Add ACL MAC entry %i in BlackList :"
9596 MAC_ADDRESS_STR, i,
9597 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
9598
9599 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
9600 sizeof(qcmacaddr));
9601 }
9602 }
9603
9604 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
9605 {
9606 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9607 "%s: SAP Set Mac Acl fail", __func__);
9608 return -EINVAL;
9609 }
9610 }
9611 else
9612 {
9613 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309614 "%s: Invalid device_mode = %s (%d)",
9615 __func__, hdd_device_modetoString(pAdapter->device_mode),
9616 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309617 return -EINVAL;
9618 }
9619
9620 return 0;
9621}
9622
Leo Chang9056f462013-08-01 19:21:11 -07009623#ifdef WLAN_NL80211_TESTMODE
9624#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -07009625void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -07009626(
9627 void *pAdapter,
9628 void *indCont
9629)
9630{
Leo Changd9df8aa2013-09-26 13:32:26 -07009631 tSirLPHBInd *lphbInd;
9632 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +05309633 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -07009634
9635 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07009636 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -07009637
c_hpothu73f35e62014-04-18 13:40:08 +05309638 if (pAdapter == NULL)
9639 {
9640 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9641 "%s: pAdapter is NULL\n",__func__);
9642 return;
9643 }
9644
Leo Chang9056f462013-08-01 19:21:11 -07009645 if (NULL == indCont)
9646 {
9647 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07009648 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -07009649 return;
9650 }
9651
c_hpothu73f35e62014-04-18 13:40:08 +05309652 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -07009653 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -07009654 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +05309655 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -07009656 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -07009657 GFP_ATOMIC);
9658 if (!skb)
9659 {
9660 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9661 "LPHB timeout, NL buffer alloc fail");
9662 return;
9663 }
9664
Leo Changac3ba772013-10-07 09:47:04 -07009665 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -07009666 {
9667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9668 "WLAN_HDD_TM_ATTR_CMD put fail");
9669 goto nla_put_failure;
9670 }
Leo Changac3ba772013-10-07 09:47:04 -07009671 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -07009672 {
9673 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9674 "WLAN_HDD_TM_ATTR_TYPE put fail");
9675 goto nla_put_failure;
9676 }
Leo Changac3ba772013-10-07 09:47:04 -07009677 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -07009678 sizeof(tSirLPHBInd), lphbInd))
9679 {
9680 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9681 "WLAN_HDD_TM_ATTR_DATA put fail");
9682 goto nla_put_failure;
9683 }
Leo Chang9056f462013-08-01 19:21:11 -07009684 cfg80211_testmode_event(skb, GFP_ATOMIC);
9685 return;
9686
9687nla_put_failure:
9688 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9689 "NLA Put fail");
9690 kfree_skb(skb);
9691
9692 return;
9693}
9694#endif /* FEATURE_WLAN_LPHB */
9695
9696static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
9697{
9698 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
9699 int err = 0;
9700#ifdef FEATURE_WLAN_LPHB
9701 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -07009702 eHalStatus smeStatus;
Leo Chang9056f462013-08-01 19:21:11 -07009703#endif /* FEATURE_WLAN_LPHB */
9704
9705 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
9706 if (err)
9707 {
9708 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9709 "%s Testmode INV ATTR", __func__);
9710 return err;
9711 }
9712
9713 if (!tb[WLAN_HDD_TM_ATTR_CMD])
9714 {
9715 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9716 "%s Testmode INV CMD", __func__);
9717 return -EINVAL;
9718 }
9719
9720 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
9721 {
9722#ifdef FEATURE_WLAN_LPHB
9723 /* Low Power Heartbeat configuration request */
9724 case WLAN_HDD_TM_CMD_WLAN_HB:
9725 {
9726 int buf_len;
9727 void *buf;
9728 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -08009729 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -07009730
9731 if (!tb[WLAN_HDD_TM_ATTR_DATA])
9732 {
9733 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9734 "%s Testmode INV DATA", __func__);
9735 return -EINVAL;
9736 }
9737
9738 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
9739 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -08009740
9741 hb_params_temp =(tSirLPHBReq *)buf;
9742 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
9743 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
9744 return -EINVAL;
9745
Leo Chang9056f462013-08-01 19:21:11 -07009746 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
9747 if (NULL == hb_params)
9748 {
9749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9750 "%s Request Buffer Alloc Fail", __func__);
9751 return -EINVAL;
9752 }
9753
9754 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -07009755 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
9756 hb_params,
9757 wlan_hdd_cfg80211_lphb_ind_handler);
9758 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -07009759 {
Leo Changd9df8aa2013-09-26 13:32:26 -07009760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9761 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -07009762 vos_mem_free(hb_params);
9763 }
Leo Chang9056f462013-08-01 19:21:11 -07009764 return 0;
9765 }
9766#endif /* FEATURE_WLAN_LPHB */
9767 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309768 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9769 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -07009770 return -EOPNOTSUPP;
9771 }
9772
9773 return err;
9774}
9775#endif /* CONFIG_NL80211_TESTMODE */
9776
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309777static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
9778 struct net_device *dev,
9779 int idx, struct survey_info *survey)
9780{
9781 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9782 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +05309783 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309784 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +05309785 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309786 v_S7_t snr,rssi;
9787 int status, i, j, filled = 0;
9788
9789 ENTER();
9790
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309791 if (NULL == pAdapter)
9792 {
9793 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9794 "%s: HDD adapter is Null", __func__);
9795 return -ENODEV;
9796 }
9797
9798 if (NULL == wiphy)
9799 {
9800 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9801 "%s: wiphy is Null", __func__);
9802 return -ENODEV;
9803 }
9804
9805 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9806 status = wlan_hdd_validate_context(pHddCtx);
9807
9808 if (0 != status)
9809 {
9810 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9811 "%s: HDD context is not valid", __func__);
9812 return status;
9813 }
9814
Mihir Sheted9072e02013-08-21 17:02:29 +05309815 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9816
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309817 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +05309818 0 != pAdapter->survey_idx ||
9819 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309820 {
9821 /* The survey dump ops when implemented completely is expected to
9822 * return a survey of all channels and the ops is called by the
9823 * kernel with incremental values of the argument 'idx' till it
9824 * returns -ENONET. But we can only support the survey for the
9825 * operating channel for now. survey_idx is used to track
9826 * that the ops is called only once and then return -ENONET for
9827 * the next iteration
9828 */
9829 pAdapter->survey_idx = 0;
9830 return -ENONET;
9831 }
9832
9833 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
9834
9835 wlan_hdd_get_snr(pAdapter, &snr);
9836 wlan_hdd_get_rssi(pAdapter, &rssi);
9837
9838 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
9839 hdd_wlan_get_freq(channel, &freq);
9840
9841
9842 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
9843 {
9844 if (NULL == wiphy->bands[i])
9845 {
9846 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9847 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
9848 continue;
9849 }
9850
9851 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
9852 {
9853 struct ieee80211_supported_band *band = wiphy->bands[i];
9854
9855 if (band->channels[j].center_freq == (v_U16_t)freq)
9856 {
9857 survey->channel = &band->channels[j];
9858 /* The Rx BDs contain SNR values in dB for the received frames
9859 * while the supplicant expects noise. So we calculate and
9860 * return the value of noise (dBm)
9861 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
9862 */
9863 survey->noise = rssi - snr;
9864 survey->filled = SURVEY_INFO_NOISE_DBM;
9865 filled = 1;
9866 }
9867 }
9868 }
9869
9870 if (filled)
9871 pAdapter->survey_idx = 1;
9872 else
9873 {
9874 pAdapter->survey_idx = 0;
9875 return -ENONET;
9876 }
9877
9878 return 0;
9879}
9880
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309881/*
9882 * FUNCTION: wlan_hdd_cfg80211_resume_wlan
9883 * this is called when cfg80211 driver resume
9884 * driver updates latest sched_scan scan result(if any) to cfg80211 database
9885 */
9886int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
9887{
9888 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9889 hdd_adapter_t *pAdapter;
9890 hdd_adapter_list_node_t *pAdapterNode, *pNext;
9891 VOS_STATUS status = VOS_STATUS_SUCCESS;
9892
9893 ENTER();
9894
9895 if ( NULL == pHddCtx )
9896 {
9897 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9898 "%s: HddCtx validation failed", __func__);
9899 return 0;
9900 }
9901
9902 if (pHddCtx->isLogpInProgress)
9903 {
9904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9905 "%s: LOGP in Progress. Ignore!!!", __func__);
9906 return 0;
9907 }
9908
Mihir Shete18156292014-03-11 15:38:30 +05309909 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309910 {
9911 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9912 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
9913 return 0;
9914 }
9915
9916 spin_lock(&pHddCtx->schedScan_lock);
9917 pHddCtx->isWiphySuspended = FALSE;
9918 if (TRUE != pHddCtx->isSchedScanUpdatePending)
9919 {
9920 spin_unlock(&pHddCtx->schedScan_lock);
9921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9922 "%s: Return resume is not due to PNO indication", __func__);
9923 return 0;
9924 }
9925 // Reset flag to avoid updatating cfg80211 data old results again
9926 pHddCtx->isSchedScanUpdatePending = FALSE;
9927 spin_unlock(&pHddCtx->schedScan_lock);
9928
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05309929
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309930 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
9931
9932 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
9933 {
9934 pAdapter = pAdapterNode->pAdapter;
9935 if ( (NULL != pAdapter) &&
9936 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
9937 {
9938 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05309939 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309940 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9941 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05309942 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309943 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05309944 {
9945 /* Acquire wakelock to handle the case where APP's tries to
9946 * suspend immediately after updating the scan results. Whis
9947 * results in app's is in suspended state and not able to
9948 * process the connect request to AP
9949 */
9950 hdd_prevent_suspend_timeout(2000);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309951 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05309952 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309953
9954 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9955 "%s : cfg80211 scan result database updated", __func__);
9956
9957 return 0;
9958
9959 }
9960 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
9961 pAdapterNode = pNext;
9962 }
9963
9964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9965 "%s: Failed to find Adapter", __func__);
9966 return 0;
9967}
9968
9969/*
9970 * FUNCTION: wlan_hdd_cfg80211_suspend_wlan
9971 * this is called when cfg80211 driver suspends
9972 */
9973int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
9974 struct cfg80211_wowlan *wow)
9975{
9976 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9977
9978 ENTER();
9979 if (NULL == pHddCtx)
9980 {
9981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9982 "%s: HddCtx validation failed", __func__);
9983 return 0;
9984 }
9985
9986 pHddCtx->isWiphySuspended = TRUE;
9987
9988 EXIT();
9989
9990 return 0;
9991}
9992
Jeff Johnson295189b2012-06-20 16:38:30 -07009993/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309994static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -07009995{
9996 .add_virtual_intf = wlan_hdd_add_virtual_intf,
9997 .del_virtual_intf = wlan_hdd_del_virtual_intf,
9998 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
9999 .change_station = wlan_hdd_change_station,
10000#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
10001 .add_beacon = wlan_hdd_cfg80211_add_beacon,
10002 .del_beacon = wlan_hdd_cfg80211_del_beacon,
10003 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010004#else
10005 .start_ap = wlan_hdd_cfg80211_start_ap,
10006 .change_beacon = wlan_hdd_cfg80211_change_beacon,
10007 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070010008#endif
10009 .change_bss = wlan_hdd_cfg80211_change_bss,
10010 .add_key = wlan_hdd_cfg80211_add_key,
10011 .get_key = wlan_hdd_cfg80211_get_key,
10012 .del_key = wlan_hdd_cfg80211_del_key,
10013 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080010014#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070010015 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080010016#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010017 .scan = wlan_hdd_cfg80211_scan,
10018 .connect = wlan_hdd_cfg80211_connect,
10019 .disconnect = wlan_hdd_cfg80211_disconnect,
10020 .join_ibss = wlan_hdd_cfg80211_join_ibss,
10021 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
10022 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
10023 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
10024 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070010025 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
10026 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053010027 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070010028#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
10029 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
10030 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
10031 .set_txq_params = wlan_hdd_set_txq_params,
10032#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010033 .get_station = wlan_hdd_cfg80211_get_station,
10034 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
10035 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010036 .add_station = wlan_hdd_cfg80211_add_station,
10037#ifdef FEATURE_WLAN_LFR
10038 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
10039 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
10040 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
10041#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070010042#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
10043 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
10044#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010045#ifdef FEATURE_WLAN_TDLS
10046 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
10047 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
10048#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010049#ifdef WLAN_FEATURE_GTK_OFFLOAD
10050 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
10051#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010052#ifdef FEATURE_WLAN_SCAN_PNO
10053 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
10054 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
10055#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053010056 .resume = wlan_hdd_cfg80211_resume_wlan,
10057 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053010058 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070010059#ifdef WLAN_NL80211_TESTMODE
10060 .testmode_cmd = wlan_hdd_cfg80211_testmode,
10061#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010062 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070010063};
10064