blob: 652330afbfcb82264b6fff733d1651e12f172a4b [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
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +0530928/* This function registers for all frame which supplicant is interested in */
929void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -0700930{
Jeff Johnson295189b2012-06-20 16:38:30 -0700931 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
932 /* Register for all P2P action, public action etc frames */
933 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
934
Jeff Johnsone7245742012-09-05 17:12:55 -0700935 ENTER();
936
Jeff Johnson295189b2012-06-20 16:38:30 -0700937 /* Right now we are registering these frame when driver is getting
938 initialized. Once we will move to 2.6.37 kernel, in which we have
939 frame register ops, we will move this code as a part of that */
940 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530941 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -0700942 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
943
944 /* GAS Initial Response */
945 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
946 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530947
Jeff Johnson295189b2012-06-20 16:38:30 -0700948 /* GAS Comeback Request */
949 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
950 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
951
952 /* GAS Comeback Response */
953 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
954 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
955
956 /* P2P Public Action */
957 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530958 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700959 P2P_PUBLIC_ACTION_FRAME_SIZE );
960
961 /* P2P Action */
962 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
963 (v_U8_t*)P2P_ACTION_FRAME,
964 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700965
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +0530966 /* WNM BSS Transition Request frame */
967 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
968 (v_U8_t*)WNM_BSS_ACTION_FRAME,
969 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -0700970
971 /* WNM-Notification */
972 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
973 (v_U8_t*)WNM_NOTIFICATION_FRAME,
974 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700975}
976
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +0530977void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -0700978{
Jeff Johnson295189b2012-06-20 16:38:30 -0700979 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
980 /* Register for all P2P action, public action etc frames */
981 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
982
Jeff Johnsone7245742012-09-05 17:12:55 -0700983 ENTER();
984
Jeff Johnson295189b2012-06-20 16:38:30 -0700985 /* Right now we are registering these frame when driver is getting
986 initialized. Once we will move to 2.6.37 kernel, in which we have
987 frame register ops, we will move this code as a part of that */
988 /* GAS Initial Request */
989
990 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
991 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
992
993 /* GAS Initial Response */
994 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
995 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530996
Jeff Johnson295189b2012-06-20 16:38:30 -0700997 /* GAS Comeback Request */
998 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
999 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
1000
1001 /* GAS Comeback Response */
1002 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
1003 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
1004
1005 /* P2P Public Action */
1006 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301007 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07001008 P2P_PUBLIC_ACTION_FRAME_SIZE );
1009
1010 /* P2P Action */
1011 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
1012 (v_U8_t*)P2P_ACTION_FRAME,
1013 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07001014 /* WNM-Notification */
1015 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
1016 (v_U8_t*)WNM_NOTIFICATION_FRAME,
1017 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07001018}
1019
1020#ifdef FEATURE_WLAN_WAPI
1021void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
1022 const u8 *mac_addr, u8 *key , int key_Len)
1023{
1024 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1025 tCsrRoamSetKey setKey;
1026 v_BOOL_t isConnected = TRUE;
1027 int status = 0;
1028 v_U32_t roamId= 0xFF;
1029 tANI_U8 *pKeyPtr = NULL;
1030 int n = 0;
1031
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05301032 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
1033 __func__, hdd_device_modetoString(pAdapter->device_mode),
1034 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001035
Gopichand Nakkalae7480202013-02-11 15:24:22 +05301036 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07001037 setKey.keyId = key_index; // Store Key ID
1038 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
1039 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
1040 setKey.paeRole = 0 ; // the PAE role
1041 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
1042 {
1043 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
1044 }
1045 else
1046 {
1047 isConnected = hdd_connIsConnected(pHddStaCtx);
1048 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
1049 }
1050 setKey.keyLength = key_Len;
1051 pKeyPtr = setKey.Key;
1052 memcpy( pKeyPtr, key, key_Len);
1053
Arif Hussain6d2a3322013-11-17 19:50:10 -08001054 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07001055 __func__, key_Len);
1056 for (n = 0 ; n < key_Len; n++)
1057 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
1058 __func__,n,setKey.Key[n]);
1059
1060 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
1061 if ( isConnected )
1062 {
1063 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
1064 pAdapter->sessionId, &setKey, &roamId );
1065 }
1066 if ( status != 0 )
1067 {
1068 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1069 "[%4d] sme_RoamSetKey returned ERROR status= %d",
1070 __LINE__, status );
1071 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1072 }
1073}
1074#endif /* FEATURE_WLAN_WAPI*/
1075
1076#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301077int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001078 beacon_data_t **ppBeacon,
1079 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001080#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301081int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001082 beacon_data_t **ppBeacon,
1083 struct cfg80211_beacon_data *params,
1084 int dtim_period)
1085#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301086{
Jeff Johnson295189b2012-06-20 16:38:30 -07001087 int size;
1088 beacon_data_t *beacon = NULL;
1089 beacon_data_t *old = NULL;
1090 int head_len,tail_len;
1091
Jeff Johnsone7245742012-09-05 17:12:55 -07001092 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001093 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301094 {
1095 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1096 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001097 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301098 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001099
1100 old = pAdapter->sessionCtx.ap.beacon;
1101
1102 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301103 {
1104 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1105 FL("session(%d) old and new heads points to NULL"),
1106 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001107 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301108 }
1109
1110 if (params->tail && !params->tail_len)
1111 {
1112 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1113 FL("tail_len is zero but tail is not NULL"));
1114 return -EINVAL;
1115 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001116
Jeff Johnson295189b2012-06-20 16:38:30 -07001117#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
1118 /* Kernel 3.0 is not updating dtim_period for set beacon */
1119 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301120 {
1121 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1122 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301124 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001125#endif
1126
1127 if(params->head)
1128 head_len = params->head_len;
1129 else
1130 head_len = old->head_len;
1131
1132 if(params->tail || !old)
1133 tail_len = params->tail_len;
1134 else
1135 tail_len = old->tail_len;
1136
1137 size = sizeof(beacon_data_t) + head_len + tail_len;
1138
1139 beacon = kzalloc(size, GFP_KERNEL);
1140
1141 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301142 {
1143 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1144 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001145 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301146 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001147
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001148#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001149 if(params->dtim_period || !old )
1150 beacon->dtim_period = params->dtim_period;
1151 else
1152 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001153#else
1154 if(dtim_period || !old )
1155 beacon->dtim_period = dtim_period;
1156 else
1157 beacon->dtim_period = old->dtim_period;
1158#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301159
Jeff Johnson295189b2012-06-20 16:38:30 -07001160 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
1161 beacon->tail = beacon->head + head_len;
1162 beacon->head_len = head_len;
1163 beacon->tail_len = tail_len;
1164
1165 if(params->head) {
1166 memcpy (beacon->head,params->head,beacon->head_len);
1167 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301168 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001169 if(old)
1170 memcpy (beacon->head,old->head,beacon->head_len);
1171 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301172
Jeff Johnson295189b2012-06-20 16:38:30 -07001173 if(params->tail) {
1174 memcpy (beacon->tail,params->tail,beacon->tail_len);
1175 }
1176 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301177 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07001178 memcpy (beacon->tail,old->tail,beacon->tail_len);
1179 }
1180
1181 *ppBeacon = beacon;
1182
1183 kfree(old);
1184
1185 return 0;
1186
1187}
Jeff Johnson295189b2012-06-20 16:38:30 -07001188
1189v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
1190{
1191 int left = length;
1192 v_U8_t *ptr = pIes;
1193 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301194
Jeff Johnson295189b2012-06-20 16:38:30 -07001195 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301196 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001197 elem_id = ptr[0];
1198 elem_len = ptr[1];
1199 left -= 2;
1200 if(elem_len > left)
1201 {
1202 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001203 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001204 eid,elem_len,left);
1205 return NULL;
1206 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301207 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07001208 {
1209 return ptr;
1210 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301211
Jeff Johnson295189b2012-06-20 16:38:30 -07001212 left -= elem_len;
1213 ptr += (elem_len + 2);
1214 }
1215 return NULL;
1216}
1217
Jeff Johnson295189b2012-06-20 16:38:30 -07001218/* Check if rate is 11g rate or not */
1219static int wlan_hdd_rate_is_11g(u8 rate)
1220{
Sanjay Devnani28322e22013-06-21 16:13:40 -07001221 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001222 u8 i;
1223 for (i = 0; i < 8; i++)
1224 {
1225 if(rate == gRateArray[i])
1226 return TRUE;
1227 }
1228 return FALSE;
1229}
1230
1231/* Check for 11g rate and set proper 11g only mode */
1232static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
1233 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
1234{
1235 u8 i, num_rates = pIe[0];
1236
1237 pIe += 1;
1238 for ( i = 0; i < num_rates; i++)
1239 {
1240 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
1241 {
1242 /* If rate set have 11g rate than change the mode to 11G */
1243 *pSapHw_mode = eSAP_DOT11_MODE_11g;
1244 if (pIe[i] & BASIC_RATE_MASK)
1245 {
1246 /* If we have 11g rate as basic rate, it means mode
1247 is 11g only mode.
1248 */
1249 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
1250 *pCheckRatesfor11g = FALSE;
1251 }
1252 }
1253 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
1254 {
1255 *require_ht = TRUE;
1256 }
1257 }
1258 return;
1259}
1260
1261static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
1262{
1263 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1264 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1265 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1266 u8 checkRatesfor11g = TRUE;
1267 u8 require_ht = FALSE;
1268 u8 *pIe=NULL;
1269
1270 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
1271
1272 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
1273 pBeacon->head_len, WLAN_EID_SUPP_RATES);
1274 if (pIe != NULL)
1275 {
1276 pIe += 1;
1277 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1278 &pConfig->SapHw_mode);
1279 }
1280
1281 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1282 WLAN_EID_EXT_SUPP_RATES);
1283 if (pIe != NULL)
1284 {
1285
1286 pIe += 1;
1287 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1288 &pConfig->SapHw_mode);
1289 }
1290
1291 if( pConfig->channel > 14 )
1292 {
1293 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
1294 }
1295
1296 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1297 WLAN_EID_HT_CAPABILITY);
1298
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301299 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001300 {
1301 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
1302 if(require_ht)
1303 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
1304 }
1305}
1306
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301307static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
1308 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
1309{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001310 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301311 v_U8_t *pIe = NULL;
1312 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1313
1314 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
1315 pBeacon->tail, pBeacon->tail_len);
1316
1317 if (pIe)
1318 {
1319 ielen = pIe[1] + 2;
1320 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1321 {
1322 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
1323 }
1324 else
1325 {
1326 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
1327 return -EINVAL;
1328 }
1329 *total_ielen += ielen;
1330 }
1331 return 0;
1332}
1333
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001334static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
1335 v_U8_t *genie, v_U8_t *total_ielen)
1336{
1337 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1338 int left = pBeacon->tail_len;
1339 v_U8_t *ptr = pBeacon->tail;
1340 v_U8_t elem_id, elem_len;
1341 v_U16_t ielen = 0;
1342
1343 if ( NULL == ptr || 0 == left )
1344 return;
1345
1346 while (left >= 2)
1347 {
1348 elem_id = ptr[0];
1349 elem_len = ptr[1];
1350 left -= 2;
1351 if (elem_len > left)
1352 {
1353 hddLog( VOS_TRACE_LEVEL_ERROR,
1354 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
1355 elem_id, elem_len, left);
1356 return;
1357 }
1358 if (IE_EID_VENDOR == elem_id)
1359 {
1360 /* skipping the VSIE's which we don't want to include or
1361 * it will be included by existing code
1362 */
1363 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
1364#ifdef WLAN_FEATURE_WFD
1365 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
1366#endif
1367 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1368 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1369 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
1370 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1371 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
1372 {
1373 ielen = ptr[1] + 2;
1374 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1375 {
1376 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
1377 *total_ielen += ielen;
1378 }
1379 else
1380 {
1381 hddLog( VOS_TRACE_LEVEL_ERROR,
1382 "IE Length is too big "
1383 "IEs eid=%d elem_len=%d total_ie_lent=%d",
1384 elem_id, elem_len, *total_ielen);
1385 }
1386 }
1387 }
1388
1389 left -= elem_len;
1390 ptr += (elem_len + 2);
1391 }
1392 return;
1393}
1394
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001395#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001396static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1397 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001398#else
1399static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1400 struct cfg80211_beacon_data *params)
1401#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001402{
1403 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301404 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001405 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07001406 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001407
1408 genie = vos_mem_malloc(MAX_GENIE_LEN);
1409
1410 if(genie == NULL) {
1411
1412 return -ENOMEM;
1413 }
1414
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301415 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1416 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301418 hddLog(LOGE,
1419 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301420 ret = -EINVAL;
1421 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001422 }
1423
1424#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301425 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1426 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
1427 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301428 hddLog(LOGE,
1429 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301430 ret = -EINVAL;
1431 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001432 }
1433#endif
1434
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301435 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1436 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001437 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301438 hddLog(LOGE,
1439 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301440 ret = -EINVAL;
1441 goto done;
1442 }
1443
1444 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
1445 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001446 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001447 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001448
1449 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1450 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
1451 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
1452 {
1453 hddLog(LOGE,
1454 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001455 ret = -EINVAL;
1456 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001457 }
1458
1459 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1460 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
1461 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1462 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1463 ==eHAL_STATUS_FAILURE)
1464 {
1465 hddLog(LOGE,
1466 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001467 ret = -EINVAL;
1468 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001469 }
1470
1471 // Added for ProResp IE
1472 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
1473 {
1474 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
1475 u8 probe_rsp_ie_len[3] = {0};
1476 u8 counter = 0;
1477 /* Check Probe Resp Length if it is greater then 255 then Store
1478 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
1479 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
1480 Store More then 255 bytes into One Variable.
1481 */
1482 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
1483 {
1484 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
1485 {
1486 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
1487 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
1488 }
1489 else
1490 {
1491 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
1492 rem_probe_resp_ie_len = 0;
1493 }
1494 }
1495
1496 rem_probe_resp_ie_len = 0;
1497
1498 if (probe_rsp_ie_len[0] > 0)
1499 {
1500 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1501 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
1502 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1503 probe_rsp_ie_len[0], NULL,
1504 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1505 {
1506 hddLog(LOGE,
1507 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001508 ret = -EINVAL;
1509 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001510 }
1511 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
1512 }
1513
1514 if (probe_rsp_ie_len[1] > 0)
1515 {
1516 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1517 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
1518 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1519 probe_rsp_ie_len[1], NULL,
1520 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1521 {
1522 hddLog(LOGE,
1523 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001524 ret = -EINVAL;
1525 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001526 }
1527 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
1528 }
1529
1530 if (probe_rsp_ie_len[2] > 0)
1531 {
1532 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1533 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
1534 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1535 probe_rsp_ie_len[2], NULL,
1536 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1537 {
1538 hddLog(LOGE,
1539 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001540 ret = -EINVAL;
1541 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001542 }
1543 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
1544 }
1545
1546 if (probe_rsp_ie_len[1] == 0 )
1547 {
1548 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1549 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
1550 eANI_BOOLEAN_FALSE) )
1551 {
1552 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001553 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07001554 }
1555 }
1556
1557 if (probe_rsp_ie_len[2] == 0 )
1558 {
1559 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1560 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
1561 eANI_BOOLEAN_FALSE) )
1562 {
1563 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001564 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07001565 }
1566 }
1567
1568 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1569 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
1570 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1571 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1572 == eHAL_STATUS_FAILURE)
1573 {
1574 hddLog(LOGE,
1575 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001576 ret = -EINVAL;
1577 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001578 }
1579 }
1580 else
1581 {
1582 // Reset WNI_CFG_PROBE_RSP Flags
1583 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
1584
1585 hddLog(VOS_TRACE_LEVEL_INFO,
1586 "%s: No Probe Response IE received in set beacon",
1587 __func__);
1588 }
1589
1590 // Added for AssocResp IE
1591 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
1592 {
1593 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1594 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
1595 params->assocresp_ies_len, NULL,
1596 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1597 {
1598 hddLog(LOGE,
1599 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001600 ret = -EINVAL;
1601 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001602 }
1603
1604 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1605 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
1606 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1607 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1608 == eHAL_STATUS_FAILURE)
1609 {
1610 hddLog(LOGE,
1611 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001612 ret = -EINVAL;
1613 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001614 }
1615 }
1616 else
1617 {
1618 hddLog(VOS_TRACE_LEVEL_INFO,
1619 "%s: No Assoc Response IE received in set beacon",
1620 __func__);
1621
1622 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1623 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
1624 eANI_BOOLEAN_FALSE) )
1625 {
1626 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001627 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07001628 }
1629 }
1630
Jeff Johnsone7245742012-09-05 17:12:55 -07001631done:
Jeff Johnson295189b2012-06-20 16:38:30 -07001632 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301633 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001634}
Jeff Johnson295189b2012-06-20 16:38:30 -07001635
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301636/*
Jeff Johnson295189b2012-06-20 16:38:30 -07001637 * FUNCTION: wlan_hdd_validate_operation_channel
1638 * called by wlan_hdd_cfg80211_start_bss() and
1639 * wlan_hdd_cfg80211_set_channel()
1640 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301641 * channel list.
1642 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001643VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001644{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301645
Jeff Johnson295189b2012-06-20 16:38:30 -07001646 v_U32_t num_ch = 0;
1647 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1648 u32 indx = 0;
1649 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301650 v_U8_t fValidChannel = FALSE, count = 0;
1651 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301652
Jeff Johnson295189b2012-06-20 16:38:30 -07001653 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1654
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301655 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001656 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301657 /* Validate the channel */
1658 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001659 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301660 if ( channel == rfChannels[count].channelNum )
1661 {
1662 fValidChannel = TRUE;
1663 break;
1664 }
1665 }
1666 if (fValidChannel != TRUE)
1667 {
1668 hddLog(VOS_TRACE_LEVEL_ERROR,
1669 "%s: Invalid Channel [%d]", __func__, channel);
1670 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001671 }
1672 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301673 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001674 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301675 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1676 valid_ch, &num_ch))
1677 {
1678 hddLog(VOS_TRACE_LEVEL_ERROR,
1679 "%s: failed to get valid channel list", __func__);
1680 return VOS_STATUS_E_FAILURE;
1681 }
1682 for (indx = 0; indx < num_ch; indx++)
1683 {
1684 if (channel == valid_ch[indx])
1685 {
1686 break;
1687 }
1688 }
1689
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05301690 if (indx >= num_ch)
1691 {
1692 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
1693 {
1694 eCsrBand band;
1695 unsigned int freq;
1696
1697 sme_GetFreqBand(hHal, &band);
1698
1699 if (eCSR_BAND_5G == band)
1700 {
1701#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
1702 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
1703 {
1704 freq = ieee80211_channel_to_frequency(channel,
1705 IEEE80211_BAND_2GHZ);
1706 }
1707 else
1708 {
1709 freq = ieee80211_channel_to_frequency(channel,
1710 IEEE80211_BAND_5GHZ);
1711 }
1712#else
1713 freq = ieee80211_channel_to_frequency(channel);
1714#endif
1715 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
1716 return VOS_STATUS_SUCCESS;
1717 }
1718 }
1719
1720 hddLog(VOS_TRACE_LEVEL_ERROR,
1721 "%s: Invalid Channel [%d]", __func__, channel);
1722 return VOS_STATUS_E_FAILURE;
1723 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001724 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05301725
Jeff Johnson295189b2012-06-20 16:38:30 -07001726 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301727
Jeff Johnson295189b2012-06-20 16:38:30 -07001728}
1729
Viral Modi3a32cc52013-02-08 11:14:52 -08001730/**
1731 * FUNCTION: wlan_hdd_cfg80211_set_channel
1732 * This function is used to set the channel number
1733 */
1734static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
1735 struct ieee80211_channel *chan,
1736 enum nl80211_channel_type channel_type
1737 )
1738{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05301739 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08001740 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07001741 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08001742 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301743 hdd_context_t *pHddCtx;
1744 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001745
1746 ENTER();
1747
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05301748
Viral Modi3a32cc52013-02-08 11:14:52 -08001749 if( NULL == dev )
1750 {
1751 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001752 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08001753 return -ENODEV;
1754 }
1755 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
1756
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05301757 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
1758 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
1759 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08001760 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05301761 "%s: device_mode = %s (%d) freq = %d", __func__,
1762 hdd_device_modetoString(pAdapter->device_mode),
1763 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301764
1765 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1766 status = wlan_hdd_validate_context(pHddCtx);
1767
1768 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08001769 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301770 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1771 "%s: HDD context is not valid", __func__);
1772 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001773 }
1774
1775 /*
1776 * Do freq to chan conversion
1777 * TODO: for 11a
1778 */
1779
1780 channel = ieee80211_frequency_to_channel(freq);
1781
1782 /* Check freq range */
1783 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
1784 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
1785 {
1786 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001787 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08001788 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
1789 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1790 return -EINVAL;
1791 }
1792
1793 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1794
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05301795 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
1796 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08001797 {
1798 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
1799 {
1800 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001801 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08001802 return -EINVAL;
1803 }
1804 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1805 "%s: set channel to [%d] for device mode =%d",
1806 __func__, channel,pAdapter->device_mode);
1807 }
1808 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08001809 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08001810 )
1811 {
1812 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1813 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
1814 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1815
1816 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
1817 {
1818 /* Link is up then return cant set channel*/
1819 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001820 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08001821 return -EINVAL;
1822 }
1823
1824 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
1825 pHddStaCtx->conn_info.operationChannel = channel;
1826 pRoamProfile->ChannelInfo.ChannelList =
1827 &pHddStaCtx->conn_info.operationChannel;
1828 }
1829 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08001830 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08001831 )
1832 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301833 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
1834 {
1835 if(VOS_STATUS_SUCCESS !=
1836 wlan_hdd_validate_operation_channel(pAdapter,channel))
1837 {
1838 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001839 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301840 return -EINVAL;
1841 }
1842 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1843 }
1844 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08001845 {
1846 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1847
1848 /* If auto channel selection is configured as enable/ 1 then ignore
1849 channel set by supplicant
1850 */
1851 if ( cfg_param->apAutoChannelSelection )
1852 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301853 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
1854 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08001855 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05301856 "%s: set channel to auto channel (0) for device mode =%s (%d)",
1857 __func__, hdd_device_modetoString(pAdapter->device_mode),
1858 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08001859 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301860 else
1861 {
1862 if(VOS_STATUS_SUCCESS !=
1863 wlan_hdd_validate_operation_channel(pAdapter,channel))
1864 {
1865 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001866 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301867 return -EINVAL;
1868 }
1869 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1870 }
Viral Modi3a32cc52013-02-08 11:14:52 -08001871 }
1872 }
1873 else
1874 {
1875 hddLog(VOS_TRACE_LEVEL_FATAL,
1876 "%s: Invalid device mode failed to set valid channel", __func__);
1877 return -EINVAL;
1878 }
1879 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301880 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001881}
1882
Jeff Johnson295189b2012-06-20 16:38:30 -07001883#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
1884static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1885 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001886#else
1887static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1888 struct cfg80211_beacon_data *params,
1889 const u8 *ssid, size_t ssid_len,
1890 enum nl80211_hidden_ssid hidden_ssid)
1891#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001892{
1893 tsap_Config_t *pConfig;
1894 beacon_data_t *pBeacon = NULL;
1895 struct ieee80211_mgmt *pMgmt_frame;
1896 v_U8_t *pIe=NULL;
1897 v_U16_t capab_info;
1898 eCsrAuthType RSNAuthType;
1899 eCsrEncryptionType RSNEncryptType;
1900 eCsrEncryptionType mcRSNEncryptType;
1901 int status = VOS_STATUS_SUCCESS;
1902 tpWLAN_SAPEventCB pSapEventCallback;
1903 hdd_hostapd_state_t *pHostapdState;
1904 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
1905 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301906 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001907 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05301908 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001909 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08001910 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Chet Lanctot40142442014-05-20 13:39:25 -07001911 v_BOOL_t MFPCapable = VOS_FALSE;
1912 v_BOOL_t MFPRequired = VOS_FALSE;
Abhishek Singhf0ac1752014-03-05 17:47:09 +05301913 eHddDot11Mode sapDot11Mode =
1914 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001915
1916 ENTER();
1917
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05301918 iniConfig = pHddCtx->cfg_ini;
1919
Jeff Johnson295189b2012-06-20 16:38:30 -07001920 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 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05302217 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002218 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05302219 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07002220
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05302221 /* If ACS disable and selected channel <= 14
2222 * OR
2223 * ACS enabled and ACS operating band is choosen as 2.4
2224 * AND
2225 * VHT in 2.4G Disabled
2226 * THEN
2227 * Fallback to 11N mode
2228 */
2229 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
2230 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Siddharth Bhalf42f8592014-05-15 13:39:07 +05302231 operatingBand == RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05302232 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07002233 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05302234 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
2235 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07002236 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
2237 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002238 }
2239#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302240
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07002241 if ( AUTO_CHANNEL_SELECT != pConfig->channel )
2242 {
2243 sme_SelectCBMode(hHal,
2244 sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode),
2245 pConfig->channel);
2246 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002247 // ht_capab is not what the name conveys,this is used for protection bitmap
2248 pConfig->ht_capab =
2249 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
2250
2251 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
2252 {
2253 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
2254 return -EINVAL;
2255 }
2256
2257 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302258 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07002259 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
2260 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302261 pConfig->obssProtEnabled =
2262 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07002263
Chet Lanctot8cecea22014-02-11 19:09:36 -08002264#ifdef WLAN_FEATURE_11W
2265 pConfig->mfpCapable = MFPCapable;
2266 pConfig->mfpRequired = MFPRequired;
2267 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
2268 pConfig->mfpCapable, pConfig->mfpRequired);
2269#endif
2270
Arif Hussain6d2a3322013-11-17 19:50:10 -08002271 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07002272 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08002273 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
2274 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
2275 (int)pConfig->channel);
2276 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
2277 pConfig->SapHw_mode, pConfig->privacy,
2278 pConfig->authType);
2279 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
2280 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
2281 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
2282 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07002283
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302284 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07002285 {
2286 //Bss already started. just return.
2287 //TODO Probably it should update some beacon params.
2288 hddLog( LOGE, "Bss Already started...Ignore the request");
2289 EXIT();
2290 return 0;
2291 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302292
Jeff Johnson295189b2012-06-20 16:38:30 -07002293 pConfig->persona = pHostapdAdapter->device_mode;
2294
2295 pSapEventCallback = hdd_hostapd_SAPEventCB;
2296 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
2297 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
2298 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002299 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002300 return -EINVAL;
2301 }
2302
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302303 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
2305
2306 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302307
Jeff Johnson295189b2012-06-20 16:38:30 -07002308 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302309 {
2310 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002311 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07002312 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002313 VOS_ASSERT(0);
2314 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302315
Jeff Johnson295189b2012-06-20 16:38:30 -07002316 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
2317
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002318#ifdef WLAN_FEATURE_P2P_DEBUG
2319 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
2320 {
2321 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
2322 {
2323 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2324 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002325 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002326 }
2327 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
2328 {
2329 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2330 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002331 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002332 }
2333 }
2334#endif
2335
Jeff Johnson295189b2012-06-20 16:38:30 -07002336 pHostapdState->bCommit = TRUE;
2337 EXIT();
2338
2339 return 0;
2340}
2341
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002342#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302343static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
2344 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002345 struct beacon_parameters *params)
2346{
2347 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302348 hdd_context_t *pHddCtx;
2349 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002350
2351 ENTER();
2352
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302353 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2354 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
2355 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05302356 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
2357 hdd_device_modetoString(pAdapter->device_mode),
2358 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002359
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302360 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2361 status = wlan_hdd_validate_context(pHddCtx);
2362
2363 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002364 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302365 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2366 "%s: HDD context is not valid", __func__);
2367 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002368 }
2369
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302370 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002371 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002372 )
2373 {
2374 beacon_data_t *old,*new;
2375
2376 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302377
Jeff Johnson295189b2012-06-20 16:38:30 -07002378 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302379 {
2380 hddLog(VOS_TRACE_LEVEL_WARN,
2381 FL("already beacon info added to session(%d)"),
2382 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002383 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302384 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002385
2386 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2387
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302388 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002389 {
2390 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002391 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002392 return -EINVAL;
2393 }
2394
2395 pAdapter->sessionCtx.ap.beacon = new;
2396
2397 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2398 }
2399
2400 EXIT();
2401 return status;
2402}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302403
2404static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07002405 struct net_device *dev,
2406 struct beacon_parameters *params)
2407{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302408 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302409 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302410 hdd_context_t *pHddCtx;
2411 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002412
2413 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302414 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2415 TRACE_CODE_HDD_CFG80211_SET_BEACON,
2416 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05302417 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
2418 __func__, hdd_device_modetoString(pAdapter->device_mode),
2419 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002420
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302421 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2422 status = wlan_hdd_validate_context(pHddCtx);
2423
2424 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002425 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302426 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2427 "%s: HDD context is not valid", __func__);
2428 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002429 }
2430
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302431 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002432 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302433 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002434 {
2435 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302436
Jeff Johnson295189b2012-06-20 16:38:30 -07002437 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302438
Jeff Johnson295189b2012-06-20 16:38:30 -07002439 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302440 {
2441 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2442 FL("session(%d) old and new heads points to NULL"),
2443 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002444 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302445 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002446
2447 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2448
2449 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302450 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002451 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002452 return -EINVAL;
2453 }
2454
2455 pAdapter->sessionCtx.ap.beacon = new;
2456
2457 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2458 }
2459
2460 EXIT();
2461 return status;
2462}
2463
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002464#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
2465
2466#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002467static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
2468 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002469#else
2470static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
2471 struct net_device *dev)
2472#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002473{
2474 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07002475 hdd_context_t *pHddCtx = NULL;
2476 hdd_scaninfo_t *pScanInfo = NULL;
2477 hdd_adapter_t *staAdapter = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302478 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05302479 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002480
2481 ENTER();
2482
2483 if (NULL == pAdapter)
2484 {
2485 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002486 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002487 return -ENODEV;
2488 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002489
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302490 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2491 TRACE_CODE_HDD_CFG80211_STOP_AP,
2492 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302493 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2494 status = wlan_hdd_validate_context(pHddCtx);
2495
2496 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002497 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302498 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2499 "%s: HDD context is not valid", __func__);
2500 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07002501 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002502
2503 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
2504 if (NULL == staAdapter)
2505 {
2506 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
2507 if (NULL == staAdapter)
2508 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002509 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2510 "%s: HDD adapter context for STA/P2P-CLI is Null",
2511 __func__);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002512 }
2513 }
2514
2515 pScanInfo = &pHddCtx->scan_info;
2516
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05302517 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
2518 __func__, hdd_device_modetoString(pAdapter->device_mode),
2519 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002520
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05302521 ret = wlan_hdd_scan_abort(pAdapter);
2522
2523 if (ret <= 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07002524 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05302525 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2526 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302527
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05302528 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07002529 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05302530 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2531 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08002532
Jeff Johnsone7245742012-09-05 17:12:55 -07002533 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05302534 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07002535 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05302536 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07002537 }
2538
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05302539 hdd_hostapd_stop(dev);
2540
Jeff Johnson295189b2012-06-20 16:38:30 -07002541 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002542 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002543 )
2544 {
2545 beacon_data_t *old;
2546
2547 old = pAdapter->sessionCtx.ap.beacon;
2548
2549 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302550 {
2551 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2552 FL("session(%d) beacon data points to NULL"),
2553 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002554 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302555 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002556
Jeff Johnson295189b2012-06-20 16:38:30 -07002557 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002558
2559 mutex_lock(&pHddCtx->sap_lock);
2560 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
2561 {
Jeff Johnson4416a782013-03-25 14:17:50 -07002562 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002563 {
2564 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
2565
2566 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
2567
2568 if (!VOS_IS_STATUS_SUCCESS(status))
2569 {
2570 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002571 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002572 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302573 }
2574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
2576 }
2577 mutex_unlock(&pHddCtx->sap_lock);
2578
2579 if(status != VOS_STATUS_SUCCESS)
2580 {
2581 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002582 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002583 return -EINVAL;
2584 }
2585
Jeff Johnson4416a782013-03-25 14:17:50 -07002586 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002587 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
2588 ==eHAL_STATUS_FAILURE)
2589 {
2590 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002591 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07002592 }
2593
Jeff Johnson4416a782013-03-25 14:17:50 -07002594 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002595 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
2596 eANI_BOOLEAN_FALSE) )
2597 {
2598 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002599 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07002600 }
2601
2602 // Reset WNI_CFG_PROBE_RSP Flags
2603 wlan_hdd_reset_prob_rspies(pAdapter);
2604
2605 pAdapter->sessionCtx.ap.beacon = NULL;
2606 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002607#ifdef WLAN_FEATURE_P2P_DEBUG
2608 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
2609 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
2610 {
2611 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
2612 "GO got removed");
2613 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
2614 }
2615#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002616 }
2617 EXIT();
2618 return status;
2619}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002620
2621#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2622
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302623static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
2624 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002625 struct cfg80211_ap_settings *params)
2626{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302627 hdd_adapter_t *pAdapter;
2628 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302629 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002630
2631 ENTER();
2632
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302633 if (NULL == dev)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002634 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302635 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302636 "%s: Device is Null", __func__);
2637 return -ENODEV;
2638 }
2639
2640 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2641 if (NULL == pAdapter)
2642 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302643 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302644 "%s: HDD adapter is Null", __func__);
2645 return -ENODEV;
2646 }
2647
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302648 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2649 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
2650 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302651 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
2652 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302653 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302654 "%s: HDD adapter magic is invalid", __func__);
2655 return -ENODEV;
2656 }
2657
2658 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302659 status = wlan_hdd_validate_context(pHddCtx);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302660
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302661 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302662 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302663 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2664 "%s: HDD context is not valid", __func__);
2665 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302666 }
2667
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05302668 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
2669 __func__, hdd_device_modetoString(pAdapter->device_mode),
2670 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302671
2672 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002673 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002674 )
2675 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302676 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002677
2678 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302679
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002680 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302681 {
2682 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2683 FL("already beacon info added to session(%d)"),
2684 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002685 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302686 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002687
2688 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, &params->beacon, params->dtim_period);
2689
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302690 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002691 {
2692 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302693 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002694 return -EINVAL;
2695 }
2696 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08002697#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07002698 wlan_hdd_cfg80211_set_channel(wiphy, dev,
2699#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
2700 params->channel, params->channel_type);
2701#else
2702 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
2703#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08002704#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002705 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
2706 params->ssid_len, params->hidden_ssid);
2707 }
2708
2709 EXIT();
2710 return status;
2711}
2712
2713
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302714static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002715 struct net_device *dev,
2716 struct cfg80211_beacon_data *params)
2717{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302718 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302719 hdd_context_t *pHddCtx;
2720 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002721
2722 ENTER();
2723
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302724 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2725 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
2726 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08002727 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002728 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302729
2730 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2731 status = wlan_hdd_validate_context(pHddCtx);
2732
2733 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002734 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302735 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2736 "%s: HDD context is not valid", __func__);
2737 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002738 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002739
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302740 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002741 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302742 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002743 {
2744 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302745
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002746 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302747
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002748 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302749 {
2750 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2751 FL("session(%d) beacon data points to NULL"),
2752 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002753 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302754 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002755
2756 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
2757
2758 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302759 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002760 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002761 return -EINVAL;
2762 }
2763
2764 pAdapter->sessionCtx.ap.beacon = new;
2765
2766 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
2767 }
2768
2769 EXIT();
2770 return status;
2771}
2772
2773#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2774
Jeff Johnson295189b2012-06-20 16:38:30 -07002775
2776static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
2777 struct net_device *dev,
2778 struct bss_parameters *params)
2779{
2780 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2781
2782 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302783
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302784 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2785 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
2786 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05302787 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
2788 __func__, hdd_device_modetoString(pAdapter->device_mode),
2789 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002790
2791 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002792 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302793 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002794 {
2795 /* ap_isolate == -1 means that in change bss, upper layer doesn't
2796 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302797 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07002798 {
2799 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302800 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002801 }
2802
2803 EXIT();
2804 return 0;
2805}
2806
Kiet Lam10841362013-11-01 11:36:50 +05302807/* FUNCTION: wlan_hdd_change_country_code_cd
2808* to wait for contry code completion
2809*/
2810void* wlan_hdd_change_country_code_cb(void *pAdapter)
2811{
2812 hdd_adapter_t *call_back_pAdapter = pAdapter;
2813 complete(&call_back_pAdapter->change_country_code);
2814 return NULL;
2815}
2816
Jeff Johnson295189b2012-06-20 16:38:30 -07002817/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05302818 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07002819 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
2820 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05302821int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07002822 struct net_device *ndev,
2823 enum nl80211_iftype type,
2824 u32 *flags,
2825 struct vif_params *params
2826 )
2827{
2828 struct wireless_dev *wdev;
2829 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002830 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07002831 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002832 tCsrRoamProfile *pRoamProfile = NULL;
2833 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302834 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002835 eMib_dot11DesiredBssType connectedBssType;
2836 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302837 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002838
2839 ENTER();
2840
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302841 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002842 {
2843 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2844 "%s: Adapter context is null", __func__);
2845 return VOS_STATUS_E_FAILURE;
2846 }
2847
2848 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2849 if (!pHddCtx)
2850 {
2851 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2852 "%s: HDD context is null", __func__);
2853 return VOS_STATUS_E_FAILURE;
2854 }
2855
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302856 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2857 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
2858 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302859 status = wlan_hdd_validate_context(pHddCtx);
2860
2861 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002862 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302863 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2864 "%s: HDD context is not valid", __func__);
2865 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002866 }
2867
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05302868 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
2869 __func__, hdd_device_modetoString(pAdapter->device_mode),
2870 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002871
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302872 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07002873 wdev = ndev->ieee80211_ptr;
2874
2875#ifdef WLAN_BTAMP_FEATURE
2876 if((NL80211_IFTYPE_P2P_CLIENT == type)||
2877 (NL80211_IFTYPE_ADHOC == type)||
2878 (NL80211_IFTYPE_AP == type)||
2879 (NL80211_IFTYPE_P2P_GO == type))
2880 {
2881 pHddCtx->isAmpAllowed = VOS_FALSE;
2882 // stop AMP traffic
2883 status = WLANBAP_StopAmp();
2884 if(VOS_STATUS_SUCCESS != status )
2885 {
2886 pHddCtx->isAmpAllowed = VOS_TRUE;
2887 hddLog(VOS_TRACE_LEVEL_FATAL,
2888 "%s: Failed to stop AMP", __func__);
2889 return -EINVAL;
2890 }
2891 }
2892#endif //WLAN_BTAMP_FEATURE
2893 /* Reset the current device mode bit mask*/
2894 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
2895
2896 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07002897 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07002898 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002899 )
2900 {
2901 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002902 if (!pWextState)
2903 {
2904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2905 "%s: pWextState is null", __func__);
2906 return VOS_STATUS_E_FAILURE;
2907 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002908 pRoamProfile = &pWextState->roamProfile;
2909 LastBSSType = pRoamProfile->BSSType;
2910
2911 switch (type)
2912 {
2913 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002914 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002915 hddLog(VOS_TRACE_LEVEL_INFO,
2916 "%s: setting interface Type to INFRASTRUCTURE", __func__);
2917 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002918#ifdef WLAN_FEATURE_11AC
2919 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
2920 {
2921 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
2922 }
2923#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302924 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07002925 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002926 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002927 //Check for sub-string p2p to confirm its a p2p interface
2928 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302929 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002930 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2931 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2932 }
2933 else
2934 {
2935 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002936 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002937 }
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05302938#ifdef FEATURE_WLAN_TDLS
2939 /* The open adapter for the p2p shall skip initializations in
2940 * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for
2941 * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke
2942 * tdls_init when the change_iface sets the device mode to
2943 * WLAN_HDD_P2P_CLIENT.
2944 */
2945
2946 if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2947 {
2948 if (0 != wlan_hdd_tdls_init (pAdapter))
2949 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302950 hddLog(VOS_TRACE_LEVEL_ERROR,
2951 "%s: tdls initialization failed", __func__);
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05302952 return -EINVAL;
2953 }
2954 }
2955#endif
2956
Jeff Johnson295189b2012-06-20 16:38:30 -07002957 break;
2958 case NL80211_IFTYPE_ADHOC:
2959 hddLog(VOS_TRACE_LEVEL_INFO,
2960 "%s: setting interface Type to ADHOC", __func__);
2961 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2962 pRoamProfile->phyMode =
2963 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002964 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002965 wdev->iftype = type;
2966 break;
2967
2968 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002969 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002970 {
2971 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2972 "%s: setting interface Type to %s", __func__,
2973 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
2974
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002975 //Cancel any remain on channel for GO mode
2976 if (NL80211_IFTYPE_P2P_GO == type)
2977 {
2978 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
2979 }
Mohit Khanna0f232092012-09-11 14:46:08 -07002980 if (NL80211_IFTYPE_AP == type)
2981 {
2982 /* As Loading WLAN Driver one interface being created for p2p device
2983 * address. This will take one HW STA and the max number of clients
2984 * that can connect to softAP will be reduced by one. so while changing
2985 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
2986 * interface as it is not required in SoftAP mode.
2987 */
2988
2989 // Get P2P Adapter
2990 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
2991
2992 if (pP2pAdapter)
2993 {
2994 hdd_stop_adapter(pHddCtx, pP2pAdapter);
2995 hdd_deinit_adapter(pHddCtx, pP2pAdapter);
2996 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
2997 }
2998 }
Swaroop Goltia2e32212014-04-09 23:37:33 +05302999 //Disable IMPS & BMPS for SAP/GO
3000 if(VOS_STATUS_E_FAILURE ==
3001 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
3002 {
3003 //Fail to Exit BMPS
3004 VOS_ASSERT(0);
3005 }
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303006#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07003007
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303008 /* A Mutex Lock is introduced while changing the mode to
3009 * protect the concurrent access for the Adapters by TDLS
3010 * module.
3011 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05303012 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303013#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003014 //De-init the adapter.
3015 hdd_stop_adapter( pHddCtx, pAdapter );
3016 hdd_deinit_adapter( pHddCtx, pAdapter );
3017 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07003018 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
3019 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303020#ifdef FEATURE_WLAN_TDLS
3021 mutex_unlock(&pHddCtx->tdls_lock);
3022#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07003023 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
3024 (pConfig->apRandomBssidEnabled))
3025 {
3026 /* To meet Android requirements create a randomized
3027 MAC address of the form 02:1A:11:Fx:xx:xx */
3028 get_random_bytes(&ndev->dev_addr[3], 3);
3029 ndev->dev_addr[0] = 0x02;
3030 ndev->dev_addr[1] = 0x1A;
3031 ndev->dev_addr[2] = 0x11;
3032 ndev->dev_addr[3] |= 0xF0;
3033 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
3034 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08003035 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
3036 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07003037 }
3038
Jeff Johnson295189b2012-06-20 16:38:30 -07003039 hdd_set_ap_ops( pAdapter->dev );
3040
Kiet Lam10841362013-11-01 11:36:50 +05303041 /* This is for only SAP mode where users can
3042 * control country through ini.
3043 * P2P GO follows station country code
3044 * acquired during the STA scanning. */
3045 if((NL80211_IFTYPE_AP == type) &&
3046 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
3047 {
3048 int status = 0;
3049 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
3050 "%s: setting country code from INI ", __func__);
3051 init_completion(&pAdapter->change_country_code);
3052 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
3053 (void *)(tSmeChangeCountryCallback)
3054 wlan_hdd_change_country_code_cb,
3055 pConfig->apCntryCode, pAdapter,
3056 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05303057 eSIR_FALSE,
3058 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05303059 if (eHAL_STATUS_SUCCESS == status)
3060 {
3061 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303062 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05303063 &pAdapter->change_country_code,
3064 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303065 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05303066 {
3067 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303068 FL("SME Timed out while setting country code %ld"),
3069 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08003070
3071 if (pHddCtx->isLogpInProgress)
3072 {
3073 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3074 "%s: LOGP in Progress. Ignore!!!", __func__);
3075 return -EAGAIN;
3076 }
Kiet Lam10841362013-11-01 11:36:50 +05303077 }
3078 }
3079 else
3080 {
3081 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003082 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05303083 return -EINVAL;
3084 }
3085 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003086 status = hdd_init_ap_mode(pAdapter);
3087 if(status != VOS_STATUS_SUCCESS)
3088 {
3089 hddLog(VOS_TRACE_LEVEL_FATAL,
3090 "%s: Error initializing the ap mode", __func__);
3091 return -EINVAL;
3092 }
3093 hdd_set_conparam(1);
3094
Jeff Johnson295189b2012-06-20 16:38:30 -07003095 /*interface type changed update in wiphy structure*/
3096 if(wdev)
3097 {
3098 wdev->iftype = type;
3099 pHddCtx->change_iface = type;
3100 }
3101 else
3102 {
3103 hddLog(VOS_TRACE_LEVEL_ERROR,
3104 "%s: ERROR !!!! Wireless dev is NULL", __func__);
3105 return -EINVAL;
3106 }
3107 goto done;
3108 }
3109
3110 default:
3111 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
3112 __func__);
3113 return -EOPNOTSUPP;
3114 }
3115 }
3116 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07003117 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07003118 )
3119 {
3120 switch(type)
3121 {
3122 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07003123 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07003124 case NL80211_IFTYPE_ADHOC:
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303125#ifdef FEATURE_WLAN_TDLS
3126
3127 /* A Mutex Lock is introduced while changing the mode to
3128 * protect the concurrent access for the Adapters by TDLS
3129 * module.
3130 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05303131 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303132#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07003133 hdd_stop_adapter( pHddCtx, pAdapter );
3134 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08003136 //Check for sub-string p2p to confirm its a p2p interface
3137 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08003138 {
3139 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
3140 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
3141 }
3142 else
3143 {
3144 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07003145 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08003146 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003147 hdd_set_conparam(0);
3148 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07003149 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
3150 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303151#ifdef FEATURE_WLAN_TDLS
3152 mutex_unlock(&pHddCtx->tdls_lock);
3153#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05303154 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07003155 if( VOS_STATUS_SUCCESS != status )
3156 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07003157 /* In case of JB, for P2P-GO, only change interface will be called,
3158 * This is the right place to enable back bmps_imps()
3159 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05303160 if (pHddCtx->hdd_wlan_suspended)
3161 {
3162 hdd_set_pwrparams(pHddCtx);
3163 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003164 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07003165 goto done;
3166 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07003167 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07003168 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07003169 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
3170 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003171 goto done;
3172 default:
3173 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
3174 __func__);
3175 return -EOPNOTSUPP;
3176
3177 }
3178
3179 }
3180 else
3181 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05303182 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
3183 __func__, hdd_device_modetoString(pAdapter->device_mode),
3184 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003185 return -EOPNOTSUPP;
3186 }
3187
3188
3189 if(pRoamProfile)
3190 {
3191 if ( LastBSSType != pRoamProfile->BSSType )
3192 {
3193 /*interface type changed update in wiphy structure*/
3194 wdev->iftype = type;
3195
3196 /*the BSS mode changed, We need to issue disconnect
3197 if connected or in IBSS disconnect state*/
3198 if ( hdd_connGetConnectedBssType(
3199 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
3200 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
3201 {
3202 /*need to issue a disconnect to CSR.*/
3203 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3204 if( eHAL_STATUS_SUCCESS ==
3205 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
3206 pAdapter->sessionId,
3207 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
3208 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303209 ret = wait_for_completion_interruptible_timeout(
3210 &pAdapter->disconnect_comp_var,
3211 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3212 if (ret <= 0)
3213 {
3214 hddLog(VOS_TRACE_LEVEL_ERROR,
3215 FL("wait on disconnect_comp_var failed %ld"), ret);
3216 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003217 }
3218 }
3219 }
3220 }
3221
3222done:
3223 /*set bitmask based on updated value*/
3224 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07003225
3226 /* Only STA mode support TM now
3227 * all other mode, TM feature should be disabled */
3228 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
3229 (~VOS_STA & pHddCtx->concurrency_mode) )
3230 {
3231 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
3232 }
3233
Jeff Johnson295189b2012-06-20 16:38:30 -07003234#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303235 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003236 (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
3237 {
3238 //we are ok to do AMP
3239 pHddCtx->isAmpAllowed = VOS_TRUE;
3240 }
3241#endif //WLAN_BTAMP_FEATURE
3242 EXIT();
3243 return 0;
3244}
3245
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05303246/*
3247 * FUNCTION: wlan_hdd_cfg80211_change_iface
3248 * wrapper function to protect the actual implementation from SSR.
3249 */
3250int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
3251 struct net_device *ndev,
3252 enum nl80211_iftype type,
3253 u32 *flags,
3254 struct vif_params *params
3255 )
3256{
3257 int ret;
3258
3259 vos_ssr_protect(__func__);
3260 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
3261 vos_ssr_unprotect(__func__);
3262
3263 return ret;
3264}
3265
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003266#ifdef FEATURE_WLAN_TDLS
3267static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
3268 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
3269{
3270 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3271 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3272 VOS_STATUS status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003273 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303274 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05303275 tANI_U16 numCurrTdlsPeers;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003276
3277 ENTER();
3278
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303279 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003280 {
3281 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3282 "Invalid arguments");
3283 return -EINVAL;
3284 }
Hoonki Lee27511902013-03-14 18:19:06 -07003285
3286 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
3287 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
3288 {
3289 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3290 "%s: TDLS mode is disabled OR not enabled in FW."
3291 MAC_ADDRESS_STR " Request declined.",
3292 __func__, MAC_ADDR_ARRAY(mac));
3293 return -ENOTSUPP;
3294 }
3295
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003296 if (pHddCtx->isLogpInProgress)
3297 {
3298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3299 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07003300 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003301 return -EBUSY;
3302 }
3303
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05303304 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003305
3306 if ( NULL == pTdlsPeer ) {
3307 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3308 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
3309 __func__, MAC_ADDR_ARRAY(mac), update);
3310 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003311 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003312
3313 /* in add station, we accept existing valid staId if there is */
3314 if ((0 == update) &&
3315 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
3316 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003317 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003318 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003319 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003320 " link_status %d. staId %d. add station ignored.",
3321 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
3322 return 0;
3323 }
3324 /* in change station, we accept only when staId is valid */
3325 if ((1 == update) &&
3326 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
3327 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
3328 {
3329 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3330 "%s: " MAC_ADDRESS_STR
3331 " link status %d. staId %d. change station %s.",
3332 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
3333 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
3334 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003335 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003336
3337 /* when others are on-going, we want to change link_status to idle */
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303338 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003339 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003340 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3341 "%s: " MAC_ADDRESS_STR
3342 " TDLS setup is ongoing. Request declined.",
3343 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07003344 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003345 }
3346
3347 /* first to check if we reached to maximum supported TDLS peer.
3348 TODO: for now, return -EPERM looks working fine,
3349 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05303350 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
3351 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003352 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003353 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3354 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05303355 " TDLS Max peer already connected. Request declined."
3356 " Num of peers (%d), Max allowed (%d).",
3357 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
3358 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07003359 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003360 }
3361 else
3362 {
3363 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303364 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003365 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003366 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003367 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3368 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
3369 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003370 return -EPERM;
3371 }
3372 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003373 if (0 == update)
3374 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003375
Jeff Johnsond75fe012013-04-06 10:53:06 -07003376 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303377 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003378 {
3379 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3380 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003381 if(StaParams->htcap_present)
3382 {
3383 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3384 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
3385 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3386 "ht_capa->extended_capabilities: %0x",
3387 StaParams->HTCap.extendedHtCapInfo);
3388 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003389 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3390 "params->capability: %0x",StaParams->capability);
3391 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003392 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003393 if(StaParams->vhtcap_present)
3394 {
3395 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3396 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
3397 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
3398 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
3399 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003400 {
3401 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003402 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003403 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
3404 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3405 "[%d]: %x ", i, StaParams->supported_rates[i]);
3406 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07003407 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303408 else if ((1 == update) && (NULL == StaParams))
3409 {
3410 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3411 "%s : update is true, but staParams is NULL. Error!", __func__);
3412 return -EPERM;
3413 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003414
3415 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
3416
3417 if (!update)
3418 {
3419 status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3420 pAdapter->sessionId, mac);
3421 }
3422 else
3423 {
3424 status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3425 pAdapter->sessionId, mac, StaParams);
3426 }
3427
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303428 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003429 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
3430
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303431 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003432 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003433 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303434 "%s: timeout waiting for tdls add station indication %ld",
3435 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003436 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003437 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303438
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003439 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
3440 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003441 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003442 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003443 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003444 }
3445
3446 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07003447
3448error:
3449 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
3450 return -EPERM;
3451
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003452}
3453#endif
3454
Jeff Johnson295189b2012-06-20 16:38:30 -07003455static int wlan_hdd_change_station(struct wiphy *wiphy,
3456 struct net_device *dev,
3457 u8 *mac,
3458 struct station_parameters *params)
3459{
3460 VOS_STATUS status = VOS_STATUS_SUCCESS;
3461 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkala29149562013-05-10 21:43:41 +05303462 hdd_context_t *pHddCtx;
3463 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003464 v_MACADDR_t STAMacAddress;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003465#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003466 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003467 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05303468 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003469#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003470 ENTER();
3471
Gopichand Nakkala29149562013-05-10 21:43:41 +05303472 if ((NULL == pAdapter))
3473 {
3474 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3475 "invalid adapter ");
3476 return -EINVAL;
3477 }
3478
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303479 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
3480 TRACE_CODE_HDD_CHANGE_STATION,
3481 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05303482 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3483 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3484
3485 if ((NULL == pHddCtx) || (NULL == pHddStaCtx))
3486 {
3487 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3488 "invalid HDD state or HDD station context");
3489 return -EINVAL;
3490 }
3491
3492 if (pHddCtx->isLogpInProgress)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003493 {
3494 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3495 "%s:LOGP in Progress. Ignore!!!", __func__);
3496 return -EAGAIN;
3497 }
3498
Jeff Johnson295189b2012-06-20 16:38:30 -07003499 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
3500
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003501 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
3502 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07003503 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003504 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07003505 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303506 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07003507 WLANTL_STA_AUTHENTICATED);
3508
Gopichand Nakkala29149562013-05-10 21:43:41 +05303509 if (status != VOS_STATUS_SUCCESS)
3510 {
3511 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3512 "%s: Not able to change TL state to AUTHENTICATED", __func__);
3513 return -EINVAL;
3514 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003515 }
3516 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07003517 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
3518 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303519#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003520 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
3521 StaParams.capability = params->capability;
3522 StaParams.uapsd_queues = params->uapsd_queues;
3523 StaParams.max_sp = params->max_sp;
3524
Naresh Jayaram3180aa42014-02-12 21:47:26 +05303525 /* Convert (first channel , number of channels) tuple to
3526 * the total list of channels. This goes with the assumption
3527 * that if the first channel is < 14, then the next channels
3528 * are an incremental of 1 else an incremental of 4 till the number
3529 * of channels.
3530 */
3531 if (0 != params->supported_channels_len) {
3532 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
3533 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
3534 {
3535 int wifi_chan_index;
3536 StaParams.supported_channels[j] = params->supported_channels[i];
3537 wifi_chan_index =
3538 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
3539 no_of_channels = params->supported_channels[i+1];
3540 for(k=1; k <= no_of_channels; k++)
3541 {
3542 StaParams.supported_channels[j+1] =
3543 StaParams.supported_channels[j] + wifi_chan_index;
3544 j+=1;
3545 }
3546 }
3547 StaParams.supported_channels_len = j;
3548 }
3549 vos_mem_copy(StaParams.supported_oper_classes,
3550 params->supported_oper_classes,
3551 params->supported_oper_classes_len);
3552 StaParams.supported_oper_classes_len =
3553 params->supported_oper_classes_len;
3554
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003555 if (0 != params->ext_capab_len)
3556 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
3557 sizeof(StaParams.extn_capability));
3558
3559 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003560 {
3561 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003562 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003563 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003564
3565 StaParams.supported_rates_len = params->supported_rates_len;
3566
3567 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
3568 * The supported_rates array , for all the structures propogating till Add Sta
3569 * to the firmware has to be modified , if the supplicant (ieee80211) is
3570 * modified to send more rates.
3571 */
3572
3573 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
3574 */
3575 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
3576 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
3577
3578 if (0 != StaParams.supported_rates_len) {
3579 int i = 0;
3580 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
3581 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003582 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003583 "Supported Rates with Length %d", StaParams.supported_rates_len);
3584 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003585 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003586 "[%d]: %0x", i, StaParams.supported_rates[i]);
3587 }
3588
3589 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003590 {
3591 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003592 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003593 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003594
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003595 if (0 != params->ext_capab_len ) {
3596 /*Define A Macro : TODO Sunil*/
3597 if ((1<<4) & StaParams.extn_capability[3]) {
3598 isBufSta = 1;
3599 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05303600 /* TDLS Channel Switching Support */
3601 if ((1<<6) & StaParams.extn_capability[3]) {
3602 isOffChannelSupported = 1;
3603 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003604 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05303605 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
3606 &StaParams, isBufSta,
3607 isOffChannelSupported);
3608
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303609 if (VOS_STATUS_SUCCESS != status) {
3610 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3611 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
3612 return -EINVAL;
3613 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003614 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
3615
3616 if (VOS_STATUS_SUCCESS != status) {
3617 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3618 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
3619 return -EINVAL;
3620 }
3621 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003622#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05303623 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003624 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003625 return status;
3626}
3627
3628/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003629 * FUNCTION: wlan_hdd_cfg80211_add_key
3630 * This function is used to initialize the key information
3631 */
3632#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003633static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003634 struct net_device *ndev,
3635 u8 key_index, bool pairwise,
3636 const u8 *mac_addr,
3637 struct key_params *params
3638 )
3639#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003640static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003641 struct net_device *ndev,
3642 u8 key_index, const u8 *mac_addr,
3643 struct key_params *params
3644 )
3645#endif
3646{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003647 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003648 tCsrRoamSetKey setKey;
3649 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303650 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003651 v_U32_t roamId= 0xFF;
3652 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003653 hdd_hostapd_state_t *pHostapdState;
3654 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003655 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303656 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003657
3658 ENTER();
3659
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303660 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
3661 TRACE_CODE_HDD_CFG80211_ADD_KEY,
3662 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303663 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3664 status = wlan_hdd_validate_context(pHddCtx);
3665
3666 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003667 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303668 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3669 "%s: HDD context is not valid", __func__);
3670 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003671 }
3672
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05303673 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
3674 __func__, hdd_device_modetoString(pAdapter->device_mode),
3675 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003676
3677 if (CSR_MAX_NUM_KEY <= key_index)
3678 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003679 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003680 key_index);
3681
3682 return -EINVAL;
3683 }
3684
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003685 if (CSR_MAX_KEY_LEN < params->key_len)
3686 {
3687 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
3688 params->key_len);
3689
3690 return -EINVAL;
3691 }
3692
3693 hddLog(VOS_TRACE_LEVEL_INFO,
3694 "%s: called with key index = %d & key length %d",
3695 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003696
3697 /*extract key idx, key len and key*/
3698 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3699 setKey.keyId = key_index;
3700 setKey.keyLength = params->key_len;
3701 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
3702
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003703 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07003704 {
3705 case WLAN_CIPHER_SUITE_WEP40:
3706 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3707 break;
3708
3709 case WLAN_CIPHER_SUITE_WEP104:
3710 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3711 break;
3712
3713 case WLAN_CIPHER_SUITE_TKIP:
3714 {
3715 u8 *pKey = &setKey.Key[0];
3716 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3717
3718 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3719
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003720 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07003721
3722 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003723 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003724 |--------------|----------|----------|
3725 <---16bytes---><--8bytes--><--8bytes-->
3726
3727 */
3728 /*Sme expects the 32 bytes key to be in the below order
3729
3730 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003731 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003732 |--------------|----------|----------|
3733 <---16bytes---><--8bytes--><--8bytes-->
3734 */
3735 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003736 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07003737
3738 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003739 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003740
3741 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003742 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003743
3744
3745 break;
3746 }
3747
3748 case WLAN_CIPHER_SUITE_CCMP:
3749 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3750 break;
3751
3752#ifdef FEATURE_WLAN_WAPI
3753 case WLAN_CIPHER_SUITE_SMS4:
3754 {
3755 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3756 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
3757 params->key, params->key_len);
3758 return 0;
3759 }
3760#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003761
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003762#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003763 case WLAN_CIPHER_SUITE_KRK:
3764 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3765 break;
3766#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003767
3768#ifdef WLAN_FEATURE_11W
3769 case WLAN_CIPHER_SUITE_AES_CMAC:
3770 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07003771 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07003772#endif
3773
Jeff Johnson295189b2012-06-20 16:38:30 -07003774 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003775 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07003776 __func__, params->cipher);
3777 return -EOPNOTSUPP;
3778 }
3779
3780 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
3781 __func__, setKey.encType);
3782
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003783 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07003784#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3785 (!pairwise)
3786#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003787 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07003788#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003789 )
3790 {
3791 /* set group key*/
3792 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3793 "%s- %d: setting Broadcast key",
3794 __func__, __LINE__);
3795 setKey.keyDirection = eSIR_RX_ONLY;
3796 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3797 }
3798 else
3799 {
3800 /* set pairwise key*/
3801 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3802 "%s- %d: setting pairwise key",
3803 __func__, __LINE__);
3804 setKey.keyDirection = eSIR_TX_RX;
3805 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3806 }
3807 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
3808 {
3809 setKey.keyDirection = eSIR_TX_RX;
3810 /*Set the group key*/
3811 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3812 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003813
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003814 if ( 0 != status )
3815 {
3816 hddLog(VOS_TRACE_LEVEL_ERROR,
3817 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3818 return -EINVAL;
3819 }
3820 /*Save the keys here and call sme_RoamSetKey for setting
3821 the PTK after peer joins the IBSS network*/
3822 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
3823 &setKey, sizeof(tCsrRoamSetKey));
3824 return status;
3825 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05303826 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
3827 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
3828 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003829 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003830 if( pHostapdState->bssState == BSS_START )
3831 {
c_hpothu7c55da62014-01-23 18:34:02 +05303832 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3833 vos_status = wlan_hdd_check_ula_done(pAdapter);
3834
3835 if ( vos_status != VOS_STATUS_SUCCESS )
3836 {
3837 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3838 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3839 __LINE__, vos_status );
3840
3841 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3842
3843 return -EINVAL;
3844 }
3845
Jeff Johnson295189b2012-06-20 16:38:30 -07003846 status = WLANSAP_SetKeySta( pVosContext, &setKey);
3847
3848 if ( status != eHAL_STATUS_SUCCESS )
3849 {
3850 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3851 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3852 __LINE__, status );
3853 }
3854 }
3855
3856 /* Saving WEP keys */
3857 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
3858 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
3859 {
3860 //Save the wep key in ap context. Issue setkey after the BSS is started.
3861 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3862 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
3863 }
3864 else
3865 {
3866 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003867 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003868 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
3869 }
3870 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003871 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
3872 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003873 {
3874 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3875 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3876
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303877#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3878 if (!pairwise)
3879#else
3880 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
3881#endif
3882 {
3883 /* set group key*/
3884 if (pHddStaCtx->roam_info.deferKeyComplete)
3885 {
3886 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3887 "%s- %d: Perform Set key Complete",
3888 __func__, __LINE__);
3889 hdd_PerformRoamSetKeyComplete(pAdapter);
3890 }
3891 }
3892
Jeff Johnson295189b2012-06-20 16:38:30 -07003893 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
3894
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08003895 pWextState->roamProfile.Keys.defaultIndex = key_index;
3896
3897
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003898 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003899 params->key, params->key_len);
3900
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303901
Jeff Johnson295189b2012-06-20 16:38:30 -07003902 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3903
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303904 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003905 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303906 __func__, setKey.peerMac[0], setKey.peerMac[1],
3907 setKey.peerMac[2], setKey.peerMac[3],
3908 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003909 setKey.keyDirection);
3910
3911 vos_status = wlan_hdd_check_ula_done(pAdapter);
3912
3913 if ( vos_status != VOS_STATUS_SUCCESS )
3914 {
3915 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3916 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3917 __LINE__, vos_status );
3918
3919 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3920
3921 return -EINVAL;
3922
3923 }
3924
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003925#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303926 /* The supplicant may attempt to set the PTK once pre-authentication
3927 is done. Save the key in the UMAC and include it in the ADD BSS
3928 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003929 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303930 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003931 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303932 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3933 "%s: Update PreAuth Key success", __func__);
3934 return 0;
3935 }
3936 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3937 {
3938 hddLog(VOS_TRACE_LEVEL_ERROR,
3939 "%s: Update PreAuth Key failed", __func__);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05303940 return -EINVAL;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003941 }
3942#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07003943
3944 /* issue set key request to SME*/
3945 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3946 pAdapter->sessionId, &setKey, &roamId );
3947
3948 if ( 0 != status )
3949 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303950 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003951 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3952 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3953 return -EINVAL;
3954 }
3955
3956
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303957 /* in case of IBSS as there was no information available about WEP keys during
3958 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07003959 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303960 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
3961 !( ( IW_AUTH_KEY_MGMT_802_1X
3962 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003963 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
3964 )
3965 &&
3966 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
3967 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
3968 )
3969 )
3970 {
3971 setKey.keyDirection = eSIR_RX_ONLY;
3972 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3973
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303974 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003975 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303976 __func__, setKey.peerMac[0], setKey.peerMac[1],
3977 setKey.peerMac[2], setKey.peerMac[3],
3978 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 setKey.keyDirection);
3980
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303981 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003982 pAdapter->sessionId, &setKey, &roamId );
3983
3984 if ( 0 != status )
3985 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303986 hddLog(VOS_TRACE_LEVEL_ERROR,
3987 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003988 __func__, status);
3989 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3990 return -EINVAL;
3991 }
3992 }
3993 }
3994
3995 return 0;
3996}
3997
3998/*
3999 * FUNCTION: wlan_hdd_cfg80211_get_key
4000 * This function is used to get the key information
4001 */
4002#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304003static int wlan_hdd_cfg80211_get_key(
4004 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004005 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304006 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07004007 const u8 *mac_addr, void *cookie,
4008 void (*callback)(void *cookie, struct key_params*)
4009 )
4010#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304011static int wlan_hdd_cfg80211_get_key(
4012 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004013 struct net_device *ndev,
4014 u8 key_index, const u8 *mac_addr, void *cookie,
4015 void (*callback)(void *cookie, struct key_params*)
4016 )
4017#endif
4018{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304019 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07004020 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4021 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
4022 struct key_params params;
4023
4024 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304025
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05304026 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
4027 __func__, hdd_device_modetoString(pAdapter->device_mode),
4028 pAdapter->device_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304029
Jeff Johnson295189b2012-06-20 16:38:30 -07004030 memset(&params, 0, sizeof(params));
4031
4032 if (CSR_MAX_NUM_KEY <= key_index)
4033 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304034 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07004035 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304036 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004037
4038 switch(pRoamProfile->EncryptionType.encryptionType[0])
4039 {
4040 case eCSR_ENCRYPT_TYPE_NONE:
4041 params.cipher = IW_AUTH_CIPHER_NONE;
4042 break;
4043
4044 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4045 case eCSR_ENCRYPT_TYPE_WEP40:
4046 params.cipher = WLAN_CIPHER_SUITE_WEP40;
4047 break;
4048
4049 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4050 case eCSR_ENCRYPT_TYPE_WEP104:
4051 params.cipher = WLAN_CIPHER_SUITE_WEP104;
4052 break;
4053
4054 case eCSR_ENCRYPT_TYPE_TKIP:
4055 params.cipher = WLAN_CIPHER_SUITE_TKIP;
4056 break;
4057
4058 case eCSR_ENCRYPT_TYPE_AES:
4059 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
4060 break;
4061
4062 default:
4063 params.cipher = IW_AUTH_CIPHER_NONE;
4064 break;
4065 }
4066
c_hpothuaaf19692014-05-17 17:01:48 +05304067 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
4068 TRACE_CODE_HDD_CFG80211_GET_KEY,
4069 pAdapter->sessionId, params.cipher));
4070
Jeff Johnson295189b2012-06-20 16:38:30 -07004071 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
4072 params.seq_len = 0;
4073 params.seq = NULL;
4074 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
4075 callback(cookie, &params);
4076 return 0;
4077}
4078
4079/*
4080 * FUNCTION: wlan_hdd_cfg80211_del_key
4081 * This function is used to delete the key information
4082 */
4083#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304084static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004085 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304086 u8 key_index,
4087 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07004088 const u8 *mac_addr
4089 )
4090#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304091static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004092 struct net_device *ndev,
4093 u8 key_index,
4094 const u8 *mac_addr
4095 )
4096#endif
4097{
4098 int status = 0;
4099
4100 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304101 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07004102 //it is observed that this is invalidating peer
4103 //key index whenever re-key is done. This is affecting data link.
4104 //It should be ok to ignore del_key.
4105#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304106 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
4107 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004108 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4109 tCsrRoamSetKey setKey;
4110 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304111
Jeff Johnson295189b2012-06-20 16:38:30 -07004112 ENTER();
4113
4114 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
4115 __func__,pAdapter->device_mode);
4116
4117 if (CSR_MAX_NUM_KEY <= key_index)
4118 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304119 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004120 key_index);
4121
4122 return -EINVAL;
4123 }
4124
4125 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4126 setKey.keyId = key_index;
4127
4128 if (mac_addr)
4129 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
4130 else
4131 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
4132
4133 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4134
4135 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07004136 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304137 )
4138 {
4139
4140 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07004141 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
4142 if( pHostapdState->bssState == BSS_START)
4143 {
4144 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304145
Jeff Johnson295189b2012-06-20 16:38:30 -07004146 if ( status != eHAL_STATUS_SUCCESS )
4147 {
4148 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4149 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
4150 __LINE__, status );
4151 }
4152 }
4153 }
4154 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304155 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07004156 )
4157 {
4158 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4159
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304160 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
4161
4162 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07004163 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304164 __func__, setKey.peerMac[0], setKey.peerMac[1],
4165 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07004166 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304167 if(pAdapter->sessionCtx.station.conn_info.connState ==
4168 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07004169 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304170 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07004171 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304172
Jeff Johnson295189b2012-06-20 16:38:30 -07004173 if ( 0 != status )
4174 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304175 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004176 "%s: sme_RoamSetKey failure, returned %d",
4177 __func__, status);
4178 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4179 return -EINVAL;
4180 }
4181 }
4182 }
4183#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07004184 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004185 return status;
4186}
4187
4188/*
4189 * FUNCTION: wlan_hdd_cfg80211_set_default_key
4190 * This function is used to set the default tx key index
4191 */
4192#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
4193static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
4194 struct net_device *ndev,
4195 u8 key_index,
4196 bool unicast, bool multicast)
4197#else
4198static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
4199 struct net_device *ndev,
4200 u8 key_index)
4201#endif
4202{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304203 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304204 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05304205 hdd_wext_state_t *pWextState;
4206 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304207 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004208
4209 ENTER();
4210
Gopichand Nakkala29149562013-05-10 21:43:41 +05304211 if ((NULL == pAdapter))
4212 {
4213 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4214 "invalid adapter");
4215 return -EINVAL;
4216 }
4217
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304218 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
4219 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
4220 pAdapter->sessionId, key_index));
4221
Gopichand Nakkala29149562013-05-10 21:43:41 +05304222 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4223 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4224
4225 if ((NULL == pWextState) || (NULL == pHddStaCtx))
4226 {
4227 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4228 "invalid Wext state or HDD context");
4229 return -EINVAL;
4230 }
4231
Arif Hussain6d2a3322013-11-17 19:50:10 -08004232 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004233 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304234
Jeff Johnson295189b2012-06-20 16:38:30 -07004235 if (CSR_MAX_NUM_KEY <= key_index)
4236 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304237 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004238 key_index);
4239
4240 return -EINVAL;
4241 }
4242
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304243 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4244 status = wlan_hdd_validate_context(pHddCtx);
4245
4246 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004247 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304248 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4249 "%s: HDD context is not valid", __func__);
4250 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004251 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304252
Jeff Johnson295189b2012-06-20 16:38:30 -07004253 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07004254 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304255 )
Jeff Johnson295189b2012-06-20 16:38:30 -07004256 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05304257 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08004258 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304259 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08004260 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07004261 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304262 {
4263 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07004264 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304265
Jeff Johnson295189b2012-06-20 16:38:30 -07004266 tCsrRoamSetKey setKey;
4267 v_U32_t roamId= 0xFF;
4268 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304269
4270 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004271 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304272
Jeff Johnson295189b2012-06-20 16:38:30 -07004273 Keys->defaultIndex = (u8)key_index;
4274 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4275 setKey.keyId = key_index;
4276 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304277
4278 vos_mem_copy(&setKey.Key[0],
4279 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07004280 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304281
Gopichand Nakkala29149562013-05-10 21:43:41 +05304282 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304283
4284 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07004285 &pHddStaCtx->conn_info.bssId[0],
4286 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304287
Gopichand Nakkala29149562013-05-10 21:43:41 +05304288 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
4289 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
4290 eCSR_ENCRYPT_TYPE_WEP104)
4291 {
4292 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
4293 even though ap is configured for WEP-40 encryption. In this canse the key length
4294 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
4295 type(104) and switching encryption type to 40*/
4296 pWextState->roamProfile.EncryptionType.encryptionType[0] =
4297 eCSR_ENCRYPT_TYPE_WEP40;
4298 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
4299 eCSR_ENCRYPT_TYPE_WEP40;
4300 }
4301
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304302 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07004303 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304304
Jeff Johnson295189b2012-06-20 16:38:30 -07004305 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304306 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07004307 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304308
Jeff Johnson295189b2012-06-20 16:38:30 -07004309 if ( 0 != status )
4310 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304311 hddLog(VOS_TRACE_LEVEL_ERROR,
4312 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004313 status);
4314 return -EINVAL;
4315 }
4316 }
4317 }
4318
4319 /* In SoftAp mode setting key direction for default mode */
4320 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
4321 {
4322 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
4323 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
4324 (eCSR_ENCRYPT_TYPE_AES !=
4325 pWextState->roamProfile.EncryptionType.encryptionType[0])
4326 )
4327 {
4328 /* Saving key direction for default key index to TX default */
4329 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
4330 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
4331 }
4332 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304333
Jeff Johnson295189b2012-06-20 16:38:30 -07004334 return status;
4335}
4336
Jeff Johnson295189b2012-06-20 16:38:30 -07004337/*
4338 * FUNCTION: wlan_hdd_cfg80211_inform_bss
4339 * This function is used to inform the BSS details to nl80211 interface.
4340 */
4341static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
4342 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
4343{
4344 struct net_device *dev = pAdapter->dev;
4345 struct wireless_dev *wdev = dev->ieee80211_ptr;
4346 struct wiphy *wiphy = wdev->wiphy;
4347 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
4348 int chan_no;
4349 int ie_length;
4350 const char *ie;
4351 unsigned int freq;
4352 struct ieee80211_channel *chan;
4353 int rssi = 0;
4354 struct cfg80211_bss *bss = NULL;
4355
4356 ENTER();
4357
4358 if( NULL == pBssDesc )
4359 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004360 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004361 return bss;
4362 }
4363
4364 chan_no = pBssDesc->channelId;
4365 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
4366 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
4367
4368 if( NULL == ie )
4369 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004370 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 return bss;
4372 }
4373
4374#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
4375 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
4376 {
4377 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4378 }
4379 else
4380 {
4381 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4382 }
4383#else
4384 freq = ieee80211_channel_to_frequency(chan_no);
4385#endif
4386
4387 chan = __ieee80211_get_channel(wiphy, freq);
4388
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +05304389 if (!chan) {
4390 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
4391 return NULL;
4392 }
4393
Jeff Johnson295189b2012-06-20 16:38:30 -07004394 bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId,
4395 &roamProfile->SSID.ssId[0], roamProfile->SSID.length,
4396 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
4397 if (bss == NULL)
4398 {
4399 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
4400
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304401 return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
4402 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07004403 pBssDesc->capabilityInfo,
4404 pBssDesc->beaconInterval, ie, ie_length,
4405 rssi, GFP_KERNEL ));
4406}
4407 else
4408 {
4409 return bss;
4410 }
4411}
4412
4413
4414
4415/*
4416 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
4417 * This function is used to inform the BSS details to nl80211 interface.
4418 */
4419struct cfg80211_bss*
4420wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
4421 tSirBssDescription *bss_desc
4422 )
4423{
4424 /*
4425 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
4426 already exists in bss data base of cfg80211 for that particular BSS ID.
4427 Using cfg80211_inform_bss_frame to update the bss entry instead of
4428 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
4429 now there is no possibility to get the mgmt(probe response) frame from PE,
4430 converting bss_desc to ieee80211_mgmt(probe response) and passing to
4431 cfg80211_inform_bss_frame.
4432 */
4433 struct net_device *dev = pAdapter->dev;
4434 struct wireless_dev *wdev = dev->ieee80211_ptr;
4435 struct wiphy *wiphy = wdev->wiphy;
4436 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004437#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4438 qcom_ie_age *qie_age = NULL;
4439 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
4440#else
Jeff Johnson295189b2012-06-20 16:38:30 -07004441 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004442#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004443 const char *ie =
4444 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
4445 unsigned int freq;
4446 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05304447 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004448 struct cfg80211_bss *bss_status = NULL;
4449 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
4450 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07004451 hdd_context_t *pHddCtx;
4452 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07004453#ifdef WLAN_OPEN_SOURCE
4454 struct timespec ts;
4455#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004456
Wilson Yangf80a0542013-10-07 13:02:37 -07004457 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4458 status = wlan_hdd_validate_context(pHddCtx);
4459
4460 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +05304461 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -07004462 {
4463 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4464 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
4465 return NULL;
4466 }
4467
4468
4469 if (0 != status)
4470 {
4471 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4472 "%s: HDD context is not valid", __func__);
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07004473 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07004474 }
4475
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05304476 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -07004477 if (!mgmt)
4478 {
4479 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4480 "%s: memory allocation failed ", __func__);
4481 return NULL;
4482 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07004483
Jeff Johnson295189b2012-06-20 16:38:30 -07004484 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07004485
4486#ifdef WLAN_OPEN_SOURCE
4487 /* Android does not want the timestamp from the frame.
4488 Instead it wants a monotonic increasing value */
4489 get_monotonic_boottime(&ts);
4490 mgmt->u.probe_resp.timestamp =
4491 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
4492#else
4493 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07004494 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
4495 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07004496
4497#endif
4498
Jeff Johnson295189b2012-06-20 16:38:30 -07004499 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
4500 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004501
4502#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4503 /* GPS Requirement: need age ie per entry. Using vendor specific. */
4504 /* Assuming this is the last IE, copy at the end */
4505 ie_length -=sizeof(qcom_ie_age);
4506 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
4507 qie_age->element_id = QCOM_VENDOR_IE_ID;
4508 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
4509 qie_age->oui_1 = QCOM_OUI1;
4510 qie_age->oui_2 = QCOM_OUI2;
4511 qie_age->oui_3 = QCOM_OUI3;
4512 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
4513 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
4514#endif
4515
Jeff Johnson295189b2012-06-20 16:38:30 -07004516 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05304517 if (bss_desc->fProbeRsp)
4518 {
4519 mgmt->frame_control |=
4520 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
4521 }
4522 else
4523 {
4524 mgmt->frame_control |=
4525 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
4526 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004527
4528#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304529 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004530 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
4531 {
4532 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4533 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304534 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004535 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
4536
4537 {
4538 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4539 }
4540 else
4541 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05304542 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
4543 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -07004544 kfree(mgmt);
4545 return NULL;
4546 }
4547#else
4548 freq = ieee80211_channel_to_frequency(chan_no);
4549#endif
4550 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004551 /*when the band is changed on the fly using the GUI, three things are done
4552 * 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)
4553 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
4554 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
4555 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
4556 * and discards the channels correponding to previous band and calls back with zero bss results.
4557 * 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
4558 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
4559 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
4560 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
4561 * So drop the bss and continue to next bss.
4562 */
4563 if(chan == NULL)
4564 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05304565 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07004566 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004567 return NULL;
4568 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004569 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304570 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07004571 * */
4572 if (( eConnectionState_Associated ==
4573 pAdapter->sessionCtx.station.conn_info.connState ) &&
4574 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
4575 pAdapter->sessionCtx.station.conn_info.bssId,
4576 WNI_CFG_BSSID_LEN)))
4577 {
4578 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
4579 rssi = (pAdapter->rssi * 100);
4580 }
4581 else
4582 {
4583 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
4584 }
4585
Nirav Shah20ac06f2013-12-12 18:14:06 +05304586 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
4587 "RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
4588 chan->center_freq, (int)(rssi/100));
4589
Jeff Johnson295189b2012-06-20 16:38:30 -07004590 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
4591 frame_len, rssi, GFP_KERNEL);
4592 kfree(mgmt);
4593 return bss_status;
4594}
4595
4596/*
4597 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
4598 * This function is used to update the BSS data base of CFG8011
4599 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304600struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004601 tCsrRoamInfo *pRoamInfo
4602 )
4603{
4604 tCsrRoamConnectedProfile roamProfile;
4605 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4606 struct cfg80211_bss *bss = NULL;
4607
4608 ENTER();
4609
4610 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
4611 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
4612
4613 if (NULL != roamProfile.pBssDesc)
4614 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304615 bss = wlan_hdd_cfg80211_inform_bss(pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004616 &roamProfile);
4617
4618 if (NULL == bss)
4619 {
4620 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
4621 __func__);
4622 }
4623
4624 sme_RoamFreeConnectProfile(hHal, &roamProfile);
4625 }
4626 else
4627 {
4628 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
4629 __func__);
4630 }
4631 return bss;
4632}
4633
4634/*
4635 * FUNCTION: wlan_hdd_cfg80211_update_bss
4636 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304637static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
4638 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07004639 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304640{
Jeff Johnson295189b2012-06-20 16:38:30 -07004641 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4642 tCsrScanResultInfo *pScanResult;
4643 eHalStatus status = 0;
4644 tScanResultHandle pResult;
4645 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07004646 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004647
4648 ENTER();
4649
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304650 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
4651 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
4652 NO_SESSION, pAdapter->sessionId));
4653
Wilson Yangf80a0542013-10-07 13:02:37 -07004654 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4655
4656 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -07004657 {
Wilson Yangf80a0542013-10-07 13:02:37 -07004658 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4659 "%s:LOGP in Progress. Ignore!!!",__func__);
4660 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004661 }
4662
Wilson Yangf80a0542013-10-07 13:02:37 -07004663
4664 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +05304665 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -07004666 {
4667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4668 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
4669 return VOS_STATUS_E_PERM;
4670 }
4671
4672
Jeff Johnson295189b2012-06-20 16:38:30 -07004673 /*
4674 * start getting scan results and populate cgf80211 BSS database
4675 */
4676 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
4677
4678 /* no scan results */
4679 if (NULL == pResult)
4680 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05304681 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
4682 __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004683 return status;
4684 }
4685
4686 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
4687
4688 while (pScanResult)
4689 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304690 /*
4691 * cfg80211_inform_bss() is not updating ie field of bss entry, if
4692 * entry already exists in bss data base of cfg80211 for that
4693 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
4694 * bss entry instead of cfg80211_inform_bss, But this call expects
4695 * mgmt packet as input. As of now there is no possibility to get
4696 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07004697 * ieee80211_mgmt(probe response) and passing to c
4698 * fg80211_inform_bss_frame.
4699 * */
4700
4701 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
4702 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304703
Jeff Johnson295189b2012-06-20 16:38:30 -07004704
4705 if (NULL == bss_status)
4706 {
4707 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004708 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004709 }
4710 else
4711 {
Yue Maf49ba872013-08-19 12:04:25 -07004712 cfg80211_put_bss(
4713#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
4714 wiphy,
4715#endif
4716 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004717 }
4718
4719 pScanResult = sme_ScanResultGetNext(hHal, pResult);
4720 }
4721
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304722 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07004723
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304724 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004725}
4726
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004727void
4728hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
4729{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304730 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -08004731 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004732} /****** end hddPrintMacAddr() ******/
4733
4734void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004735hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004736{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304737 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004738 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004739 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
4740 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
4741 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004742} /****** end hddPrintPmkId() ******/
4743
4744//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
4745//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
4746
4747//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
4748//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
4749
4750#define dump_bssid(bssid) \
4751 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004752 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
4753 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004754 }
4755
4756#define dump_pmkid(pMac, pmkid) \
4757 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004758 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
4759 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004760 }
4761
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004762#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004763/*
4764 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
4765 * This function is used to notify the supplicant of a new PMKSA candidate.
4766 */
4767int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304768 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004769 int index, bool preauth )
4770{
Jeff Johnsone7245742012-09-05 17:12:55 -07004771#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004772 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004773 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004774
4775 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07004776 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004777
4778 if( NULL == pRoamInfo )
4779 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004780 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004781 return -EINVAL;
4782 }
4783
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004784 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
4785 {
4786 dump_bssid(pRoamInfo->bssid);
4787 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004788 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004789 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004790#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304791 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004792}
4793#endif //FEATURE_WLAN_LFR
4794
Yue Maef608272013-04-08 23:09:17 -07004795#ifdef FEATURE_WLAN_LFR_METRICS
4796/*
4797 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
4798 * 802.11r/LFR metrics reporting function to report preauth initiation
4799 *
4800 */
4801#define MAX_LFR_METRICS_EVENT_LENGTH 100
4802VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
4803 tCsrRoamInfo *pRoamInfo)
4804{
4805 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4806 union iwreq_data wrqu;
4807
4808 ENTER();
4809
4810 if (NULL == pAdapter)
4811 {
4812 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4813 return VOS_STATUS_E_FAILURE;
4814 }
4815
4816 /* create the event */
4817 memset(&wrqu, 0, sizeof(wrqu));
4818 memset(metrics_notification, 0, sizeof(metrics_notification));
4819
4820 wrqu.data.pointer = metrics_notification;
4821 wrqu.data.length = scnprintf(metrics_notification,
4822 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
4823 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
4824
4825 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4826
4827 EXIT();
4828
4829 return VOS_STATUS_SUCCESS;
4830}
4831
4832/*
4833 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
4834 * 802.11r/LFR metrics reporting function to report preauth completion
4835 * or failure
4836 */
4837VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
4838 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
4839{
4840 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4841 union iwreq_data wrqu;
4842
4843 ENTER();
4844
4845 if (NULL == pAdapter)
4846 {
4847 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4848 return VOS_STATUS_E_FAILURE;
4849 }
4850
4851 /* create the event */
4852 memset(&wrqu, 0, sizeof(wrqu));
4853 memset(metrics_notification, 0, sizeof(metrics_notification));
4854
4855 scnprintf(metrics_notification, sizeof(metrics_notification),
4856 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
4857 MAC_ADDR_ARRAY(pRoamInfo->bssid));
4858
4859 if (1 == preauth_status)
4860 strncat(metrics_notification, " TRUE", 5);
4861 else
4862 strncat(metrics_notification, " FALSE", 6);
4863
4864 wrqu.data.pointer = metrics_notification;
4865 wrqu.data.length = strlen(metrics_notification);
4866
4867 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4868
4869 EXIT();
4870
4871 return VOS_STATUS_SUCCESS;
4872}
4873
4874/*
4875 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
4876 * 802.11r/LFR metrics reporting function to report handover initiation
4877 *
4878 */
4879VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
4880 tCsrRoamInfo *pRoamInfo)
4881{
4882 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4883 union iwreq_data wrqu;
4884
4885 ENTER();
4886
4887 if (NULL == pAdapter)
4888 {
4889 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4890 return VOS_STATUS_E_FAILURE;
4891 }
4892
4893 /* create the event */
4894 memset(&wrqu, 0, sizeof(wrqu));
4895 memset(metrics_notification, 0, sizeof(metrics_notification));
4896
4897 wrqu.data.pointer = metrics_notification;
4898 wrqu.data.length = scnprintf(metrics_notification,
4899 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
4900 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
4901
4902 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4903
4904 EXIT();
4905
4906 return VOS_STATUS_SUCCESS;
4907}
4908#endif
4909
Jeff Johnson295189b2012-06-20 16:38:30 -07004910/*
4911 * FUNCTION: hdd_cfg80211_scan_done_callback
4912 * scanning callback function, called after finishing scan
4913 *
4914 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304915static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -07004916 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
4917{
4918 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304919 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004920 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004921 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4922 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07004923 struct cfg80211_scan_request *req = NULL;
4924 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05304925 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304926 long waitRet = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004927
4928 ENTER();
4929
4930 hddLog(VOS_TRACE_LEVEL_INFO,
4931 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -08004932 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004933 __func__, halHandle, pContext, (int) scanId, (int) status);
4934
Kiet Lamac06e2c2013-10-23 16:25:07 +05304935 pScanInfo->mScanPendingCounter = 0;
4936
Jeff Johnson295189b2012-06-20 16:38:30 -07004937 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304938 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -07004939 &pScanInfo->scan_req_completion_event,
4940 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304941 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004942 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304943 hddLog(VOS_TRACE_LEVEL_ERROR,
4944 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -07004945 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004946 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004947 }
4948
Yue Maef608272013-04-08 23:09:17 -07004949 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 {
4951 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004952 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004953 }
4954
4955 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304956 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -07004957 {
4958 hddLog(VOS_TRACE_LEVEL_INFO,
4959 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004960 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004961 (int) scanId);
4962 }
4963
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304964 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004965 pAdapter);
4966
4967 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304968 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004969
4970
4971 /* If any client wait scan result through WEXT
4972 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004973 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07004974 {
4975 /* The other scan request waiting for current scan finish
4976 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004977 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004978 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004979 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07004980 }
4981 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004982 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004983 {
4984 struct net_device *dev = pAdapter->dev;
4985 union iwreq_data wrqu;
4986 int we_event;
4987 char *msg;
4988
4989 memset(&wrqu, '\0', sizeof(wrqu));
4990 we_event = SIOCGIWSCAN;
4991 msg = NULL;
4992 wireless_send_event(dev, we_event, &wrqu, msg);
4993 }
4994 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004995 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004996
4997 /* Get the Scan Req */
4998 req = pAdapter->request;
4999
5000 if (!req)
5001 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005002 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07005003 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07005004 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07005005 }
5006
5007 /*
5008 * setting up 0, just in case.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305009 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005010 req->n_ssids = 0;
5011 req->n_channels = 0;
5012 req->ie = 0;
5013
Jeff Johnson295189b2012-06-20 16:38:30 -07005014 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07005015 /* Scan is no longer pending */
5016 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005017
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -07005018 /*
5019 * cfg80211_scan_done informing NL80211 about completion
5020 * of scanning
5021 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05305022 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
5023 {
5024 aborted = true;
5025 }
5026 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08005027 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07005028
Jeff Johnsone7245742012-09-05 17:12:55 -07005029allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07005030 /* release the wake lock at the end of the scan*/
5031 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07005032
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07005033 /* Acquire wakelock to handle the case where APP's tries to suspend
5034 * immediatly after the driver gets connect request(i.e after scan)
5035 * from supplicant, this result in app's is suspending and not able
5036 * to process the connect request to AP */
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05305037 hdd_prevent_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07005038
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07005039#ifdef FEATURE_WLAN_TDLS
5040 wlan_hdd_tdls_scan_done_callback(pAdapter);
5041#endif
5042
Jeff Johnson295189b2012-06-20 16:38:30 -07005043 EXIT();
5044 return 0;
5045}
5046
5047/*
Rashmi Ramannab1429032014-04-26 14:59:09 +05305048 * FUNCTION: hdd_isConnectionInProgress
5049 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005050 *
5051 */
Rashmi Ramannab1429032014-04-26 14:59:09 +05305052v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx )
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005053{
5054 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
5055 hdd_station_ctx_t *pHddStaCtx = NULL;
5056 hdd_adapter_t *pAdapter = NULL;
5057 VOS_STATUS status = 0;
5058 v_U8_t staId = 0;
5059 v_U8_t *staMac = NULL;
5060
c_hpothu9b781ba2013-12-30 20:57:45 +05305061 if (TRUE == pHddCtx->btCoexModeSet)
5062 {
5063 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +05305064 FL("BTCoex Mode operation in progress"));
5065 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +05305066 }
5067
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005068 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
5069
5070 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
5071 {
5072 pAdapter = pAdapterNode->pAdapter;
5073
5074 if( pAdapter )
5075 {
5076 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305077 "%s: Adapter with device mode %s (%d) exists",
5078 __func__, hdd_device_modetoString(pAdapter->device_mode),
5079 pAdapter->device_mode);
Rashmi Ramannab1429032014-04-26 14:59:09 +05305080 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
5081 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
5082 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
5083 (eConnectionState_Connecting ==
5084 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
5085 {
5086 hddLog(VOS_TRACE_LEVEL_ERROR,
5087 "%s: %p(%d) Connection is in progress", __func__,
5088 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
5089 return VOS_TRUE;
5090 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005091 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305092 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
5093 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005094 {
5095 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5096 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305097 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005098 {
5099 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
5100 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08005101 "%s: client " MAC_ADDRESS_STR
5102 " is in the middle of WPS/EAPOL exchange.", __func__,
5103 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +05305104 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005105 }
5106 }
5107 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
5108 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
5109 {
5110 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
5111 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305112 if ((pAdapter->aStaInfo[staId].isUsed) &&
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005113 (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState))
5114 {
5115 staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
5116
5117 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08005118 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
5119 "middle of WPS/EAPOL exchange.", __func__,
5120 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +05305121 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005122 }
5123 }
5124 }
5125 }
5126 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
5127 pAdapterNode = pNext;
5128 }
Rashmi Ramannab1429032014-04-26 14:59:09 +05305129 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305130}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005131
5132/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05305133 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -07005134 * this scan respond to scan trigger and update cfg80211 scan database
5135 * later, scan dump command can be used to recieve scan results
5136 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05305137int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08005138#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
5139 struct net_device *dev,
5140#endif
5141 struct cfg80211_scan_request *request)
5142{
Siddharth Bhal0c162d02014-05-06 19:50:42 +05305143 hdd_adapter_t *pAdapter = NULL;
5144 hdd_context_t *pHddCtx = NULL;
5145 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305146 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005147 tCsrScanRequest scanRequest;
5148 tANI_U8 *channelList = NULL, i;
5149 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305150 int status;
5151 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005152 v_U8_t* pP2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005153
Siddharth Bhal0c162d02014-05-06 19:50:42 +05305154#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
5155 struct net_device *dev = NULL;
5156 if (NULL == request)
5157 {
5158 hddLog(VOS_TRACE_LEVEL_ERROR,
5159 "%s: scan req param null", __func__);
5160 return -EINVAL;
5161 }
5162 dev = request->wdev->netdev;
5163#endif
5164
5165 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
5166 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5167 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5168
Jeff Johnson295189b2012-06-20 16:38:30 -07005169 ENTER();
5170
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305171
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305172 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
5173 __func__, hdd_device_modetoString(pAdapter->device_mode),
5174 pAdapter->device_mode);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005175
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305176 status = wlan_hdd_validate_context(pHddCtx);
5177
5178 if (0 != status)
5179 {
5180 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5181 "%s: HDD context is not valid", __func__);
5182 return status;
5183 }
5184
Siddharth Bhal0c162d02014-05-06 19:50:42 +05305185 if (NULL == pwextBuf)
5186 {
5187 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
5188 __func__);
5189 return -EIO;
5190 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305191 cfg_param = pHddCtx->cfg_ini;
5192 pScanInfo = &pHddCtx->scan_info;
5193
Jeff Johnson295189b2012-06-20 16:38:30 -07005194#ifdef WLAN_BTAMP_FEATURE
5195 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005196 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -07005197 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005198 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005199 "%s: No scanning when AMP is on", __func__);
5200 return -EOPNOTSUPP;
5201 }
5202#endif
5203 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005204 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07005205 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005206 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305207 "%s: Not scanning on device_mode = %s (%d)",
5208 __func__, hdd_device_modetoString(pAdapter->device_mode),
5209 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005210 return -EOPNOTSUPP;
5211 }
5212
5213 if (TRUE == pScanInfo->mScanPending)
5214 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05305215 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
5216 {
5217 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
5218 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005219 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005220 }
5221
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305222 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -07005223 //Channel and action frame is pending
5224 //Otherwise Cancel Remain On Channel and allow Scan
5225 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005226 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -07005227 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05305228 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -07005229 return -EBUSY;
5230 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005231#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07005232 /* if tdls disagree scan right now, return immediately.
5233 tdls will schedule the scan when scan is allowed. (return SUCCESS)
5234 or will reject the scan if any TDLS is in progress. (return -EBUSY)
5235 */
5236 status = wlan_hdd_tdls_scan_callback (pAdapter,
5237 wiphy,
5238#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
5239 dev,
Gopichand Nakkalac3c42b92013-03-20 19:42:34 -07005240#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07005241 request);
5242 if(status <= 0)
5243 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05305244 if(!status)
5245 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
5246 "scan rejected %d", __func__, status);
5247 else
5248 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
5249 __func__, status);
5250
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07005251 return status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005252 }
5253#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07005254
Jeff Johnson295189b2012-06-20 16:38:30 -07005255 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
5256 {
5257 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -08005258 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005259 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305260 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005261 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
5262 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05305263 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005264 "%s: MAX TM Level Scan not allowed", __func__);
5265 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305266 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005267 }
5268 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
5269
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005270 /* Check if scan is allowed at this point of time.
5271 */
Rashmi Ramannab1429032014-04-26 14:59:09 +05305272 if (hdd_isConnectionInProgress(pHddCtx))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08005273 {
5274 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
5275 return -EBUSY;
5276 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305277
Jeff Johnson295189b2012-06-20 16:38:30 -07005278 vos_mem_zero( &scanRequest, sizeof(scanRequest));
5279
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05305280 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
5281 (int)request->n_ssids);
5282
5283 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
5284 * Becasue of this, driver is assuming that this is not wildcard scan and so
5285 * is not aging out the scan results.
5286 */
5287 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07005288 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05305289 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005290 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05305291
5292 if ((request->ssids) && (0 < request->n_ssids))
5293 {
5294 tCsrSSIDInfo *SsidInfo;
5295 int j;
5296 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
5297 /* Allocate num_ssid tCsrSSIDInfo structure */
5298 SsidInfo = scanRequest.SSIDs.SSIDList =
5299 ( tCsrSSIDInfo *)vos_mem_malloc(
5300 request->n_ssids*sizeof(tCsrSSIDInfo));
5301
5302 if(NULL == scanRequest.SSIDs.SSIDList)
5303 {
5304 hddLog(VOS_TRACE_LEVEL_ERROR,
5305 "%s: memory alloc failed SSIDInfo buffer", __func__);
5306 return -ENOMEM;
5307 }
5308
5309 /* copy all the ssid's and their length */
5310 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
5311 {
5312 /* get the ssid length */
5313 SsidInfo->SSID.length = request->ssids[j].ssid_len;
5314 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
5315 SsidInfo->SSID.length);
5316 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
5317 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
5318 j, SsidInfo->SSID.ssId);
5319 }
5320 /* set the scan type to active */
5321 scanRequest.scanType = eSIR_ACTIVE_SCAN;
5322 }
5323 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07005324 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +05305325 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
5326 TRACE_CODE_HDD_CFG80211_SCAN,
5327 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07005328 /* set the scan type to active */
5329 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07005330 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05305331 else
5332 {
5333 /*Set the scan type to default type, in this case it is ACTIVE*/
5334 scanRequest.scanType = pScanInfo->scan_mode;
5335 }
5336 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
5337 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07005338
5339 /* set BSSType to default type */
5340 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
5341
5342 /*TODO: scan the requested channels only*/
5343
5344 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05305345 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -07005346 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05305347 hddLog(VOS_TRACE_LEVEL_WARN,
5348 "No of Scan Channels exceeded limit: %d", request->n_channels);
5349 request->n_channels = MAX_CHANNEL;
5350 }
5351
5352 hddLog(VOS_TRACE_LEVEL_INFO,
5353 "No of Scan Channels: %d", request->n_channels);
5354
5355
5356 if( request->n_channels )
5357 {
5358 char chList [(request->n_channels*5)+1];
5359 int len;
5360 channelList = vos_mem_malloc( request->n_channels );
5361 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +05305362 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05305363 hddLog(VOS_TRACE_LEVEL_ERROR,
5364 "%s: memory alloc failed channelList", __func__);
5365 status = -ENOMEM;
5366 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +05305367 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05305368
5369 for( i = 0, len = 0; i < request->n_channels ; i++ )
5370 {
5371 channelList[i] = request->channels[i]->hw_value;
5372 len += snprintf(chList+len, 5, "%d ", channelList[i]);
5373 }
5374
Nirav Shah20ac06f2013-12-12 18:14:06 +05305375 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05305376 "Channel-List: %s ", chList);
5377 }
c_hpothu53512302014-04-15 18:49:53 +05305378
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05305379 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
5380 scanRequest.ChannelInfo.ChannelList = channelList;
5381
5382 /* set requestType to full scan */
5383 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
5384
5385 /* Flush the scan results(only p2p beacons) for STA scan and P2P
5386 * search (Flush on both full scan and social scan but not on single
5387 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
5388 */
5389
5390 /* Supplicant does single channel scan after 8-way handshake
5391 * and in that case driver shoudnt flush scan results. If
5392 * driver flushes the scan results here and unfortunately if
5393 * the AP doesnt respond to our probe req then association
5394 * fails which is not desired
5395 */
5396
5397 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
5398 {
5399 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
5400 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
5401 pAdapter->sessionId );
5402 }
5403
5404 if( request->ie_len )
5405 {
5406 /* save this for future association (join requires this) */
5407 /*TODO: Array needs to be converted to dynamic allocation,
5408 * as multiple ie.s can be sent in cfg80211_scan_request structure
5409 * CR 597966
5410 */
5411 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
5412 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
5413 pScanInfo->scanAddIE.length = request->ie_len;
5414
5415 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
5416 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
5417 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07005418 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05305419 if ( request->ie_len <= SIR_MAC_MAX_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -07005420 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05305421 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
5422 memcpy( pwextBuf->roamProfile.addIEScan,
5423 request->ie, request->ie_len);
5424 }
5425 else
5426 {
5427 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
5428 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07005429 }
5430
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05305431 }
5432 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
5433 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
5434
5435 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
5436 request->ie_len);
5437 if (pP2pIe != NULL)
5438 {
5439#ifdef WLAN_FEATURE_P2P_DEBUG
5440 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
5441 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
5442 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +05305443 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05305444 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
5445 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
5446 "Go nego completed to Connection is started");
5447 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
5448 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +05305449 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05305450 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
5451 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07005452 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05305453 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
5454 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
5455 "Disconnected state to Connection is started");
5456 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
5457 "for 4way Handshake");
5458 }
5459#endif
5460
5461 /* no_cck will be set during p2p find to disable 11b rates */
5462 if(TRUE == request->no_cck)
5463 {
5464 hddLog(VOS_TRACE_LEVEL_INFO,
5465 "%s: This is a P2P Search", __func__);
5466 scanRequest.p2pSearch = 1;
5467
5468 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +05305469 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05305470 /* set requestType to P2P Discovery */
5471 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
5472 }
5473
5474 /*
5475 Skip Dfs Channel in case of P2P Search
5476 if it is set in ini file
5477 */
5478 if(cfg_param->skipDfsChnlInP2pSearch)
5479 {
5480 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +05305481 }
5482 else
5483 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05305484 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05305485 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005486
Agarwal Ashish4f616132013-12-30 23:32:50 +05305487 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005488 }
5489 }
5490
5491 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
5492
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07005493 /* acquire the wakelock to avoid the apps suspend during the scan. To
5494 * address the following issues.
5495 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
5496 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
5497 * for long time, this result in apps running at full power for long time.
5498 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
5499 * be stuck in full power because of resume BMPS
5500 */
5501 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07005502
Nirav Shah20ac06f2013-12-12 18:14:06 +05305503 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5504 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305505 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
5506 scanRequest.requestType, scanRequest.scanType,
5507 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +05305508 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
5509
Jeff Johnsone7245742012-09-05 17:12:55 -07005510 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005511 pAdapter->sessionId, &scanRequest, &scanId,
5512 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -07005513
Jeff Johnson295189b2012-06-20 16:38:30 -07005514 if (eHAL_STATUS_SUCCESS != status)
5515 {
5516 hddLog(VOS_TRACE_LEVEL_ERROR,
5517 "%s: sme_ScanRequest returned error %d", __func__, status);
5518 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07005519 if(eHAL_STATUS_RESOURCES == status)
5520 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05305521 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
5522 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07005523 status = -EBUSY;
5524 } else {
5525 status = -EIO;
5526 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07005527 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07005528 goto free_mem;
5529 }
5530
5531 pScanInfo->mScanPending = TRUE;
5532 pAdapter->request = request;
5533 pScanInfo->scanId = scanId;
5534
5535 complete(&pScanInfo->scan_req_completion_event);
5536
5537free_mem:
5538 if( scanRequest.SSIDs.SSIDList )
5539 {
5540 vos_mem_free(scanRequest.SSIDs.SSIDList);
5541 }
5542
5543 if( channelList )
5544 vos_mem_free( channelList );
5545
5546 EXIT();
5547
5548 return status;
5549}
5550
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05305551int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
5552#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
5553 struct net_device *dev,
5554#endif
5555 struct cfg80211_scan_request *request)
5556{
5557 int ret;
5558
5559 vos_ssr_protect(__func__);
5560 ret = __wlan_hdd_cfg80211_scan(wiphy,
5561#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
5562 dev,
5563#endif
5564 request);
5565 vos_ssr_unprotect(__func__);
5566
5567 return ret;
5568}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005569
5570void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
5571{
5572 v_U8_t iniDot11Mode =
5573 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
5574 eHddDot11Mode hddDot11Mode = iniDot11Mode;
5575
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05305576 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
5577 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005578 switch ( iniDot11Mode )
5579 {
5580 case eHDD_DOT11_MODE_AUTO:
5581 case eHDD_DOT11_MODE_11ac:
5582 case eHDD_DOT11_MODE_11ac_ONLY:
5583#ifdef WLAN_FEATURE_11AC
5584 hddDot11Mode = eHDD_DOT11_MODE_11ac;
5585#else
5586 hddDot11Mode = eHDD_DOT11_MODE_11n;
5587#endif
5588 break;
5589 case eHDD_DOT11_MODE_11n:
5590 case eHDD_DOT11_MODE_11n_ONLY:
5591 hddDot11Mode = eHDD_DOT11_MODE_11n;
5592 break;
5593 default:
5594 hddDot11Mode = iniDot11Mode;
5595 break;
5596 }
5597 /* This call decides required channel bonding mode */
5598 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
5599 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
5600 operationChannel);
5601}
5602
Jeff Johnson295189b2012-06-20 16:38:30 -07005603/*
5604 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305605 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -07005606 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305607int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -07005608 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07005609{
5610 int status = 0;
5611 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -08005612 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005613 v_U32_t roamId;
5614 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005615 eCsrAuthType RSNAuthType;
5616
5617 ENTER();
5618
5619 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -08005620 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5621
5622 status = wlan_hdd_validate_context(pHddCtx);
5623 if (status)
5624 {
5625 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5626 "%s: HDD context is not valid!", __func__);
5627 return status;
5628 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305629
Jeff Johnson295189b2012-06-20 16:38:30 -07005630 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
5631 {
5632 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
5633 return -EINVAL;
5634 }
5635
5636 pRoamProfile = &pWextState->roamProfile;
5637
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305638 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07005639 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005640 hdd_station_ctx_t *pHddStaCtx;
5641 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005642
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305643 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07005644 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
5645 {
5646 /*QoS not enabled in cfg file*/
5647 pRoamProfile->uapsd_mask = 0;
5648 }
5649 else
5650 {
5651 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305652 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -07005653 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
5654 }
5655
5656 pRoamProfile->SSIDs.numOfSSIDs = 1;
5657 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
5658 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305659 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005660 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
5661 ssid, ssid_len);
5662
5663 if (bssid)
5664 {
5665 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
5666 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
5667 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305668 /* Save BSSID in seperate variable as well, as RoamProfile
5669 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -07005670 case of join failure we should send valid BSSID to supplicant
5671 */
5672 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
5673 WNI_CFG_BSSID_LEN);
5674 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07005675 else
5676 {
5677 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
5678 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005679
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05305680 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
5681 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07005682 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
5683 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305684 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005685 /*set gen ie*/
5686 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
5687 /*set auth*/
5688 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5689 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005690#ifdef FEATURE_WLAN_WAPI
5691 if (pAdapter->wapi_info.nWapiMode)
5692 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005693 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005694 switch (pAdapter->wapi_info.wapiAuthMode)
5695 {
5696 case WAPI_AUTH_MODE_PSK:
5697 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005698 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005699 pAdapter->wapi_info.wapiAuthMode);
5700 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5701 break;
5702 }
5703 case WAPI_AUTH_MODE_CERT:
5704 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005705 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005706 pAdapter->wapi_info.wapiAuthMode);
5707 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5708 break;
5709 }
5710 } // End of switch
5711 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5712 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
5713 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005714 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005715 pRoamProfile->AuthType.numEntries = 1;
5716 pRoamProfile->EncryptionType.numEntries = 1;
5717 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5718 pRoamProfile->mcEncryptionType.numEntries = 1;
5719 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5720 }
5721 }
5722#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305723#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305724 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305725 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
5726 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5727 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305728 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
5729 sizeof (tSirGtkOffloadParams));
5730 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305731 }
5732#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005733 pRoamProfile->csrPersona = pAdapter->device_mode;
5734
Jeff Johnson32d95a32012-09-10 13:15:23 -07005735 if( operatingChannel )
5736 {
5737 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
5738 pRoamProfile->ChannelInfo.numOfChannels = 1;
5739 }
Chet Lanctot186b5732013-03-18 10:26:30 -07005740 else
5741 {
5742 pRoamProfile->ChannelInfo.ChannelList = NULL;
5743 pRoamProfile->ChannelInfo.numOfChannels = 0;
5744 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005745 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
5746 {
5747 hdd_select_cbmode(pAdapter,operatingChannel);
5748 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05305749
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005750 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
5751 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305752 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005753 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005754 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
5755 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305756 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5757 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +05305758 {
5759 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5760 "%s: Set HDD connState to eConnectionState_Connecting",
5761 __func__);
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005762 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5763 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +05305764 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305765 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005766 pAdapter->sessionId, pRoamProfile, &roamId);
5767
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305768 if ((eHAL_STATUS_SUCCESS != status) &&
5769 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5770 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305771
5772 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005773 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
5774 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
5775 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305776 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005777 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305778 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005779
5780 pRoamProfile->ChannelInfo.ChannelList = NULL;
5781 pRoamProfile->ChannelInfo.numOfChannels = 0;
5782
Jeff Johnson295189b2012-06-20 16:38:30 -07005783 }
5784 else
5785 {
5786 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
5787 return -EINVAL;
5788 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005789 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005790 return status;
5791}
5792
5793/*
5794 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
5795 * This function is used to set the authentication type (OPEN/SHARED).
5796 *
5797 */
5798static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
5799 enum nl80211_auth_type auth_type)
5800{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305801 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005802 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5803
5804 ENTER();
5805
5806 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305807 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -07005808 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005809 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305810 hddLog(VOS_TRACE_LEVEL_INFO,
5811 "%s: set authentication type to AUTOSWITCH", __func__);
5812 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
5813 break;
5814
5815 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07005816#ifdef WLAN_FEATURE_VOWIFI_11R
5817 case NL80211_AUTHTYPE_FT:
5818#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305819 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005820 "%s: set authentication type to OPEN", __func__);
5821 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5822 break;
5823
5824 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305825 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005826 "%s: set authentication type to SHARED", __func__);
5827 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
5828 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005829#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005830 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305831 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005832 "%s: set authentication type to CCKM WPA", __func__);
5833 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
5834 break;
5835#endif
5836
5837
5838 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305839 hddLog(VOS_TRACE_LEVEL_ERROR,
5840 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005841 auth_type);
5842 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
5843 return -EINVAL;
5844 }
5845
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305846 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005847 pHddStaCtx->conn_info.authType;
5848 return 0;
5849}
5850
5851/*
5852 * FUNCTION: wlan_hdd_set_akm_suite
5853 * This function is used to set the key mgmt type(PSK/8021x).
5854 *
5855 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305856static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005857 u32 key_mgmt
5858 )
5859{
5860 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5861 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305862
Jeff Johnson295189b2012-06-20 16:38:30 -07005863 /*set key mgmt type*/
5864 switch(key_mgmt)
5865 {
5866 case WLAN_AKM_SUITE_PSK:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305867#ifdef WLAN_FEATURE_VOWIFI_11R
5868 case WLAN_AKM_SUITE_FT_PSK:
5869#endif
5870 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -07005871 __func__);
5872 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5873 break;
5874
5875 case WLAN_AKM_SUITE_8021X:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305876#ifdef WLAN_FEATURE_VOWIFI_11R
5877 case WLAN_AKM_SUITE_FT_8021X:
5878#endif
5879 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -07005880 __func__);
5881 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5882 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005883#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005884#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
5885#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5886 case WLAN_AKM_SUITE_CCKM:
5887 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
5888 __func__);
5889 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
5890 break;
5891#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07005892#ifndef WLAN_AKM_SUITE_OSEN
5893#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
5894 case WLAN_AKM_SUITE_OSEN:
5895 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
5896 __func__);
5897 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5898 break;
5899#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005900
5901 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305902 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005903 __func__, key_mgmt);
5904 return -EINVAL;
5905
5906 }
5907 return 0;
5908}
5909
5910/*
5911 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305912 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -07005913 * (NONE/WEP40/WEP104/TKIP/CCMP).
5914 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305915static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
5916 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -07005917 bool ucast
5918 )
5919{
5920 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305921 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005922 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5923
5924 ENTER();
5925
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305926 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005927 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305928 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -07005929 __func__, cipher);
5930 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5931 }
5932 else
5933 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305934
Jeff Johnson295189b2012-06-20 16:38:30 -07005935 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305936 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005937 {
5938 case IW_AUTH_CIPHER_NONE:
5939 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5940 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305941
Jeff Johnson295189b2012-06-20 16:38:30 -07005942 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305943 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07005944 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305945
Jeff Johnson295189b2012-06-20 16:38:30 -07005946 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305947 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -07005948 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305949
Jeff Johnson295189b2012-06-20 16:38:30 -07005950 case WLAN_CIPHER_SUITE_TKIP:
5951 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5952 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305953
Jeff Johnson295189b2012-06-20 16:38:30 -07005954 case WLAN_CIPHER_SUITE_CCMP:
5955 encryptionType = eCSR_ENCRYPT_TYPE_AES;
5956 break;
5957#ifdef FEATURE_WLAN_WAPI
5958 case WLAN_CIPHER_SUITE_SMS4:
5959 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
5960 break;
5961#endif
5962
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005963#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005964 case WLAN_CIPHER_SUITE_KRK:
5965 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
5966 break;
5967#endif
5968 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305969 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005970 __func__, cipher);
5971 return -EOPNOTSUPP;
5972 }
5973 }
5974
5975 if (ucast)
5976 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305977 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005978 __func__, encryptionType);
5979 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
5980 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305981 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005982 encryptionType;
5983 }
5984 else
5985 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305986 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005987 __func__, encryptionType);
5988 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
5989 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5990 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
5991 }
5992
5993 return 0;
5994}
5995
5996
5997/*
5998 * FUNCTION: wlan_hdd_cfg80211_set_ie
5999 * This function is used to parse WPA/RSN IE's.
6000 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306001int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
6002 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -07006003 size_t ie_len
6004 )
6005{
6006 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6007 u8 *genie = ie;
6008 v_U16_t remLen = ie_len;
6009#ifdef FEATURE_WLAN_WAPI
6010 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
6011 u16 *tmp;
6012 v_U16_t akmsuiteCount;
6013 int *akmlist;
6014#endif
6015 ENTER();
6016
6017 /* clear previous assocAddIE */
6018 pWextState->assocAddIE.length = 0;
6019 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006020 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006021
6022 while (remLen >= 2)
6023 {
6024 v_U16_t eLen = 0;
6025 v_U8_t elementId;
6026 elementId = *genie++;
6027 eLen = *genie++;
6028 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306029
Arif Hussain6d2a3322013-11-17 19:50:10 -08006030 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07006031 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306032
6033 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -07006034 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306035 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006036 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 -07006037 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306038 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006039 "%s: Invalid WPA IE", __func__);
6040 return -EINVAL;
6041 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306042 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -07006043 {
6044 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306045 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07006046 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306047
Jeff Johnson295189b2012-06-20 16:38:30 -07006048 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
6049 {
Jeff Johnson902c9832012-12-10 14:28:09 -08006050 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
6051 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07006052 VOS_ASSERT(0);
6053 return -ENOMEM;
6054 }
6055 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
6056 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
6057 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306058
Jeff Johnson295189b2012-06-20 16:38:30 -07006059 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
6060 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
6061 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
6062 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306063 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
6064 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006065 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
6066 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
6067 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
6068 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
6069 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
6070 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306071 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +05306072 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006073 {
6074 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306075 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07006076 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306077
Jeff Johnson295189b2012-06-20 16:38:30 -07006078 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
6079 {
Jeff Johnson902c9832012-12-10 14:28:09 -08006080 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
6081 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07006082 VOS_ASSERT(0);
6083 return -ENOMEM;
6084 }
6085 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
6086 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
6087 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306088
Jeff Johnson295189b2012-06-20 16:38:30 -07006089 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
6090 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
6091 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006092#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306093 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
6094 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006095 /*Consider WFD IE, only for P2P Client */
6096 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
6097 {
6098 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306099 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07006100 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306101
Jeff Johnson295189b2012-06-20 16:38:30 -07006102 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
6103 {
Jeff Johnson902c9832012-12-10 14:28:09 -08006104 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
6105 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07006106 VOS_ASSERT(0);
6107 return -ENOMEM;
6108 }
6109 // WFD IE is saved to Additional IE ; it should be accumulated to handle
6110 // WPS IE + P2P IE + WFD IE
6111 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
6112 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306113
Jeff Johnson295189b2012-06-20 16:38:30 -07006114 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
6115 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
6116 }
6117#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006118 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306119 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006120 HS20_OUI_TYPE_SIZE)) )
6121 {
6122 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306123 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006124 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006125
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006126 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
6127 {
Jeff Johnson902c9832012-12-10 14:28:09 -08006128 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
6129 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006130 VOS_ASSERT(0);
6131 return -ENOMEM;
6132 }
6133 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
6134 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006135
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006136 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
6137 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
6138 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006139 /* Appending OSEN Information Element in Assiciation Request */
6140 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
6141 OSEN_OUI_TYPE_SIZE)) )
6142 {
6143 v_U16_t curAddIELen = pWextState->assocAddIE.length;
6144 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
6145 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006146
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006147 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
6148 {
6149 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
6150 "Need bigger buffer space");
6151 VOS_ASSERT(0);
6152 return -ENOMEM;
6153 }
6154 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
6155 pWextState->assocAddIE.length += eLen + 2;
6156
6157 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
6158 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
6159 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
6160 }
6161
6162 break;
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -07006163 if (WLAN_HDD_IBSS == pAdapter->device_mode) {
6164
6165 /* populating as ADDIE in beacon frames */
6166 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
6167 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
6168 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
6169 {
6170 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
6171 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
6172 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6173 {
6174 hddLog(LOGE,
6175 "Coldn't pass "
6176 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
6177 }
6178 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
6179 else
6180 hddLog(LOGE,
6181 "Could not pass on "
6182 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
6183
6184 /* IBSS mode doesn't contain params->proberesp_ies still
6185 beaconIE's need to be populated in probe response frames */
6186 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
6187 {
6188 u16 rem_probe_resp_ie_len = eLen + 2;
6189 u8 probe_rsp_ie_len[3] = {0};
6190 u8 counter = 0;
6191
6192 /* Check Probe Resp Length if it is greater then 255 then
6193 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
6194 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
6195 not able Store More then 255 bytes into One Variable */
6196
6197 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
6198 {
6199 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
6200 {
6201 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
6202 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
6203 }
6204 else
6205 {
6206 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
6207 rem_probe_resp_ie_len = 0;
6208 }
6209 }
6210
6211 rem_probe_resp_ie_len = 0;
6212
6213 if (probe_rsp_ie_len[0] > 0)
6214 {
6215 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
6216 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
6217 (tANI_U8*)(genie - 2),
6218 probe_rsp_ie_len[0], NULL,
6219 eANI_BOOLEAN_FALSE)
6220 == eHAL_STATUS_FAILURE)
6221 {
6222 hddLog(LOGE,
6223 "Could not pass"
6224 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
6225 }
6226 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
6227 }
6228
6229 if (probe_rsp_ie_len[1] > 0)
6230 {
6231 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
6232 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
6233 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
6234 probe_rsp_ie_len[1], NULL,
6235 eANI_BOOLEAN_FALSE)
6236 == eHAL_STATUS_FAILURE)
6237 {
6238 hddLog(LOGE,
6239 "Could not pass"
6240 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
6241 }
6242 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
6243 }
6244
6245 if (probe_rsp_ie_len[2] > 0)
6246 {
6247 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
6248 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
6249 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
6250 probe_rsp_ie_len[2], NULL,
6251 eANI_BOOLEAN_FALSE)
6252 == eHAL_STATUS_FAILURE)
6253 {
6254 hddLog(LOGE,
6255 "Could not pass"
6256 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
6257 }
6258 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
6259 }
6260
6261 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
6262 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
6263 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6264 {
6265 hddLog(LOGE,
6266 "Could not pass"
6267 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
6268 }
6269 }
6270 else
6271 {
6272 // Reset WNI_CFG_PROBE_RSP Flags
6273 wlan_hdd_reset_prob_rspies(pAdapter);
6274
6275 hddLog(VOS_TRACE_LEVEL_INFO,
6276 "%s: No Probe Response IE received in set beacon",
6277 __func__);
6278 }
6279 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -07006280 break;
6281 case DOT11F_EID_RSN:
6282 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
6283 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
6284 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
6285 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
6286 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
6287 break;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006288 /* Appending Extended Capabilities with Interworking bit set in Assoc Req */
6289 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306290 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006291 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306292 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006293 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306294
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006295 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
6296 {
Jeff Johnson902c9832012-12-10 14:28:09 -08006297 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
6298 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006299 VOS_ASSERT(0);
6300 return -ENOMEM;
6301 }
6302 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
6303 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306304
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006305 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
6306 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
6307 break;
6308 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006309#ifdef FEATURE_WLAN_WAPI
6310 case WLAN_EID_WAPI:
6311 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006312 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07006313 pAdapter->wapi_info.nWapiMode);
6314 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306315 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -07006316 akmsuiteCount = WPA_GET_LE16(tmp);
6317 tmp = tmp + 1;
6318 akmlist = (int *)(tmp);
6319 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
6320 {
6321 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
6322 }
6323 else
6324 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006325 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -07006326 VOS_ASSERT(0);
6327 return -EINVAL;
6328 }
6329
6330 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
6331 {
6332 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006333 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006334 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306335 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006336 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306337 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006338 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006339 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006340 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
6341 }
6342 break;
6343#endif
6344 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306345 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006346 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07006347 /* when Unknown IE is received we should break and continue
6348 * to the next IE in the buffer instead we were returning
6349 * so changing this to break */
6350 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006351 }
6352 genie += eLen;
6353 remLen -= eLen;
6354 }
6355 EXIT();
6356 return 0;
6357}
6358
6359/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +05306360 * FUNCTION: hdd_isWPAIEPresent
6361 * Parse the received IE to find the WPA IE
6362 *
6363 */
6364static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
6365{
6366 v_U8_t eLen = 0;
6367 v_U16_t remLen = ie_len;
6368 v_U8_t elementId = 0;
6369
6370 while (remLen >= 2)
6371 {
6372 elementId = *ie++;
6373 eLen = *ie++;
6374 remLen -= 2;
6375 if (eLen > remLen)
6376 {
6377 hddLog(VOS_TRACE_LEVEL_ERROR,
6378 "%s: IE length is wrong %d", __func__, eLen);
6379 return FALSE;
6380 }
6381 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
6382 {
6383 /* OUI - 0x00 0X50 0XF2
6384 WPA Information Element - 0x01
6385 WPA version - 0x01*/
6386 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
6387 return TRUE;
6388 }
6389 ie += eLen;
6390 remLen -= eLen;
6391 }
6392 return FALSE;
6393}
6394
6395/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006396 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306397 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006398 * parameters during connect operation.
6399 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306400int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006401 struct cfg80211_connect_params *req
6402 )
6403{
6404 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306405 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006406 ENTER();
6407
6408 /*set wpa version*/
6409 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
6410
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306411 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07006412 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +05306413 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07006414 {
6415 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
6416 }
6417 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
6418 {
6419 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
6420 }
6421 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306422
6423 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006424 pWextState->wpaVersion);
6425
6426 /*set authentication type*/
6427 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
6428
6429 if (0 > status)
6430 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306431 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006432 "%s: failed to set authentication type ", __func__);
6433 return status;
6434 }
6435
6436 /*set key mgmt type*/
6437 if (req->crypto.n_akm_suites)
6438 {
6439 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
6440 if (0 > status)
6441 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306442 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -07006443 __func__);
6444 return status;
6445 }
6446 }
6447
6448 /*set pairwise cipher type*/
6449 if (req->crypto.n_ciphers_pairwise)
6450 {
6451 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
6452 req->crypto.ciphers_pairwise[0], true);
6453 if (0 > status)
6454 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306455 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006456 "%s: failed to set unicast cipher type", __func__);
6457 return status;
6458 }
6459 }
6460 else
6461 {
6462 /*Reset previous cipher suite to none*/
6463 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
6464 if (0 > status)
6465 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306466 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006467 "%s: failed to set unicast cipher type", __func__);
6468 return status;
6469 }
6470 }
6471
6472 /*set group cipher type*/
6473 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
6474 false);
6475
6476 if (0 > status)
6477 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306478 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -07006479 __func__);
6480 return status;
6481 }
6482
Chet Lanctot186b5732013-03-18 10:26:30 -07006483#ifdef WLAN_FEATURE_11W
6484 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
6485#endif
6486
Jeff Johnson295189b2012-06-20 16:38:30 -07006487 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
6488 if (req->ie_len)
6489 {
6490 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
6491 if ( 0 > status)
6492 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306493 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006494 __func__);
6495 return status;
6496 }
6497 }
6498
6499 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306500 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006501 {
6502 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
6503 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
6504 )
6505 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306506 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -07006507 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
6508 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306509 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07006510 __func__);
6511 return -EOPNOTSUPP;
6512 }
6513 else
6514 {
6515 u8 key_len = req->key_len;
6516 u8 key_idx = req->key_idx;
6517
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306518 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006519 && (CSR_MAX_NUM_KEY > key_idx)
6520 )
6521 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306522 hddLog(VOS_TRACE_LEVEL_INFO,
6523 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006524 __func__, key_idx, key_len);
6525 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306526 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07006527 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306528 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -07006529 (u8)key_len;
6530 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
6531 }
6532 }
6533 }
6534 }
6535
6536 return status;
6537}
6538
6539/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +05306540 * FUNCTION: wlan_hdd_try_disconnect
6541 * This function is used to disconnect from previous
6542 * connection
6543 */
6544static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
6545{
6546 long ret = 0;
6547 hdd_station_ctx_t *pHddStaCtx;
6548 eMib_dot11DesiredBssType connectedBssType;
6549
6550 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6551
6552 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
6553
6554 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
6555 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
6556 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
6557 {
6558 /* Issue disconnect to CSR */
6559 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6560 if( eHAL_STATUS_SUCCESS ==
6561 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
6562 pAdapter->sessionId,
6563 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
6564 {
6565 ret = wait_for_completion_interruptible_timeout(
6566 &pAdapter->disconnect_comp_var,
6567 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6568 if (0 >= ret)
6569 {
6570 hddLog(LOGE, FL("Failed to receive disconnect event"));
6571 return -EALREADY;
6572 }
6573 }
6574 }
6575 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
6576 {
6577 ret = wait_for_completion_interruptible_timeout(
6578 &pAdapter->disconnect_comp_var,
6579 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6580 if (0 >= ret)
6581 {
6582 hddLog(LOGE, FL("Failed to receive disconnect event"));
6583 return -EALREADY;
6584 }
6585 }
6586
6587 return 0;
6588}
6589
6590/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05306591 * FUNCTION: __wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306592 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006593 * parameters during connect operation.
6594 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05306595static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006596 struct net_device *ndev,
6597 struct cfg80211_connect_params *req
6598 )
6599{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306600 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306601 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006602 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -08006603 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006604
6605 ENTER();
6606
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306607 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6608 TRACE_CODE_HDD_CFG80211_CONNECT,
6609 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306610 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306611 "%s: device_mode = %s (%d)", __func__,
6612 hdd_device_modetoString(pAdapter->device_mode),
6613 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006614
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306615 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08006616 if (!pHddCtx)
6617 {
6618 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6619 "%s: HDD context is null", __func__);
6620 return VOS_STATUS_E_FAILURE;
6621 }
6622
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306623 status = wlan_hdd_validate_context(pHddCtx);
6624
6625 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006626 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306627 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6628 "%s: HDD context is not valid", __func__);
6629 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006630 }
6631
6632#ifdef WLAN_BTAMP_FEATURE
6633 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306634 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -07006635 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306636 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006637 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08006638 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -07006639 }
6640#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +05306641
6642 //If Device Mode is Station Concurrent Sessions Exit BMps
6643 //P2P Mode will be taken care in Open/close adapter
6644 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
6645 (vos_concurrent_sessions_running()))
6646 {
6647 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
6648 }
6649
6650 /*Try disconnecting if already in connected state*/
6651 status = wlan_hdd_try_disconnect(pAdapter);
6652 if ( 0 > status)
6653 {
6654 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
6655 " connection"));
6656 return -EALREADY;
6657 }
6658
Jeff Johnson295189b2012-06-20 16:38:30 -07006659 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306660 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -07006661
6662 if ( 0 > status)
6663 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306664 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -07006665 __func__);
6666 return status;
6667 }
6668
Mohit Khanna765234a2012-09-11 15:08:35 -07006669 if ( req->channel )
6670 {
6671 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
6672 req->ssid_len, req->bssid,
6673 req->channel->hw_value);
6674 }
6675 else
6676 {
6677 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306678 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -07006679 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006680
6681 if (0 > status)
6682 {
6683 //ReEnable BMPS if disabled
6684 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
6685 (NULL != pHddCtx))
6686 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306687 if (pHddCtx->hdd_wlan_suspended)
6688 {
6689 hdd_set_pwrparams(pHddCtx);
6690 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006691 //ReEnable Bmps and Imps back
6692 hdd_enable_bmps_imps(pHddCtx);
6693 }
6694
6695 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6696 return status;
6697 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306698 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006699 EXIT();
6700 return status;
6701}
6702
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05306703static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
6704 struct net_device *ndev,
6705 struct cfg80211_connect_params *req)
6706{
6707 int ret;
6708 vos_ssr_protect(__func__);
6709 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
6710 vos_ssr_unprotect(__func__);
6711
6712 return ret;
6713}
Jeff Johnson295189b2012-06-20 16:38:30 -07006714
6715/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306716 * FUNCTION: wlan_hdd_disconnect
6717 * This function is used to issue a disconnect request to SME
6718 */
6719int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
6720{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306721 int status;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306722 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306723 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6724
6725 status = wlan_hdd_validate_context(pHddCtx);
6726
6727 if (0 != status)
6728 {
6729 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6730 "%s: HDD context is not valid", __func__);
6731 return status;
6732 }
6733
6734 pHddCtx->isAmpAllowed = VOS_TRUE;
Abhishek Singhf4669da2014-05-26 15:07:49 +05306735 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6736 "%s: Set HDD connState to eConnectionState_Disconnecting",
6737 __func__);
Vinay Krishna Erannab09d3e72014-03-26 21:23:55 +05306738 pHddStaCtx->conn_info.connState = eConnectionState_Disconnecting;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306739 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306740
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306741 /*issue disconnect*/
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05306742
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306743 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
6744 pAdapter->sessionId, reason);
6745
6746 if ( 0 != status )
6747 {
6748 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006749 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306750 __func__, (int)status );
6751 return -EINVAL;
6752 }
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05306753 status = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306754 &pAdapter->disconnect_comp_var,
6755 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05306756 if (!status)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306757 {
6758 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05306759 "%s: Failed to disconnect, timed out", __func__);
6760 return -ETIMEDOUT;
6761 }
6762 else if (status == -ERESTARTSYS)
6763 {
6764 hddLog(VOS_TRACE_LEVEL_ERROR,
6765 "%s: Failed to disconnect, wait interrupted", __func__);
6766 return status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306767 }
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306768 /*stop tx queues*/
6769 netif_tx_disable(pAdapter->dev);
6770 netif_carrier_off(pAdapter->dev);
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05306771 return 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306772}
6773
6774
6775/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05306776 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -07006777 * This function is used to issue a disconnect request to SME
6778 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05306779static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006780 struct net_device *dev,
6781 u16 reason
6782 )
6783{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306784 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6785 tCsrRoamProfile *pRoamProfile =
Jeff Johnson295189b2012-06-20 16:38:30 -07006786 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306787 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006788 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006789 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306790#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006791 tANI_U8 staIdx;
6792#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306793
Jeff Johnson295189b2012-06-20 16:38:30 -07006794 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306795
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306796 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6797 TRACE_CODE_HDD_CFG80211_DISCONNECT,
6798 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306799 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
6800 __func__, hdd_device_modetoString(pAdapter->device_mode),
6801 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006802
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306803 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
6804 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006805
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306806 status = wlan_hdd_validate_context(pHddCtx);
6807
6808 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006809 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306810 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6811 "%s: HDD context is not valid", __func__);
6812 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006813 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306814
Jeff Johnson295189b2012-06-20 16:38:30 -07006815 if (NULL != pRoamProfile)
6816 {
6817 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +05306818 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
6819 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -07006820 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306821 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07006822 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306823 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07006824 switch(reason)
6825 {
6826 case WLAN_REASON_MIC_FAILURE:
6827 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
6828 break;
6829
6830 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
6831 case WLAN_REASON_DISASSOC_AP_BUSY:
6832 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
6833 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
6834 break;
6835
6836 case WLAN_REASON_PREV_AUTH_NOT_VALID:
6837 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +05306838 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -07006839 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
6840 break;
6841
Jeff Johnson295189b2012-06-20 16:38:30 -07006842 default:
6843 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
6844 break;
6845 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306846 pScanInfo = &pHddCtx->scan_info;
6847 if (pScanInfo->mScanPending)
6848 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306849 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306850 "Aborting Scan");
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306851 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
6852 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306853 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006854
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006855#ifdef FEATURE_WLAN_TDLS
6856 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006857 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006858 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006859 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
6860 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006861 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006862 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006863 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006864 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006865 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006866 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006867 MAC_ADDR_ARRAY(mac));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006868 sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006869 pAdapter->sessionId,
6870 mac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006871 }
6872 }
6873#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05306874 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306875 status = wlan_hdd_disconnect(pAdapter, reasonCode);
6876 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -07006877 {
6878 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006879 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006880 __func__, (int)status );
6881 return -EINVAL;
6882 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006883 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +05306884 else
6885 {
6886 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
6887 "called while in %d state", __func__,
6888 pHddStaCtx->conn_info.connState);
6889 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006890 }
6891 else
6892 {
6893 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
6894 }
6895
6896 return status;
6897}
6898
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05306899static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
6900 struct net_device *dev,
6901 u16 reason
6902 )
6903{
6904 int ret;
6905 vos_ssr_protect(__func__);
6906 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
6907 vos_ssr_unprotect(__func__);
6908
6909 return ret;
6910}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306911
Jeff Johnson295189b2012-06-20 16:38:30 -07006912/*
6913 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306914 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006915 * settings in IBSS mode.
6916 */
6917static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306918 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006919 struct cfg80211_ibss_params *params
6920 )
6921{
6922 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306923 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006924 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6925 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306926
Jeff Johnson295189b2012-06-20 16:38:30 -07006927 ENTER();
6928
6929 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -07006930 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006931
6932 if (params->ie_len && ( NULL != params->ie) )
6933 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006934 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6935 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006936 {
6937 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
6938 encryptionType = eCSR_ENCRYPT_TYPE_AES;
6939 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006940 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006941 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006942 tDot11fIEWPA dot11WPAIE;
6943 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006944 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006945
Wilson Yang00256342013-10-10 23:13:38 -07006946 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006947 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6948 params->ie_len, DOT11F_EID_WPA);
6949 if ( NULL != ie )
6950 {
6951 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
6952 // Unpack the WPA IE
6953 //Skip past the EID byte and length byte - and four byte WiFi OUI
6954 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
6955 &ie[2+4],
6956 ie[1] - 4,
6957 &dot11WPAIE);
6958 /*Extract the multicast cipher, the encType for unicast
6959 cipher for wpa-none is none*/
6960 encryptionType =
6961 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
6962 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006963 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006964
Jeff Johnson295189b2012-06-20 16:38:30 -07006965 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
6966
6967 if (0 > status)
6968 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306969 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006970 __func__);
6971 return status;
6972 }
6973 }
6974
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306975 pWextState->roamProfile.AuthType.authType[0] =
6976 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -07006977 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6978
6979 if (params->privacy)
6980 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306981 /* Security enabled IBSS, At this time there is no information available
6982 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -07006983 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306984 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -07006985 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306986 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -07006987 *enable privacy bit in beacons */
6988
6989 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6990 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006991 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
6992 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07006993 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
6994 pWextState->roamProfile.EncryptionType.numEntries = 1;
6995 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07006996 return status;
6997}
6998
6999/*
7000 * FUNCTION: wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307001 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07007002 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307003static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007004 struct net_device *dev,
7005 struct cfg80211_ibss_params *params
7006 )
7007{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307008 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07007009 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7010 tCsrRoamProfile *pRoamProfile;
7011 int status;
krunal sonie9002db2013-11-25 14:24:17 -08007012 bool alloc_bssid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007013 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307014 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007015
7016 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307017
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307018 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7019 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
7020 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307021 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307022 "%s: device_mode = %s (%d)", __func__,
7023 hdd_device_modetoString(pAdapter->device_mode),
7024 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007025
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307026 status = wlan_hdd_validate_context(pHddCtx);
7027
7028 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007029 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307030 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7031 "%s: HDD context is not valid", __func__);
7032 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007033 }
7034
7035 if (NULL == pWextState)
7036 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007037 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -07007038 __func__);
7039 return -EIO;
7040 }
7041
Vinay Krishna Eranna21042322014-01-08 19:21:39 +05307042 /*Try disconnecting if already in connected state*/
7043 status = wlan_hdd_try_disconnect(pAdapter);
7044 if ( 0 > status)
7045 {
7046 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
7047 " IBSS connection"));
7048 return -EALREADY;
7049 }
7050
Jeff Johnson295189b2012-06-20 16:38:30 -07007051 pRoamProfile = &pWextState->roamProfile;
7052
7053 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
7054 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307055 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007056 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007057 return -EINVAL;
7058 }
7059
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -07007060 /* BSSID is provided by upper layers hence no need to AUTO generate */
7061 if (NULL != params->bssid) {
7062 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
7063 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
7064 hddLog (VOS_TRACE_LEVEL_ERROR,
7065 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
7066 return -EIO;
7067 }
7068 }
krunal sonie9002db2013-11-25 14:24:17 -08007069 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
7070 {
7071 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
7072 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
7073 {
7074 hddLog (VOS_TRACE_LEVEL_ERROR,
7075 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
7076 return -EIO;
7077 }
7078 params->bssid = vos_mem_malloc(sizeof(VOS_MAC_ADDR_SIZE));
7079 if (!params->bssid)
7080 {
7081 hddLog (VOS_TRACE_LEVEL_ERROR,
7082 "%s:Failed memory allocation", __func__);
7083 return -EIO;
7084 }
7085 vos_mem_copy((v_U8_t *)params->bssid,
7086 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
7087 VOS_MAC_ADDR_SIZE);
7088 alloc_bssid = VOS_TRUE;
7089 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -07007090
Jeff Johnson295189b2012-06-20 16:38:30 -07007091 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -07007092 if (NULL !=
7093#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
7094 params->chandef.chan)
7095#else
7096 params->channel)
7097#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007098 {
7099 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07007100 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
7101 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7102 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7103 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007104
7105 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307106 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -07007107 ieee80211_frequency_to_channel(
7108#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
7109 params->chandef.chan->center_freq);
7110#else
7111 params->channel->center_freq);
7112#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07007113
7114 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
7115 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -07007116 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07007117 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
7118 __func__);
7119 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -07007120 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07007121
7122 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -07007123 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07007124 if (channelNum == validChan[indx])
7125 {
7126 break;
7127 }
7128 }
7129 if (indx >= numChans)
7130 {
7131 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007132 __func__, channelNum);
7133 return -EINVAL;
7134 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07007135 /* Set the Operational Channel */
7136 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
7137 channelNum);
7138 pRoamProfile->ChannelInfo.numOfChannels = 1;
7139 pHddStaCtx->conn_info.operationChannel = channelNum;
7140 pRoamProfile->ChannelInfo.ChannelList =
7141 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07007142 }
7143
7144 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307145 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -07007146 if (status < 0)
7147 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307148 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -07007149 __func__);
7150 return status;
7151 }
7152
7153 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307154 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07007155 params->ssid_len, params->bssid,
7156 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07007157
7158 if (0 > status)
7159 {
7160 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
7161 return status;
7162 }
7163
krunal sonie9002db2013-11-25 14:24:17 -08007164 if (NULL != params->bssid &&
7165 pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 &&
7166 alloc_bssid == VOS_TRUE)
7167 {
7168 vos_mem_free(params->bssid);
7169 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007170 return 0;
7171}
7172
7173/*
7174 * FUNCTION: wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307175 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07007176 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307177static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007178 struct net_device *dev
7179 )
7180{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307181 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07007182 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7183 tCsrRoamProfile *pRoamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307184 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7185 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007186
7187 ENTER();
7188
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307189 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7190 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
7191 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307192 status = wlan_hdd_validate_context(pHddCtx);
7193
7194 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007195 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307196 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7197 "%s: HDD context is not valid", __func__);
7198 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007199 }
7200
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307201 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
7202 hdd_device_modetoString(pAdapter->device_mode),
7203 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007204 if (NULL == pWextState)
7205 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007206 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -07007207 __func__);
7208 return -EIO;
7209 }
7210
7211 pRoamProfile = &pWextState->roamProfile;
7212
7213 /* Issue disconnect only if interface type is set to IBSS */
7214 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
7215 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307216 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -07007217 __func__);
7218 return -EINVAL;
7219 }
7220
7221 /* Issue Disconnect request */
7222 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7223 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
7224 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
7225
7226 return 0;
7227}
7228
7229/*
7230 * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params
7231 * This function is used to set the phy parameters
7232 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
7233 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307234static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007235 u32 changed)
7236{
7237 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7238 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307239 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007240
7241 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307242 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7243 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
7244 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307245 status = wlan_hdd_validate_context(pHddCtx);
7246
7247 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007248 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307249 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7250 "%s: HDD context is not valid", __func__);
7251 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007252 }
7253
Jeff Johnson295189b2012-06-20 16:38:30 -07007254 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
7255 {
7256 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
7257 WNI_CFG_RTS_THRESHOLD_STAMAX :
7258 wiphy->rts_threshold;
7259
7260 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307261 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -07007262 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307263 hddLog(VOS_TRACE_LEVEL_ERROR,
7264 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007265 __func__, rts_threshold);
7266 return -EINVAL;
7267 }
7268
7269 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
7270 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307271 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07007272 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307273 hddLog(VOS_TRACE_LEVEL_ERROR,
7274 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007275 __func__, rts_threshold);
7276 return -EIO;
7277 }
7278
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307279 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007280 rts_threshold);
7281 }
7282
7283 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
7284 {
7285 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
7286 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
7287 wiphy->frag_threshold;
7288
7289 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307290 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007291 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307292 hddLog(VOS_TRACE_LEVEL_ERROR,
7293 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007294 frag_threshold);
7295 return -EINVAL;
7296 }
7297
7298 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
7299 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307300 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07007301 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307302 hddLog(VOS_TRACE_LEVEL_ERROR,
7303 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007304 __func__, frag_threshold);
7305 return -EIO;
7306 }
7307
7308 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
7309 frag_threshold);
7310 }
7311
7312 if ((changed & WIPHY_PARAM_RETRY_SHORT)
7313 || (changed & WIPHY_PARAM_RETRY_LONG))
7314 {
7315 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
7316 wiphy->retry_short :
7317 wiphy->retry_long;
7318
7319 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
7320 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
7321 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307322 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007323 __func__, retry_value);
7324 return -EINVAL;
7325 }
7326
7327 if (changed & WIPHY_PARAM_RETRY_SHORT)
7328 {
7329 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
7330 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307331 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07007332 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307333 hddLog(VOS_TRACE_LEVEL_ERROR,
7334 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007335 __func__, retry_value);
7336 return -EIO;
7337 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307338 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007339 __func__, retry_value);
7340 }
7341 else if (changed & WIPHY_PARAM_RETRY_SHORT)
7342 {
7343 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
7344 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307345 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07007346 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307347 hddLog(VOS_TRACE_LEVEL_ERROR,
7348 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007349 __func__, retry_value);
7350 return -EIO;
7351 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307352 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007353 __func__, retry_value);
7354 }
7355 }
7356
7357 return 0;
7358}
7359
7360/*
7361 * FUNCTION: wlan_hdd_cfg80211_set_txpower
7362 * This function is used to set the txpower
7363 */
7364static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07007365#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
7366 struct wireless_dev *wdev,
7367#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007368#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307369 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07007370#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307371 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07007372#endif
7373 int dbm)
7374{
7375 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307376 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007377 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
7378 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307379 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007380
7381 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307382 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7383 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
7384 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307385 status = wlan_hdd_validate_context(pHddCtx);
7386
7387 if (0 != status)
7388 {
7389 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7390 "%s: HDD context is not valid", __func__);
7391 return status;
7392 }
7393
7394 hHal = pHddCtx->hHal;
7395
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307396 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
7397 dbm, ccmCfgSetCallback,
7398 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07007399 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307400 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007401 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
7402 return -EIO;
7403 }
7404
7405 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
7406 dbm);
7407
7408 switch(type)
7409 {
7410 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
7411 /* Fall through */
7412 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
7413 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
7414 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307415 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
7416 __func__);
7417 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07007418 }
7419 break;
7420 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307421 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07007422 __func__);
7423 return -EOPNOTSUPP;
7424 break;
7425 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307426 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
7427 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -07007428 return -EIO;
7429 }
7430
7431 return 0;
7432}
7433
7434/*
7435 * FUNCTION: wlan_hdd_cfg80211_get_txpower
7436 * This function is used to read the txpower
7437 */
Yue Maf49ba872013-08-19 12:04:25 -07007438static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
7439#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
7440 struct wireless_dev *wdev,
7441#endif
7442 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -07007443{
7444
7445 hdd_adapter_t *pAdapter;
7446 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307447 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007448
Jeff Johnsone7245742012-09-05 17:12:55 -07007449 ENTER();
7450
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307451 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007452
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307453 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007454 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307455 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7456 "%s: HDD context is not valid", __func__);
7457 *dbm = 0;
7458 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007459 }
7460
Jeff Johnson295189b2012-06-20 16:38:30 -07007461 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
7462 if (NULL == pAdapter)
7463 {
7464 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
7465 return -ENOENT;
7466 }
7467
7468 wlan_hdd_get_classAstats(pAdapter);
7469 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
7470
Jeff Johnsone7245742012-09-05 17:12:55 -07007471 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007472 return 0;
7473}
7474
7475static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
7476 u8* mac, struct station_info *sinfo)
7477{
7478 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
7479 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7480 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +05307481 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -07007482
7483 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
7484 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07007485
7486 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
7487 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
7488 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
7489 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
7490 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
7491 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
7492 tANI_U16 maxRate = 0;
7493 tANI_U16 myRate;
7494 tANI_U16 currentRate = 0;
7495 tANI_U8 maxSpeedMCS = 0;
7496 tANI_U8 maxMCSIdx = 0;
7497 tANI_U8 rateFlag = 1;
7498 tANI_U8 i, j, rssidx;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07007499 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307500 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007501
Leo Chang6f8870f2013-03-26 18:11:36 -07007502#ifdef WLAN_FEATURE_11AC
7503 tANI_U32 vht_mcs_map;
7504 eDataRate11ACMaxMcs vhtMaxMcs;
7505#endif /* WLAN_FEATURE_11AC */
7506
Jeff Johnsone7245742012-09-05 17:12:55 -07007507 ENTER();
7508
Jeff Johnson295189b2012-06-20 16:38:30 -07007509 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
7510 (0 == ssidlen))
7511 {
7512 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
7513 " Invalid ssidlen, %d", __func__, ssidlen);
7514 /*To keep GUI happy*/
7515 return 0;
7516 }
7517
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307518 status = wlan_hdd_validate_context(pHddCtx);
7519
7520 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007521 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307522 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7523 "%s: HDD context is not valid", __func__);
7524 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007525 }
7526
Jeff Johnson295189b2012-06-20 16:38:30 -07007527
Kiet Lam3b17fc82013-09-27 05:24:08 +05307528 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
7529 sinfo->filled |= STATION_INFO_SIGNAL;
7530
c_hpothu44ff4e02014-05-08 00:13:57 +05307531 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
7532 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
7533 sinfo->signal >= pCfg->linkSpeedRssiHigh))
7534 {
7535 rate_flags = pAdapter->maxRateFlags;
7536 }
7537 else
7538 {
7539 wlan_hdd_get_station_stats(pAdapter);
7540 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
7541 }
7542
Jeff Johnson295189b2012-06-20 16:38:30 -07007543 //convert to the UI units of 100kbps
7544 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
7545
7546#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -07007547 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 -07007548 sinfo->signal,
7549 pCfg->reportMaxLinkSpeed,
7550 myRate,
7551 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007552 (int) pCfg->linkSpeedRssiMid,
7553 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -07007554 (int) rate_flags,
7555 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07007556#endif //LINKSPEED_DEBUG_ENABLED
7557
7558 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
7559 {
7560 // we do not want to necessarily report the current speed
7561 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
7562 {
7563 // report the max possible speed
7564 rssidx = 0;
7565 }
7566 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
7567 {
7568 // report the max possible speed with RSSI scaling
7569 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
7570 {
7571 // report the max possible speed
7572 rssidx = 0;
7573 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007574 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -07007575 {
7576 // report middle speed
7577 rssidx = 1;
7578 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007579 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
7580 {
7581 // report middle speed
7582 rssidx = 2;
7583 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007584 else
7585 {
7586 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007587 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07007588 }
7589 }
7590 else
7591 {
7592 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
7593 hddLog(VOS_TRACE_LEVEL_ERROR,
7594 "%s: Invalid value for reportMaxLinkSpeed: %u",
7595 __func__, pCfg->reportMaxLinkSpeed);
7596 rssidx = 0;
7597 }
7598
7599 maxRate = 0;
7600
7601 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05307602 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
7603 OperationalRates, &ORLeng))
7604 {
7605 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
7606 /*To keep GUI happy*/
7607 return 0;
7608 }
7609
Jeff Johnson295189b2012-06-20 16:38:30 -07007610 for (i = 0; i < ORLeng; i++)
7611 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007612 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07007613 {
7614 /* Validate Rate Set */
7615 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
7616 {
7617 currentRate = supported_data_rate[j].supported_rate[rssidx];
7618 break;
7619 }
7620 }
7621 /* Update MAX rate */
7622 maxRate = (currentRate > maxRate)?currentRate:maxRate;
7623 }
7624
7625 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05307626 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
7627 ExtendedRates, &ERLeng))
7628 {
7629 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
7630 /*To keep GUI happy*/
7631 return 0;
7632 }
7633
Jeff Johnson295189b2012-06-20 16:38:30 -07007634 for (i = 0; i < ERLeng; i++)
7635 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007636 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07007637 {
7638 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
7639 {
7640 currentRate = supported_data_rate[j].supported_rate[rssidx];
7641 break;
7642 }
7643 }
7644 /* Update MAX rate */
7645 maxRate = (currentRate > maxRate)?currentRate:maxRate;
7646 }
Kiet Lamb69f8dc2013-11-15 15:34:27 +05307647 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +05307648 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +05307649 if we have good rssi */
Kaushik, Sushantdc304d82014-01-22 10:58:37 +05307650 if ((0 == rssidx) ||
Kiet Lamb69f8dc2013-11-15 15:34:27 +05307651 (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed))
Jeff Johnson295189b2012-06-20 16:38:30 -07007652 {
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05307653 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
7654 MCSRates, &MCSLeng))
7655 {
7656 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
7657 /*To keep GUI happy*/
7658 return 0;
7659 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007660 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -07007661#ifdef WLAN_FEATURE_11AC
7662 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307663 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -07007664 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007665 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307666 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -07007667 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -07007668 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007669 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007670 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007671 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -07007672 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007673 maxMCSIdx = 7;
7674 }
7675 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
7676 {
7677 maxMCSIdx = 8;
7678 }
7679 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
7680 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307681 //VHT20 is supporting 0~8
7682 if (rate_flags & eHAL_TX_RATE_VHT20)
7683 maxMCSIdx = 8;
7684 else
7685 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -07007686 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307687
7688 if (rate_flags & eHAL_TX_RATE_VHT80)
7689 {
7690 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
7691 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
7692 }
7693 else if (rate_flags & eHAL_TX_RATE_VHT40)
7694 {
7695 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
7696 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
7697 }
7698 else if (rate_flags & eHAL_TX_RATE_VHT20)
7699 {
7700 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
7701 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
7702 }
7703
Leo Chang6f8870f2013-03-26 18:11:36 -07007704 maxSpeedMCS = 1;
7705 if (currentRate > maxRate)
7706 {
7707 maxRate = currentRate;
7708 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307709
Leo Chang6f8870f2013-03-26 18:11:36 -07007710 }
7711 else
7712#endif /* WLAN_FEATURE_11AC */
7713 {
7714 if (rate_flags & eHAL_TX_RATE_HT40)
7715 {
7716 rateFlag |= 1;
7717 }
7718 if (rate_flags & eHAL_TX_RATE_SGI)
7719 {
7720 rateFlag |= 2;
7721 }
7722
7723 for (i = 0; i < MCSLeng; i++)
7724 {
7725 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
7726 for (j = 0; j < temp; j++)
7727 {
7728 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
7729 {
7730 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
7731 break;
7732 }
7733 }
7734 if ((j < temp) && (currentRate > maxRate))
7735 {
7736 maxRate = currentRate;
7737 maxSpeedMCS = 1;
7738 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
7739 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007740 }
7741 }
7742 }
7743
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307744 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
7745 {
7746 maxRate = myRate;
7747 maxSpeedMCS = 1;
7748 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
7749 }
7750
Jeff Johnson295189b2012-06-20 16:38:30 -07007751 // make sure we report a value at least as big as our current rate
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007752 if (((maxRate < myRate) && (0 == rssidx)) ||
7753 (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -07007754 {
7755 maxRate = myRate;
7756 if (rate_flags & eHAL_TX_RATE_LEGACY)
7757 {
7758 maxSpeedMCS = 0;
7759 }
7760 else
7761 {
7762 maxSpeedMCS = 1;
7763 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
7764 }
7765 }
7766
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307767 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -07007768 {
7769 sinfo->txrate.legacy = maxRate;
7770#ifdef LINKSPEED_DEBUG_ENABLED
7771 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
7772#endif //LINKSPEED_DEBUG_ENABLED
7773 }
7774 else
7775 {
7776 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -07007777#ifdef WLAN_FEATURE_11AC
7778 sinfo->txrate.nss = 1;
7779 if (rate_flags & eHAL_TX_RATE_VHT80)
7780 {
7781 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307782 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -07007783 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307784 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -07007785 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307786 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7787 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7788 }
7789 else if (rate_flags & eHAL_TX_RATE_VHT20)
7790 {
7791 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7792 }
7793#endif /* WLAN_FEATURE_11AC */
7794 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
7795 {
7796 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7797 if (rate_flags & eHAL_TX_RATE_HT40)
7798 {
7799 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7800 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007801 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007802 if (rate_flags & eHAL_TX_RATE_SGI)
7803 {
7804 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7805 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307806
Jeff Johnson295189b2012-06-20 16:38:30 -07007807#ifdef LINKSPEED_DEBUG_ENABLED
7808 pr_info("Reporting MCS rate %d flags %x\n",
7809 sinfo->txrate.mcs,
7810 sinfo->txrate.flags );
7811#endif //LINKSPEED_DEBUG_ENABLED
7812 }
7813 }
7814 else
7815 {
7816 // report current rate instead of max rate
7817
7818 if (rate_flags & eHAL_TX_RATE_LEGACY)
7819 {
7820 //provide to the UI in units of 100kbps
7821 sinfo->txrate.legacy = myRate;
7822#ifdef LINKSPEED_DEBUG_ENABLED
7823 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
7824#endif //LINKSPEED_DEBUG_ENABLED
7825 }
7826 else
7827 {
7828 //must be MCS
7829 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -07007830#ifdef WLAN_FEATURE_11AC
7831 sinfo->txrate.nss = 1;
7832 if (rate_flags & eHAL_TX_RATE_VHT80)
7833 {
7834 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7835 }
7836 else
7837#endif /* WLAN_FEATURE_11AC */
7838 {
7839 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7840 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007841 if (rate_flags & eHAL_TX_RATE_SGI)
7842 {
7843 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7844 }
7845 if (rate_flags & eHAL_TX_RATE_HT40)
7846 {
7847 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7848 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007849#ifdef WLAN_FEATURE_11AC
7850 else if (rate_flags & eHAL_TX_RATE_VHT80)
7851 {
7852 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
7853 }
7854#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -07007855#ifdef LINKSPEED_DEBUG_ENABLED
7856 pr_info("Reporting actual MCS rate %d flags %x\n",
7857 sinfo->txrate.mcs,
7858 sinfo->txrate.flags );
7859#endif //LINKSPEED_DEBUG_ENABLED
7860 }
7861 }
7862 sinfo->filled |= STATION_INFO_TX_BITRATE;
7863
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07007864 sinfo->tx_packets =
7865 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
7866 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
7867 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
7868 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
7869
7870 sinfo->tx_retries =
7871 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
7872 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
7873 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
7874 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
7875
7876 sinfo->tx_failed =
7877 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
7878 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
7879 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
7880 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
7881
7882 sinfo->filled |=
7883 STATION_INFO_TX_PACKETS |
7884 STATION_INFO_TX_RETRIES |
7885 STATION_INFO_TX_FAILED;
7886
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307887 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7888 TRACE_CODE_HDD_CFG80211_GET_STA,
7889 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07007890 EXIT();
7891 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007892}
7893
7894static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -07007895 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -07007896{
7897 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307898 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007899 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307900 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007901
Jeff Johnsone7245742012-09-05 17:12:55 -07007902 ENTER();
7903
Jeff Johnson295189b2012-06-20 16:38:30 -07007904 if (NULL == pAdapter)
7905 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007906 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007907 return -ENODEV;
7908 }
7909
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307910 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7911 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
7912 pAdapter->sessionId, timeout));
7913
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307914 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307915 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307916
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307917 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307918 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307919 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7920 "%s: HDD context is not valid", __func__);
7921 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307922 }
7923
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307924 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
7925 (TRUE == pHddCtx->hdd_wlan_suspended) &&
7926 (pHddCtx->cfg_ini->fhostArpOffload) &&
7927 (eConnectionState_Associated ==
7928 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
7929 {
Amar Singhald53568e2013-09-26 11:03:45 -07007930
7931 hddLog(VOS_TRACE_LEVEL_INFO,
7932 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307933 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307934 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7935 {
7936 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007937 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307938 __func__, vos_status);
7939 }
7940 }
7941
Jeff Johnson295189b2012-06-20 16:38:30 -07007942 /**The get power cmd from the supplicant gets updated by the nl only
7943 *on successful execution of the function call
7944 *we are oppositely mapped w.r.t mode in the driver
7945 **/
7946 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
7947
Jeff Johnsone7245742012-09-05 17:12:55 -07007948 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007949 if (VOS_STATUS_E_FAILURE == vos_status)
7950 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307951 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7952 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007953 return -EINVAL;
7954 }
7955 return 0;
7956}
7957
7958
7959#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7960static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
7961 struct net_device *netdev,
7962 u8 key_index)
7963{
Jeff Johnsone7245742012-09-05 17:12:55 -07007964 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007965 return 0;
7966}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307967#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -07007968
7969#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7970static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7971 struct net_device *dev,
7972 struct ieee80211_txq_params *params)
7973{
Jeff Johnsone7245742012-09-05 17:12:55 -07007974 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007975 return 0;
7976}
7977#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7978static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7979 struct ieee80211_txq_params *params)
7980{
Jeff Johnsone7245742012-09-05 17:12:55 -07007981 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007982 return 0;
7983}
7984#endif //LINUX_VERSION_CODE
7985
7986static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
7987 struct net_device *dev, u8 *mac)
7988{
7989 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307990 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007991 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307992 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007993 v_U8_t staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007994
Jeff Johnsone7245742012-09-05 17:12:55 -07007995 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307996
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307997 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -07007998 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307999 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008000 return -EINVAL;
8001 }
8002
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308003 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8004 TRACE_CODE_HDD_CFG80211_DEL_STA,
8005 pAdapter->sessionId, pAdapter->device_mode));
8006
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308007 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8008 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07008009
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308010 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008011 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308012 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8013 "%s: HDD context is not valid", __func__);
8014 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008015 }
8016
Jeff Johnson295189b2012-06-20 16:38:30 -07008017 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07008018 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07008019 )
8020 {
8021 if( NULL == mac )
8022 {
8023 v_U16_t i;
8024 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
8025 {
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07008026 if ((pAdapter->aStaInfo[i].isUsed) &&
8027 (!pAdapter->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -07008028 {
8029 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
8030 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08008031 "%s: Delete STA with MAC::"
8032 MAC_ADDRESS_STR,
8033 __func__, MAC_ADDR_ARRAY(macAddr));
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07008034 vos_status = hdd_softap_sta_deauth(pAdapter, macAddr);
8035 if (VOS_IS_STATUS_SUCCESS(vos_status))
8036 pAdapter->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008037 }
8038 }
8039 }
8040 else
8041 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008042
8043 vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId);
8044 if (!VOS_IS_STATUS_SUCCESS(vos_status))
8045 {
8046 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08008047 "%s: Skip this DEL STA as this is not used::"
8048 MAC_ADDRESS_STR,
8049 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008050 return -ENOENT;
8051 }
8052
8053 if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE)
8054 {
8055 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08008056 "%s: Skip this DEL STA as deauth is in progress::"
8057 MAC_ADDRESS_STR,
8058 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008059 return -ENOENT;
8060 }
8061
8062 pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE;
8063
Jeff Johnson295189b2012-06-20 16:38:30 -07008064 hddLog(VOS_TRACE_LEVEL_INFO,
8065 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -08008066 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -07008067 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -08008068 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008069
8070 vos_status = hdd_softap_sta_deauth(pAdapter, mac);
8071 if (!VOS_IS_STATUS_SUCCESS(vos_status))
8072 {
8073 pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE;
8074 hddLog(VOS_TRACE_LEVEL_INFO,
8075 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -08008076 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008077 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -08008078 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008079 return -ENOENT;
8080 }
8081
Jeff Johnson295189b2012-06-20 16:38:30 -07008082 }
8083 }
8084
8085 EXIT();
8086
8087 return 0;
8088}
8089
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008090static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
8091 struct net_device *dev, u8 *mac, struct station_parameters *params)
8092{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308093 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008094 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008095#ifdef FEATURE_WLAN_TDLS
8096 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008097 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308098
8099 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8100 TRACE_CODE_HDD_CFG80211_ADD_STA,
8101 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008102 mask = params->sta_flags_mask;
8103
8104 set = params->sta_flags_set;
8105
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008106#ifdef WLAN_FEATURE_TDLS_DEBUG
8107 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8108 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
8109 __func__, mask, set, MAC_ADDR_ARRAY(mac));
8110#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008111
8112 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
8113 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008114 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008115 }
8116 }
8117#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008118 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008119}
8120
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008121
8122#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -07008123
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008124static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07008125 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008126{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308127 tANI_U32 j=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008128 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Agarwal Ashish3da95242014-05-21 14:57:17 +05308129 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008130 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308131 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308132 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008133 tANI_U8 BSSIDMatched = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308134 hdd_context_t *pHddCtx;
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008135 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
8136 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07008137
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308138 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308139 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008140 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308141 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008142 return -EINVAL;
8143 }
8144
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308145 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8146 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008147
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308148 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008149 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308150 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8151 "%s: HDD context is not valid", __func__);
8152 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008153 }
8154
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308155 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008156 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Agarwal Ashish3da95242014-05-21 14:57:17 +05308157 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008158
Agarwal Ashish3da95242014-05-21 14:57:17 +05308159 for (j = 0; j < pHddStaCtx->PMKIDCacheIndex; j++)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008160 {
Agarwal Ashish3da95242014-05-21 14:57:17 +05308161 if (vos_mem_compare(pHddStaCtx->PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008162 pmksa->bssid, WNI_CFG_BSSID_LEN))
8163 {
8164 /* BSSID matched previous entry. Overwrite it. */
8165 BSSIDMatched = 1;
Agarwal Ashish3da95242014-05-21 14:57:17 +05308166 vos_mem_copy(pHddStaCtx->PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008167 pmksa->bssid, WNI_CFG_BSSID_LEN);
Agarwal Ashish3da95242014-05-21 14:57:17 +05308168 vos_mem_copy(pHddStaCtx->PMKIDCache[j].PMKID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308169 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008170 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308171 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008172 __func__, j );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008173 dump_bssid(pmksa->bssid);
8174 dump_pmkid(halHandle, pmksa->pmkid);
8175 break;
8176 }
8177 }
8178
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07008179 /* Check we compared all entries,if then take the first slot now */
Agarwal Ashish3da95242014-05-21 14:57:17 +05308180 if (j == MAX_PMKSAIDS_IN_CACHE) pHddStaCtx->PMKIDCacheIndex=0;
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07008181
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008182 if (!BSSIDMatched)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308183 {
8184 // Now, we DON'T have a BSSID match, so take a new entry in the cache.
Agarwal Ashish3da95242014-05-21 14:57:17 +05308185 vos_mem_copy(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex].BSSID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308186 pmksa->bssid, ETHER_ADDR_LEN);
Agarwal Ashish3da95242014-05-21 14:57:17 +05308187 vos_mem_copy(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex].PMKID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308188 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008189 CSR_RSN_PMKID_SIZE);
Agarwal Ashish3da95242014-05-21 14:57:17 +05308190 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: Adding a new cache entry %d.",
8191 __func__, pHddStaCtx->PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008192 dump_bssid(pmksa->bssid);
8193 dump_pmkid(halHandle, pmksa->pmkid);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308194 // Increment the HDD Local Cache index
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008195 // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME
Agarwal Ashish3da95242014-05-21 14:57:17 +05308196 if (pHddStaCtx->PMKIDCacheIndex <= (MAX_PMKSAIDS_IN_CACHE-1))
8197 pHddStaCtx->PMKIDCacheIndex++;
8198 else
8199 pHddStaCtx->PMKIDCacheIndex = 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008200 }
8201
8202
8203 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Agarwal Ashish3da95242014-05-21 14:57:17 +05308204 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.",
8205 __func__, pHddStaCtx->PMKIDCacheIndex );
8206
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008207 // Finally set the PMKSA ID Cache in CSR
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308208 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Agarwal Ashish3da95242014-05-21 14:57:17 +05308209 pHddStaCtx->PMKIDCache,
8210 pHddStaCtx->PMKIDCacheIndex);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308211 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8212 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
8213 pAdapter->sessionId, result));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008214 return 0;
8215}
8216
8217
Wilson Yang6507c4e2013-10-01 20:11:19 -07008218
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008219static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -07008220 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008221{
Wilson Yang6507c4e2013-10-01 20:11:19 -07008222 tANI_U32 j=0;
8223 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Agarwal Ashish3da95242014-05-21 14:57:17 +05308224 hdd_station_ctx_t *pHddStaCtx;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008225 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008226 tANI_U8 BSSIDMatched = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008227 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -08008228 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008229
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008230 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
8231 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -07008232
8233 /* Validate pAdapter */
8234 if (NULL == pAdapter)
8235 {
8236 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
8237 return -EINVAL;
8238 }
8239
8240 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8241 status = wlan_hdd_validate_context(pHddCtx);
8242
8243 if (0 != status)
8244 {
8245 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8246 "%s: HDD context is not valid", __func__);
8247 return status;
8248 }
8249
8250 /*Retrieve halHandle*/
8251 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Agarwal Ashish3da95242014-05-21 14:57:17 +05308252 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Wilson Yang6507c4e2013-10-01 20:11:19 -07008253
8254 /*in case index is 0,no entry to delete*/
Agarwal Ashish3da95242014-05-21 14:57:17 +05308255 if (0 == pHddStaCtx->PMKIDCacheIndex)
Wilson Yang6507c4e2013-10-01 20:11:19 -07008256 {
Agarwal Ashish3da95242014-05-21 14:57:17 +05308257 hddLog(VOS_TRACE_LEVEL_INFO, FL("No entries to flush"));
8258 return 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008259 }
8260
8261 /*find the matching PMKSA entry from j=0 to (index-1),
8262 * and delete the matched one
8263 */
Agarwal Ashish3da95242014-05-21 14:57:17 +05308264 for (j = 0; j < pHddStaCtx->PMKIDCacheIndex; j++)
Wilson Yang6507c4e2013-10-01 20:11:19 -07008265 {
Agarwal Ashish3da95242014-05-21 14:57:17 +05308266 if (vos_mem_compare(pHddStaCtx->PMKIDCache[j].BSSID,
Wilson Yang6507c4e2013-10-01 20:11:19 -07008267 pmksa->bssid,
8268 WNI_CFG_BSSID_LEN))
8269 {
8270 /* BSSID matched entry */
8271 BSSIDMatched = 1;
Agarwal Ashish3da95242014-05-21 14:57:17 +05308272 if (j < pHddStaCtx->PMKIDCacheIndex-1)
Wilson Yang6507c4e2013-10-01 20:11:19 -07008273 {
8274 /*replace the matching entry with the last entry in HDD local cache*/
Agarwal Ashish3da95242014-05-21 14:57:17 +05308275 vos_mem_copy(pHddStaCtx->PMKIDCache[j].BSSID,
8276 pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].BSSID,
8277 VOS_MAC_ADDR_SIZE);
8278 vos_mem_copy(pHddStaCtx->PMKIDCache[j].PMKID,
8279 pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].PMKID,
8280 CSR_RSN_PMKID_SIZE);
8281 }
Wilson Yang6507c4e2013-10-01 20:11:19 -07008282
8283 /*clear the last entry in HDD cache ---[index-1]*/
Agarwal Ashish3da95242014-05-21 14:57:17 +05308284 vos_mem_zero(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].BSSID,
8285 VOS_MAC_ADDR_SIZE);
8286 vos_mem_zero(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].PMKID,
8287 CSR_RSN_PMKID_SIZE);
Wilson Yang6507c4e2013-10-01 20:11:19 -07008288 /*reduce the PMKID array index*/
Agarwal Ashish3da95242014-05-21 14:57:17 +05308289 pHddStaCtx->PMKIDCacheIndex--;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008290 /*delete the last PMKID cache in CSR*/
Wilson Yangef657d32014-01-15 19:19:23 -08008291 if (eHAL_STATUS_SUCCESS !=
8292 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pmksa->bssid))
Wilson Yang6507c4e2013-10-01 20:11:19 -07008293 {
8294 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cannot delete PMKSA %d CONTENT.",
Agarwal Ashish3da95242014-05-21 14:57:17 +05308295 __func__, pHddStaCtx->PMKIDCacheIndex);
Wilson Yangef657d32014-01-15 19:19:23 -08008296 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008297 }
8298
8299 dump_bssid(pmksa->bssid);
8300 dump_pmkid(halHandle,pmksa->pmkid);
8301
8302 break;
8303 }
8304 }
8305
8306 /* we compare all entries,but cannot find matching entry */
8307 if (j == MAX_PMKSAIDS_IN_CACHE && !BSSIDMatched)
8308 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008309 hddLog(VOS_TRACE_LEVEL_FATAL,
8310 "%s: No such PMKSA entry existed " MAC_ADDRESS_STR,
8311 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -07008312 dump_bssid(pmksa->bssid);
8313 dump_pmkid(halHandle, pmksa->pmkid);
8314 return -EINVAL;
8315 }
Wilson Yangef657d32014-01-15 19:19:23 -08008316 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008317}
8318
Wilson Yang6507c4e2013-10-01 20:11:19 -07008319
8320
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008321static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
8322{
Wilson Yang6507c4e2013-10-01 20:11:19 -07008323 tANI_U32 j=0;
8324 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Agarwal Ashish3da95242014-05-21 14:57:17 +05308325 hdd_station_ctx_t *pHddStaCtx;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008326 tHalHandle halHandle;
8327 hdd_context_t *pHddCtx;
8328 tANI_U8 *pBSSId;
Wilson Yangef657d32014-01-15 19:19:23 -08008329 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008330
8331 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__);
8332
8333 /* Validate pAdapter */
8334 if (NULL == pAdapter)
8335 {
8336 hddLog(VOS_TRACE_LEVEL_ERROR,
8337 "%s: Invalid Adapter" ,__func__);
8338 return -EINVAL;
8339 }
8340
8341 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8342 status = wlan_hdd_validate_context(pHddCtx);
8343
8344 if (0 != status)
8345 {
8346 hddLog(VOS_TRACE_LEVEL_ERROR,
8347 "%s: HDD context is not valid", __func__);
8348 return status;
8349 }
8350
8351 /*Retrieve halHandle*/
8352 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Agarwal Ashish3da95242014-05-21 14:57:17 +05308353 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Wilson Yang6507c4e2013-10-01 20:11:19 -07008354
8355 /*in case index is 0,no entry to delete*/
Agarwal Ashish3da95242014-05-21 14:57:17 +05308356 if (0 == pHddStaCtx->PMKIDCacheIndex)
Wilson Yang6507c4e2013-10-01 20:11:19 -07008357 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +05308358 hddLog(VOS_TRACE_LEVEL_ERROR, FL("No entries to flush"));
Agarwal Ashish3da95242014-05-21 14:57:17 +05308359 return 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008360 }
8361
8362 /*delete all the PMKSA one by one */
Agarwal Ashish3da95242014-05-21 14:57:17 +05308363 for (j = 0; j < pHddStaCtx->PMKIDCacheIndex; j++)
Wilson Yang6507c4e2013-10-01 20:11:19 -07008364 {
Agarwal Ashish3da95242014-05-21 14:57:17 +05308365 pBSSId =(tANI_U8 *)(pHddStaCtx->PMKIDCache[j].BSSID);
Wilson Yang6507c4e2013-10-01 20:11:19 -07008366 /*delete the PMKID in CSR*/
Wilson Yangef657d32014-01-15 19:19:23 -08008367 if (eHAL_STATUS_SUCCESS !=
8368 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId))
Wilson Yang6507c4e2013-10-01 20:11:19 -07008369 {
8370 hddLog(VOS_TRACE_LEVEL_ERROR ,"%s cannot flush PMKIDCache %d.",
8371 __func__,j);
Wilson Yangef657d32014-01-15 19:19:23 -08008372 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -07008373 }
Kiet Lam8d21d5b2013-10-31 17:18:29 +05308374 /*clear the entry in HDD cache 0--index-1 */
Agarwal Ashish3da95242014-05-21 14:57:17 +05308375 vos_mem_zero(pHddStaCtx->PMKIDCache[j].BSSID, VOS_MAC_ADDR_SIZE);
8376 vos_mem_zero(pHddStaCtx->PMKIDCache[j].PMKID, CSR_RSN_PMKID_SIZE);
8377 }
Wilson Yang6507c4e2013-10-01 20:11:19 -07008378
Agarwal Ashish3da95242014-05-21 14:57:17 +05308379 pHddStaCtx->PMKIDCacheIndex = 0;
Wilson Yangef657d32014-01-15 19:19:23 -08008380 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008381}
8382#endif
8383
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008384#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308385static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008386 struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie)
8387{
8388 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8389 hdd_station_ctx_t *pHddStaCtx;
8390
8391 if (NULL == pAdapter)
8392 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008393 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008394 return -ENODEV;
8395 }
8396
8397 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8398
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308399 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8400 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
8401 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008402 // Added for debug on reception of Re-assoc Req.
8403 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8404 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008405 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008406 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008407 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008408 }
8409
8410#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08008411 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008412 ftie->ie_len);
8413#endif
8414
8415 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +05308416 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
8417 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008418 ftie->ie_len);
8419 return 0;
8420}
8421#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008422
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308423#ifdef FEATURE_WLAN_SCAN_PNO
8424
8425void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
8426 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
8427{
8428 int ret;
8429 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
8430 hdd_context_t *pHddCtx;
8431
Nirav Shah80830bf2013-12-31 16:35:12 +05308432 ENTER();
8433
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308434 if (NULL == pAdapter)
8435 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05308436 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308437 "%s: HDD adapter is Null", __func__);
8438 return ;
8439 }
8440
8441 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8442 if (NULL == pHddCtx)
8443 {
8444 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8445 "%s: HDD context is Null!!!", __func__);
8446 return ;
8447 }
8448
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308449 spin_lock(&pHddCtx->schedScan_lock);
8450 if (TRUE == pHddCtx->isWiphySuspended)
8451 {
8452 pHddCtx->isSchedScanUpdatePending = TRUE;
8453 spin_unlock(&pHddCtx->schedScan_lock);
8454 hddLog(VOS_TRACE_LEVEL_INFO,
8455 "%s: Update cfg80211 scan database after it resume", __func__);
8456 return ;
8457 }
8458 spin_unlock(&pHddCtx->schedScan_lock);
8459
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308460 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
8461
8462 if (0 > ret)
8463 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
8464
8465 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8467 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308468}
8469
8470/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308471 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +05308472 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308473 */
8474static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
8475{
8476 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
8477 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308478 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308479 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8480 int status = 0;
8481 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
8482
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +05308483 /* The current firmware design does not allow PNO during any
8484 * active sessions. Hence, determine the active sessions
8485 * and return a failure.
8486 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308487 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
8488 {
8489 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308490 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308491
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308492 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
8493 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
8494 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
8495 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
8496 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
8497 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308498 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308499 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308500 }
8501 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
8502 pAdapterNode = pNext;
8503 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308504 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308505}
8506
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +05308507void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
8508{
8509 hdd_adapter_t *pAdapter = callbackContext;
8510 hdd_context_t *pHddCtx;
8511
8512 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
8513 {
8514 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8515 FL("Invalid adapter or adapter has invalid magic"));
8516 return;
8517 }
8518
8519 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8520 if (0 != wlan_hdd_validate_context(pHddCtx))
8521 {
8522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8523 FL("HDD context is not valid"));
8524 return;
8525 }
8526
8527 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8528 FL("PNO enable response status = %d"), status);
8529
8530 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
8531 complete(&pAdapter->pno_comp_var);
8532}
8533
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308534/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +05308535 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
8536 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308537 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +05308538static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308539 struct net_device *dev, struct cfg80211_sched_scan_request *request)
8540{
8541 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8542 tpSirPNOScanReq pPnoRequest = NULL;
8543 hdd_context_t *pHddCtx;
8544 tHalHandle hHal;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05308545 v_U32_t i, indx, num_ch, tempInterval;
Sushant Kaushikd62d9782014-02-19 15:39:40 +05308546 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
8547 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308548 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
8549 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308550 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308551
8552 if (NULL == pAdapter)
8553 {
8554 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8555 "%s: HDD adapter is Null", __func__);
8556 return -ENODEV;
8557 }
8558
8559 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308560 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308561
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308562 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308563 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308564 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8565 "%s: HDD context is not valid", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308566 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308567 }
8568
8569 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8570 if (NULL == hHal)
8571 {
8572 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8573 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308574 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308575 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308576
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05308577 ret = wlan_hdd_scan_abort(pAdapter);
8578 if (ret <= 0)
8579 {
8580 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8581 "%s: aborting the existing scan is unsuccessfull", __func__);
8582 return -EBUSY;
8583 }
8584
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308585 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308586 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +05308587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05308588 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05308589 return -EBUSY;
8590 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308591
c_hpothu37f21312014-04-09 21:49:54 +05308592 if (TRUE == pHddCtx->isPnoEnable)
8593 {
8594 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8595 FL("already PNO is enabled"));
8596 return -EBUSY;
8597 }
8598 pHddCtx->isPnoEnable = TRUE;
8599
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308600 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
8601 if (NULL == pPnoRequest)
8602 {
8603 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8604 "%s: vos_mem_malloc failed", __func__);
c_hpothu37f21312014-04-09 21:49:54 +05308605 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308606 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308607 }
8608
Madan Mohan Koyyalamudic3f04352013-09-26 19:21:48 +05308609 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308610 pPnoRequest->enable = 1; /*Enable PNO */
8611 pPnoRequest->ucNetworksCount = request->n_match_sets;
8612
8613 if (( !pPnoRequest->ucNetworksCount ) ||
8614 ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
8615 {
8616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +05308617 "%s: Network input is not correct %d Max Network supported is %d",
8618 __func__, pPnoRequest->ucNetworksCount,
8619 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308620 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308621 goto error;
8622 }
8623
8624 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
8625 {
8626 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +05308627 "%s: Incorrect number of channels %d",
8628 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308629 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308630 goto error;
8631 }
8632
8633 /* Framework provides one set of channels(all)
8634 * common for all saved profile */
8635 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
8636 channels_allowed, &num_channels_allowed))
8637 {
8638 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8639 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308640 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308641 goto error;
8642 }
8643 /* Checking each channel against allowed channel list */
8644 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +05308645 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308646 {
Nirav Shah80830bf2013-12-31 16:35:12 +05308647 char chList [(request->n_channels*5)+1];
8648 int len;
8649 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308650 {
Nirav Shah80830bf2013-12-31 16:35:12 +05308651 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308652 {
Nirav Shah80830bf2013-12-31 16:35:12 +05308653 if (request->channels[i]->hw_value == channels_allowed[indx])
8654 {
8655 valid_ch[num_ch++] = request->channels[i]->hw_value;
8656 len += snprintf(chList+len, 5, "%d ",
8657 request->channels[i]->hw_value);
8658 break ;
8659 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308660 }
8661 }
Nirav Shah80830bf2013-12-31 16:35:12 +05308662 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
8663 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308664
8665 /* Filling per profile params */
8666 for (i = 0; i < pPnoRequest->ucNetworksCount; i++)
8667 {
8668 pPnoRequest->aNetworks[i].ssId.length =
8669 request->match_sets[i].ssid.ssid_len;
8670
8671 if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) ||
8672 ( pPnoRequest->aNetworks[i].ssId.length > 32 ) )
8673 {
8674 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +05308675 "%s: SSID Len %d is not correct for network %d",
8676 __func__, pPnoRequest->aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308677 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308678 goto error;
8679 }
8680
8681 memcpy(pPnoRequest->aNetworks[i].ssId.ssId,
8682 request->match_sets[i].ssid.ssid,
8683 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +05308684 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8685 "%s: SSID of network %d is %s ", __func__,
8686 i, pPnoRequest->aNetworks[i].ssId.ssId);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308687 pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
8688 pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/
8689 pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
8690
8691 /*Copying list of valid channel into request */
8692 memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch);
8693 pPnoRequest->aNetworks[i].ucChannelCount = num_ch;
8694
8695 pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value
8696 }
8697
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +05308698 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -08008699 "request->ie_len = %zu", request->ie_len);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +05308700 if ((0 < request->ie_len) && (NULL != request->ie))
8701 {
8702 pPnoRequest->us24GProbeTemplateLen = request->ie_len;
8703 memcpy(&pPnoRequest->p24GProbeTemplate, request->ie,
8704 pPnoRequest->us24GProbeTemplateLen);
8705
8706 pPnoRequest->us5GProbeTemplateLen = request->ie_len;
8707 memcpy(&pPnoRequest->p5GProbeTemplate, request->ie,
8708 pPnoRequest->us5GProbeTemplateLen);
8709 }
8710
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05308711 /* Driver gets only one time interval which is hardcoded in
8712 * supplicant for 10000ms. Taking power consumption into account 6 timers
8713 * will be used, Timervalue is increased exponentially i.e 10,20,40,
8714 * 80,160,320 secs. And number of scan cycle for each timer
8715 * is configurable through INI param gPNOScanTimerRepeatValue.
8716 * If it is set to 0 only one timer will be used and PNO scan cycle
8717 * will be repeated after each interval specified by supplicant
8718 * till PNO is disabled.
8719 */
8720 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
8721 pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
8722 else
8723 pPnoRequest->scanTimers.ucScanTimersCount =
8724 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
8725
8726 tempInterval = (request->interval)/1000;
8727 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8728 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
8729 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
8730 for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++)
8731 {
8732 pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat =
8733 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
8734 pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval;
8735 tempInterval *= 2;
8736 }
8737 //Repeat last timer until pno disabled.
8738 pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
8739
Madan Mohan Koyyalamudid206c7b2013-09-26 22:54:51 +05308740 pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308741
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +05308742 INIT_COMPLETION(pAdapter->pno_comp_var);
8743 pPnoRequest->statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
8744 pPnoRequest->callbackContext = pAdapter;
8745 pAdapter->pno_req_status = 0;
8746
Nirav Shah80830bf2013-12-31 16:35:12 +05308747 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8748 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
8749 pAdapter->sessionId, pPnoRequest->enable, pPnoRequest->modePNO,
8750 pPnoRequest->scanTimers.ucScanTimersCount);
8751
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308752 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
8753 pPnoRequest, pAdapter->sessionId,
8754 hdd_cfg80211_sched_scan_done_callback, pAdapter);
8755 if (eHAL_STATUS_SUCCESS != status)
8756 {
8757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +05308758 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308759 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308760 goto error;
8761 }
8762
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +05308763 ret = wait_for_completion_timeout(
8764 &pAdapter->pno_comp_var,
8765 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
8766 if (0 >= ret)
8767 {
8768 // Did not receive the response for PNO enable in time.
8769 // Assuming the PNO enable was success.
8770 // Returning error from here, because we timeout, results
8771 // in side effect of Wifi (Wifi Setting) not to work.
8772 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8773 FL("Timed out waiting for PNO to be Enabled"));
8774 ret = 0;
8775 goto error;
8776 }
8777
8778 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +05308779 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308780
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308781error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +05308782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8783 FL("PNO scanRequest offloaded ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308784 vos_mem_free(pPnoRequest);
c_hpothu37f21312014-04-09 21:49:54 +05308785 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308786 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308787}
8788
8789/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +05308790 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
8791 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308792 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +05308793static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
8794 struct net_device *dev, struct cfg80211_sched_scan_request *request)
8795{
8796 int ret;
8797
8798 vos_ssr_protect(__func__);
8799 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
8800 vos_ssr_unprotect(__func__);
8801
8802 return ret;
8803}
8804
8805/*
8806 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
8807 * Function to disable PNO
8808 */
8809static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308810 struct net_device *dev)
8811{
8812 eHalStatus status = eHAL_STATUS_FAILURE;
8813 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8814 hdd_context_t *pHddCtx;
8815 tHalHandle hHal;
8816 tpSirPNOScanReq pPnoRequest = NULL;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308817 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308818
8819 ENTER();
8820
8821 if (NULL == pAdapter)
8822 {
8823 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8824 "%s: HDD adapter is Null", __func__);
8825 return -ENODEV;
8826 }
8827
8828 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308829
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308830 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308831 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308832 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308833 "%s: HDD context is Null", __func__);
8834 return -ENODEV;
8835 }
8836
8837 /* The return 0 is intentional when isLogpInProgress and
8838 * isLoadUnloadInProgress. We did observe a crash due to a return of
8839 * failure in sched_scan_stop , especially for a case where the unload
8840 * of the happens at the same time. The function __cfg80211_stop_sched_scan
8841 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
8842 * success. If it returns a failure , then its next invocation due to the
8843 * clean up of the second interface will have the dev pointer corresponding
8844 * to the first one leading to a crash.
8845 */
8846 if (pHddCtx->isLogpInProgress)
8847 {
8848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8849 "%s: LOGP in Progress. Ignore!!!", __func__);
8850 return ret;
8851 }
8852
Mihir Shete18156292014-03-11 15:38:30 +05308853 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308854 {
8855 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8856 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
8857 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308858 }
8859
8860 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8861 if (NULL == hHal)
8862 {
8863 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8864 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308865 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308866 }
8867
8868 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
8869 if (NULL == pPnoRequest)
8870 {
8871 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8872 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308873 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308874 }
8875
8876 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
8877 pPnoRequest->enable = 0; /* Disable PNO */
8878 pPnoRequest->ucNetworksCount = 0;
8879
8880 status = sme_SetPreferredNetworkList(hHal, pPnoRequest,
8881 pAdapter->sessionId,
8882 NULL, pAdapter);
8883 if (eHAL_STATUS_SUCCESS != status)
8884 {
8885 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8886 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308887 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +05308888 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308889 }
c_hpothu37f21312014-04-09 21:49:54 +05308890 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308891
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +05308892error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308893 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +05308894 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308895 vos_mem_free(pPnoRequest);
8896
8897 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308898 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308899}
8900
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +05308901/*
8902 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
8903 * NL interface to disable PNO
8904 */
8905static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
8906 struct net_device *dev)
8907{
8908 int ret;
8909
8910 vos_ssr_protect(__func__);
8911 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
8912 vos_ssr_unprotect(__func__);
8913
8914 return ret;
8915}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308916#endif /*FEATURE_WLAN_SCAN_PNO*/
8917
8918
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008919#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +05308920#if TDLS_MGMT_VERSION2
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008921static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
8922 u8 *peer, u8 action_code, u8 dialog_token,
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +05308923 u16 status_code, u32 peer_capability, const u8 *buf, size_t len)
8924#else
8925static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
8926 u8 *peer, u8 action_code, u8 dialog_token,
8927 u16 status_code, const u8 *buf, size_t len)
8928#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008929{
8930
8931 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8932 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008933 u8 peerMac[6];
8934 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008935 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -08008936 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -07008937 long rc;
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +05308938#if !(TDLS_MGMT_VERSION2)
8939 u32 peer_capability = 0;
8940#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308941 tANI_U16 numCurrTdlsPeers;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008942
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308943 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8944 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
8945 pAdapter->sessionId, action_code));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008946 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008947 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308948 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008949 "Invalid arguments");
8950 return -EINVAL;
8951 }
8952
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008953 if (pHddCtx->isLogpInProgress)
8954 {
8955 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8956 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008957 wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008958 return -EBUSY;
8959 }
8960
Hoonki Lee27511902013-03-14 18:19:06 -07008961 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008962 {
Hoonki Lee27511902013-03-14 18:19:06 -07008963 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8964 "%s: TDLS mode is disabled OR not enabled in FW."
8965 MAC_ADDRESS_STR " action %d declined.",
8966 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008967 return -ENOTSUPP;
8968 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008969
Hoonki Lee27511902013-03-14 18:19:06 -07008970 /* other than teardown frame, other mgmt frames are not sent if disabled */
8971 if (SIR_MAC_TDLS_TEARDOWN != action_code)
8972 {
8973 /* if tdls_mode is disabled to respond to peer's request */
8974 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
8975 {
8976 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8977 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008978 " TDLS mode is disabled. action %d declined.",
8979 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -07008980
8981 return -ENOTSUPP;
8982 }
8983 }
8984
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008985 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
8986 {
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308987 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008988 {
8989 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008990 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008991 " TDLS setup is ongoing. action %d declined.",
8992 __func__, MAC_ADDR_ARRAY(peer), action_code);
8993 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008994 }
8995 }
8996
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008997 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
8998 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -08008999 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05309000 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
9001 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -08009002 {
9003 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
9004 we return error code at 'add_station()'. Hence we have this
9005 check again in addtion to add_station().
9006 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08009007 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -08009008 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009009 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9010 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05309011 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
9012 __func__, MAC_ADDR_ARRAY(peer), action_code,
9013 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +05309014 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -08009015 }
9016 else
9017 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08009018 /* maximum reached. tweak to send error code to peer and return
9019 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -08009020 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009021 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9022 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05309023 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
9024 __func__, MAC_ADDR_ARRAY(peer), status_code,
9025 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07009026 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08009027 /* fall through to send setup resp with failure status
9028 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -08009029 }
9030 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08009031 else
9032 {
9033 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05309034 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009035 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -08009036 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009037 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07009038 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
9039 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08009040 return -EPERM;
9041 }
9042 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08009043 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08009044 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009045
Hoonki Lee1090c6a2013-01-16 17:40:54 -08009046#ifdef WLAN_FEATURE_TDLS_DEBUG
9047 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +05309048 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009049 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
9050 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08009051#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009052
Hoonki Leea34dd892013-02-05 22:56:02 -08009053 /*Except teardown responder will not be used so just make 0*/
9054 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08009055 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -08009056 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07009057
9058 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05309059 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07009060
9061 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
9062 responder = pTdlsPeer->is_responder;
9063 else
Hoonki Leea34dd892013-02-05 22:56:02 -08009064 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07009065 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +05309066 "%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 -07009067 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
9068 dialog_token, status_code, len);
9069 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -08009070 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009071 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009072
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05309073 /* For explicit trigger of DIS_REQ come out of BMPS for
9074 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -07009075 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05309076 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
9077 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -07009078 {
9079 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
9080 {
9081 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05309082 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Hoonki Lee14621352013-04-16 17:51:19 -07009083 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
9084 }
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05309085 if (SIR_MAC_TDLS_DIS_REQ != action_code)
9086 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
Hoonki Lee14621352013-04-16 17:51:19 -07009087 }
9088
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009089 /* make sure doesn't call send_mgmt() while it is pending */
9090 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
9091 {
9092 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009093 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009094 __func__, MAC_ADDR_ARRAY(peer), action_code);
9095 return -EBUSY;
9096 }
9097
9098 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08009099 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
9100
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009101 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05309102 peerMac, action_code, dialog_token, status_code, peer_capability, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009103
Gopichand Nakkalab977a972013-02-18 19:15:09 -08009104 if (VOS_STATUS_SUCCESS != status)
9105 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9107 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009108 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -07009109 wlan_hdd_tdls_check_bmps(pAdapter);
Sunil Dutt388ac8f2013-11-28 18:06:52 +05309110 return -EINVAL;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009111 }
9112
Hoonki Leed37cbb32013-04-20 00:31:14 -07009113 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
9114 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
9115
9116 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08009117 {
Hoonki Leed37cbb32013-04-20 00:31:14 -07009118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009119 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -07009120 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009121 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -08009122
9123 if (pHddCtx->isLogpInProgress)
9124 {
9125 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9126 "%s: LOGP in Progress. Ignore!!!", __func__);
9127 return -EAGAIN;
9128 }
9129
Hoonki Leed37cbb32013-04-20 00:31:14 -07009130 wlan_hdd_tdls_check_bmps(pAdapter);
Sunil Dutt388ac8f2013-11-28 18:06:52 +05309131 return -EINVAL;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08009132 }
9133
Gopichand Nakkala05922802013-03-14 12:23:19 -07009134 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -07009135 {
9136 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -07009137 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -07009138 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08009139
Hoonki Leea34dd892013-02-05 22:56:02 -08009140 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
9141 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08009142 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -08009143 }
9144 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
9145 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08009146 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -08009147 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009148
9149 return 0;
9150}
9151
9152static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
9153 u8 *peer, enum nl80211_tdls_operation oper)
9154{
9155 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9156 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309157 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009158 hddTdlsPeer_t *pTdlsPeer;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009159
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309160 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9161 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
9162 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309163 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009164 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08009165 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07009166 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009167 return -EINVAL;
9168 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -08009169
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309170 status = wlan_hdd_validate_context(pHddCtx);
9171
9172 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009173 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309174 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9175 "%s: HDD context is not valid", __func__);
9176 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009177 }
9178
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009179
9180 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -08009181 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009182 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -08009183 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07009184 "TDLS Disabled in INI OR not enabled in FW. "
9185 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009186 return -ENOTSUPP;
9187 }
9188
9189 switch (oper) {
9190 case NL80211_TDLS_ENABLE_LINK:
9191 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009192 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309193 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05309194 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009195
Sunil Dutt41de4e22013-11-14 18:09:02 +05309196 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
9197
9198 if ( NULL == pTdlsPeer ) {
9199 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
9200 " (oper %d) not exsting. ignored",
9201 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
9202 return -EINVAL;
9203 }
9204
9205 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9206 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
9207 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
9208 "NL80211_TDLS_ENABLE_LINK");
9209
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -07009210 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
9211 {
9212 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
9213 MAC_ADDRESS_STR " failed",
9214 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
9215 return -EINVAL;
9216 }
9217
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009218 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009219 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05309220 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05309221
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05309222 if (0 != wlan_hdd_tdls_get_link_establish_params(
9223 pAdapter, peer,&tdlsLinkEstablishParams)) {
9224 return -EINVAL;
9225 }
9226 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05309227
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05309228 sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter),
9229 pAdapter->sessionId, peer, &tdlsLinkEstablishParams);
9230 /* Send TDLS peer UAPSD capabilities to the firmware and
9231 * register with the TL on after the response for this operation
9232 * is received .
9233 */
9234 ret = wait_for_completion_interruptible_timeout(
9235 &pAdapter->tdls_link_establish_req_comp,
9236 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
9237 if (ret <= 0)
9238 {
9239 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9240 "%s: Link Establish Request Faled Status %ld",
9241 __func__, ret);
9242 return -EINVAL;
9243 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05309244 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07009245 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED);
Gopichand Nakkala471708b2013-06-04 20:03:01 +05309246 /* Mark TDLS client Authenticated .*/
9247 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
9248 pTdlsPeer->staId,
9249 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07009250 if (VOS_STATUS_SUCCESS == status)
9251 {
Hoonki Lee14621352013-04-16 17:51:19 -07009252 if (pTdlsPeer->is_responder == 0)
9253 {
9254 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
9255
9256 wlan_hdd_tdls_timer_restart(pAdapter,
9257 &pTdlsPeer->initiatorWaitTimeoutTimer,
9258 WAIT_TIME_TDLS_INITIATOR);
9259 /* suspend initiator TX until it receives direct packet from the
9260 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
9261 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9262 &staId, NULL);
9263 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07009264 wlan_hdd_tdls_increment_peer_count(pAdapter);
9265 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009266 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05309267
9268 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05309269 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
9270 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05309271 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05309272 int ac;
9273 uint8 ucAc[4] = { WLANTL_AC_VO,
9274 WLANTL_AC_VI,
9275 WLANTL_AC_BK,
9276 WLANTL_AC_BE };
9277 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
9278 for(ac=0; ac < 4; ac++)
9279 {
9280 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9281 pTdlsPeer->staId, ucAc[ac],
9282 tlTid[ac], tlTid[ac], 0, 0,
9283 WLANTL_BI_DIR );
9284 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05309285 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009286 }
9287
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009288 }
9289 break;
9290 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -08009291 {
Sunil Dutt41de4e22013-11-14 18:09:02 +05309292 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
9293
9294 if ( NULL == pTdlsPeer ) {
9295 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
9296 " (oper %d) not exsting. ignored",
9297 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
9298 return -EINVAL;
9299 }
9300
9301 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9302 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
9303 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
9304 "NL80211_TDLS_DISABLE_LINK");
9305
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009306 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -08009307 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009308 long status;
9309
9310 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
9311
Lee Hoonkic1262f22013-01-24 21:59:00 -08009312 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
9313 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009314
9315 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
9316 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
9317 if (status <= 0)
9318 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009319 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9321 "%s: Del station failed status %ld",
9322 __func__, status);
9323 return -EPERM;
9324 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009325 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Lee Hoonkic1262f22013-01-24 21:59:00 -08009326 }
9327 else
9328 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009329 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9330 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -08009331 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08009332 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009333 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009334 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +05309335 {
9336 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9337 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
9338 __func__, MAC_ADDR_ARRAY(peer));
9339
9340 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
9341 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
9342
9343 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9344 " %s TDLS External control and Implicit Trigger not enabled ",
9345 __func__);
9346 return -ENOTSUPP;
9347 }
9348
Sunil Dutt41de4e22013-11-14 18:09:02 +05309349
9350 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
9351
9352 if ( NULL == pTdlsPeer ) {
9353 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
9354 " peer not exsting",
9355 __func__, MAC_ADDR_ARRAY(peer));
Naresh Jayaram937abdf2013-11-26 19:50:25 +05309356 return -EINVAL;
Sunil Dutt41de4e22013-11-14 18:09:02 +05309357 }
9358 else {
9359 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
9360 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
9361 }
Naresh Jayaram937abdf2013-11-26 19:50:25 +05309362
9363 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) )
9364 return -EINVAL;
Sunil Dutt41de4e22013-11-14 18:09:02 +05309365 break;
9366 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009367 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +05309368 {
Naresh Jayaramdb4514b2013-11-25 18:08:10 +05309369 hddTdlsPeer_t *pTdlsPeer;
Sunil Dutt41de4e22013-11-14 18:09:02 +05309370 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9371 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
9372 __func__, MAC_ADDR_ARRAY(peer));
9373
9374 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
9375 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
9376
9377 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9378 " %s TDLS External control and Implicit Trigger not enabled ",
9379 __func__);
9380 return -ENOTSUPP;
9381 }
9382
Naresh Jayaramdb4514b2013-11-25 18:08:10 +05309383 /* To cater the requirement of establishing the TDLS link
9384 * irrespective of the data traffic , get an entry of TDLS peer.
9385 */
9386 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
9387 if (pTdlsPeer == NULL) {
9388 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9389 "%s: peer " MAC_ADDRESS_STR " not existing",
9390 __func__, MAC_ADDR_ARRAY(peer));
9391 return -EINVAL;
9392 }
Naresh Jayaram937abdf2013-11-26 19:50:25 +05309393
9394 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
9395
9396 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9397 " %s TDLS Add Force Peer Failed",
9398 __func__);
9399 return -EINVAL;
9400 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +05309401 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +05309402 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009403 case NL80211_TDLS_DISCOVERY_REQ:
9404 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309405 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9406 "%s: We don't support in-driver setup/teardown/discovery "
9407 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009408 return -ENOTSUPP;
9409 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309410 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9411 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009412 return -ENOTSUPP;
9413 }
9414 return 0;
9415}
Chilam NG571c65a2013-01-19 12:27:36 +05309416
9417int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
9418 struct net_device *dev, u8 *peer)
9419{
Arif Hussaina7c8e412013-11-20 11:06:42 -08009420 hddLog(VOS_TRACE_LEVEL_INFO,
9421 "tdls send discover req: "MAC_ADDRESS_STR,
9422 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +05309423
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +05309424#if TDLS_MGMT_VERSION2
9425 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
9426 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
9427#else
Chilam NG571c65a2013-01-19 12:27:36 +05309428 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
9429 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +05309430#endif
Chilam NG571c65a2013-01-19 12:27:36 +05309431}
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009432#endif
9433
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309434#ifdef WLAN_FEATURE_GTK_OFFLOAD
9435/*
9436 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
9437 * Callback rountine called upon receiving response for
9438 * get offload info
9439 */
9440void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
9441 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
9442{
9443
9444 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309445 tANI_U8 tempReplayCounter[8];
9446 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309447
9448 ENTER();
9449
9450 if (NULL == pAdapter)
9451 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309452 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309453 "%s: HDD adapter is Null", __func__);
9454 return ;
9455 }
9456
9457 if (NULL == pGtkOffloadGetInfoRsp)
9458 {
9459 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9460 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
9461 return ;
9462 }
9463
9464 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
9465 {
9466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9467 "%s: wlan Failed to get replay counter value",
9468 __func__);
9469 return ;
9470 }
9471
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309472 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9473 /* Update replay counter */
9474 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
9475 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
9476
9477 {
9478 /* changing from little to big endian since supplicant
9479 * works on big endian format
9480 */
9481 int i;
9482 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
9483
9484 for (i = 0; i < 8; i++)
9485 {
9486 tempReplayCounter[7-i] = (tANI_U8)p[i];
9487 }
9488 }
9489
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309490 /* Update replay counter to NL */
9491 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309492 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309493}
9494
9495/*
9496 * FUNCTION: wlan_hdd_cfg80211_set_rekey_data
9497 * This function is used to offload GTK rekeying job to the firmware.
9498 */
9499int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
9500 struct cfg80211_gtk_rekey_data *data)
9501{
9502 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9503 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9504 hdd_station_ctx_t *pHddStaCtx;
9505 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309506 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309507 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309508 eHalStatus status = eHAL_STATUS_FAILURE;
9509
9510 ENTER();
9511
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309512
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309513 if (NULL == pAdapter)
9514 {
9515 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9516 "%s: HDD adapter is Null", __func__);
9517 return -ENODEV;
9518 }
9519
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309520 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9521 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
9522 pAdapter->sessionId, pAdapter->device_mode));
9523
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309524 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309525
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309526 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309527 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309528 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9529 "%s: HDD context is not valid", __func__);
9530 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309531 }
9532
9533 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9534 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9535 if (NULL == hHal)
9536 {
9537 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9538 "%s: HAL context is Null!!!", __func__);
9539 return -EAGAIN;
9540 }
9541
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309542 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
9543 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
9544 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
9545 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309546 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309547 {
9548 /* changing from big to little endian since driver
9549 * works on little endian format
9550 */
9551 tANI_U8 *p =
9552 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
9553 int i;
9554
9555 for (i = 0; i < 8; i++)
9556 {
9557 p[7-i] = data->replay_ctr[i];
9558 }
9559 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309560
9561 if (TRUE == pHddCtx->hdd_wlan_suspended)
9562 {
9563 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309564 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
9565 sizeof (tSirGtkOffloadParams));
9566 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309567 pAdapter->sessionId);
9568
9569 if (eHAL_STATUS_SUCCESS != status)
9570 {
9571 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9572 "%s: sme_SetGTKOffload failed, returned %d",
9573 __func__, status);
9574 return status;
9575 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9577 "%s: sme_SetGTKOffload successfull", __func__);
9578 }
9579 else
9580 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309581 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9582 "%s: wlan not suspended GTKOffload request is stored",
9583 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309584 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309585
9586 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309587}
9588#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
9589
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309590/*
9591 * FUNCTION: wlan_hdd_cfg80211_set_mac_acl
9592 * This function is used to set access control policy
9593 */
9594static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
9595 struct net_device *dev, const struct cfg80211_acl_data *params)
9596{
9597 int i;
9598 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9599 hdd_hostapd_state_t *pHostapdState;
9600 tsap_Config_t *pConfig;
9601 v_CONTEXT_t pVosContext = NULL;
9602 hdd_context_t *pHddCtx;
9603 int status;
9604
9605 ENTER();
9606
9607 if (NULL == pAdapter)
9608 {
9609 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9610 "%s: HDD adapter is Null", __func__);
9611 return -ENODEV;
9612 }
9613
9614 if (NULL == params)
9615 {
9616 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9617 "%s: params is Null", __func__);
9618 return -EINVAL;
9619 }
9620
9621 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9622 status = wlan_hdd_validate_context(pHddCtx);
9623
9624 if (0 != status)
9625 {
9626 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9627 "%s: HDD context is not valid", __func__);
9628 return status;
9629 }
9630
9631 pVosContext = pHddCtx->pvosContext;
9632 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
9633
9634 if (NULL == pHostapdState)
9635 {
9636 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9637 "%s: pHostapdState is Null", __func__);
9638 return -EINVAL;
9639 }
9640
9641 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
9642 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
9643
9644 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
9645 {
9646 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
9647
9648 /* default value */
9649 pConfig->num_accept_mac = 0;
9650 pConfig->num_deny_mac = 0;
9651
9652 /**
9653 * access control policy
9654 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
9655 * listed in hostapd.deny file.
9656 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
9657 * listed in hostapd.accept file.
9658 */
9659 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
9660 {
9661 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
9662 }
9663 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
9664 {
9665 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
9666 }
9667 else
9668 {
9669 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9670 "%s:Acl Policy : %d is not supported",
9671 __func__, params->acl_policy);
9672 return -ENOTSUPP;
9673 }
9674
9675 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
9676 {
9677 pConfig->num_accept_mac = params->n_acl_entries;
9678 for (i = 0; i < params->n_acl_entries; i++)
9679 {
9680 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9681 "** Add ACL MAC entry %i in WhiletList :"
9682 MAC_ADDRESS_STR, i,
9683 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
9684
9685 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
9686 sizeof(qcmacaddr));
9687 }
9688 }
9689 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
9690 {
9691 pConfig->num_deny_mac = params->n_acl_entries;
9692 for (i = 0; i < params->n_acl_entries; i++)
9693 {
9694 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9695 "** Add ACL MAC entry %i in BlackList :"
9696 MAC_ADDRESS_STR, i,
9697 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
9698
9699 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
9700 sizeof(qcmacaddr));
9701 }
9702 }
9703
9704 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
9705 {
9706 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9707 "%s: SAP Set Mac Acl fail", __func__);
9708 return -EINVAL;
9709 }
9710 }
9711 else
9712 {
9713 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309714 "%s: Invalid device_mode = %s (%d)",
9715 __func__, hdd_device_modetoString(pAdapter->device_mode),
9716 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309717 return -EINVAL;
9718 }
9719
9720 return 0;
9721}
9722
Leo Chang9056f462013-08-01 19:21:11 -07009723#ifdef WLAN_NL80211_TESTMODE
9724#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -07009725void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -07009726(
9727 void *pAdapter,
9728 void *indCont
9729)
9730{
Leo Changd9df8aa2013-09-26 13:32:26 -07009731 tSirLPHBInd *lphbInd;
9732 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +05309733 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -07009734
9735 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07009736 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -07009737
c_hpothu73f35e62014-04-18 13:40:08 +05309738 if (pAdapter == NULL)
9739 {
9740 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9741 "%s: pAdapter is NULL\n",__func__);
9742 return;
9743 }
9744
Leo Chang9056f462013-08-01 19:21:11 -07009745 if (NULL == indCont)
9746 {
9747 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07009748 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -07009749 return;
9750 }
9751
c_hpothu73f35e62014-04-18 13:40:08 +05309752 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -07009753 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -07009754 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +05309755 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -07009756 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -07009757 GFP_ATOMIC);
9758 if (!skb)
9759 {
9760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9761 "LPHB timeout, NL buffer alloc fail");
9762 return;
9763 }
9764
Leo Changac3ba772013-10-07 09:47:04 -07009765 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -07009766 {
9767 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9768 "WLAN_HDD_TM_ATTR_CMD put fail");
9769 goto nla_put_failure;
9770 }
Leo Changac3ba772013-10-07 09:47:04 -07009771 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -07009772 {
9773 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9774 "WLAN_HDD_TM_ATTR_TYPE put fail");
9775 goto nla_put_failure;
9776 }
Leo Changac3ba772013-10-07 09:47:04 -07009777 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -07009778 sizeof(tSirLPHBInd), lphbInd))
9779 {
9780 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9781 "WLAN_HDD_TM_ATTR_DATA put fail");
9782 goto nla_put_failure;
9783 }
Leo Chang9056f462013-08-01 19:21:11 -07009784 cfg80211_testmode_event(skb, GFP_ATOMIC);
9785 return;
9786
9787nla_put_failure:
9788 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9789 "NLA Put fail");
9790 kfree_skb(skb);
9791
9792 return;
9793}
9794#endif /* FEATURE_WLAN_LPHB */
9795
9796static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
9797{
9798 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
9799 int err = 0;
9800#ifdef FEATURE_WLAN_LPHB
9801 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -07009802 eHalStatus smeStatus;
Leo Chang9056f462013-08-01 19:21:11 -07009803#endif /* FEATURE_WLAN_LPHB */
9804
9805 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
9806 if (err)
9807 {
9808 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9809 "%s Testmode INV ATTR", __func__);
9810 return err;
9811 }
9812
9813 if (!tb[WLAN_HDD_TM_ATTR_CMD])
9814 {
9815 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9816 "%s Testmode INV CMD", __func__);
9817 return -EINVAL;
9818 }
9819
9820 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
9821 {
9822#ifdef FEATURE_WLAN_LPHB
9823 /* Low Power Heartbeat configuration request */
9824 case WLAN_HDD_TM_CMD_WLAN_HB:
9825 {
9826 int buf_len;
9827 void *buf;
9828 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -08009829 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -07009830
9831 if (!tb[WLAN_HDD_TM_ATTR_DATA])
9832 {
9833 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9834 "%s Testmode INV DATA", __func__);
9835 return -EINVAL;
9836 }
9837
9838 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
9839 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -08009840
9841 hb_params_temp =(tSirLPHBReq *)buf;
9842 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
9843 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
9844 return -EINVAL;
9845
Leo Chang9056f462013-08-01 19:21:11 -07009846 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
9847 if (NULL == hb_params)
9848 {
9849 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9850 "%s Request Buffer Alloc Fail", __func__);
9851 return -EINVAL;
9852 }
9853
9854 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -07009855 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
9856 hb_params,
9857 wlan_hdd_cfg80211_lphb_ind_handler);
9858 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -07009859 {
Leo Changd9df8aa2013-09-26 13:32:26 -07009860 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9861 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -07009862 vos_mem_free(hb_params);
9863 }
Leo Chang9056f462013-08-01 19:21:11 -07009864 return 0;
9865 }
9866#endif /* FEATURE_WLAN_LPHB */
9867 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309868 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9869 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -07009870 return -EOPNOTSUPP;
9871 }
9872
9873 return err;
9874}
9875#endif /* CONFIG_NL80211_TESTMODE */
9876
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309877static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
9878 struct net_device *dev,
9879 int idx, struct survey_info *survey)
9880{
9881 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9882 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +05309883 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309884 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +05309885 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309886 v_S7_t snr,rssi;
9887 int status, i, j, filled = 0;
9888
9889 ENTER();
9890
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309891 if (NULL == pAdapter)
9892 {
9893 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9894 "%s: HDD adapter is Null", __func__);
9895 return -ENODEV;
9896 }
9897
9898 if (NULL == wiphy)
9899 {
9900 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9901 "%s: wiphy is Null", __func__);
9902 return -ENODEV;
9903 }
9904
9905 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9906 status = wlan_hdd_validate_context(pHddCtx);
9907
9908 if (0 != status)
9909 {
9910 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9911 "%s: HDD context is not valid", __func__);
9912 return status;
9913 }
9914
Mihir Sheted9072e02013-08-21 17:02:29 +05309915 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9916
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309917 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +05309918 0 != pAdapter->survey_idx ||
9919 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309920 {
9921 /* The survey dump ops when implemented completely is expected to
9922 * return a survey of all channels and the ops is called by the
9923 * kernel with incremental values of the argument 'idx' till it
9924 * returns -ENONET. But we can only support the survey for the
9925 * operating channel for now. survey_idx is used to track
9926 * that the ops is called only once and then return -ENONET for
9927 * the next iteration
9928 */
9929 pAdapter->survey_idx = 0;
9930 return -ENONET;
9931 }
9932
9933 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
9934
9935 wlan_hdd_get_snr(pAdapter, &snr);
9936 wlan_hdd_get_rssi(pAdapter, &rssi);
9937
9938 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
9939 hdd_wlan_get_freq(channel, &freq);
9940
9941
9942 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
9943 {
9944 if (NULL == wiphy->bands[i])
9945 {
9946 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9947 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
9948 continue;
9949 }
9950
9951 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
9952 {
9953 struct ieee80211_supported_band *band = wiphy->bands[i];
9954
9955 if (band->channels[j].center_freq == (v_U16_t)freq)
9956 {
9957 survey->channel = &band->channels[j];
9958 /* The Rx BDs contain SNR values in dB for the received frames
9959 * while the supplicant expects noise. So we calculate and
9960 * return the value of noise (dBm)
9961 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
9962 */
9963 survey->noise = rssi - snr;
9964 survey->filled = SURVEY_INFO_NOISE_DBM;
9965 filled = 1;
9966 }
9967 }
9968 }
9969
9970 if (filled)
9971 pAdapter->survey_idx = 1;
9972 else
9973 {
9974 pAdapter->survey_idx = 0;
9975 return -ENONET;
9976 }
9977
9978 return 0;
9979}
9980
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309981/*
9982 * FUNCTION: wlan_hdd_cfg80211_resume_wlan
9983 * this is called when cfg80211 driver resume
9984 * driver updates latest sched_scan scan result(if any) to cfg80211 database
9985 */
9986int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
9987{
9988 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9989 hdd_adapter_t *pAdapter;
9990 hdd_adapter_list_node_t *pAdapterNode, *pNext;
9991 VOS_STATUS status = VOS_STATUS_SUCCESS;
9992
9993 ENTER();
9994
9995 if ( NULL == pHddCtx )
9996 {
9997 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9998 "%s: HddCtx validation failed", __func__);
9999 return 0;
10000 }
10001
10002 if (pHddCtx->isLogpInProgress)
10003 {
10004 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10005 "%s: LOGP in Progress. Ignore!!!", __func__);
10006 return 0;
10007 }
10008
Mihir Shete18156292014-03-11 15:38:30 +053010009 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053010010 {
10011 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10012 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
10013 return 0;
10014 }
10015
10016 spin_lock(&pHddCtx->schedScan_lock);
10017 pHddCtx->isWiphySuspended = FALSE;
10018 if (TRUE != pHddCtx->isSchedScanUpdatePending)
10019 {
10020 spin_unlock(&pHddCtx->schedScan_lock);
10021 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10022 "%s: Return resume is not due to PNO indication", __func__);
10023 return 0;
10024 }
10025 // Reset flag to avoid updatating cfg80211 data old results again
10026 pHddCtx->isSchedScanUpdatePending = FALSE;
10027 spin_unlock(&pHddCtx->schedScan_lock);
10028
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053010029
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053010030 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
10031
10032 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
10033 {
10034 pAdapter = pAdapterNode->pAdapter;
10035 if ( (NULL != pAdapter) &&
10036 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
10037 {
10038 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053010039 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053010040 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10041 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053010042 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053010043 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053010044 {
10045 /* Acquire wakelock to handle the case where APP's tries to
10046 * suspend immediately after updating the scan results. Whis
10047 * results in app's is in suspended state and not able to
10048 * process the connect request to AP
10049 */
10050 hdd_prevent_suspend_timeout(2000);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053010051 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053010052 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053010053
10054 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10055 "%s : cfg80211 scan result database updated", __func__);
10056
10057 return 0;
10058
10059 }
10060 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
10061 pAdapterNode = pNext;
10062 }
10063
10064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10065 "%s: Failed to find Adapter", __func__);
10066 return 0;
10067}
10068
10069/*
10070 * FUNCTION: wlan_hdd_cfg80211_suspend_wlan
10071 * this is called when cfg80211 driver suspends
10072 */
10073int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
10074 struct cfg80211_wowlan *wow)
10075{
10076 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
10077
10078 ENTER();
10079 if (NULL == pHddCtx)
10080 {
10081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10082 "%s: HddCtx validation failed", __func__);
10083 return 0;
10084 }
10085
10086 pHddCtx->isWiphySuspended = TRUE;
10087
10088 EXIT();
10089
10090 return 0;
10091}
10092
Jeff Johnson295189b2012-06-20 16:38:30 -070010093/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010094static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070010095{
10096 .add_virtual_intf = wlan_hdd_add_virtual_intf,
10097 .del_virtual_intf = wlan_hdd_del_virtual_intf,
10098 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
10099 .change_station = wlan_hdd_change_station,
10100#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
10101 .add_beacon = wlan_hdd_cfg80211_add_beacon,
10102 .del_beacon = wlan_hdd_cfg80211_del_beacon,
10103 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010104#else
10105 .start_ap = wlan_hdd_cfg80211_start_ap,
10106 .change_beacon = wlan_hdd_cfg80211_change_beacon,
10107 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070010108#endif
10109 .change_bss = wlan_hdd_cfg80211_change_bss,
10110 .add_key = wlan_hdd_cfg80211_add_key,
10111 .get_key = wlan_hdd_cfg80211_get_key,
10112 .del_key = wlan_hdd_cfg80211_del_key,
10113 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080010114#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070010115 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080010116#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010117 .scan = wlan_hdd_cfg80211_scan,
10118 .connect = wlan_hdd_cfg80211_connect,
10119 .disconnect = wlan_hdd_cfg80211_disconnect,
10120 .join_ibss = wlan_hdd_cfg80211_join_ibss,
10121 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
10122 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
10123 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
10124 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070010125 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
10126 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053010127 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070010128#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
10129 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
10130 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
10131 .set_txq_params = wlan_hdd_set_txq_params,
10132#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010133 .get_station = wlan_hdd_cfg80211_get_station,
10134 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
10135 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010136 .add_station = wlan_hdd_cfg80211_add_station,
10137#ifdef FEATURE_WLAN_LFR
10138 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
10139 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
10140 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
10141#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070010142#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
10143 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
10144#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010145#ifdef FEATURE_WLAN_TDLS
10146 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
10147 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
10148#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010149#ifdef WLAN_FEATURE_GTK_OFFLOAD
10150 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
10151#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010152#ifdef FEATURE_WLAN_SCAN_PNO
10153 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
10154 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
10155#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053010156 .resume = wlan_hdd_cfg80211_resume_wlan,
10157 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053010158 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070010159#ifdef WLAN_NL80211_TESTMODE
10160 .testmode_cmd = wlan_hdd_cfg80211_testmode,
10161#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010162 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070010163};
10164