blob: b484065b4818d9c1e3b3b88095bad751f2996bec [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 Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Kiet Lamaa8e15a2014-02-11 23:30:06 -080026 */
Kiet Lam842dad02014-02-18 18:44:02 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/**========================================================================
32
33 \file wlan_hdd_cfg80211.c
34
35 \brief WLAN Host Device Driver implementation
36
Jeff Johnson295189b2012-06-20 16:38:30 -070037 ========================================================================*/
38
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070039/**=========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070040
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070041 EDIT HISTORY FOR FILE
Jeff Johnson295189b2012-06-20 16:38:30 -070042
43
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070044 This section contains comments describing changes made to the module.
45 Notice that changes are listed in reverse chronological order.
Jeff Johnson295189b2012-06-20 16:38:30 -070046
47
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070048 $Header:$ $DateTime: $ $Author: $
Jeff Johnson295189b2012-06-20 16:38:30 -070049
50
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070051 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070052 -------- --- --------------------------------------------------------
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070053 21/12/09 Ashwani Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070054
55 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070056 Ganesh K
Jeff Johnson295189b2012-06-20 16:38:30 -070057 ==========================================================================*/
58
Jeff Johnson295189b2012-06-20 16:38:30 -070059
60#include <linux/version.h>
61#include <linux/module.h>
62#include <linux/kernel.h>
63#include <linux/init.h>
64#include <linux/wireless.h>
65#include <wlan_hdd_includes.h>
66#include <net/arp.h>
67#include <net/cfg80211.h>
68#include <linux/wireless.h>
69#include <wlan_hdd_wowl.h>
70#include <aniGlobal.h>
71#include "ccmApi.h"
72#include "sirParams.h"
73#include "dot11f.h"
74#include "wlan_hdd_assoc.h"
75#include "wlan_hdd_wext.h"
76#include "sme_Api.h"
77#include "wlan_hdd_p2p.h"
78#include "wlan_hdd_cfg80211.h"
79#include "wlan_hdd_hostapd.h"
80#include "sapInternal.h"
81#include "wlan_hdd_softap_tx_rx.h"
82#include "wlan_hdd_main.h"
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053083#include "wlan_hdd_assoc.h"
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053084#include "wlan_hdd_power.h"
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053085#include "wlan_hdd_trace.h"
86#include "vos_types.h"
87#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070088#ifdef WLAN_BTAMP_FEATURE
89#include "bap_hdd_misc.h"
90#endif
91#include <qc_sap_ioctl.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080092#ifdef FEATURE_WLAN_TDLS
93#include "wlan_hdd_tdls.h"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053094#include "wlan_hdd_wmm.h"
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053095#include "wlan_qct_wda.h"
Mohit Khanna698ba2a2012-12-04 15:08:18 -080096#endif
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053097#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070098#include "wlan_hdd_dev_pwr.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070099
100#define g_mode_rates_size (12)
101#define a_mode_rates_size (8)
102#define FREQ_BASE_80211G (2407)
103#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700104#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +0530105#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -0700106#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
krunal soni2a6a9062014-02-11 14:14:23 -0800107 ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700108
109#define HDD2GHZCHAN(freq, chan, flag) { \
110 .band = IEEE80211_BAND_2GHZ, \
111 .center_freq = (freq), \
112 .hw_value = (chan),\
113 .flags = (flag), \
114 .max_antenna_gain = 0 ,\
115 .max_power = 30, \
116}
117
118#define HDD5GHZCHAN(freq, chan, flag) { \
119 .band = IEEE80211_BAND_5GHZ, \
120 .center_freq = (freq), \
121 .hw_value = (chan),\
122 .flags = (flag), \
123 .max_antenna_gain = 0 ,\
124 .max_power = 30, \
125}
126
127#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
128{\
129 .bitrate = rate, \
130 .hw_value = rate_id, \
131 .flags = flag, \
132}
133
Lee Hoonkic1262f22013-01-24 21:59:00 -0800134#ifndef WLAN_FEATURE_TDLS_DEBUG
135#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_INFO
136#else
137#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_ERROR
138#endif
139
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530140#ifdef WLAN_FEATURE_VOWIFI_11R
141#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
142#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
143#endif
144
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530145#define HDD_CHANNEL_14 14
Dasari Srinivase18b2cf2014-10-28 17:09:42 +0530146#define WLAN_HDD_MAX_FEATURE_SET 8
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530147
Sunil Duttc69bccb2014-05-26 21:30:20 +0530148#ifdef WLAN_FEATURE_LINK_LAYER_STATS
149/*
150 * Used to allocate the size of 4096 for the link layer stats.
151 * The size of 4096 is considered assuming that all data per
152 * respective event fit with in the limit.Please take a call
153 * on the limit based on the data requirements on link layer
154 * statistics.
155 */
156#define LL_STATS_EVENT_BUF_SIZE 4096
157#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +0530158#ifdef WLAN_FEATURE_EXTSCAN
159/*
160 * Used to allocate the size of 4096 for the EXTScan NL data.
161 * The size of 4096 is considered assuming that all data per
162 * respective event fit with in the limit.Please take a call
163 * on the limit based on the data requirements.
164 */
165
166#define EXTSCAN_EVENT_BUF_SIZE 4096
167#define EXTSCAN_MAX_CACHED_RESULTS_PER_IND 32
168#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +0530169
Atul Mittal115287b2014-07-08 13:26:33 +0530170/*EXT TDLS*/
171/*
172 * Used to allocate the size of 4096 for the TDLS.
173 * The size of 4096 is considered assuming that all data per
174 * respective event fit with in the limit.Please take a call
175 * on the limit based on the data requirements on link layer
176 * statistics.
177 */
178#define EXTTDLS_EVENT_BUF_SIZE 4096
179
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530180static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700181{
182 WLAN_CIPHER_SUITE_WEP40,
183 WLAN_CIPHER_SUITE_WEP104,
184 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800185#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700186#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
187 WLAN_CIPHER_SUITE_KRK,
188 WLAN_CIPHER_SUITE_CCMP,
189#else
190 WLAN_CIPHER_SUITE_CCMP,
191#endif
192#ifdef FEATURE_WLAN_WAPI
193 WLAN_CIPHER_SUITE_SMS4,
194#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700195#ifdef WLAN_FEATURE_11W
196 WLAN_CIPHER_SUITE_AES_CMAC,
197#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700198};
199
200static inline int is_broadcast_ether_addr(const u8 *addr)
201{
202 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
203 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
204}
205
206static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530207{
Jeff Johnson295189b2012-06-20 16:38:30 -0700208 HDD2GHZCHAN(2412, 1, 0) ,
209 HDD2GHZCHAN(2417, 2, 0) ,
210 HDD2GHZCHAN(2422, 3, 0) ,
211 HDD2GHZCHAN(2427, 4, 0) ,
212 HDD2GHZCHAN(2432, 5, 0) ,
213 HDD2GHZCHAN(2437, 6, 0) ,
214 HDD2GHZCHAN(2442, 7, 0) ,
215 HDD2GHZCHAN(2447, 8, 0) ,
216 HDD2GHZCHAN(2452, 9, 0) ,
217 HDD2GHZCHAN(2457, 10, 0) ,
218 HDD2GHZCHAN(2462, 11, 0) ,
219 HDD2GHZCHAN(2467, 12, 0) ,
220 HDD2GHZCHAN(2472, 13, 0) ,
221 HDD2GHZCHAN(2484, 14, 0) ,
222};
223
Jeff Johnson295189b2012-06-20 16:38:30 -0700224static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
225{
226 HDD2GHZCHAN(2412, 1, 0) ,
227 HDD2GHZCHAN(2437, 6, 0) ,
228 HDD2GHZCHAN(2462, 11, 0) ,
229};
Jeff Johnson295189b2012-06-20 16:38:30 -0700230
231static struct ieee80211_channel hdd_channels_5_GHZ[] =
232{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700233 HDD5GHZCHAN(4920, 240, 0) ,
234 HDD5GHZCHAN(4940, 244, 0) ,
235 HDD5GHZCHAN(4960, 248, 0) ,
236 HDD5GHZCHAN(4980, 252, 0) ,
237 HDD5GHZCHAN(5040, 208, 0) ,
238 HDD5GHZCHAN(5060, 212, 0) ,
239 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700240 HDD5GHZCHAN(5180, 36, 0) ,
241 HDD5GHZCHAN(5200, 40, 0) ,
242 HDD5GHZCHAN(5220, 44, 0) ,
243 HDD5GHZCHAN(5240, 48, 0) ,
244 HDD5GHZCHAN(5260, 52, 0) ,
245 HDD5GHZCHAN(5280, 56, 0) ,
246 HDD5GHZCHAN(5300, 60, 0) ,
247 HDD5GHZCHAN(5320, 64, 0) ,
248 HDD5GHZCHAN(5500,100, 0) ,
249 HDD5GHZCHAN(5520,104, 0) ,
250 HDD5GHZCHAN(5540,108, 0) ,
251 HDD5GHZCHAN(5560,112, 0) ,
252 HDD5GHZCHAN(5580,116, 0) ,
253 HDD5GHZCHAN(5600,120, 0) ,
254 HDD5GHZCHAN(5620,124, 0) ,
255 HDD5GHZCHAN(5640,128, 0) ,
256 HDD5GHZCHAN(5660,132, 0) ,
257 HDD5GHZCHAN(5680,136, 0) ,
258 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800259#ifdef FEATURE_WLAN_CH144
260 HDD5GHZCHAN(5720,144, 0) ,
261#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700262 HDD5GHZCHAN(5745,149, 0) ,
263 HDD5GHZCHAN(5765,153, 0) ,
264 HDD5GHZCHAN(5785,157, 0) ,
265 HDD5GHZCHAN(5805,161, 0) ,
266 HDD5GHZCHAN(5825,165, 0) ,
267};
268
269static struct ieee80211_rate g_mode_rates[] =
270{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530271 HDD_G_MODE_RATETAB(10, 0x1, 0),
272 HDD_G_MODE_RATETAB(20, 0x2, 0),
273 HDD_G_MODE_RATETAB(55, 0x4, 0),
274 HDD_G_MODE_RATETAB(110, 0x8, 0),
275 HDD_G_MODE_RATETAB(60, 0x10, 0),
276 HDD_G_MODE_RATETAB(90, 0x20, 0),
277 HDD_G_MODE_RATETAB(120, 0x40, 0),
278 HDD_G_MODE_RATETAB(180, 0x80, 0),
279 HDD_G_MODE_RATETAB(240, 0x100, 0),
280 HDD_G_MODE_RATETAB(360, 0x200, 0),
281 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700282 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530283};
Jeff Johnson295189b2012-06-20 16:38:30 -0700284
285static struct ieee80211_rate a_mode_rates[] =
286{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530287 HDD_G_MODE_RATETAB(60, 0x10, 0),
288 HDD_G_MODE_RATETAB(90, 0x20, 0),
289 HDD_G_MODE_RATETAB(120, 0x40, 0),
290 HDD_G_MODE_RATETAB(180, 0x80, 0),
291 HDD_G_MODE_RATETAB(240, 0x100, 0),
292 HDD_G_MODE_RATETAB(360, 0x200, 0),
293 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700294 HDD_G_MODE_RATETAB(540, 0x800, 0),
295};
296
297static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
298{
299 .channels = hdd_channels_2_4_GHZ,
300 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
301 .band = IEEE80211_BAND_2GHZ,
302 .bitrates = g_mode_rates,
303 .n_bitrates = g_mode_rates_size,
304 .ht_cap.ht_supported = 1,
305 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
306 | IEEE80211_HT_CAP_GRN_FLD
307 | IEEE80211_HT_CAP_DSSSCCK40
308 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
309 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
310 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
311 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
312 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
313 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
314};
315
Jeff Johnson295189b2012-06-20 16:38:30 -0700316static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
317{
318 .channels = hdd_social_channels_2_4_GHZ,
319 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
320 .band = IEEE80211_BAND_2GHZ,
321 .bitrates = g_mode_rates,
322 .n_bitrates = g_mode_rates_size,
323 .ht_cap.ht_supported = 1,
324 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
325 | IEEE80211_HT_CAP_GRN_FLD
326 | IEEE80211_HT_CAP_DSSSCCK40
327 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
328 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
329 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
330 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
331 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
332 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
333};
Jeff Johnson295189b2012-06-20 16:38:30 -0700334
335static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
336{
337 .channels = hdd_channels_5_GHZ,
338 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
339 .band = IEEE80211_BAND_5GHZ,
340 .bitrates = a_mode_rates,
341 .n_bitrates = a_mode_rates_size,
342 .ht_cap.ht_supported = 1,
343 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
344 | IEEE80211_HT_CAP_GRN_FLD
345 | IEEE80211_HT_CAP_DSSSCCK40
346 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
347 | IEEE80211_HT_CAP_SGI_40
348 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
349 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
350 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
351 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
352 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
353 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
354};
355
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530356/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700357 TX/RX direction for each kind of interface */
358static const struct ieee80211_txrx_stypes
359wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
360 [NL80211_IFTYPE_STATION] = {
361 .tx = 0xffff,
362 .rx = BIT(SIR_MAC_MGMT_ACTION) |
363 BIT(SIR_MAC_MGMT_PROBE_REQ),
364 },
365 [NL80211_IFTYPE_AP] = {
366 .tx = 0xffff,
367 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
368 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
369 BIT(SIR_MAC_MGMT_PROBE_REQ) |
370 BIT(SIR_MAC_MGMT_DISASSOC) |
371 BIT(SIR_MAC_MGMT_AUTH) |
372 BIT(SIR_MAC_MGMT_DEAUTH) |
373 BIT(SIR_MAC_MGMT_ACTION),
374 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700375 [NL80211_IFTYPE_ADHOC] = {
376 .tx = 0xffff,
377 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
378 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
379 BIT(SIR_MAC_MGMT_PROBE_REQ) |
380 BIT(SIR_MAC_MGMT_DISASSOC) |
381 BIT(SIR_MAC_MGMT_AUTH) |
382 BIT(SIR_MAC_MGMT_DEAUTH) |
383 BIT(SIR_MAC_MGMT_ACTION),
384 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700385 [NL80211_IFTYPE_P2P_CLIENT] = {
386 .tx = 0xffff,
387 .rx = BIT(SIR_MAC_MGMT_ACTION) |
388 BIT(SIR_MAC_MGMT_PROBE_REQ),
389 },
390 [NL80211_IFTYPE_P2P_GO] = {
391 /* This is also same as for SoftAP */
392 .tx = 0xffff,
393 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
394 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
395 BIT(SIR_MAC_MGMT_PROBE_REQ) |
396 BIT(SIR_MAC_MGMT_DISASSOC) |
397 BIT(SIR_MAC_MGMT_AUTH) |
398 BIT(SIR_MAC_MGMT_DEAUTH) |
399 BIT(SIR_MAC_MGMT_ACTION),
400 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700401};
402
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800403#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800404static const struct ieee80211_iface_limit
405wlan_hdd_iface_limit[] = {
406 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800407 /* max = 3 ; Our driver create two interfaces during driver init
408 * wlan0 and p2p0 interfaces. p2p0 is considered as station
409 * interface until a group is formed. In JB architecture, once the
410 * group is formed, interface type of p2p0 is changed to P2P GO or
411 * Client.
412 * When supplicant remove the group, it first issue a set interface
413 * cmd to change the mode back to Station. In JB this works fine as
414 * we advertize two station type interface during driver init.
415 * Some vendors create separate interface for P2P GO/Client,
416 * after group formation(Third one). But while group remove
417 * supplicant first tries to change the mode(3rd interface) to STATION
418 * But as we advertized only two sta type interfaces nl80211 was
419 * returning error for the third one which was leading to failure in
420 * delete interface. Ideally while removing the group, supplicant
421 * should not try to change the 3rd interface mode to Station type.
422 * Till we get a fix in wpa_supplicant, we advertize max STA
423 * interface type to 3
424 */
425 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800426 .types = BIT(NL80211_IFTYPE_STATION),
427 },
428 {
429 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700430 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800431 },
432 {
433 .max = 1,
434 .types = BIT(NL80211_IFTYPE_P2P_GO) |
435 BIT(NL80211_IFTYPE_P2P_CLIENT),
436 },
437};
438
439/* By default, only single channel concurrency is allowed */
440static struct ieee80211_iface_combination
441wlan_hdd_iface_combination = {
442 .limits = wlan_hdd_iface_limit,
443 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800444 /*
445 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
446 * and p2p0 interfaces during driver init
447 * Some vendors create separate interface for P2P operations.
448 * wlan0: STA interface
449 * p2p0: P2P Device interface, action frames goes
450 * through this interface.
451 * p2p-xx: P2P interface, After GO negotiation this interface is
452 * created for p2p operations(GO/CLIENT interface).
453 */
454 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800455 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
456 .beacon_int_infra_match = false,
457};
458#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800459
Jeff Johnson295189b2012-06-20 16:38:30 -0700460static struct cfg80211_ops wlan_hdd_cfg80211_ops;
461
462/* Data rate 100KBPS based on IE Index */
463struct index_data_rate_type
464{
465 v_U8_t beacon_rate_index;
466 v_U16_t supported_rate[4];
467};
468
469/* 11B, 11G Rate table include Basic rate and Extended rate
470 The IDX field is the rate index
471 The HI field is the rate when RSSI is strong or being ignored
472 (in this case we report actual rate)
473 The MID field is the rate when RSSI is moderate
474 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
475 The LO field is the rate when RSSI is low
476 (in this case we don't report rates, actual current rate used)
477 */
478static const struct
479{
480 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700481 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700482} supported_data_rate[] =
483{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700484/* IDX HI HM LM LO (RSSI-based index */
485 {2, { 10, 10, 10, 0}},
486 {4, { 20, 20, 10, 0}},
487 {11, { 55, 20, 10, 0}},
488 {12, { 60, 55, 20, 0}},
489 {18, { 90, 55, 20, 0}},
490 {22, {110, 55, 20, 0}},
491 {24, {120, 90, 60, 0}},
492 {36, {180, 120, 60, 0}},
493 {44, {220, 180, 60, 0}},
494 {48, {240, 180, 90, 0}},
495 {66, {330, 180, 90, 0}},
496 {72, {360, 240, 90, 0}},
497 {96, {480, 240, 120, 0}},
498 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700499};
500
501/* MCS Based rate table */
502static struct index_data_rate_type supported_mcs_rate[] =
503{
504/* MCS L20 L40 S20 S40 */
505 {0, {65, 135, 72, 150}},
506 {1, {130, 270, 144, 300}},
507 {2, {195, 405, 217, 450}},
508 {3, {260, 540, 289, 600}},
509 {4, {390, 810, 433, 900}},
510 {5, {520, 1080, 578, 1200}},
511 {6, {585, 1215, 650, 1350}},
512 {7, {650, 1350, 722, 1500}}
513};
514
Leo Chang6f8870f2013-03-26 18:11:36 -0700515#ifdef WLAN_FEATURE_11AC
516
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530517#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700518
519struct index_vht_data_rate_type
520{
521 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530522 v_U16_t supported_VHT80_rate[2];
523 v_U16_t supported_VHT40_rate[2];
524 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700525};
526
527typedef enum
528{
529 DATA_RATE_11AC_MAX_MCS_7,
530 DATA_RATE_11AC_MAX_MCS_8,
531 DATA_RATE_11AC_MAX_MCS_9,
532 DATA_RATE_11AC_MAX_MCS_NA
533} eDataRate11ACMaxMcs;
534
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +0530535/* SSID broadcast type */
536typedef enum eSSIDBcastType
537{
538 eBCAST_UNKNOWN = 0,
539 eBCAST_NORMAL = 1,
540 eBCAST_HIDDEN = 2,
541} tSSIDBcastType;
542
Leo Chang6f8870f2013-03-26 18:11:36 -0700543/* MCS Based VHT rate table */
544static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
545{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530546/* MCS L80 S80 L40 S40 L20 S40*/
547 {0, {293, 325}, {135, 150}, {65, 72}},
548 {1, {585, 650}, {270, 300}, {130, 144}},
549 {2, {878, 975}, {405, 450}, {195, 217}},
550 {3, {1170, 1300}, {540, 600}, {260, 289}},
551 {4, {1755, 1950}, {810, 900}, {390, 433}},
552 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
553 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
554 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
555 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
556 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700557};
558#endif /* WLAN_FEATURE_11AC */
559
c_hpothu79aab322014-07-14 21:11:01 +0530560/*array index points to MCS and array value points respective rssi*/
561static int rssiMcsTbl[][10] =
562{
563/*MCS 0 1 2 3 4 5 6 7 8 9*/
564 {-82, -79, -77, -74, -70, -66, -65, -64, -59, -57}, //20
565 {-79, -76, -74, -71, -67, -63, -62, -61, -56, -54}, //40
566 {-76, -73, -71, -68, -64, -60, -59, -58, -53, -51} //80
567};
568
Jeff Johnson295189b2012-06-20 16:38:30 -0700569extern struct net_device_ops net_ops_struct;
Dasari Srinivas7875a302014-09-26 17:50:57 +0530570#ifdef FEATURE_WLAN_SCAN_PNO
571static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter);
572#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700573
Leo Chang9056f462013-08-01 19:21:11 -0700574#ifdef WLAN_NL80211_TESTMODE
575enum wlan_hdd_tm_attr
576{
577 WLAN_HDD_TM_ATTR_INVALID = 0,
578 WLAN_HDD_TM_ATTR_CMD = 1,
579 WLAN_HDD_TM_ATTR_DATA = 2,
580 WLAN_HDD_TM_ATTR_TYPE = 3,
581 /* keep last */
582 WLAN_HDD_TM_ATTR_AFTER_LAST,
583 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
584};
585
586enum wlan_hdd_tm_cmd
587{
588 WLAN_HDD_TM_CMD_WLAN_HB = 1,
589};
590
591#define WLAN_HDD_TM_DATA_MAX_LEN 5000
592
593static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
594{
595 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
596 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
597 .len = WLAN_HDD_TM_DATA_MAX_LEN },
598};
599#endif /* WLAN_NL80211_TESTMODE */
600
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800601#ifdef FEATURE_WLAN_CH_AVOID
602/*
603 * FUNCTION: wlan_hdd_send_avoid_freq_event
604 * This is called when wlan driver needs to send vendor specific
605 * avoid frequency range event to userspace
606 */
607int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
608 tHddAvoidFreqList *pAvoidFreqList)
609{
610 struct sk_buff *vendor_event;
611
612 ENTER();
613
614 if (!pHddCtx)
615 {
616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
617 "%s: HDD context is null", __func__);
618 return -1;
619 }
620
621 if (!pAvoidFreqList)
622 {
623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
624 "%s: pAvoidFreqList is null", __func__);
625 return -1;
626 }
627
628 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
629 sizeof(tHddAvoidFreqList),
Sunil Duttc69bccb2014-05-26 21:30:20 +0530630 QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800631 GFP_KERNEL);
632 if (!vendor_event)
633 {
634 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
635 "%s: cfg80211_vendor_event_alloc failed", __func__);
636 return -1;
637 }
638
639 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
640 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
641
642 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
643
644 EXIT();
645 return 0;
646}
647#endif /* FEATURE_WLAN_CH_AVOID */
648
Sunil Duttc69bccb2014-05-26 21:30:20 +0530649#ifdef WLAN_FEATURE_LINK_LAYER_STATS
650
651static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
652 struct sk_buff *vendor_event)
653{
654 if (nla_put_u8(vendor_event,
655 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
656 stats->rate.preamble) ||
657 nla_put_u8(vendor_event,
658 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
659 stats->rate.nss) ||
660 nla_put_u8(vendor_event,
661 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
662 stats->rate.bw) ||
663 nla_put_u8(vendor_event,
664 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
665 stats->rate.rateMcsIdx) ||
666 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
667 stats->rate.bitrate ) ||
668 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
669 stats->txMpdu ) ||
670 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
671 stats->rxMpdu ) ||
672 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
673 stats->mpduLost ) ||
674 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
675 stats->retries) ||
676 nla_put_u32(vendor_event,
677 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
678 stats->retriesShort ) ||
679 nla_put_u32(vendor_event,
680 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
681 stats->retriesLong))
682 {
683 hddLog(VOS_TRACE_LEVEL_ERROR,
684 FL("QCA_WLAN_VENDOR_ATTR put fail"));
685 return FALSE;
686 }
687 return TRUE;
688}
689
690static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
691 struct sk_buff *vendor_event)
692{
693 u32 i = 0;
694 struct nlattr *rateInfo;
695 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
696 stats->type) ||
697 nla_put(vendor_event,
698 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
699 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
700 nla_put_u32(vendor_event,
701 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
702 stats->capabilities) ||
703 nla_put_u32(vendor_event,
704 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
705 stats->numRate))
706 {
707 hddLog(VOS_TRACE_LEVEL_ERROR,
708 FL("QCA_WLAN_VENDOR_ATTR put fail"));
709 goto error;
710 }
711
712 rateInfo = nla_nest_start(vendor_event,
713 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
714 for (i = 0; i < stats->numRate; i++)
715 {
716 struct nlattr *rates;
717 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
718 stats->rateStats +
719 (i * sizeof(tSirWifiRateStat)));
720 rates = nla_nest_start(vendor_event, i);
721
722 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
723 {
724 hddLog(VOS_TRACE_LEVEL_ERROR,
725 FL("QCA_WLAN_VENDOR_ATTR put fail"));
726 return FALSE;
727 }
728 nla_nest_end(vendor_event, rates);
729 }
730 nla_nest_end(vendor_event, rateInfo);
731
732 return TRUE;
733error:
734 return FALSE;
735}
736
737static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
738 struct sk_buff *vendor_event)
739{
740 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
741 stats->ac ) ||
742 nla_put_u32(vendor_event,
743 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
744 stats->txMpdu ) ||
745 nla_put_u32(vendor_event,
746 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
747 stats->rxMpdu ) ||
748 nla_put_u32(vendor_event,
749 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
750 stats->txMcast ) ||
751 nla_put_u32(vendor_event,
752 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
753 stats->rxMcast ) ||
754 nla_put_u32(vendor_event,
755 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
756 stats->rxAmpdu ) ||
757 nla_put_u32(vendor_event,
758 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
759 stats->txAmpdu ) ||
760 nla_put_u32(vendor_event,
761 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
762 stats->mpduLost )||
763 nla_put_u32(vendor_event,
764 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
765 stats->retries ) ||
766 nla_put_u32(vendor_event,
767 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
768 stats->retriesShort ) ||
769 nla_put_u32(vendor_event,
770 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
771 stats->retriesLong ) ||
772 nla_put_u32(vendor_event,
773 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
774 stats->contentionTimeMin ) ||
775 nla_put_u32(vendor_event,
776 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
777 stats->contentionTimeMax ) ||
778 nla_put_u32(vendor_event,
779 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
780 stats->contentionTimeAvg ) ||
781 nla_put_u32(vendor_event,
782 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
783 stats->contentionNumSamples ))
784 {
785 hddLog(VOS_TRACE_LEVEL_ERROR,
786 FL("QCA_WLAN_VENDOR_ATTR put fail") );
787 return FALSE;
788 }
789 return TRUE;
790}
791
792static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
793 struct sk_buff *vendor_event)
794{
Dino Myclec8f3f332014-07-21 16:48:27 +0530795 if (nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530796 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
797 nla_put(vendor_event,
798 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
799 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
800 nla_put_u32(vendor_event,
801 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
802 stats->state ) ||
803 nla_put_u32(vendor_event,
804 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
805 stats->roaming ) ||
806 nla_put_u32(vendor_event,
807 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
808 stats->capabilities ) ||
809 nla_put(vendor_event,
810 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
811 strlen(stats->ssid), stats->ssid) ||
812 nla_put(vendor_event,
813 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
814 WNI_CFG_BSSID_LEN, stats->bssid) ||
815 nla_put(vendor_event,
816 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
817 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
818 nla_put(vendor_event,
819 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
820 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
821 )
822 {
823 hddLog(VOS_TRACE_LEVEL_ERROR,
824 FL("QCA_WLAN_VENDOR_ATTR put fail") );
825 return FALSE;
826 }
827 return TRUE;
828}
829
Dino Mycle3b9536d2014-07-09 22:05:24 +0530830static v_BOOL_t put_wifi_iface_stats(hdd_adapter_t *pAdapter,
831 tpSirWifiIfaceStat pWifiIfaceStat,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530832 struct sk_buff *vendor_event)
833{
834 int i = 0;
835 struct nlattr *wmmInfo;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530836 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
837 WLANTL_InterfaceStatsType *pWifiIfaceStatTL = NULL;
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530838 tSirWifiWmmAcStat accessclassStats;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530839
Sunil Duttc69bccb2014-05-26 21:30:20 +0530840 if (FALSE == put_wifi_interface_info(
841 &pWifiIfaceStat->info,
842 vendor_event))
843 {
844 hddLog(VOS_TRACE_LEVEL_ERROR,
845 FL("QCA_WLAN_VENDOR_ATTR put fail") );
846 return FALSE;
847
848 }
Dino Mycle3b9536d2014-07-09 22:05:24 +0530849 pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *)
850 vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType));
851 if (NULL == pWifiIfaceStatTL)
852 {
853 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
854 return FALSE;
855 }
856
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530857 accessclassStats = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK];
858 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK] =
859 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE];
860 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE] = accessclassStats;
861
862 accessclassStats.ac = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac;
863 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac =
864 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac;
865 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac = accessclassStats.ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530866
867 if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED)
868 {
869 if (VOS_STATUS_SUCCESS ==
870 WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
871 pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL))
872 {
873 /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are
874 * obtained from TL structure
875 */
876
877 pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx +
878 pWifiIfaceStatTL->mgmtRx;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530879 pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData;
880
Srinivas Dasari98947432014-11-07 19:41:24 +0530881 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMcast
882 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMcast;
883 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMcast
884 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMcast;
885 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMcast
886 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMcast;
887 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMcast
888 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMcast;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530889
Srinivas Dasari98947432014-11-07 19:41:24 +0530890 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMpdu
891 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMpdu;
892 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMpdu
893 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMpdu;
894 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMpdu
895 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMpdu;
896 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMpdu
897 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530898
Srinivas Dasari98947432014-11-07 19:41:24 +0530899 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxAmpdu
900 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxAmpdu;
901 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxAmpdu
902 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxAmpdu;
903 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxAmpdu
904 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxAmpdu;
905 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxAmpdu
906 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxAmpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530907 }
908 else
909 {
910 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL"));
911 }
912
Dino Mycle3b9536d2014-07-09 22:05:24 +0530913 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast =
914 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO];
915 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast =
916 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI];
917 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast =
918 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE];
919 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast =
920 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK];
921 }
922 else
923 {
924 hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated"));
925 }
926
927
Sunil Duttc69bccb2014-05-26 21:30:20 +0530928
929 if (nla_put_u32(vendor_event,
930 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
931 pWifiIfaceStat->beaconRx) ||
932 nla_put_u32(vendor_event,
933 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
934 pWifiIfaceStat->mgmtRx) ||
935 nla_put_u32(vendor_event,
936 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
937 pWifiIfaceStat->mgmtActionRx) ||
938 nla_put_u32(vendor_event,
939 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
940 pWifiIfaceStat->mgmtActionTx) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +0530941 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530942 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
943 pWifiIfaceStat->rssiMgmt) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +0530944 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530945 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
946 pWifiIfaceStat->rssiData) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +0530947 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530948 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
949 pWifiIfaceStat->rssiAck))
950 {
951 hddLog(VOS_TRACE_LEVEL_ERROR,
952 FL("QCA_WLAN_VENDOR_ATTR put fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +0530953 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +0530954 return FALSE;
955 }
956
957 wmmInfo = nla_nest_start(vendor_event,
958 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
959 for (i = 0; i < WIFI_AC_MAX; i++)
960 {
961 struct nlattr *wmmStats;
962 wmmStats = nla_nest_start(vendor_event, i);
963 if (FALSE == put_wifi_wmm_ac_stat(
964 &pWifiIfaceStat->AccessclassStats[i],
965 vendor_event))
966 {
967 hddLog(VOS_TRACE_LEVEL_ERROR,
968 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +0530969 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +0530970 return FALSE;
971 }
972
973 nla_nest_end(vendor_event, wmmStats);
974 }
975 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +0530976 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +0530977 return TRUE;
978}
979
980static tSirWifiInterfaceMode
981 hdd_map_device_to_ll_iface_mode ( int deviceMode )
982{
983 switch (deviceMode)
984 {
985 case WLAN_HDD_INFRA_STATION:
986 return WIFI_INTERFACE_STA;
987 case WLAN_HDD_SOFTAP:
988 return WIFI_INTERFACE_SOFTAP;
989 case WLAN_HDD_P2P_CLIENT:
990 return WIFI_INTERFACE_P2P_CLIENT;
991 case WLAN_HDD_P2P_GO:
992 return WIFI_INTERFACE_P2P_GO;
993 case WLAN_HDD_IBSS:
994 return WIFI_INTERFACE_IBSS;
995 default:
Dino Myclec8f3f332014-07-21 16:48:27 +0530996 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530997 }
998}
999
1000static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
1001 tpSirWifiInterfaceInfo pInfo)
1002{
1003 v_U8_t *staMac = NULL;
1004 hdd_station_ctx_t *pHddStaCtx;
1005 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1006 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1007
1008 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
1009
1010 vos_mem_copy(pInfo->macAddr,
1011 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1012
1013 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1014 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
1015 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
1016 {
1017 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1018 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
1019 {
1020 pInfo->state = WIFI_DISCONNECTED;
1021 }
1022 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
1023 {
1024 hddLog(VOS_TRACE_LEVEL_ERROR,
1025 "%s: Session ID %d, Connection is in progress", __func__,
1026 pAdapter->sessionId);
1027 pInfo->state = WIFI_ASSOCIATING;
1028 }
1029 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1030 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
1031 {
1032 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
1033 hddLog(VOS_TRACE_LEVEL_ERROR,
1034 "%s: client " MAC_ADDRESS_STR
1035 " is in the middle of WPS/EAPOL exchange.", __func__,
1036 MAC_ADDR_ARRAY(staMac));
1037 pInfo->state = WIFI_AUTHENTICATING;
1038 }
1039 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1040 {
1041 pInfo->state = WIFI_ASSOCIATED;
1042 vos_mem_copy(pInfo->bssid,
1043 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
1044 vos_mem_copy(pInfo->ssid,
1045 pHddStaCtx->conn_info.SSID.SSID.ssId,
1046 pHddStaCtx->conn_info.SSID.SSID.length);
1047 //NULL Terminate the string.
1048 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
1049 }
1050 }
1051 vos_mem_copy(pInfo->countryStr,
1052 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1053
1054 vos_mem_copy(pInfo->apCountryStr,
1055 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1056
1057 return TRUE;
1058}
1059
1060/*
1061 * hdd_link_layer_process_peer_stats () - This function is called after
1062 * receiving Link Layer Peer statistics from FW.This function converts
1063 * the firmware data to the NL data and sends the same to the kernel/upper
1064 * layers.
1065 */
1066static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
1067 v_VOID_t *pData)
1068{
1069 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1070 tpSirWifiRateStat pWifiRateStat;
1071 tpSirWifiPeerStat pWifiPeerStat;
1072 tpSirWifiPeerInfo pWifiPeerInfo;
1073 struct nlattr *peerInfo;
1074 struct sk_buff *vendor_event;
1075 int status, i;
1076
1077 status = wlan_hdd_validate_context(pHddCtx);
1078 if (0 != status)
1079 {
1080 hddLog(VOS_TRACE_LEVEL_ERROR,
1081 FL("HDD context is not valid") );
1082 return;
1083 }
1084
1085 pWifiPeerStat = (tpSirWifiPeerStat) pData;
1086
1087 hddLog(VOS_TRACE_LEVEL_INFO,
1088 "LL_STATS_PEER_ALL : numPeers %u",
1089 pWifiPeerStat->numPeers);
1090 {
1091 for (i = 0; i < pWifiPeerStat->numPeers; i++)
1092 {
1093 pWifiPeerInfo = (tpSirWifiPeerInfo)
1094 ((uint8 *)pWifiPeerStat->peerInfo +
1095 ( i * sizeof(tSirWifiPeerInfo)));
1096
Dasari Srinivas1be0c4e2014-10-19 13:03:41 +05301097 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) {
1098 pWifiPeerInfo->type = WIFI_PEER_AP;
1099 }
1100 if (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) {
1101 pWifiPeerInfo->type = WIFI_PEER_P2P_GO;
1102 }
1103
Sunil Duttc69bccb2014-05-26 21:30:20 +05301104 hddLog(VOS_TRACE_LEVEL_INFO,
1105 " %d) LL_STATS Channel Stats "
1106 " Peer Type %u "
1107 " peerMacAddress %pM "
1108 " capabilities 0x%x "
1109 " numRate %u ",
1110 i,
1111 pWifiPeerInfo->type,
1112 pWifiPeerInfo->peerMacAddress,
1113 pWifiPeerInfo->capabilities,
1114 pWifiPeerInfo->numRate);
1115 {
1116 int j;
1117 for (j = 0; j < pWifiPeerInfo->numRate; j++)
1118 {
1119 pWifiRateStat = (tpSirWifiRateStat)
1120 ((tANI_U8 *) pWifiPeerInfo->rateStats +
1121 ( j * sizeof(tSirWifiRateStat)));
1122
1123 hddLog(VOS_TRACE_LEVEL_INFO,
1124 " peer Rate Stats "
1125 " preamble %u "
1126 " nss %u "
1127 " bw %u "
1128 " rateMcsIdx %u "
1129 " reserved %u "
1130 " bitrate %u "
1131 " txMpdu %u "
1132 " rxMpdu %u "
1133 " mpduLost %u "
1134 " retries %u "
1135 " retriesShort %u "
1136 " retriesLong %u",
1137 pWifiRateStat->rate.preamble,
1138 pWifiRateStat->rate.nss,
1139 pWifiRateStat->rate.bw,
1140 pWifiRateStat->rate.rateMcsIdx,
1141 pWifiRateStat->rate.reserved,
1142 pWifiRateStat->rate.bitrate,
1143 pWifiRateStat->txMpdu,
1144 pWifiRateStat->rxMpdu,
1145 pWifiRateStat->mpduLost,
1146 pWifiRateStat->retries,
1147 pWifiRateStat->retriesShort,
1148 pWifiRateStat->retriesLong);
1149 }
1150 }
1151 }
1152 }
1153
1154 /*
1155 * Allocate a size of 4096 for the peer stats comprising
1156 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1157 * sizeof (tSirWifiRateStat).Each field is put with an
1158 * NL attribute.The size of 4096 is considered assuming
1159 * that number of rates shall not exceed beyond 50 with
1160 * the sizeof (tSirWifiRateStat) being 32.
1161 */
1162 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1163 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1164 QCA_NL80211_VENDOR_SUBCMD_LL_PEER_INFO_STATS_INDEX,
1165 GFP_KERNEL);
1166 if (!vendor_event)
1167 {
1168 hddLog(VOS_TRACE_LEVEL_ERROR,
1169 "%s: cfg80211_vendor_event_alloc failed",
1170 __func__);
1171 return;
1172 }
1173 if (nla_put_u32(vendor_event,
1174 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1175 pWifiPeerStat->numPeers))
1176 {
1177 hddLog(VOS_TRACE_LEVEL_ERROR,
1178 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1179 kfree_skb(vendor_event);
1180 return;
1181 }
1182
1183 peerInfo = nla_nest_start(vendor_event,
1184 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
1185
1186 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1187 pWifiPeerStat->peerInfo);
1188
1189 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1190 {
1191 struct nlattr *peers = nla_nest_start(vendor_event, i);
1192 int numRate = pWifiPeerInfo->numRate;
1193
1194 if (FALSE == put_wifi_peer_info(
1195 pWifiPeerInfo, vendor_event))
1196 {
1197 hddLog(VOS_TRACE_LEVEL_ERROR,
1198 "%s: put_wifi_peer_info put fail", __func__);
1199 kfree_skb(vendor_event);
1200 return;
1201 }
1202
1203 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1204 pWifiPeerStat->peerInfo +
1205 (i * sizeof(tSirWifiPeerInfo)) +
1206 (numRate * sizeof (tSirWifiRateStat)));
1207 nla_nest_end(vendor_event, peers);
1208 }
1209 nla_nest_end(vendor_event, peerInfo);
1210 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
1211}
1212
1213/*
1214 * hdd_link_layer_process_iface_stats () - This function is called after
1215 * receiving Link Layer Interface statistics from FW.This function converts
1216 * the firmware data to the NL data and sends the same to the kernel/upper
1217 * layers.
1218 */
1219static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1220 v_VOID_t *pData)
1221{
1222 tpSirWifiIfaceStat pWifiIfaceStat;
1223 struct sk_buff *vendor_event;
1224 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1225 int status;
1226
1227 status = wlan_hdd_validate_context(pHddCtx);
1228 if (0 != status)
1229 {
1230 hddLog(VOS_TRACE_LEVEL_ERROR,
1231 FL("HDD context is not valid") );
1232 return;
1233 }
1234 /*
1235 * Allocate a size of 4096 for the interface stats comprising
1236 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1237 * assuming that all these fit with in the limit.Please take
1238 * a call on the limit based on the data requirements on
1239 * interface statistics.
1240 */
1241 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1242 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1243 QCA_NL80211_VENDOR_SUBCMD_LL_IFACE_STATS_INDEX,
1244 GFP_KERNEL);
1245 if (!vendor_event)
1246 {
1247 hddLog(VOS_TRACE_LEVEL_ERROR,
1248 FL("cfg80211_vendor_event_alloc failed") );
1249 return;
1250 }
1251
1252 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1253
Dino Mycle3b9536d2014-07-09 22:05:24 +05301254
1255 if (FALSE == hdd_get_interface_info( pAdapter,
1256 &pWifiIfaceStat->info))
1257 {
1258 hddLog(VOS_TRACE_LEVEL_ERROR,
1259 FL("hdd_get_interface_info get fail") );
1260 kfree_skb(vendor_event);
1261 return;
1262 }
1263
1264 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
1265 vendor_event))
1266 {
1267 hddLog(VOS_TRACE_LEVEL_ERROR,
1268 FL("put_wifi_iface_stats fail") );
1269 kfree_skb(vendor_event);
1270 return;
1271 }
1272
Sunil Duttc69bccb2014-05-26 21:30:20 +05301273 hddLog(VOS_TRACE_LEVEL_INFO,
1274 "WMI_LINK_STATS_IFACE Data");
1275
1276 hddLog(VOS_TRACE_LEVEL_INFO,
1277 "LL_STATS_IFACE: "
1278 " Mode %u "
1279 " MAC %pM "
1280 " State %u "
1281 " Roaming %u "
1282 " capabilities 0x%x "
1283 " SSID %s "
1284 " BSSID %pM",
1285 pWifiIfaceStat->info.mode,
1286 pWifiIfaceStat->info.macAddr,
1287 pWifiIfaceStat->info.state,
1288 pWifiIfaceStat->info.roaming,
1289 pWifiIfaceStat->info.capabilities,
1290 pWifiIfaceStat->info.ssid,
1291 pWifiIfaceStat->info.bssid);
1292
1293 hddLog(VOS_TRACE_LEVEL_INFO,
1294 " AP country str: %c%c%c",
1295 pWifiIfaceStat->info.apCountryStr[0],
1296 pWifiIfaceStat->info.apCountryStr[1],
1297 pWifiIfaceStat->info.apCountryStr[2]);
1298
1299
1300 hddLog(VOS_TRACE_LEVEL_INFO,
1301 " Country Str Association: %c%c%c",
1302 pWifiIfaceStat->info.countryStr[0],
1303 pWifiIfaceStat->info.countryStr[1],
1304 pWifiIfaceStat->info.countryStr[2]);
1305
1306 hddLog(VOS_TRACE_LEVEL_INFO,
1307 " beaconRx %u "
1308 " mgmtRx %u "
1309 " mgmtActionRx %u "
1310 " mgmtActionTx %u "
Dino Mycle3b9536d2014-07-09 22:05:24 +05301311 " rssiMgmt %d "
1312 " rssiData %d "
1313 " rssiAck %d",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301314 pWifiIfaceStat->beaconRx,
1315 pWifiIfaceStat->mgmtRx,
1316 pWifiIfaceStat->mgmtActionRx,
1317 pWifiIfaceStat->mgmtActionTx,
1318 pWifiIfaceStat->rssiMgmt,
1319 pWifiIfaceStat->rssiData,
1320 pWifiIfaceStat->rssiAck );
1321
1322
1323 {
1324 int i;
1325 for (i = 0 ; i < WIFI_AC_MAX; i ++)
1326 {
1327 hddLog(VOS_TRACE_LEVEL_INFO,
1328
1329 " %d) LL_STATS IFACE: "
1330 " ac: %u txMpdu: %u "
1331 " rxMpdu: %u txMcast: %u "
1332 " rxMcast: %u rxAmpdu: %u "
1333 " txAmpdu: %u mpduLost: %u "
1334 " retries: %u retriesShort: %u "
1335 " retriesLong: %u contentionTimeMin: %u "
1336 " contentionTimeMax: %u contentionTimeAvg: %u "
1337 " contentionNumSamples: %u",
1338 i,
1339 pWifiIfaceStat->AccessclassStats[i].ac,
1340 pWifiIfaceStat->AccessclassStats[i].txMpdu,
1341 pWifiIfaceStat->AccessclassStats[i].rxMpdu,
1342 pWifiIfaceStat->AccessclassStats[i].txMcast,
1343 pWifiIfaceStat->AccessclassStats[i].rxMcast,
1344 pWifiIfaceStat->AccessclassStats[i].rxAmpdu,
1345 pWifiIfaceStat->AccessclassStats[i].txAmpdu,
1346 pWifiIfaceStat->AccessclassStats[i].mpduLost,
1347 pWifiIfaceStat->AccessclassStats[i].retries,
1348 pWifiIfaceStat->
1349 AccessclassStats[i].retriesShort,
1350 pWifiIfaceStat->AccessclassStats[i].retriesLong,
1351 pWifiIfaceStat->
1352 AccessclassStats[i].contentionTimeMin,
1353 pWifiIfaceStat->
1354 AccessclassStats[i].contentionTimeMax,
1355 pWifiIfaceStat->
1356 AccessclassStats[i].contentionTimeAvg,
1357 pWifiIfaceStat->
1358 AccessclassStats[i].contentionNumSamples);
1359
1360 }
1361 }
1362
Sunil Duttc69bccb2014-05-26 21:30:20 +05301363 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
1364}
1365
1366/*
1367 * hdd_link_layer_process_radio_stats () - This function is called after
1368 * receiving Link Layer Radio statistics from FW.This function converts
1369 * the firmware data to the NL data and sends the same to the kernel/upper
1370 * layers.
1371 */
1372static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1373 v_VOID_t *pData)
1374{
1375 int status, i;
1376 tpSirWifiRadioStat pWifiRadioStat;
1377 tpSirWifiChannelStats pWifiChannelStats;
1378 struct sk_buff *vendor_event;
1379 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1380 struct nlattr *chList;
1381
1382 status = wlan_hdd_validate_context(pHddCtx);
1383 if (0 != status)
1384 {
1385 hddLog(VOS_TRACE_LEVEL_ERROR,
1386 FL("HDD context is not valid") );
1387 return;
1388 }
1389 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1390
1391 hddLog(VOS_TRACE_LEVEL_INFO,
1392 "LL_STATS_RADIO"
1393 " radio is %d onTime is %u "
1394 " txTime is %u rxTime is %u "
1395 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05301396 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05301397 " onTimePnoScan is %u onTimeHs20 is %u "
1398 " numChannels is %u",
1399 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1400 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1401 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301402 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301403 pWifiRadioStat->onTimeRoamScan,
1404 pWifiRadioStat->onTimePnoScan,
1405 pWifiRadioStat->onTimeHs20,
1406 pWifiRadioStat->numChannels);
1407 /*
1408 * Allocate a size of 4096 for the Radio stats comprising
1409 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1410 * (tSirWifiChannelStats).Each channel data is put with an
1411 * NL attribute.The size of 4096 is considered assuming that
1412 * number of channels shall not exceed beyond 60 with the
1413 * sizeof (tSirWifiChannelStats) being 24 bytes.
1414 */
1415
1416 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1417 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN ,
1418 QCA_NL80211_VENDOR_SUBCMD_LL_RADIO_STATS_INDEX,
1419 GFP_KERNEL);
1420
1421 if (!vendor_event)
1422 {
1423 hddLog(VOS_TRACE_LEVEL_ERROR,
1424 FL("cfg80211_vendor_event_alloc failed") );
1425 return;
1426 }
1427
1428 if (nla_put_u32(vendor_event,
1429 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1430 pWifiRadioStat->radio) ||
1431 nla_put_u32(vendor_event,
1432 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1433 pWifiRadioStat->onTime) ||
1434 nla_put_u32(vendor_event,
1435 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1436 pWifiRadioStat->txTime) ||
1437 nla_put_u32(vendor_event,
1438 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1439 pWifiRadioStat->rxTime) ||
1440 nla_put_u32(vendor_event,
1441 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1442 pWifiRadioStat->onTimeScan) ||
1443 nla_put_u32(vendor_event,
1444 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1445 pWifiRadioStat->onTimeNbd) ||
1446 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301447 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
1448 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05301449 nla_put_u32(vendor_event,
1450 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1451 pWifiRadioStat->onTimeRoamScan) ||
1452 nla_put_u32(vendor_event,
1453 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1454 pWifiRadioStat->onTimePnoScan) ||
1455 nla_put_u32(vendor_event,
1456 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1457 pWifiRadioStat->onTimeHs20) ||
1458 nla_put_u32(vendor_event,
1459 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1460 pWifiRadioStat->numChannels))
1461 {
1462 hddLog(VOS_TRACE_LEVEL_ERROR,
1463 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1464 kfree_skb(vendor_event);
1465 return ;
1466 }
1467
1468 chList = nla_nest_start(vendor_event,
1469 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
1470 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1471 {
1472 struct nlattr *chInfo;
1473
1474 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1475 pWifiRadioStat->channels +
1476 (i * sizeof(tSirWifiChannelStats)));
1477
1478 hddLog(VOS_TRACE_LEVEL_INFO,
1479 " %d) Channel Info"
1480 " width is %u "
1481 " CenterFreq %u "
1482 " CenterFreq0 %u "
1483 " CenterFreq1 %u "
1484 " onTime %u "
1485 " ccaBusyTime %u",
1486 i,
1487 pWifiChannelStats->channel.width,
1488 pWifiChannelStats->channel.centerFreq,
1489 pWifiChannelStats->channel.centerFreq0,
1490 pWifiChannelStats->channel.centerFreq1,
1491 pWifiChannelStats->onTime,
1492 pWifiChannelStats->ccaBusyTime);
1493
1494
1495 chInfo = nla_nest_start(vendor_event, i);
1496
1497 if (nla_put_u32(vendor_event,
1498 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1499 pWifiChannelStats->channel.width) ||
1500 nla_put_u32(vendor_event,
1501 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1502 pWifiChannelStats->channel.centerFreq) ||
1503 nla_put_u32(vendor_event,
1504 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1505 pWifiChannelStats->channel.centerFreq0) ||
1506 nla_put_u32(vendor_event,
1507 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1508 pWifiChannelStats->channel.centerFreq1) ||
1509 nla_put_u32(vendor_event,
1510 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1511 pWifiChannelStats->onTime) ||
1512 nla_put_u32(vendor_event,
1513 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1514 pWifiChannelStats->ccaBusyTime))
1515 {
1516 hddLog(VOS_TRACE_LEVEL_ERROR,
1517 FL("cfg80211_vendor_event_alloc failed") );
1518 kfree_skb(vendor_event);
1519 return ;
1520 }
1521 nla_nest_end(vendor_event, chInfo);
1522 }
1523 nla_nest_end(vendor_event, chList);
1524
1525 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
1526 return;
1527}
1528
1529/*
1530 * hdd_link_layer_stats_ind_callback () - This function is called after
1531 * receiving Link Layer indications from FW.This callback converts the firmware
1532 * data to the NL data and send the same to the kernel/upper layers.
1533 */
1534static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1535 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05301536 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301537{
Dino Mycled3d50022014-07-07 12:58:25 +05301538 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
1539 hdd_adapter_t *pAdapter = NULL;
1540 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301541 int status;
1542
1543 status = wlan_hdd_validate_context(pHddCtx);
1544
1545 if (0 != status)
1546 {
1547 hddLog(VOS_TRACE_LEVEL_ERROR,
1548 FL("HDD context is not valid"));
1549 return;
1550 }
1551
Dino Mycled3d50022014-07-07 12:58:25 +05301552
1553
1554 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
1555 if (NULL == pAdapter)
1556 {
1557 hddLog(VOS_TRACE_LEVEL_ERROR,
1558 FL(" MAC address %pM does not exist with host"),
1559 macAddr);
1560 return;
1561 }
1562
Sunil Duttc69bccb2014-05-26 21:30:20 +05301563 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301564 "%s: Interface: %s LLStats indType: %d", __func__,
1565 pAdapter->dev->name, indType);
1566
Sunil Duttc69bccb2014-05-26 21:30:20 +05301567 switch (indType)
1568 {
1569 case SIR_HAL_LL_STATS_RESULTS_RSP:
1570 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301571 hddLog(VOS_TRACE_LEVEL_INFO,
1572 FL("RESPONSE SIR_HAL_LL_STATS_RESULTS_RSP") );
1573 hddLog(VOS_TRACE_LEVEL_INFO,
1574 "LL_STATS RESULTS RESPONSE paramID = 0x%x",
1575 linkLayerStatsResults->paramId);
1576 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301577 "LL_STATS RESULTS RESPONSE ifaceId = %u MAC: %pM",
1578 linkLayerStatsResults->ifaceId, macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301579 hddLog(VOS_TRACE_LEVEL_INFO,
1580 "LL_STATS RESULTS RESPONSE respId = %u",
1581 linkLayerStatsResults->respId);
1582 hddLog(VOS_TRACE_LEVEL_INFO,
1583 "LL_STATS RESULTS RESPONSE moreResultToFollow = %u",
1584 linkLayerStatsResults->moreResultToFollow);
1585 hddLog(VOS_TRACE_LEVEL_INFO,
1586 "LL_STATS RESULTS RESPONSE result = %p",
1587 linkLayerStatsResults->result);
1588 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1589 {
1590 hdd_link_layer_process_radio_stats(pAdapter,
1591 (v_VOID_t *)linkLayerStatsResults->result);
1592 }
1593 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1594 {
1595 hdd_link_layer_process_iface_stats(pAdapter,
1596 (v_VOID_t *)linkLayerStatsResults->result);
1597 }
1598 else if ( linkLayerStatsResults->paramId &
1599 WMI_LINK_STATS_ALL_PEER )
1600 {
1601 hdd_link_layer_process_peer_stats(pAdapter,
1602 (v_VOID_t *)linkLayerStatsResults->result);
1603 } /* WMI_LINK_STATS_ALL_PEER */
1604 else
1605 {
1606 hddLog(VOS_TRACE_LEVEL_ERROR,
1607 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1608 }
1609
1610 break;
1611 }
1612 default:
1613 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1614 break;
1615 }
1616 return;
1617}
1618
1619const struct
1620nla_policy
1621qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1622{
1623 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1624 { .type = NLA_U32 },
1625 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1626 { .type = NLA_U32 },
1627};
1628
1629static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1630 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05301631 const void *data,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301632 int data_len)
1633{
1634 int status;
1635 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301636 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301637 struct net_device *dev = wdev->netdev;
1638 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1639 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Srinivas Dasari98947432014-11-07 19:41:24 +05301640 hdd_station_ctx_t *pHddStaCtx;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301641
1642 status = wlan_hdd_validate_context(pHddCtx);
1643 if (0 != status)
1644 {
1645 hddLog(VOS_TRACE_LEVEL_ERROR,
1646 FL("HDD context is not valid"));
1647 return -EINVAL;
1648 }
1649
1650 if (NULL == pAdapter)
1651 {
1652 hddLog(VOS_TRACE_LEVEL_ERROR,
1653 FL("HDD adapter is Null"));
1654 return -ENODEV;
1655 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301656 /* check the LLStats Capability */
1657 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1658 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1659 {
1660 hddLog(VOS_TRACE_LEVEL_ERROR,
1661 FL("Link Layer Statistics not supported by Firmware"));
1662 return -EINVAL;
1663 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301664
1665 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1666 (struct nlattr *)data,
1667 data_len, qca_wlan_vendor_ll_set_policy))
1668 {
1669 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1670 return -EINVAL;
1671 }
1672 if (!tb_vendor
1673 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1674 {
1675 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1676 return -EINVAL;
1677 }
1678 if (!tb_vendor[
1679 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1680 {
1681 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1682 return -EINVAL;
1683 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301684 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301685 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301686
Dino Mycledf0a5d92014-07-04 09:41:55 +05301687 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301688 nla_get_u32(
1689 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1690
Dino Mycledf0a5d92014-07-04 09:41:55 +05301691 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301692 nla_get_u32(
1693 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1694
Dino Mycled3d50022014-07-07 12:58:25 +05301695 vos_mem_copy(linkLayerStatsSetReq.macAddr,
1696 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301697
1698
1699 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301700 "LL_STATS_SET reqId = %d", linkLayerStatsSetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301701 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301702 "LL_STATS_SET MAC = %pM", linkLayerStatsSetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301703 hddLog(VOS_TRACE_LEVEL_INFO,
1704 "LL_STATS_SET mpduSizeThreshold = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301705 linkLayerStatsSetReq.mpduSizeThreshold);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301706 hddLog(VOS_TRACE_LEVEL_INFO,
1707 "LL_STATS_SET aggressive Statistics Gathering = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301708 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301709
1710 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1711 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05301712 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301713 {
1714 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1715 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301716 return -EINVAL;
1717
1718 }
Srinivas Dasari98947432014-11-07 19:41:24 +05301719
1720 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1721 if (VOS_STATUS_SUCCESS !=
1722 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1723 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE))
1724 {
1725 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1726 "WLANTL_ClearInterfaceStats Failed", __func__);
1727 return -EINVAL;
1728 }
1729
1730 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1731 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1732 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1733 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1734
Sunil Duttc69bccb2014-05-26 21:30:20 +05301735 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301736 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301737 {
1738 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1739 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301740 return -EINVAL;
1741 }
1742
1743 pAdapter->isLinkLayerStatsSet = 1;
1744
1745 return 0;
1746}
1747
1748const struct
1749nla_policy
1750qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1751{
1752 /* Unsigned 32bit value provided by the caller issuing the GET stats
1753 * command. When reporting
1754 * the stats results, the driver uses the same value to indicate
1755 * which GET request the results
1756 * correspond to.
1757 */
1758 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1759
1760 /* Unsigned 32bit value . bit mask to identify what statistics are
1761 requested for retrieval */
1762 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1763};
1764
1765static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1766 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05301767 const void *data,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301768 int data_len)
1769{
1770 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1771 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301772 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301773 struct net_device *dev = wdev->netdev;
1774 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1775 int status;
1776
1777 status = wlan_hdd_validate_context(pHddCtx);
1778 if (0 != status)
1779 {
1780 hddLog(VOS_TRACE_LEVEL_ERROR,
1781 FL("HDD context is not valid"));
1782 return -EINVAL ;
1783 }
1784
1785 if (NULL == pAdapter)
1786 {
1787 hddLog(VOS_TRACE_LEVEL_FATAL,
1788 "%s: HDD adapter is Null", __func__);
1789 return -ENODEV;
1790 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301791 /* check the LLStats Capability */
1792 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1793 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1794 {
1795 hddLog(VOS_TRACE_LEVEL_ERROR,
1796 FL("Link Layer Statistics not supported by Firmware"));
1797 return -EINVAL;
1798 }
1799
Sunil Duttc69bccb2014-05-26 21:30:20 +05301800
1801 if (!pAdapter->isLinkLayerStatsSet)
1802 {
1803 hddLog(VOS_TRACE_LEVEL_FATAL,
1804 "%s: isLinkLayerStatsSet : %d",
1805 __func__, pAdapter->isLinkLayerStatsSet);
1806 return -EINVAL;
1807 }
1808
1809 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
1810 (struct nlattr *)data,
1811 data_len, qca_wlan_vendor_ll_get_policy))
1812 {
1813 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1814 return -EINVAL;
1815 }
1816
1817 if (!tb_vendor
1818 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
1819 {
1820 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
1821 return -EINVAL;
1822 }
1823
1824 if (!tb_vendor
1825 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
1826 {
1827 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
1828 return -EINVAL;
1829 }
1830
Sunil Duttc69bccb2014-05-26 21:30:20 +05301831
Dino Mycledf0a5d92014-07-04 09:41:55 +05301832 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301833 nla_get_u32( tb_vendor[
1834 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05301835 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301836 nla_get_u32( tb_vendor[
1837 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
1838
Dino Mycled3d50022014-07-07 12:58:25 +05301839 vos_mem_copy(linkLayerStatsGetReq.macAddr,
1840 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301841
1842 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301843 "LL_STATS_GET reqId = %d", linkLayerStatsGetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301844 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301845 "LL_STATS_GET MAC = %pM", linkLayerStatsGetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301846 hddLog(VOS_TRACE_LEVEL_INFO,
1847 "LL_STATS_GET paramIdMask = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301848 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301849
1850 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301851 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301852 {
1853 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1854 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301855 return -EINVAL;
1856 }
1857 return 0;
1858}
1859
1860const struct
1861nla_policy
1862qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
1863{
1864 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
1865 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
1866 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
1867 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
1868};
1869
1870static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
1871 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05301872 const void *data,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301873 int data_len)
1874{
1875 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1876 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301877 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301878 struct net_device *dev = wdev->netdev;
1879 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1880 u32 statsClearReqMask;
1881 u8 stopReq;
1882 int status;
1883
1884 status = wlan_hdd_validate_context(pHddCtx);
1885 if (0 != status)
1886 {
1887 hddLog(VOS_TRACE_LEVEL_ERROR,
1888 FL("HDD context is not valid"));
1889 return -EINVAL;
1890 }
1891
1892 if (NULL == pAdapter)
1893 {
1894 hddLog(VOS_TRACE_LEVEL_FATAL,
1895 "%s: HDD adapter is Null", __func__);
1896 return -ENODEV;
1897 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301898 /* check the LLStats Capability */
1899 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1900 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1901 {
1902 hddLog(VOS_TRACE_LEVEL_ERROR,
1903 FL("Enable LLStats Capability"));
1904 return -EINVAL;
1905 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301906
1907 if (!pAdapter->isLinkLayerStatsSet)
1908 {
1909 hddLog(VOS_TRACE_LEVEL_FATAL,
1910 "%s: isLinkLayerStatsSet : %d",
1911 __func__, pAdapter->isLinkLayerStatsSet);
1912 return -EINVAL;
1913 }
1914
1915 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
1916 (struct nlattr *)data,
1917 data_len, qca_wlan_vendor_ll_clr_policy))
1918 {
1919 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1920 return -EINVAL;
1921 }
1922
1923 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
1924
1925 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
1926 {
1927 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
1928 return -EINVAL;
1929
1930 }
1931
Sunil Duttc69bccb2014-05-26 21:30:20 +05301932
Dino Mycledf0a5d92014-07-04 09:41:55 +05301933 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301934 nla_get_u32(
1935 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
1936
Dino Mycledf0a5d92014-07-04 09:41:55 +05301937 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301938 nla_get_u8(
1939 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
1940
1941 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301942 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301943
Dino Mycled3d50022014-07-07 12:58:25 +05301944 vos_mem_copy(linkLayerStatsClearReq.macAddr,
1945 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301946
1947 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301948 "LL_STATS_CLEAR reqId = %d", linkLayerStatsClearReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301949 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301950 "LL_STATS_CLEAR MAC = %pM", linkLayerStatsClearReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301951 hddLog(VOS_TRACE_LEVEL_INFO,
1952 "LL_STATS_CLEAR statsClearReqMask = 0x%X",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301953 linkLayerStatsClearReq.statsClearReqMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301954 hddLog(VOS_TRACE_LEVEL_INFO,
1955 "LL_STATS_CLEAR stopReq = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301956 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301957
1958 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301959 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301960 {
1961 struct sk_buff *temp_skbuff;
Srinivas Dasari98947432014-11-07 19:41:24 +05301962 hdd_station_ctx_t *pHddStaCtx;
1963
1964 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1965 if (VOS_STATUS_SUCCESS !=
1966 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1967 pHddStaCtx->conn_info.staId[0], statsClearReqMask))
1968 {
1969 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1970 "WLANTL_ClearInterfaceStats Failed", __func__);
1971 return -EINVAL;
1972 }
1973 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
1974 (statsClearReqMask & WIFI_STATS_IFACE)) {
1975 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1976 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1977 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1978 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1979 }
1980
Sunil Duttc69bccb2014-05-26 21:30:20 +05301981 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
1982 2 * sizeof(u32) +
1983 NLMSG_HDRLEN);
1984
1985 if (temp_skbuff != NULL)
1986 {
1987
1988 if (nla_put_u32(temp_skbuff,
1989 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
1990 statsClearReqMask) ||
1991 nla_put_u32(temp_skbuff,
1992 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
1993 stopReq))
1994 {
1995 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
1996 kfree_skb(temp_skbuff);
1997 return -EINVAL;
1998 }
1999 /* If the ask is to stop the stats collection as part of clear
2000 * (stopReq = 1) , ensure that no further requests of get
2001 * go to the firmware by having isLinkLayerStatsSet set to 0.
2002 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302003 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05302004 * case the firmware is just asked to clear the statistics.
2005 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05302006 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302007 pAdapter->isLinkLayerStatsSet = 0;
2008 return cfg80211_vendor_cmd_reply(temp_skbuff);
2009 }
2010 return -ENOMEM;
2011 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302012 return -EINVAL;
2013}
2014#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2015
Dino Mycle6fb96c12014-06-10 11:52:40 +05302016#ifdef WLAN_FEATURE_EXTSCAN
2017static const struct nla_policy
2018wlan_hdd_extscan_config_policy
2019 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
2020{
2021 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
2022 { .type = NLA_U32 },
2023 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
2024 { .type = NLA_U32 },
2025 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
2026 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
2027 { .type = NLA_U32 },
2028 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
2029 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
2030
2031 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
2032 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
2033 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
2034 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
2035 { .type = NLA_U8 },
2036 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
2037 { .type = NLA_U32 },
2038 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
2039 { .type = NLA_U32 },
2040 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
2041 { .type = NLA_U32 },
2042 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD] =
2043 { .type = NLA_U8 },
2044 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
2045 { .type = NLA_U8 },
2046 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
2047 { .type = NLA_U8 },
2048
2049 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
2050 { .type = NLA_U32 },
2051 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] =
2052 { .type = NLA_UNSPEC },
2053 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
2054 { .type = NLA_S32 },
2055 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
2056 { .type = NLA_S32 },
2057 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
2058 { .type = NLA_U32 },
2059 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
2060 { .type = NLA_U32 },
2061 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE] =
2062 { .type = NLA_U32 },
2063 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]
2064 = { .type = NLA_U32 },
2065 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING] =
2066 { .type = NLA_U32 },
2067 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP] = { .type =
2068 NLA_U32 },
2069};
2070
2071static void wlan_hdd_cfg80211_extscan_get_capabilities_ind(void *ctx, void *pMsg)
2072{
2073 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2074 struct sk_buff *skb = NULL;
2075 tpSirEXTScanCapabilitiesEvent pData =
2076 (tpSirEXTScanCapabilitiesEvent) pMsg;
2077
2078 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2079 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2080 "or pData(%p) is null"), pData);
2081 return;
2082 }
2083
2084 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2085 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2086 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES_INDEX,
2087 GFP_KERNEL);
2088
2089 if (!skb) {
2090 hddLog(VOS_TRACE_LEVEL_ERROR,
2091 FL("cfg80211_vendor_event_alloc failed"));
2092 return;
2093 }
2094
2095 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2096 hddLog(VOS_TRACE_LEVEL_INFO, "Scan cache size (%u)", pData->scanCacheSize);
2097 hddLog(VOS_TRACE_LEVEL_INFO, "Scan buckets (%u)", pData->scanBuckets);
2098 hddLog(VOS_TRACE_LEVEL_INFO, "Max AP per scan (%u)", pData->maxApPerScan);
2099 hddLog(VOS_TRACE_LEVEL_INFO, "maxRssiSampleSize (%u)",
2100 pData->maxRssiSampleSize);
2101 hddLog(VOS_TRACE_LEVEL_INFO, "maxScanReportingThreshold (%u)",
2102 pData->maxScanReportingThreshold);
2103 hddLog(VOS_TRACE_LEVEL_INFO, "maxHotlistAPs (%u)", pData->maxHotlistAPs);
2104 hddLog(VOS_TRACE_LEVEL_INFO, "maxSignificantWifiChangeAPs (%u)",
2105 pData->maxSignificantWifiChangeAPs);
2106 hddLog(VOS_TRACE_LEVEL_INFO, "maxBsidHistoryEntries (%u)",
2107 pData->maxBsidHistoryEntries);
2108
2109 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2110 pData->requestId) ||
2111 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status) ||
2112 nla_put_u32(skb,
2113 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE,
2114 pData->scanCacheSize) ||
2115 nla_put_u32(skb,
2116 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS,
2117 pData->scanBuckets) ||
2118 nla_put_u32(skb,
2119 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN,
2120 pData->maxApPerScan) ||
2121 nla_put_u32(skb,
2122 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE,
2123 pData->maxRssiSampleSize) ||
2124 nla_put_u32(skb,
2125 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD,
2126 pData->maxScanReportingThreshold) ||
2127 nla_put_u32(skb,
2128 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_APS,
2129 pData->maxHotlistAPs) ||
2130 nla_put_u32(skb,
2131 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS,
2132 pData->maxSignificantWifiChangeAPs) ||
2133 nla_put_u32(skb,
2134 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES,
2135 pData->maxBsidHistoryEntries)) {
2136 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2137 goto nla_put_failure;
2138 }
2139
2140 cfg80211_vendor_event(skb, GFP_KERNEL);
2141 return;
2142
2143nla_put_failure:
2144 kfree_skb(skb);
2145 return;
2146}
2147
2148
2149static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg)
2150{
2151 tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg;
2152 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2153 struct sk_buff *skb = NULL;
2154 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
2155
2156
2157 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2158 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2159 "or pData(%p) is null"), pData);
2160 return;
2161 }
2162
2163 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2164 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2165 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START_INDEX,
2166 GFP_KERNEL);
2167
2168 if (!skb) {
2169 hddLog(VOS_TRACE_LEVEL_ERROR,
2170 FL("cfg80211_vendor_event_alloc failed"));
2171 return;
2172 }
2173 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2174 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2175 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2176
2177 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2178 pData->requestId) ||
2179 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2180 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2181 goto nla_put_failure;
2182 }
2183
2184 /*
2185 * Store the Request ID for comparing with the requestID obtained
2186 * in other requests.HDD shall return a failure is the extscan_stop
2187 * request is issued with a different requestId as that of the
2188 * extscan_start request. Also, This requestId shall be used while
2189 * indicating the full scan results to the upper layers.
2190 * The requestId is stored with the assumption that the firmware
2191 * shall return the ext scan start request's requestId in ext scan
2192 * start response.
2193 */
2194 if (pData->status == 0)
2195 pMac->sme.extScanStartReqId = pData->requestId;
2196
2197
2198 cfg80211_vendor_event(skb, GFP_KERNEL);
2199 return;
2200
2201nla_put_failure:
2202 kfree_skb(skb);
2203 return;
2204}
2205
2206
2207static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
2208{
2209 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
2210 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2211 struct sk_buff *skb = NULL;
2212
2213 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2214 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2215 "or pData(%p) is null"), pData);
2216 return;
2217 }
2218
2219 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2220 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2221 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP_INDEX,
2222 GFP_KERNEL);
2223
2224 if (!skb) {
2225 hddLog(VOS_TRACE_LEVEL_ERROR,
2226 FL("cfg80211_vendor_event_alloc failed"));
2227 return;
2228 }
2229 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2230 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2231
2232 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2233 pData->requestId) ||
2234 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2235 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2236 goto nla_put_failure;
2237 }
2238
2239 cfg80211_vendor_event(skb, GFP_KERNEL);
2240 return;
2241
2242nla_put_failure:
2243 kfree_skb(skb);
2244 return;
2245}
2246
2247
2248static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
2249 void *pMsg)
2250{
2251 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2252 struct sk_buff *skb = NULL;
2253 tpSirEXTScanSetBssidHotListRspParams pData =
2254 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
2255
2256 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2257 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2258 "or pData(%p) is null"), pData);
2259 return;
2260 }
2261 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2262 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2263 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST_INDEX,
2264 GFP_KERNEL);
2265
2266 if (!skb) {
2267 hddLog(VOS_TRACE_LEVEL_ERROR,
2268 FL("cfg80211_vendor_event_alloc failed"));
2269 return;
2270 }
2271 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2272 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2273 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2274
2275 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2276 pData->requestId) ||
2277 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2278 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2279 goto nla_put_failure;
2280 }
2281
2282 cfg80211_vendor_event(skb, GFP_KERNEL);
2283 return;
2284
2285nla_put_failure:
2286 kfree_skb(skb);
2287 return;
2288}
2289
2290static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
2291 void *pMsg)
2292{
2293 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2294 struct sk_buff *skb = NULL;
2295 tpSirEXTScanResetBssidHotlistRspParams pData =
2296 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
2297
2298 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2299 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2300 "or pData(%p) is null"), pData);
2301 return;
2302 }
2303
2304 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2305 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2306 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST_INDEX,
2307 GFP_KERNEL);
2308
2309 if (!skb) {
2310 hddLog(VOS_TRACE_LEVEL_ERROR,
2311 FL("cfg80211_vendor_event_alloc failed"));
2312 return;
2313 }
2314 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2315 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2316
2317 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2318 pData->requestId) ||
2319 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2320 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2321 goto nla_put_failure;
2322 }
2323
2324 cfg80211_vendor_event(skb, GFP_KERNEL);
2325 return;
2326
2327nla_put_failure:
2328 kfree_skb(skb);
2329 return;
2330}
2331
2332
2333static void wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(void *ctx,
2334 void *pMsg)
2335{
2336 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2337 struct sk_buff *skb = NULL;
2338 tpSirEXTScanSetSignificantChangeRspParams pData =
2339 (tpSirEXTScanSetSignificantChangeRspParams) pMsg;
2340
2341 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2342 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2343 "or pData(%p) is null"), pData);
2344 return;
2345 }
2346
2347 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2348 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2349 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE_INDEX,
2350 GFP_KERNEL);
2351
2352 if (!skb) {
2353 hddLog(VOS_TRACE_LEVEL_ERROR,
2354 FL("cfg80211_vendor_event_alloc failed"));
2355 return;
2356 }
2357 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2358 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2359 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2360
2361 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2362 pData->requestId) ||
2363 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2364 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2365 goto nla_put_failure;
2366 }
2367
2368 cfg80211_vendor_event(skb, GFP_KERNEL);
2369 return;
2370
2371nla_put_failure:
2372 kfree_skb(skb);
2373 return;
2374}
2375
2376
2377static void wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(void *ctx,
2378 void *pMsg)
2379{
2380 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2381 struct sk_buff *skb = NULL;
2382 tpSirEXTScanResetSignificantChangeRspParams pData =
2383 (tpSirEXTScanResetSignificantChangeRspParams) pMsg;
2384
2385 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2386 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2387 "or pData(%p) is null"), pData);
2388 return;
2389 }
2390
2391 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2392 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2393 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE_INDEX,
2394 GFP_KERNEL);
2395
2396 if (!skb) {
2397 hddLog(VOS_TRACE_LEVEL_ERROR,
2398 FL("cfg80211_vendor_event_alloc failed"));
2399 return;
2400 }
2401 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2402 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2403 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2404
2405 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2406 pData->requestId) ||
2407 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2408 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2409 goto nla_put_failure;
2410 }
2411
2412 cfg80211_vendor_event(skb, GFP_KERNEL);
2413 return;
2414
2415nla_put_failure:
2416 kfree_skb(skb);
2417 return;
2418}
2419
2420static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
2421 void *pMsg)
2422{
2423 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2424 struct sk_buff *skb = NULL;
2425 tANI_U32 i = 0, j, resultsPerEvent;
2426 tANI_S32 totalResults;
2427 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2428 tpSirWifiScanResult pSirWifiScanResult;
2429
2430 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2431 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2432 "or pData(%p) is null"), pData);
2433 return;
2434 }
2435 totalResults = pData->numOfAps;
2436 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2437 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2438 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2439
2440 do{
2441 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
2442 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
2443 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
2444
2445 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2446 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2447 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS_INDEX,
2448 GFP_KERNEL);
2449
2450 if (!skb) {
2451 hddLog(VOS_TRACE_LEVEL_ERROR,
2452 FL("cfg80211_vendor_event_alloc failed"));
2453 return;
2454 }
2455
2456 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
2457
2458 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2459 pData->requestId) ||
2460 nla_put_u32(skb,
2461 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2462 resultsPerEvent)) {
2463 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2464 goto fail;
2465 }
2466 if (nla_put_u8(skb,
2467 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2468 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
2469 {
2470 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2471 goto fail;
2472 }
2473
2474 if (resultsPerEvent) {
2475 struct nlattr *aps;
2476
2477 aps = nla_nest_start(skb,
2478 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2479 if (!aps)
2480 {
2481 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2482 goto fail;
2483 }
2484
2485 for (j = 0; j < resultsPerEvent; j++, i++) {
2486 struct nlattr *ap;
2487 pSirWifiScanResult = (tpSirWifiScanResult) ((tANI_U8 *)
2488 pData->ap + ( i* sizeof(tSirWifiScanResult)));
2489
2490 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
2491 "Ssid (%s)"
2492 "Bssid: %pM "
2493 "Channel (%u)"
2494 "Rssi (%d)"
2495 "RTT (%u)"
2496 "RTT_SD (%u)",
2497 i,
2498 pSirWifiScanResult->ts,
2499 pSirWifiScanResult->ssid,
2500 pSirWifiScanResult->bssid,
2501 pSirWifiScanResult->channel,
2502 pSirWifiScanResult->rssi,
2503 pSirWifiScanResult->rtt,
2504 pSirWifiScanResult->rtt_sd);
2505
2506 ap = nla_nest_start(skb, j + 1);
2507 if (!ap)
2508 {
2509 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2510 goto fail;
2511 }
2512
2513 if (nla_put_u64(skb,
2514 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2515 pSirWifiScanResult->ts) )
2516 {
2517 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2518 goto fail;
2519 }
2520 if (nla_put(skb,
2521 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2522 sizeof(pSirWifiScanResult->ssid),
2523 pSirWifiScanResult->ssid) )
2524 {
2525 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2526 goto fail;
2527 }
2528 if (nla_put(skb,
2529 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2530 sizeof(pSirWifiScanResult->bssid),
2531 pSirWifiScanResult->bssid) )
2532 {
2533 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2534 goto fail;
2535 }
2536 if (nla_put_u32(skb,
2537 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2538 pSirWifiScanResult->channel) )
2539 {
2540 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2541 goto fail;
2542 }
Dasari Srinivas90747d72014-10-08 12:16:15 +05302543 if (nla_put_s32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302544 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2545 pSirWifiScanResult->rssi) )
2546 {
2547 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2548 goto fail;
2549 }
2550 if (nla_put_u32(skb,
2551 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2552 pSirWifiScanResult->rtt) )
2553 {
2554 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2555 goto fail;
2556 }
2557 if (nla_put_u32(skb,
2558 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2559 pSirWifiScanResult->rtt_sd))
2560 {
2561 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2562 goto fail;
2563 }
2564
2565 nla_nest_end(skb, ap);
2566 }
2567 nla_nest_end(skb, aps);
2568
2569 }
2570 cfg80211_vendor_event(skb, GFP_KERNEL);
2571 } while (totalResults > 0);
2572
2573 return;
2574fail:
2575 kfree_skb(skb);
2576 return;
2577}
2578
2579static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
2580 void *pMsg)
2581{
2582 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2583 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2584 struct sk_buff *skb = NULL;
2585 tANI_U32 i;
2586
2587 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2588 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2589 "or pData(%p) is null"), pData);
2590 return;
2591 }
2592
2593 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2594 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2595 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX,
2596 GFP_KERNEL);
2597
2598 if (!skb) {
2599 hddLog(VOS_TRACE_LEVEL_ERROR,
2600 FL("cfg80211_vendor_event_alloc failed"));
2601 return;
2602 }
2603 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2604 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2605 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2606 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2607
2608 for (i = 0; i < pData->numOfAps; i++) {
2609 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
2610 "Ssid (%s) "
2611 "Bssid (" MAC_ADDRESS_STR ") "
2612 "Channel (%u) "
2613 "Rssi (%d) "
2614 "RTT (%u) "
2615 "RTT_SD (%u) ",
2616 i,
2617 pData->ap[i].ts,
2618 pData->ap[i].ssid,
2619 MAC_ADDR_ARRAY(pData->ap[i].bssid),
2620 pData->ap[i].channel,
2621 pData->ap[i].rssi,
2622 pData->ap[i].rtt,
2623 pData->ap[i].rtt_sd);
2624 }
2625
2626 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2627 pData->requestId) ||
2628 nla_put_u32(skb,
2629 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2630 pData->numOfAps)) {
2631 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2632 goto fail;
2633 }
2634 if (pData->numOfAps) {
2635 struct nlattr *aps;
2636
2637 aps = nla_nest_start(skb,
2638 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2639 if (!aps)
2640 goto fail;
2641
2642 for (i = 0; i < pData->numOfAps; i++) {
2643 struct nlattr *ap;
2644
2645 ap = nla_nest_start(skb, i + 1);
2646 if (!ap)
2647 goto fail;
2648
2649 if (nla_put_u64(skb,
2650 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2651 pData->ap[i].ts) ||
2652 nla_put(skb,
2653 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2654 sizeof(pData->ap[i].ssid),
2655 pData->ap[i].ssid) ||
2656 nla_put(skb,
2657 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2658 sizeof(pData->ap[i].bssid),
2659 pData->ap[i].bssid) ||
2660 nla_put_u32(skb,
2661 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2662 pData->ap[i].channel) ||
2663 nla_put_s32(skb,
2664 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2665 pData->ap[i].rssi) ||
2666 nla_put_u32(skb,
2667 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2668 pData->ap[i].rtt) ||
2669 nla_put_u32(skb,
2670 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2671 pData->ap[i].rtt_sd))
2672 goto fail;
2673
2674 nla_nest_end(skb, ap);
2675 }
2676 nla_nest_end(skb, aps);
2677
2678 if (nla_put_u8(skb,
2679 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2680 pData->moreData))
2681 goto fail;
2682 }
2683
2684 cfg80211_vendor_event(skb, GFP_KERNEL);
2685 return;
2686
2687fail:
2688 kfree_skb(skb);
2689 return;
2690
2691}
2692static void wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(void *ctx,
2693 void *pMsg)
2694{
2695 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2696 struct sk_buff *skb = NULL;
2697 tANI_U32 i, j;
2698 tpSirWifiSignificantChangeEvent pData =
2699 (tpSirWifiSignificantChangeEvent) pMsg;
2700
2701 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2702 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2703 "or pData(%p) is null"), pData);
2704 return;
2705 }
2706 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2707 EXTSCAN_EVENT_BUF_SIZE,
2708 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE_INDEX,
2709 GFP_KERNEL);
2710
2711 if (!skb) {
2712 hddLog(VOS_TRACE_LEVEL_ERROR,
2713 FL("cfg80211_vendor_event_alloc failed"));
2714 return;
2715 }
2716 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2717 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2718 hddLog(VOS_TRACE_LEVEL_INFO, "total List Size %u ", pData->numSigRssiBss);
2719 hddLog(VOS_TRACE_LEVEL_INFO, " CUrrent List size (%u)",
2720 pData->numSigRssiBss);
2721 hddLog(VOS_TRACE_LEVEL_INFO, "moreData (%u)", pData->moreData);
2722
2723 for (i = 0; i < pData->numSigRssiBss; i++) {
2724 hddLog(VOS_TRACE_LEVEL_INFO , "Rssi List [%d] BSSID: (%pM) Channel %u "
2725 " num RSSI %u ",
2726 i, pData->sigRssiResult[i].bssid,
2727 pData->sigRssiResult[i].channel,
2728 pData->sigRssiResult[i].numRssi);
2729
2730 for (j = 0; j < pData->sigRssiResult[i].numRssi; j++){
2731
2732 hddLog(VOS_TRACE_LEVEL_INFO,
2733 " [%d]",
Dino Myclec8f3f332014-07-21 16:48:27 +05302734 pData->sigRssiResult[i].rssi[j]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302735
2736 }
2737 }
2738
2739
2740 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2741 pData->requestId) ||
2742 nla_put_u32(skb,
2743 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2744 pData->numSigRssiBss)) {
2745 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2746 goto fail;
2747 }
2748
2749 if (pData->numSigRssiBss) {
2750 struct nlattr *aps;
2751 aps = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2752 if (!aps)
2753 goto fail;
2754 for (i = 0; i < pData->numSigRssiBss; i++) {
2755 struct nlattr *ap;
2756
2757 ap = nla_nest_start(skb, i);
2758 if (!ap)
2759 goto fail;
2760 if (nla_put(skb,
2761 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_BSSID,
2762 sizeof(tSirMacAddr), pData->sigRssiResult[i].bssid) ||
2763 nla_put_u32(skb,
2764 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_CHANNEL,
2765 pData->sigRssiResult[i].channel) ||
2766 nla_put_u32(skb,
2767 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_NUM_RSSI,
2768 pData->sigRssiResult[i].numRssi) ||
2769 nla_put(skb,
2770 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_RSSI_LIST,
2771 sizeof(s32) * pData->sigRssiResult[i].numRssi,
2772 pData->sigRssiResult[i].rssi))
2773 goto fail;
2774 nla_nest_end(skb, ap);
2775 }
2776 nla_nest_end(skb, aps);
2777 if (nla_put_u8(skb,
2778 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2779 pData->moreData))
2780 goto fail;
2781 }
2782 cfg80211_vendor_event(skb, GFP_KERNEL);
2783 return;
2784fail:
2785 kfree_skb(skb);
2786 return;
2787}
2788
2789static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
2790 void *pMsg)
2791{
2792 struct sk_buff *skb;
2793 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2794 tpSirWifiFullScanResultEvent pData =
2795 (tpSirWifiFullScanResultEvent) (pMsg);
2796
2797 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2798 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2799 "or pData(%p) is null"), pData);
2800 return;
2801 }
2802
2803 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2804 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2805 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
2806 GFP_KERNEL);
2807
2808 if (!skb) {
2809 hddLog(VOS_TRACE_LEVEL_ERROR,
2810 FL("cfg80211_vendor_event_alloc failed"));
2811 return;
2812 }
2813
2814 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2815 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
2816 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
2817 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
2818 "Ssid (%s)"
2819 "Bssid (" MAC_ADDRESS_STR ")"
2820 "Channel (%u)"
2821 "Rssi (%d)"
2822 "RTT (%u)"
2823 "RTT_SD (%u)"),
2824 pData->ap.ts,
2825 pData->ap.ssid,
2826 MAC_ADDR_ARRAY(pData->ap.bssid),
2827 pData->ap.channel,
2828 pData->ap.rssi,
2829 pData->ap.rtt,
2830 pData->ap.rtt_sd);
2831 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
2832 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2833 pData->requestId) ||
2834 nla_put_u64(skb,
2835 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2836 pData->ap.ts) ||
2837 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2838 sizeof(pData->ap.ssid),
2839 pData->ap.ssid) ||
2840 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2841 WNI_CFG_BSSID_LEN,
2842 pData->ap.bssid) ||
2843 nla_put_u32(skb,
2844 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2845 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05302846 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302847 pData->ap.rssi) ||
2848 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2849 pData->ap.rtt) ||
2850 nla_put_u32(skb,
2851 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2852 pData->ap.rtt_sd) ||
2853 nla_put_u16(skb,
2854 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
2855 pData->ap.beaconPeriod) ||
2856 nla_put_u16(skb,
2857 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
2858 pData->ap.capability) ||
2859 nla_put_u32(skb,
2860 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
2861 pData->ieLength))
2862 {
2863 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2864 goto nla_put_failure;
2865 }
2866 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
2867 pData->ieLength,
2868 pData->ie))
2869 {
2870 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2871 goto nla_put_failure;
2872 }
2873
2874 cfg80211_vendor_event(skb, GFP_KERNEL);
2875 return;
2876
2877nla_put_failure:
2878 kfree_skb(skb);
2879 return;
2880}
2881
2882static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
2883 void *pMsg)
2884{
2885 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2886 struct sk_buff *skb = NULL;
2887 tpSirEXTScanResultsAvailableIndParams pData =
2888 (tpSirEXTScanResultsAvailableIndParams) pMsg;
2889
2890 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2891 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2892 "or pData(%p) is null"), pData);
2893 return;
2894 }
2895
2896 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2897 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2898 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
2899 GFP_KERNEL);
2900
2901 if (!skb) {
2902 hddLog(VOS_TRACE_LEVEL_ERROR,
2903 FL("cfg80211_vendor_event_alloc failed"));
2904 return;
2905 }
2906
2907 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2908 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2909 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
2910 pData->numResultsAvailable);
2911 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2912 pData->requestId) ||
2913 nla_put_u32(skb,
2914 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2915 pData->numResultsAvailable)) {
2916 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2917 goto nla_put_failure;
2918 }
2919
2920 cfg80211_vendor_event(skb, GFP_KERNEL);
2921 return;
2922
2923nla_put_failure:
2924 kfree_skb(skb);
2925 return;
2926}
2927
2928static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
2929{
2930 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2931 struct sk_buff *skb = NULL;
2932 tpSirEXTScanProgressIndParams pData =
2933 (tpSirEXTScanProgressIndParams) pMsg;
2934
2935 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2936 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2937 "or pData(%p) is null"), pData);
2938 return;
2939 }
2940
2941 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2942 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2943 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
2944 GFP_KERNEL);
2945
2946 if (!skb) {
2947 hddLog(VOS_TRACE_LEVEL_ERROR,
2948 FL("cfg80211_vendor_event_alloc failed"));
2949 return;
2950 }
2951 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2952 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
2953 pData->extScanEventType);
2954 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
2955 pData->status);
2956
2957 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
2958 pData->extScanEventType) ||
2959 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05302960 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2961 pData->requestId) ||
2962 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302963 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
2964 pData->status)) {
2965 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2966 goto nla_put_failure;
2967 }
2968
2969 cfg80211_vendor_event(skb, GFP_KERNEL);
2970 return;
2971
2972nla_put_failure:
2973 kfree_skb(skb);
2974 return;
2975}
2976
2977void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
2978 void *pMsg)
2979{
2980 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2981
2982 if (wlan_hdd_validate_context(pHddCtx)) {
Dasari Srinivasb46ed1d2014-10-08 13:03:08 +05302983 hddLog(VOS_TRACE_LEVEL_INFO, FL("HDD context is not valid"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302984 return;
2985 }
2986
2987 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
2988
2989
2990 switch(evType) {
2991 case SIR_HAL_EXTSCAN_START_RSP:
2992 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
2993 break;
2994
2995 case SIR_HAL_EXTSCAN_STOP_RSP:
2996 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
2997 break;
2998 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
2999 /* There is no need to send this response to upper layer
3000 Just log the message */
3001 hddLog(VOS_TRACE_LEVEL_INFO,
3002 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
3003 break;
3004 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
3005 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
3006 break;
3007
3008 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
3009 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
3010 break;
3011
3012 case SIR_HAL_EXTSCAN_SET_SIGNF_RSSI_CHANGE_RSP:
3013 wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(ctx, pMsg);
3014 break;
3015
3016 case SIR_HAL_EXTSCAN_RESET_SIGNF_RSSI_CHANGE_RSP:
3017 wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(ctx, pMsg);
3018 break;
3019 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
3020 wlan_hdd_cfg80211_extscan_get_capabilities_ind(ctx, pMsg);
3021 break;
3022 case SIR_HAL_EXTSCAN_PROGRESS_IND:
3023 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
3024 break;
3025 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
3026 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
3027 break;
3028 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
3029 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
3030 break;
3031 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
3032 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
3033 break;
3034 case SIR_HAL_EXTSCAN_SIGNF_WIFI_CHANGE_IND:
3035 wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(ctx, pMsg);
3036 break;
3037 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
3038 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
3039 break;
3040 default:
3041 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
3042 break;
3043 }
3044}
3045
3046static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3047 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303048 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303049{
Dino Myclee8843b32014-07-04 14:21:45 +05303050 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303051 struct net_device *dev = wdev->netdev;
3052 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3053 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3054 struct nlattr
3055 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3056 eHalStatus status;
3057
3058 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering"));
3059 status = wlan_hdd_validate_context(pHddCtx);
3060 if (0 != status)
3061 {
3062 hddLog(VOS_TRACE_LEVEL_ERROR,
3063 FL("HDD context is not valid"));
3064 return -EINVAL;
3065 }
Dino Myclee8843b32014-07-04 14:21:45 +05303066 /* check the EXTScan Capability */
3067 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3068 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3069 {
3070 hddLog(VOS_TRACE_LEVEL_ERROR,
3071 FL("EXTScan not enabled/supported by Firmware"));
3072 return -EINVAL;
3073 }
3074
Dino Mycle6fb96c12014-06-10 11:52:40 +05303075 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3076 data, dataLen,
3077 wlan_hdd_extscan_config_policy)) {
3078 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3079 return -EINVAL;
3080 }
3081
3082 /* Parse and fetch request Id */
3083 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3084 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3085 return -EINVAL;
3086 }
3087
Dino Mycle6fb96c12014-06-10 11:52:40 +05303088
Dino Myclee8843b32014-07-04 14:21:45 +05303089 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303090 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303091 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303092
Dino Myclee8843b32014-07-04 14:21:45 +05303093 reqMsg.sessionId = pAdapter->sessionId;
3094 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303095
Dino Myclee8843b32014-07-04 14:21:45 +05303096 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303097 if (!HAL_STATUS_SUCCESS(status)) {
3098 hddLog(VOS_TRACE_LEVEL_ERROR,
3099 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303100 return -EINVAL;
3101 }
3102
3103 return 0;
3104}
3105
3106
3107static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3108 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303109 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303110{
Dino Myclee8843b32014-07-04 14:21:45 +05303111 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303112 struct net_device *dev = wdev->netdev;
3113 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3114 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3115 struct nlattr
3116 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3117 eHalStatus status;
3118
3119 status = wlan_hdd_validate_context(pHddCtx);
3120 if (0 != status)
3121 {
3122 hddLog(VOS_TRACE_LEVEL_ERROR,
3123 FL("HDD context is not valid"));
3124 return -EINVAL;
3125 }
Dino Myclee8843b32014-07-04 14:21:45 +05303126 /* check the EXTScan Capability */
3127 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3128 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3129 {
3130 hddLog(VOS_TRACE_LEVEL_ERROR,
3131 FL("EXTScan not enabled/supported by Firmware"));
3132 return -EINVAL;
3133 }
3134
Dino Mycle6fb96c12014-06-10 11:52:40 +05303135 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3136 data, dataLen,
3137 wlan_hdd_extscan_config_policy)) {
3138 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3139 return -EINVAL;
3140 }
3141 /* Parse and fetch request Id */
3142 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3143 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3144 return -EINVAL;
3145 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303146
Dino Myclee8843b32014-07-04 14:21:45 +05303147 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303148 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3149
Dino Myclee8843b32014-07-04 14:21:45 +05303150 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303151
Dino Myclee8843b32014-07-04 14:21:45 +05303152 reqMsg.sessionId = pAdapter->sessionId;
3153 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303154
3155 /* Parse and fetch flush parameter */
3156 if (!tb
3157 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3158 {
3159 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3160 goto failed;
3161 }
Dino Myclee8843b32014-07-04 14:21:45 +05303162 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303163 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3164
Dino Myclee8843b32014-07-04 14:21:45 +05303165 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303166
Dino Myclee8843b32014-07-04 14:21:45 +05303167 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303168 if (!HAL_STATUS_SUCCESS(status)) {
3169 hddLog(VOS_TRACE_LEVEL_ERROR,
3170 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303171 return -EINVAL;
3172 }
3173 return 0;
3174
3175failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303176 return -EINVAL;
3177}
3178
3179static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3180 struct wireless_dev *wdev,
3181 void *data, int dataLen)
3182{
3183 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3184 struct net_device *dev = wdev->netdev;
3185 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3186 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3187 struct nlattr
3188 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3189 struct nlattr
3190 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3191 struct nlattr *apTh;
3192 eHalStatus status;
3193 tANI_U8 i = 0;
3194 int rem;
3195
3196 status = wlan_hdd_validate_context(pHddCtx);
3197 if (0 != status)
3198 {
3199 hddLog(VOS_TRACE_LEVEL_ERROR,
3200 FL("HDD context is not valid"));
3201 return -EINVAL;
3202 }
Dino Myclee8843b32014-07-04 14:21:45 +05303203 /* check the EXTScan Capability */
3204 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3205 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3206 {
3207 hddLog(VOS_TRACE_LEVEL_ERROR,
3208 FL("EXTScan not enabled/supported by Firmware"));
3209 return -EINVAL;
3210 }
3211
Dino Mycle6fb96c12014-06-10 11:52:40 +05303212 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3213 data, dataLen,
3214 wlan_hdd_extscan_config_policy)) {
3215 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3216 return -EINVAL;
3217 }
3218
3219 /* Parse and fetch request Id */
3220 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3221 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3222 return -EINVAL;
3223 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303224 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3225 vos_mem_malloc(sizeof(*pReqMsg));
3226 if (!pReqMsg) {
3227 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3228 return -ENOMEM;
3229 }
3230
Dino Myclee8843b32014-07-04 14:21:45 +05303231
Dino Mycle6fb96c12014-06-10 11:52:40 +05303232 pReqMsg->requestId = nla_get_u32(
3233 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3234 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3235
3236 /* Parse and fetch number of APs */
3237 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3238 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3239 goto fail;
3240 }
3241
3242 pReqMsg->sessionId = pAdapter->sessionId;
3243 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3244
3245 pReqMsg->numAp = nla_get_u32(
3246 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
3247 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3248
3249 nla_for_each_nested(apTh,
3250 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3251 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3252 nla_data(apTh), nla_len(apTh),
3253 NULL)) {
3254 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3255 goto fail;
3256 }
3257
3258 /* Parse and fetch MAC address */
3259 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3260 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3261 goto fail;
3262 }
3263 memcpy(pReqMsg->ap[i].bssid, nla_data(
3264 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3265 sizeof(tSirMacAddr));
3266 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3267
3268 /* Parse and fetch low RSSI */
3269 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3270 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3271 goto fail;
3272 }
3273 pReqMsg->ap[i].low = nla_get_s32(
3274 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3275 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3276
3277 /* Parse and fetch high RSSI */
3278 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3279 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3280 goto fail;
3281 }
3282 pReqMsg->ap[i].high = nla_get_s32(
3283 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3284 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3285 pReqMsg->ap[i].high);
3286
3287 /* Parse and fetch channel */
3288 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3289 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3290 goto fail;
3291 }
3292 pReqMsg->ap[i].channel = nla_get_u32(
3293 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3294 hddLog(VOS_TRACE_LEVEL_INFO,
3295 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3296 i++;
3297 }
3298 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3299 if (!HAL_STATUS_SUCCESS(status)) {
3300 hddLog(VOS_TRACE_LEVEL_ERROR,
3301 FL("sme_SetBssHotlist failed(err=%d)"), status);
3302 vos_mem_free(pReqMsg);
3303 return -EINVAL;
3304 }
3305
Dino Myclee8843b32014-07-04 14:21:45 +05303306 vos_mem_free(pReqMsg);
3307
Dino Mycle6fb96c12014-06-10 11:52:40 +05303308 return 0;
3309
3310fail:
3311 vos_mem_free(pReqMsg);
3312 return -EINVAL;
3313}
3314
3315static int wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
3316 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303317 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303318{
3319 tpSirEXTScanSetSignificantChangeReqParams pReqMsg = NULL;
3320 struct net_device *dev = wdev->netdev;
3321 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3322 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3323 struct nlattr
3324 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3325 struct nlattr
3326 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3327 struct nlattr *apTh;
3328 eHalStatus status;
3329 int i = 0;
3330 int rem;
3331
3332 status = wlan_hdd_validate_context(pHddCtx);
3333 if (0 != status)
3334 {
3335 hddLog(VOS_TRACE_LEVEL_ERROR,
3336 FL("HDD context is not valid"));
3337 return -EINVAL;
3338 }
Dino Myclee8843b32014-07-04 14:21:45 +05303339 /* check the EXTScan Capability */
3340 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3341 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3342 {
3343 hddLog(VOS_TRACE_LEVEL_ERROR,
3344 FL("EXTScan not enabled/supported by Firmware"));
3345 return -EINVAL;
3346 }
3347
Dino Mycle6fb96c12014-06-10 11:52:40 +05303348 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3349 data, dataLen,
3350 wlan_hdd_extscan_config_policy)) {
3351 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3352 return -EINVAL;
3353 }
3354
3355 /* Parse and fetch request Id */
3356 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3357 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3358 return -EINVAL;
3359 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303360 pReqMsg = (tpSirEXTScanSetSignificantChangeReqParams)
Dino Myclee8843b32014-07-04 14:21:45 +05303361 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303362 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05303363 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3364 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303365 }
3366
Dino Myclee8843b32014-07-04 14:21:45 +05303367
3368
Dino Mycle6fb96c12014-06-10 11:52:40 +05303369 pReqMsg->requestId = nla_get_u32(
3370 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3371 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3372
3373 /* Parse and fetch RSSI sample size */
3374 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE])
3375 {
3376 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr RSSI sample size failed"));
3377 goto fail;
3378 }
3379 pReqMsg->rssiSampleSize = nla_get_u32(
3380 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE]);
3381 hddLog(VOS_TRACE_LEVEL_INFO,
3382 FL("RSSI sample size (%u)"), pReqMsg->rssiSampleSize);
3383
3384 /* Parse and fetch lost AP sample size */
3385 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE])
3386 {
3387 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr lost AP sample size failed"));
3388 goto fail;
3389 }
3390 pReqMsg->lostApSampleSize = nla_get_u32(
3391 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]);
3392 hddLog(VOS_TRACE_LEVEL_INFO,
3393 FL("Lost AP sample size (%u)"), pReqMsg->lostApSampleSize);
3394 /* Parse and fetch minimum Breaching */
3395 if (!tb
3396 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]) {
3397 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr minBreaching failed"));
3398 goto fail;
3399 }
3400 pReqMsg->minBreaching = nla_get_u32(
3401 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]);
3402 hddLog(VOS_TRACE_LEVEL_INFO, FL(" Breaching (%d)"), pReqMsg->minBreaching);
3403
3404 /* Parse and fetch number of APs */
3405 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]) {
3406 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3407 goto fail;
3408 }
3409 pReqMsg->numAp = nla_get_u32(
3410 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]);
3411 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3412
3413 pReqMsg->sessionId = pAdapter->sessionId;
3414 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3415
3416 nla_for_each_nested(apTh,
3417 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3418 if(nla_parse(tb2,
3419 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3420 nla_data(apTh), nla_len(apTh),
3421 NULL)) {
3422 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3423 goto fail;
3424 }
3425
3426 /* Parse and fetch MAC address */
3427 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3428 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3429 goto fail;
3430 }
3431 memcpy(pReqMsg->ap[i].bssid, nla_data(
3432 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3433 sizeof(tSirMacAddr));
3434
3435 /* Parse and fetch low RSSI */
3436 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3437 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3438 goto fail;
3439 }
3440 pReqMsg->ap[i].low = nla_get_s32(
3441 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3442 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3443
3444 /* Parse and fetch high RSSI */
3445 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3446 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3447 goto fail;
3448 }
3449 pReqMsg->ap[i].high = nla_get_s32(
3450 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3451 hddLog(VOS_TRACE_LEVEL_INFO,
3452 FL("RSSI High (%d)"), pReqMsg->ap[i].high);
3453
3454 /* Parse and fetch channel */
3455 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3456 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3457 goto fail;
3458 }
3459 pReqMsg->ap[i].channel = nla_get_u32(
3460 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3461 hddLog(VOS_TRACE_LEVEL_INFO,
3462 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3463 i++;
3464 }
3465
3466 status = sme_SetSignificantChange(pHddCtx->hHal, pReqMsg);
3467 if (!HAL_STATUS_SUCCESS(status)) {
3468 hddLog(VOS_TRACE_LEVEL_ERROR,
3469 FL("sme_SetSignificantChange failed(err=%d)"), status);
3470 vos_mem_free(pReqMsg);
3471 return -EINVAL;
3472 }
Dino Myclee8843b32014-07-04 14:21:45 +05303473 vos_mem_free(pReqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303474 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Exiting"));
3475 return 0;
3476
3477fail:
3478 vos_mem_free(pReqMsg);
3479 return -EINVAL;
3480}
3481
3482static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
3483 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303484 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303485{
3486 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3487 tANI_U32 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
3488 tANI_U8 numChannels = 0;
3489 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3490 tANI_U32 requestId;
3491 tWifiBand wifiBand;
3492 eHalStatus status;
3493 struct sk_buff *replySkb;
3494 tANI_U8 i;
3495
3496 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering"));
3497 status = wlan_hdd_validate_context(pHddCtx);
3498 if (0 != status)
3499 {
3500 hddLog(VOS_TRACE_LEVEL_ERROR,
3501 FL("HDD context is not valid"));
3502 return -EINVAL;
3503 }
Dino Myclee8843b32014-07-04 14:21:45 +05303504 /* check the EXTScan Capability */
3505 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3506 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3507 {
3508 hddLog(VOS_TRACE_LEVEL_ERROR,
3509 FL("EXTScan not enabled/supported by Firmware"));
3510 return -EINVAL;
3511 }
3512
Dino Mycle6fb96c12014-06-10 11:52:40 +05303513 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3514 data, dataLen,
3515 wlan_hdd_extscan_config_policy)) {
3516 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3517 return -EINVAL;
3518 }
3519
3520 /* Parse and fetch request Id */
3521 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3522 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3523 return -EINVAL;
3524 }
3525 requestId = nla_get_u32(
3526 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3527 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
3528
3529 /* Parse and fetch wifi band */
3530 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
3531 {
3532 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
3533 return -EINVAL;
3534 }
3535 wifiBand = nla_get_u32(
3536 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
3537 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
3538
3539 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
3540 wifiBand, ChannelList,
3541 &numChannels);
3542 if (eHAL_STATUS_SUCCESS != status) {
3543 hddLog(VOS_TRACE_LEVEL_ERROR,
3544 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
3545 return -EINVAL;
3546 }
3547 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of channels (%d)"), numChannels);
3548 for (i = 0; i < numChannels; i++)
3549 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %u ", ChannelList[i]);
3550
3551 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
3552 sizeof(u32) * numChannels +
3553 NLMSG_HDRLEN);
3554
3555 if (!replySkb) {
3556 hddLog(VOS_TRACE_LEVEL_ERROR,
3557 FL("valid channels: buffer alloc fail"));
3558 return -EINVAL;
3559 }
3560 if (nla_put_u32(replySkb,
3561 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
3562 numChannels) ||
3563 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
3564 sizeof(u32) * numChannels, ChannelList)) {
3565
3566 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3567 kfree_skb(replySkb);
3568 return -EINVAL;
3569 }
3570
3571 return cfg80211_vendor_cmd_reply(replySkb);
3572}
3573
3574static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
3575 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303576 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303577{
Dino Myclee8843b32014-07-04 14:21:45 +05303578 tpSirEXTScanStartReqParams pReqMsg = NULL;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303579 struct net_device *dev = wdev->netdev;
3580 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3581 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3582 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3583 struct nlattr *bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3584 struct nlattr *channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3585 struct nlattr *buckets;
3586 struct nlattr *channels;
3587 int rem1;
3588 int rem2;
3589 eHalStatus status;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303590 tANI_U32 j = 0, index = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303591
3592 status = wlan_hdd_validate_context(pHddCtx);
3593 if (0 != status)
3594 {
3595 hddLog(VOS_TRACE_LEVEL_ERROR,
3596 FL("HDD context is not valid"));
3597 return -EINVAL;
3598 }
Dino Myclee8843b32014-07-04 14:21:45 +05303599 /* check the EXTScan Capability */
3600 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3601 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3602 {
3603 hddLog(VOS_TRACE_LEVEL_ERROR,
3604 FL("EXTScan not enabled/supported by Firmware"));
3605 return -EINVAL;
3606 }
3607
Dino Mycle6fb96c12014-06-10 11:52:40 +05303608 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3609 data, dataLen,
3610 wlan_hdd_extscan_config_policy)) {
3611 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3612 return -EINVAL;
3613 }
3614
3615 /* Parse and fetch request Id */
3616 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3617 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3618 return -EINVAL;
3619 }
3620
Dino Myclee8843b32014-07-04 14:21:45 +05303621 pReqMsg = (tpSirEXTScanStartReqParams)
3622 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303623 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05303624 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3625 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303626 }
3627
3628 pReqMsg->requestId = nla_get_u32(
3629 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3630 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3631
3632 pReqMsg->sessionId = pAdapter->sessionId;
3633 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3634
3635 /* Parse and fetch base period */
3636 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]) {
3637 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
3638 goto fail;
3639 }
3640 pReqMsg->basePeriod = nla_get_u32(
3641 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]);
3642 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
3643 pReqMsg->basePeriod);
3644
3645 /* Parse and fetch max AP per scan */
3646 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]) {
3647 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
3648 goto fail;
3649 }
3650 pReqMsg->maxAPperScan = nla_get_u32(
3651 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]);
3652 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
3653 pReqMsg->maxAPperScan);
3654
3655 /* Parse and fetch report threshold */
3656 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]) {
3657 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
3658 goto fail;
3659 }
3660 pReqMsg->reportThreshold = nla_get_u8(
3661 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]);
3662 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
3663 pReqMsg->reportThreshold);
3664
3665 /* Parse and fetch number of buckets */
3666 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]) {
3667 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
3668 goto fail;
3669 }
3670 pReqMsg->numBuckets = nla_get_u8(
3671 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]);
3672 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
3673 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
3674 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
3675 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
3676 }
3677 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
3678 pReqMsg->numBuckets);
3679 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
3680 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
3681 goto fail;
3682 }
3683
3684 nla_for_each_nested(buckets,
3685 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
3686 if(nla_parse(bucket,
3687 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3688 nla_data(buckets), nla_len(buckets), NULL)) { //policy
3689 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3690 goto fail;
3691 }
3692
3693 /* Parse and fetch bucket spec */
3694 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
3695 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket index failed"));
3696 goto fail;
3697 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303698
3699 pReqMsg->buckets[index].bucket = nla_get_u8(
3700 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
3701
3702 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bucket spec Index (%d)"),
3703 pReqMsg->buckets[index].bucket);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303704
3705 /* Parse and fetch wifi band */
3706 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
3707 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
3708 goto fail;
3709 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303710 pReqMsg->buckets[index].band = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303711 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
3712 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303713 pReqMsg->buckets[index].band);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303714
3715 /* Parse and fetch period */
3716 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
3717 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr period failed"));
3718 goto fail;
3719 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303720 pReqMsg->buckets[index].period = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303721 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
3722 hddLog(VOS_TRACE_LEVEL_INFO, FL("period (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303723 pReqMsg->buckets[index].period);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303724
3725 /* Parse and fetch report events */
3726 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
3727 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report events failed"));
3728 goto fail;
3729 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303730 pReqMsg->buckets[index].reportEvents = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303731 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
3732 hddLog(VOS_TRACE_LEVEL_INFO, FL("report events (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303733 pReqMsg->buckets[index].reportEvents);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303734
3735 /* Parse and fetch number of channels */
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303736 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS])
3737 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303738 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr num channels failed"));
3739 goto fail;
3740 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303741 pReqMsg->buckets[index].numChannels = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303742 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
3743 hddLog(VOS_TRACE_LEVEL_INFO, FL("num channels (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303744 pReqMsg->buckets[index].numChannels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303745
3746 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
3747 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel spec failed"));
3748 goto fail;
3749 }
3750
3751 j = 0;
3752 nla_for_each_nested(channels,
3753 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
3754 if(nla_parse(channel,
3755 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3756 nla_data(channels), nla_len(channels),
3757 NULL)) { //wlan_hdd_extscan_config_policy here
3758 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3759 goto fail;
3760 }
3761
3762 /* Parse and fetch channel */
3763 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
3764 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3765 goto fail;
3766 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303767 pReqMsg->buckets[index].channels[j].channel = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303768 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
3769 hddLog(VOS_TRACE_LEVEL_INFO, FL("channel (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303770 pReqMsg->buckets[index].channels[j].channel);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303771
3772 /* Parse and fetch dwell time */
3773 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
3774 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dwelltime failed"));
3775 goto fail;
3776 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303777 pReqMsg->buckets[index].channels[j].dwellTimeMs = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303778 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
3779 hddLog(VOS_TRACE_LEVEL_INFO, FL("Dwell time (%u ms)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303780 pReqMsg->buckets[index].channels[j].dwellTimeMs);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303781
3782 /* Parse and fetch channel spec passive */
3783 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
3784 hddLog(VOS_TRACE_LEVEL_ERROR,
3785 FL("attr channel spec passive failed"));
3786 goto fail;
3787 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303788 pReqMsg->buckets[index].channels[j].passive = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303789 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
3790 hddLog(VOS_TRACE_LEVEL_INFO, FL("Chnl spec passive (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303791 pReqMsg->buckets[index].channels[j].passive);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303792 j++;
3793 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303794 index++;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303795 }
3796 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
3797 if (!HAL_STATUS_SUCCESS(status)) {
3798 hddLog(VOS_TRACE_LEVEL_ERROR,
3799 FL("sme_EXTScanStart failed(err=%d)"), status);
3800 vos_mem_free(pReqMsg);
3801 return -EINVAL;
3802 }
3803
Dino Myclee8843b32014-07-04 14:21:45 +05303804 vos_mem_free(pReqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303805 return 0;
3806
3807fail:
3808 vos_mem_free(pReqMsg);
3809 return -EINVAL;
3810}
3811
3812static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
3813 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303814 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303815{
Dino Myclee8843b32014-07-04 14:21:45 +05303816 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303817 struct net_device *dev = wdev->netdev;
3818 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3819 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3820 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3821 eHalStatus status;
3822
3823 status = wlan_hdd_validate_context(pHddCtx);
3824 if (0 != status)
3825 {
3826 hddLog(VOS_TRACE_LEVEL_ERROR,
3827 FL("HDD context is not valid"));
3828 return -EINVAL;
3829 }
Dino Myclee8843b32014-07-04 14:21:45 +05303830 /* check the EXTScan Capability */
3831 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3832 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3833 {
3834 hddLog(VOS_TRACE_LEVEL_ERROR,
3835 FL("EXTScan not enabled/supported by Firmware"));
3836 return -EINVAL;
3837 }
3838
Dino Mycle6fb96c12014-06-10 11:52:40 +05303839 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3840 data, dataLen,
3841 wlan_hdd_extscan_config_policy)) {
3842 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3843 return -EINVAL;
3844 }
3845
3846 /* Parse and fetch request Id */
3847 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3848 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3849 return -EINVAL;
3850 }
3851
Dino Myclee8843b32014-07-04 14:21:45 +05303852 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303853 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303854 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303855
Dino Myclee8843b32014-07-04 14:21:45 +05303856 reqMsg.sessionId = pAdapter->sessionId;
3857 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303858
Dino Myclee8843b32014-07-04 14:21:45 +05303859 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303860 if (!HAL_STATUS_SUCCESS(status)) {
3861 hddLog(VOS_TRACE_LEVEL_ERROR,
3862 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303863 return -EINVAL;
3864 }
3865
3866 return 0;
3867}
3868
3869static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
3870 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303871 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303872{
Dino Myclee8843b32014-07-04 14:21:45 +05303873 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303874 struct net_device *dev = wdev->netdev;
3875 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3876 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3877 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3878 eHalStatus status;
3879
3880 status = wlan_hdd_validate_context(pHddCtx);
3881 if (0 != status)
3882 {
3883 hddLog(VOS_TRACE_LEVEL_ERROR,
3884 FL("HDD context is not valid"));
3885 return -EINVAL;
3886 }
Dino Myclee8843b32014-07-04 14:21:45 +05303887 /* check the EXTScan Capability */
3888 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3889 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3890 {
3891 hddLog(VOS_TRACE_LEVEL_ERROR,
3892 FL("EXTScan not enabled/supported by Firmware"));
3893 return -EINVAL;
3894 }
3895
Dino Mycle6fb96c12014-06-10 11:52:40 +05303896 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3897 data, dataLen,
3898 wlan_hdd_extscan_config_policy)) {
3899 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3900 return -EINVAL;
3901 }
3902
3903 /* Parse and fetch request Id */
3904 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3905 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3906 return -EINVAL;
3907 }
3908
Dino Myclee8843b32014-07-04 14:21:45 +05303909 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303910 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303911 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303912
Dino Myclee8843b32014-07-04 14:21:45 +05303913 reqMsg.sessionId = pAdapter->sessionId;
3914 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303915
Dino Myclee8843b32014-07-04 14:21:45 +05303916 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303917 if (!HAL_STATUS_SUCCESS(status)) {
3918 hddLog(VOS_TRACE_LEVEL_ERROR,
3919 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303920 return -EINVAL;
3921 }
3922
3923 return 0;
3924}
3925
3926static int wlan_hdd_cfg80211_extscan_reset_significant_change(
3927 struct wiphy *wiphy,
3928 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303929 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303930{
Dino Myclee8843b32014-07-04 14:21:45 +05303931 tSirEXTScanResetSignificantChangeReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303932 struct net_device *dev = wdev->netdev;
3933 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3934 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3935 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3936 eHalStatus status;
3937
3938 hddLog(VOS_TRACE_LEVEL_INFO, FL(" Entering"));
3939 status = wlan_hdd_validate_context(pHddCtx);
3940 if (0 != status)
3941 {
3942 hddLog(VOS_TRACE_LEVEL_ERROR,
3943 FL("HDD context is not valid"));
3944 return -EINVAL;
3945 }
Dino Myclee8843b32014-07-04 14:21:45 +05303946 /* check the EXTScan Capability */
3947 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3948 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3949 {
3950 hddLog(VOS_TRACE_LEVEL_ERROR,
3951 FL("EXTScan not enabled/supported by Firmware"));
3952 return -EINVAL;
3953 }
3954
Dino Mycle6fb96c12014-06-10 11:52:40 +05303955 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3956 data, dataLen,
3957 wlan_hdd_extscan_config_policy)) {
3958 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3959 return -EINVAL;
3960 }
3961
3962 /* Parse and fetch request Id */
3963 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3964 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3965 return -EINVAL;
3966 }
3967
Dino Mycle6fb96c12014-06-10 11:52:40 +05303968
Dino Myclee8843b32014-07-04 14:21:45 +05303969 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303970 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303971 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303972
Dino Myclee8843b32014-07-04 14:21:45 +05303973 reqMsg.sessionId = pAdapter->sessionId;
3974 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303975
Dino Myclee8843b32014-07-04 14:21:45 +05303976 status = sme_ResetSignificantChange(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303977 if (!HAL_STATUS_SUCCESS(status)) {
3978 hddLog(VOS_TRACE_LEVEL_ERROR,
3979 FL("sme_ResetSignificantChange failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303980 return -EINVAL;
3981 }
3982
3983 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Exiting"));
3984 return 0;
3985}
3986
3987#endif /* WLAN_FEATURE_EXTSCAN */
3988
Atul Mittal115287b2014-07-08 13:26:33 +05303989/*EXT TDLS*/
3990static const struct nla_policy
3991wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
3992{
3993 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
3994 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
3995 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
3996 {.type = NLA_S32 },
3997 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
3998 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
3999
4000};
4001
4002static const struct nla_policy
4003wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
4004{
4005 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4006
4007};
4008
4009static const struct nla_policy
4010wlan_hdd_tdls_config_state_change_policy[
4011 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
4012{
4013 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
4014 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
4015 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304016 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
4017 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
4018 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304019
4020};
4021
4022static const struct nla_policy
4023wlan_hdd_tdls_config_get_status_policy[
4024 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
4025{
4026 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
4027 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
4028 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304029 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
4030 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
4031 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304032
4033};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304034
4035static const struct nla_policy
4036wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
4037{
4038 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
4039};
4040
4041static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
4042 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304043 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304044 int data_len)
4045{
4046
4047 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4048 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
4049
4050 if (0 != wlan_hdd_validate_context(pHddCtx)){
4051 hddLog(VOS_TRACE_LEVEL_ERROR, FL("hdd Ctx invalid while spoof macAddr"));
4052 return -EINVAL;
4053 }
4054 if (FALSE == pHddCtx->cfg_ini->enableMacSpoofing) {
4055 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MAC_SPOOFED_SCAN disabled in ini"));
4056 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05304057 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304058 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
4059 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MAC_SPOOFED_SCAN not supported by FW"));
4060 return -ENOTSUPP;
4061 }
4062
4063 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
4064 data, data_len, wlan_hdd_mac_config)) {
4065 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4066 return -EINVAL;
4067 }
4068
4069 /* Parse and fetch mac address */
4070 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
4071 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4072 return -EINVAL;
4073 }
4074
4075 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
4076 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4077 VOS_MAC_ADDR_LAST_3_BYTES);
4078
Siddharth Bhal76972212014-10-15 16:22:51 +05304079 pHddCtx->spoofMacAddr.isEnabled = TRUE;
4080
4081 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304082 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4083 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05304084 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
4085 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
4086 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
4087 {
4088 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
4089 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
4090 VOS_MAC_ADDRESS_LEN);
4091 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304092 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304093
Siddharth Bhal76972212014-10-15 16:22:51 +05304094 if (VOS_STATUS_SUCCESS != hdd_processSpoofMacAddrRequest(pHddCtx))
4095 {
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304096 hddLog(LOGE, FL("Failed to send Spoof Mac Addr to FW"));
4097 }
4098
4099 return 0;
4100}
4101
Atul Mittal115287b2014-07-08 13:26:33 +05304102static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
4103 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304104 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304105 int data_len)
4106{
4107 u8 peer[6] = {0};
4108 struct net_device *dev = wdev->netdev;
4109 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4110 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4111 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
4112 eHalStatus ret;
4113 tANI_S32 state;
4114 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304115 tANI_S32 global_operating_class = 0;
4116 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05304117 struct sk_buff *skb = NULL;
4118
4119 ret = wlan_hdd_validate_context(pHddCtx);
4120 if (0 != ret) {
4121
4122 return -EINVAL;
4123 }
4124 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
4125
4126 return -ENOTSUPP;
4127 }
4128 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
4129 data, data_len,
4130 wlan_hdd_tdls_config_get_status_policy)) {
4131 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4132 return -EINVAL;
4133 }
4134
4135 /* Parse and fetch mac address */
4136 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
4137 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4138 return -EINVAL;
4139 }
4140
4141 memcpy(peer, nla_data(
4142 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
4143 sizeof(peer));
4144 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4145
4146 ret = wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
4147
4148 if (0 != ret) {
4149 hddLog(VOS_TRACE_LEVEL_ERROR,
4150 FL("get status Failed"));
4151 return -EINVAL;
4152 }
4153 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304154 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05304155 NLMSG_HDRLEN);
4156
4157 if (!skb) {
4158 hddLog(VOS_TRACE_LEVEL_ERROR,
4159 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
4160 return -EINVAL;
4161 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304162 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reason (%d) Status (%d) class (%d) channel (%d) peer" MAC_ADDRESS_STR),
Atul Mittal115287b2014-07-08 13:26:33 +05304163 reason,
4164 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304165 global_operating_class,
4166 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05304167 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304168 if (nla_put_s32(skb,
4169 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
4170 state) ||
4171 nla_put_s32(skb,
4172 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
4173 reason) ||
4174 nla_put_s32(skb,
4175 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
4176 global_operating_class) ||
4177 nla_put_s32(skb,
4178 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
4179 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05304180
4181 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4182 goto nla_put_failure;
4183 }
4184
4185 return cfg80211_vendor_cmd_reply(skb);
4186
4187nla_put_failure:
4188 kfree_skb(skb);
4189 return -EINVAL;
4190}
4191
4192static int wlan_hdd_cfg80211_exttdls_callback(tANI_U8* mac,
4193 tANI_S32 state,
4194 tANI_S32 reason,
4195 void *ctx)
4196{
4197 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
4198 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4199 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304200 tANI_S32 global_operating_class = 0;
4201 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05304202
4203 if (wlan_hdd_validate_context(pHddCtx)) {
4204 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "));
4205 return -EINVAL;
4206 }
4207
4208 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
4209
4210 return -ENOTSUPP;
4211 }
4212 skb = cfg80211_vendor_event_alloc(
4213 pHddCtx->wiphy,
4214 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
4215 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
4216 GFP_KERNEL);
4217
4218 if (!skb) {
4219 hddLog(VOS_TRACE_LEVEL_ERROR,
4220 FL("cfg80211_vendor_event_alloc failed"));
4221 return -EINVAL;
4222 }
4223 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304224 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
4225 reason,
4226 state,
4227 global_operating_class,
4228 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05304229 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
4230 MAC_ADDR_ARRAY(mac));
4231
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304232 if (nla_put(skb,
4233 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
4234 VOS_MAC_ADDR_SIZE, mac) ||
4235 nla_put_s32(skb,
4236 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
4237 state) ||
4238 nla_put_s32(skb,
4239 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
4240 reason) ||
4241 nla_put_s32(skb,
4242 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
4243 channel) ||
4244 nla_put_s32(skb,
4245 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
4246 global_operating_class)
4247 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05304248 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4249 goto nla_put_failure;
4250 }
4251
4252 cfg80211_vendor_event(skb, GFP_KERNEL);
4253 return (0);
4254
4255nla_put_failure:
4256 kfree_skb(skb);
4257 return -EINVAL;
4258}
4259
4260static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
4261 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304262 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304263 int data_len)
4264{
4265 u8 peer[6] = {0};
4266 struct net_device *dev = wdev->netdev;
4267 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4268 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4269 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
4270 eHalStatus status;
4271 tdls_req_params_t pReqMsg = {0};
4272
4273 status = wlan_hdd_validate_context(pHddCtx);
4274 if (0 != status) {
4275 hddLog(VOS_TRACE_LEVEL_ERROR,
4276 FL("HDD context is not valid"));
4277 return -EINVAL;
4278 }
4279 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
4280
4281 return -ENOTSUPP;
4282 }
4283 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
4284 data, data_len,
4285 wlan_hdd_tdls_config_enable_policy)) {
4286 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4287 return -EINVAL;
4288 }
4289
4290 /* Parse and fetch mac address */
4291 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
4292 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4293 return -EINVAL;
4294 }
4295
4296 memcpy(peer, nla_data(
4297 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
4298 sizeof(peer));
4299 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4300
4301 /* Parse and fetch channel */
4302 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
4303 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4304 return -EINVAL;
4305 }
4306 pReqMsg.channel = nla_get_s32(
4307 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
4308 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
4309
4310 /* Parse and fetch global operating class */
4311 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
4312 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
4313 return -EINVAL;
4314 }
4315 pReqMsg.global_operating_class = nla_get_s32(
4316 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
4317 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
4318 pReqMsg.global_operating_class);
4319
4320 /* Parse and fetch latency ms */
4321 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
4322 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
4323 return -EINVAL;
4324 }
4325 pReqMsg.max_latency_ms = nla_get_s32(
4326 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
4327 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
4328 pReqMsg.max_latency_ms);
4329
4330 /* Parse and fetch required bandwidth kbps */
4331 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
4332 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
4333 return -EINVAL;
4334 }
4335
4336 pReqMsg.min_bandwidth_kbps = nla_get_s32(
4337 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
4338 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
4339 pReqMsg.min_bandwidth_kbps);
4340
4341 return (wlan_hdd_tdls_extctrl_config_peer(pAdapter,
4342 peer,
4343 wlan_hdd_cfg80211_exttdls_callback));
4344}
4345
4346static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
4347 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304348 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304349 int data_len)
4350{
4351 u8 peer[6] = {0};
4352 struct net_device *dev = wdev->netdev;
4353 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4354 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4355 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
4356 eHalStatus status;
4357
4358 status = wlan_hdd_validate_context(pHddCtx);
4359 if (0 != status) {
4360 hddLog(VOS_TRACE_LEVEL_ERROR,
4361 FL("HDD context is not valid"));
4362 return -EINVAL;
4363 }
4364 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
4365
4366 return -ENOTSUPP;
4367 }
4368 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
4369 data, data_len,
4370 wlan_hdd_tdls_config_disable_policy)) {
4371 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4372 return -EINVAL;
4373 }
4374 /* Parse and fetch mac address */
4375 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
4376 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4377 return -EINVAL;
4378 }
4379
4380 memcpy(peer, nla_data(
4381 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
4382 sizeof(peer));
4383 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4384
4385 return (wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer));
4386}
4387
Dasari Srinivas7875a302014-09-26 17:50:57 +05304388static int
4389wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
4390 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304391 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05304392{
4393 struct net_device *dev = wdev->netdev;
4394 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4395 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4396 struct sk_buff *skb = NULL;
4397 tANI_U32 fset = 0;
4398
4399 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
4400 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
4401 fset |= WIFI_FEATURE_INFRA;
4402 }
4403
4404 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
4405 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
4406 fset |= WIFI_FEATURE_INFRA_5G;
4407 }
4408
4409#ifdef WLAN_FEATURE_P2P
4410 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
4411 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
4412 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
4413 fset |= WIFI_FEATURE_P2P;
4414 }
4415#endif
4416
4417 /* Soft-AP is supported currently by default */
4418 fset |= WIFI_FEATURE_SOFT_AP;
4419
4420#ifdef WLAN_FEATURE_EXTSCAN
4421 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
4422 sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) {
4423 hddLog(LOG1, FL("EXTScan is supported by firmware"));
4424 fset |= WIFI_FEATURE_EXTSCAN;
4425 }
4426#endif
4427
4428#ifdef WLAN_FEATURE_NAN
4429 if (sme_IsFeatureSupportedByFW(NAN)) {
4430 hddLog(LOG1, FL("NAN is supported by firmware"));
4431 fset |= WIFI_FEATURE_NAN;
4432 }
4433#endif
4434
4435 /* D2D RTT is not supported currently by default */
4436 if (sme_IsFeatureSupportedByFW(RTT)) {
4437 hddLog(LOG1, FL("RTT is supported by firmware"));
4438 fset |= WIFI_FEATURE_D2AP_RTT;
4439 }
4440
4441#ifdef FEATURE_WLAN_BATCH_SCAN
4442 if (fset & WIFI_FEATURE_EXTSCAN) {
4443 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
4444 fset &= ~WIFI_FEATURE_BATCH_SCAN;
4445 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
4446 hddLog(LOG1, FL("Batch scan is supported by firmware"));
4447 fset |= WIFI_FEATURE_BATCH_SCAN;
4448 }
4449#endif
4450
4451#ifdef FEATURE_WLAN_SCAN_PNO
4452 if (pHddCtx->cfg_ini->configPNOScanSupport &&
4453 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
4454 hddLog(LOG1, FL("PNO is supported by firmware"));
4455 fset |= WIFI_FEATURE_PNO;
4456 }
4457#endif
4458
4459 /* STA+STA is supported currently by default */
4460 fset |= WIFI_FEATURE_ADDITIONAL_STA;
4461
4462#ifdef FEATURE_WLAN_TDLS
4463 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
4464 sme_IsFeatureSupportedByFW(TDLS)) {
4465 hddLog(LOG1, FL("TDLS is supported by firmware"));
4466 fset |= WIFI_FEATURE_TDLS;
4467 }
4468
4469 /* TDLS_OFFCHANNEL is not supported currently by default */
4470#endif
4471
4472#ifdef WLAN_AP_STA_CONCURRENCY
4473 /* AP+STA concurrency is supported currently by default */
4474 fset |= WIFI_FEATURE_AP_STA;
4475#endif
4476
4477 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
4478 NLMSG_HDRLEN);
4479
4480 if (!skb) {
4481 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
4482 return -EINVAL;
4483 }
4484 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
4485
4486 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
4487 hddLog(LOGE, FL("nla put fail"));
4488 goto nla_put_failure;
4489 }
4490
4491 return cfg80211_vendor_cmd_reply(skb);
4492
4493nla_put_failure:
4494 kfree_skb(skb);
4495 return -EINVAL;
4496}
4497
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05304498static int
4499wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
4500 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304501 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05304502{
4503 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
4504 uint8_t i, feature_sets, max_feature_sets;
4505 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX + 1];
4506 struct sk_buff *reply_skb;
4507
4508 ENTER();
4509
4510 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX,
4511 data, data_len, NULL)) {
4512 hddLog(LOGE, FL("Invalid ATTR"));
4513 return -EINVAL;
4514 }
4515
4516 /* Parse and fetch max feature set */
4517 if (!tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
4518 hddLog(LOGE, FL("Attr max feature set size failed"));
4519 return -EINVAL;
4520 }
4521 max_feature_sets = nla_get_u32(
4522 tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
4523 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
4524
4525 /* Fill feature combination matrix */
4526 feature_sets = 0;
4527 if (feature_sets >= WLAN_HDD_MAX_FEATURE_SET) goto max_buffer_err;
4528 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
4529 WIFI_FEATURE_P2P;
4530
4531 if (feature_sets >= WLAN_HDD_MAX_FEATURE_SET) goto max_buffer_err;
4532 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
4533 WIFI_FEATURE_SOFT_AP;
4534
4535 if (feature_sets >= WLAN_HDD_MAX_FEATURE_SET) goto max_buffer_err;
4536 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
4537 WIFI_FEATURE_SOFT_AP;
4538
4539 if (feature_sets >= WLAN_HDD_MAX_FEATURE_SET) goto max_buffer_err;
4540 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
4541 WIFI_FEATURE_SOFT_AP |
4542 WIFI_FEATURE_P2P;
4543
4544 /* Add more feature combinations here */
4545
4546 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
4547 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
4548 hddLog(LOG1, "Feature set matrix");
4549 for (i = 0; i < feature_sets; i++)
4550 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
4551
4552 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
4553 sizeof(u32) * feature_sets +
4554 NLMSG_HDRLEN);
4555
4556 if (reply_skb) {
4557 if (nla_put_u32(reply_skb,
4558 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
4559 feature_sets) ||
4560 nla_put(reply_skb,
4561 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
4562 sizeof(u32) * feature_sets, feature_set_matrix)) {
4563 hddLog(LOGE, FL("nla put fail"));
4564 kfree_skb(reply_skb);
4565 return -EINVAL;
4566 }
4567
4568 return cfg80211_vendor_cmd_reply(reply_skb);
4569 }
4570 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
4571 return -ENOMEM;
4572
4573max_buffer_err:
4574 hddLog(LOGE, FL("Feature set max buffer size reached. feature_sets(%d) max(%d)"),
4575 feature_sets, WLAN_HDD_MAX_FEATURE_SET);
4576 return -EINVAL;
4577}
4578
Agarwal Ashish738843c2014-09-25 12:27:56 +05304579static const struct nla_policy
4580wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
4581 +1] =
4582{
4583 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
4584};
4585
4586static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
4587 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304588 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05304589 int data_len)
4590{
4591 struct net_device *dev = wdev->netdev;
4592 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4593 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4594 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4595 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
4596 eHalStatus status;
4597 u32 dfsFlag = 0;
4598
4599 status = wlan_hdd_validate_context(pHddCtx);
4600 if (0 != status) {
4601 hddLog(VOS_TRACE_LEVEL_ERROR,
4602 FL("HDD context is not valid"));
4603 return -EINVAL;
4604 }
4605 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
4606 data, data_len,
4607 wlan_hdd_set_no_dfs_flag_config_policy)) {
4608 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4609 return -EINVAL;
4610 }
4611
4612 /* Parse and fetch required bandwidth kbps */
4613 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
4614 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
4615 return -EINVAL;
4616 }
4617
4618 dfsFlag = nla_get_u32(
4619 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
4620 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
4621 dfsFlag);
4622
4623 pHddCtx->disable_dfs_flag = dfsFlag;
4624
4625 sme_disable_dfs_channel(hHal, dfsFlag);
4626 sme_FilterScanResults(hHal, pAdapter->sessionId);
4627 return 0;
4628}
Atul Mittal115287b2014-07-08 13:26:33 +05304629
Mukul Sharma2a271632014-10-13 14:59:01 +05304630const struct
4631nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
4632{
4633 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
4634 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
4635};
4636
4637static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05304638 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05304639{
4640
4641 u8 bssid[6] = {0};
4642 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4643 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
4644 eHalStatus status = eHAL_STATUS_SUCCESS;
4645 v_U32_t isFwrRoamEnabled = FALSE;
4646 int ret;
4647
4648 if (NULL == pHddCtx) {
4649 hddLog(VOS_TRACE_LEVEL_ERROR,
4650 FL("HDD context is not valid"));
4651 return -EINVAL;
4652 }
4653
4654 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
4655 data, data_len,
4656 qca_wlan_vendor_attr);
4657 if (ret){
4658 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4659 return -EINVAL;
4660 }
4661
4662 /* Parse and fetch Enable flag */
4663 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
4664 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
4665 return -EINVAL;
4666 }
4667
4668 isFwrRoamEnabled = nla_get_u32(
4669 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
4670
4671 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
4672
4673 /* Parse and fetch bssid */
4674 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
4675 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
4676 return -EINVAL;
4677 }
4678
4679 memcpy(bssid, nla_data(
4680 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
4681 sizeof(bssid));
4682 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
4683
4684 //Update roaming
4685 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
4686 return status;
4687}
4688
Sunil Duttc69bccb2014-05-26 21:30:20 +05304689const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
4690{
Mukul Sharma2a271632014-10-13 14:59:01 +05304691 {
4692 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4693 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
4694 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4695 WIPHY_VENDOR_CMD_NEED_NETDEV |
4696 WIPHY_VENDOR_CMD_NEED_RUNNING,
Jeff Johnson393c2702014-12-16 11:09:35 +05304697 .doit = (void *)wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05304698 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05304699#ifdef WLAN_FEATURE_LINK_LAYER_STATS
4700 {
4701 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4702 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
4703 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4704 WIPHY_VENDOR_CMD_NEED_NETDEV |
4705 WIPHY_VENDOR_CMD_NEED_RUNNING,
Jeff Johnson393c2702014-12-16 11:09:35 +05304706 .doit = (void *)wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05304707 },
4708
4709 {
4710 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4711 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
4712 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4713 WIPHY_VENDOR_CMD_NEED_NETDEV |
4714 WIPHY_VENDOR_CMD_NEED_RUNNING,
Jeff Johnson393c2702014-12-16 11:09:35 +05304715 .doit = (void *)wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05304716 },
4717
4718 {
4719 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4720 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
4721 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4722 WIPHY_VENDOR_CMD_NEED_NETDEV |
4723 WIPHY_VENDOR_CMD_NEED_RUNNING,
Jeff Johnson393c2702014-12-16 11:09:35 +05304724 .doit = (void *)wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05304725 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05304726#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05304727#ifdef WLAN_FEATURE_EXTSCAN
4728 {
4729 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4730 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
4731 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4732 WIPHY_VENDOR_CMD_NEED_NETDEV |
4733 WIPHY_VENDOR_CMD_NEED_RUNNING,
Jeff Johnson393c2702014-12-16 11:09:35 +05304734 .doit = (void *)wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05304735 },
4736 {
4737 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4738 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
4739 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4740 WIPHY_VENDOR_CMD_NEED_NETDEV |
4741 WIPHY_VENDOR_CMD_NEED_RUNNING,
Jeff Johnson393c2702014-12-16 11:09:35 +05304742 .doit = (void *)wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05304743 },
4744 {
4745 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4746 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
4747 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4748 WIPHY_VENDOR_CMD_NEED_NETDEV,
Jeff Johnson393c2702014-12-16 11:09:35 +05304749 .doit = (void *)wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05304750 },
4751 {
4752 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4753 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
4754 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4755 WIPHY_VENDOR_CMD_NEED_NETDEV |
4756 WIPHY_VENDOR_CMD_NEED_RUNNING,
Jeff Johnson393c2702014-12-16 11:09:35 +05304757 .doit = (void *)wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05304758 },
4759 {
4760 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4761 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
4762 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4763 WIPHY_VENDOR_CMD_NEED_NETDEV |
4764 WIPHY_VENDOR_CMD_NEED_RUNNING,
Jeff Johnson393c2702014-12-16 11:09:35 +05304765 .doit = (void *)wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05304766 },
4767 {
4768 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4769 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
4770 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4771 WIPHY_VENDOR_CMD_NEED_NETDEV |
4772 WIPHY_VENDOR_CMD_NEED_RUNNING,
Jeff Johnson393c2702014-12-16 11:09:35 +05304773 .doit = (void *)wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05304774 },
4775 {
4776 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4777 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
4778 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4779 WIPHY_VENDOR_CMD_NEED_NETDEV |
4780 WIPHY_VENDOR_CMD_NEED_RUNNING,
Jeff Johnson393c2702014-12-16 11:09:35 +05304781 .doit = (void *)wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05304782 },
4783 {
4784 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4785 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE,
4786 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4787 WIPHY_VENDOR_CMD_NEED_NETDEV |
4788 WIPHY_VENDOR_CMD_NEED_RUNNING,
Jeff Johnson393c2702014-12-16 11:09:35 +05304789 .doit = (void *)wlan_hdd_cfg80211_extscan_set_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05304790 },
4791 {
4792 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4793 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE,
4794 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4795 WIPHY_VENDOR_CMD_NEED_NETDEV |
4796 WIPHY_VENDOR_CMD_NEED_RUNNING,
Jeff Johnson393c2702014-12-16 11:09:35 +05304797 .doit = (void *)wlan_hdd_cfg80211_extscan_reset_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05304798 },
4799#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05304800/*EXT TDLS*/
4801 {
4802 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4803 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
4804 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4805 WIPHY_VENDOR_CMD_NEED_NETDEV |
4806 WIPHY_VENDOR_CMD_NEED_RUNNING,
Jeff Johnson393c2702014-12-16 11:09:35 +05304807 .doit = (void *)wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05304808 },
4809 {
4810 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4811 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
4812 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4813 WIPHY_VENDOR_CMD_NEED_NETDEV |
4814 WIPHY_VENDOR_CMD_NEED_RUNNING,
Jeff Johnson393c2702014-12-16 11:09:35 +05304815 .doit = (void *)wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05304816 },
4817 {
4818 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4819 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
4820 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4821 WIPHY_VENDOR_CMD_NEED_NETDEV,
Jeff Johnson393c2702014-12-16 11:09:35 +05304822 .doit = (void *)wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05304823 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05304824 {
4825 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4826 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
4827 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4828 WIPHY_VENDOR_CMD_NEED_NETDEV,
Jeff Johnson393c2702014-12-16 11:09:35 +05304829 .doit = (void *)wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05304830 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05304831 {
4832 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4833 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
4834 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4835 WIPHY_VENDOR_CMD_NEED_NETDEV,
Jeff Johnson393c2702014-12-16 11:09:35 +05304836 .doit = (void *)wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05304837 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304838 {
4839 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4840 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
4841 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4842 WIPHY_VENDOR_CMD_NEED_NETDEV,
Jeff Johnson393c2702014-12-16 11:09:35 +05304843 .doit = (void *) wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304844 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05304845 {
4846 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4847 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
4848 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4849 WIPHY_VENDOR_CMD_NEED_NETDEV,
Jeff Johnson393c2702014-12-16 11:09:35 +05304850 .doit = (void *)wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05304851 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05304852};
4853
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08004854/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05304855static const
4856struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08004857{
4858#ifdef FEATURE_WLAN_CH_AVOID
4859 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05304860 .vendor_id = QCA_NL80211_VENDOR_ID,
4861 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08004862 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05304863#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
4864#ifdef WLAN_FEATURE_LINK_LAYER_STATS
4865 {
4866 /* Index = 1*/
4867 .vendor_id = QCA_NL80211_VENDOR_ID,
4868 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
4869 },
4870 {
4871 /* Index = 2*/
4872 .vendor_id = QCA_NL80211_VENDOR_ID,
4873 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
4874 },
4875 {
4876 /* Index = 3*/
4877 .vendor_id = QCA_NL80211_VENDOR_ID,
4878 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
4879 },
4880 {
4881 /* Index = 4*/
4882 .vendor_id = QCA_NL80211_VENDOR_ID,
4883 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
4884 },
4885 {
4886 /* Index = 5*/
4887 .vendor_id = QCA_NL80211_VENDOR_ID,
4888 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
4889 },
4890 {
4891 /* Index = 6*/
4892 .vendor_id = QCA_NL80211_VENDOR_ID,
4893 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
4894 },
4895#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05304896#ifdef WLAN_FEATURE_EXTSCAN
4897 {
4898 .vendor_id = QCA_NL80211_VENDOR_ID,
4899 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
4900 },
4901 {
4902 .vendor_id = QCA_NL80211_VENDOR_ID,
4903 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
4904 },
4905 {
4906 .vendor_id = QCA_NL80211_VENDOR_ID,
4907 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
4908 },
4909 {
4910 .vendor_id = QCA_NL80211_VENDOR_ID,
4911 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
4912 },
4913 {
4914 .vendor_id = QCA_NL80211_VENDOR_ID,
4915 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
4916 },
4917 {
4918 .vendor_id = QCA_NL80211_VENDOR_ID,
4919 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
4920 },
4921 {
4922 .vendor_id = QCA_NL80211_VENDOR_ID,
4923 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
4924 },
4925 {
4926 .vendor_id = QCA_NL80211_VENDOR_ID,
4927 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
4928 },
4929 {
4930 .vendor_id = QCA_NL80211_VENDOR_ID,
4931 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
4932 },
4933 {
4934 .vendor_id = QCA_NL80211_VENDOR_ID,
4935 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
4936 },
4937 {
4938 .vendor_id = QCA_NL80211_VENDOR_ID,
4939 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE
4940 },
4941 {
4942 .vendor_id = QCA_NL80211_VENDOR_ID,
4943 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE
4944 },
4945 {
4946 .vendor_id = QCA_NL80211_VENDOR_ID,
4947 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE
4948 },
4949#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05304950/*EXT TDLS*/
4951 {
4952 .vendor_id = QCA_NL80211_VENDOR_ID,
4953 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
4954 },
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08004955};
4956
Jeff Johnson295189b2012-06-20 16:38:30 -07004957/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05304958 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304959 * This function is called by hdd_wlan_startup()
4960 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05304961 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07004962 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05304963struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07004964{
4965 struct wiphy *wiphy;
4966 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304967 /*
4968 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07004969 */
4970 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
4971
4972 if (!wiphy)
4973 {
4974 /* Print error and jump into err label and free the memory */
4975 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
4976 return NULL;
4977 }
4978
Sunil Duttc69bccb2014-05-26 21:30:20 +05304979
Jeff Johnson295189b2012-06-20 16:38:30 -07004980 return wiphy;
4981}
4982
4983/*
4984 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304985 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07004986 * private ioctl to change the band value
4987 */
4988int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
4989{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05304990 int i, j;
4991 eNVChannelEnabledType channelEnabledState;
4992
Jeff Johnsone7245742012-09-05 17:12:55 -07004993 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304994
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05304995 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07004996 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05304997
4998 if (NULL == wiphy->bands[i])
4999 {
5000 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
5001 __func__, i);
5002 continue;
5003 }
5004
5005 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5006 {
5007 struct ieee80211_supported_band *band = wiphy->bands[i];
5008
5009 channelEnabledState = vos_nv_getChannelEnabledState(
5010 band->channels[j].hw_value);
5011
5012 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
5013 {
Abhishek Singh678227a2014-11-04 10:52:38 +05305014 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305015 continue;
5016 }
5017 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
5018 {
5019 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5020 continue;
5021 }
5022
5023 if (NV_CHANNEL_DISABLE == channelEnabledState ||
5024 NV_CHANNEL_INVALID == channelEnabledState)
5025 {
5026 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5027 }
5028 else if (NV_CHANNEL_DFS == channelEnabledState)
5029 {
5030 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5031 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
5032 }
5033 else
5034 {
5035 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
5036 |IEEE80211_CHAN_RADAR);
5037 }
5038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005039 }
5040 return 0;
5041}
5042/*
5043 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305044 * This function is called by hdd_wlan_startup()
5045 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07005046 * This function is used to initialize and register wiphy structure.
5047 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305048int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005049 struct wiphy *wiphy,
5050 hdd_config_t *pCfg
5051 )
5052{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305053 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305054 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5055
Jeff Johnsone7245742012-09-05 17:12:55 -07005056 ENTER();
5057
Jeff Johnson295189b2012-06-20 16:38:30 -07005058 /* Now bind the underlying wlan device with wiphy */
5059 set_wiphy_dev(wiphy, dev);
5060
5061 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005062
Kiet Lam6c583332013-10-14 05:37:09 +05305063#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07005064 /* the flag for the other case would be initialzed in
5065 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07005066 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05305067#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005068
Amar Singhalfddc28c2013-09-05 13:03:40 -07005069 /* This will disable updating of NL channels from passive to
5070 * active if a beacon is received on passive channel. */
5071 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Amar Singhalf0073192013-09-20 12:34:56 -07005072
Amar Singhalfddc28c2013-09-05 13:03:40 -07005073
Amar Singhala49cbc52013-10-08 18:37:44 -07005074
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005075#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07005076 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
5077 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
5078 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07005079 | WIPHY_FLAG_OFFCHAN_TX;
Kiet Lam6c583332013-10-14 05:37:09 +05305080 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005081#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005082
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005083#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005084 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08005085#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005086 || pCfg->isFastRoamIniFeatureEnabled
5087#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005088#ifdef FEATURE_WLAN_ESE
5089 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005090#endif
5091 )
5092 {
5093 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
5094 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08005095#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005096#ifdef FEATURE_WLAN_TDLS
5097 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
5098 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
5099#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305100#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05305101 if (pCfg->configPNOScanSupport)
5102 {
5103 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
5104 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
5105 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
5106 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
5107 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305108#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005109
Amar Singhalfddc28c2013-09-05 13:03:40 -07005110#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005111 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
5112 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07005113 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005114 driver need to determine what to do with both
5115 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07005116
5117 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07005118#else
5119 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005120#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005121
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305122 wiphy->max_scan_ssids = MAX_SCAN_SSID;
5123
Madan Mohan Koyyalamudi6815b162013-07-19 17:17:46 +05305124 wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07005125
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05305126 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
5127
Jeff Johnson295189b2012-06-20 16:38:30 -07005128 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305129 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07005130 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -07005131 | BIT(NL80211_IFTYPE_P2P_CLIENT)
5132 | BIT(NL80211_IFTYPE_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07005133 | BIT(NL80211_IFTYPE_AP);
5134
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305135 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005136 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305137#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5138 if( pCfg->enableMCC )
5139 {
5140 /* Currently, supports up to two channels */
5141 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005142
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305143 if( !pCfg->allowMCCGODiffBI )
5144 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005145
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305146 }
5147 wiphy->iface_combinations = &wlan_hdd_iface_combination;
5148 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005149#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305150 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005151
Jeff Johnson295189b2012-06-20 16:38:30 -07005152 /* Before registering we need to update the ht capabilitied based
5153 * on ini values*/
5154 if( !pCfg->ShortGI20MhzEnable )
5155 {
5156 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5157 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5158 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5159 }
5160
5161 if( !pCfg->ShortGI40MhzEnable )
5162 {
5163 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
5164 }
5165
5166 if( !pCfg->nChannelBondingMode5GHz )
5167 {
5168 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5169 }
5170
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305171 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305172 if (true == hdd_is_5g_supported(pHddCtx))
5173 {
5174 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
5175 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305176
5177 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
5178 {
5179
5180 if (NULL == wiphy->bands[i])
5181 {
5182 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
5183 __func__, i);
5184 continue;
5185 }
5186
5187 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5188 {
5189 struct ieee80211_supported_band *band = wiphy->bands[i];
5190
5191 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
5192 {
5193 // Enable social channels for P2P
5194 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
5195 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5196 else
5197 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5198 continue;
5199 }
5200 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
5201 {
5202 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5203 continue;
5204 }
5205 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005206 }
5207 /*Initialise the supported cipher suite details*/
5208 wiphy->cipher_suites = hdd_cipher_suites;
5209 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
5210
5211 /*signal strength in mBm (100*dBm) */
5212 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
5213
5214#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05305215 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07005216#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005217
Sunil Duttc69bccb2014-05-26 21:30:20 +05305218 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
5219 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005220 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
5221 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
5222
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305223 EXIT();
5224 return 0;
5225}
5226
5227/* In this function we are registering wiphy. */
5228int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
5229{
5230 ENTER();
5231 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005232 if (0 > wiphy_register(wiphy))
5233 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305234 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07005235 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
5236 return -EIO;
5237 }
5238
5239 EXIT();
5240 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305241}
Jeff Johnson295189b2012-06-20 16:38:30 -07005242
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305243/* In this function we are updating channel list when,
5244 regulatory domain is FCC and country code is US.
5245 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
5246 As per FCC smart phone is not a indoor device.
5247 GO should not opeate on indoor channels */
5248void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
5249{
5250 int j;
5251 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5252 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
5253 //Default counrtycode from NV at the time of wiphy initialization.
5254 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
5255 &defaultCountryCode[0]))
5256 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005257 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305258 }
5259 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
5260 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305261 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
5262 {
5263 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
5264 return;
5265 }
5266 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
5267 {
5268 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
5269 // Mark UNII -1 band channel as passive
5270 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
5271 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
5272 }
5273 }
5274}
5275
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05305276/* This function registers for all frame which supplicant is interested in */
5277void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005278{
Jeff Johnson295189b2012-06-20 16:38:30 -07005279 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5280 /* Register for all P2P action, public action etc frames */
5281 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
5282
Jeff Johnsone7245742012-09-05 17:12:55 -07005283 ENTER();
5284
Jeff Johnson295189b2012-06-20 16:38:30 -07005285 /* Right now we are registering these frame when driver is getting
5286 initialized. Once we will move to 2.6.37 kernel, in which we have
5287 frame register ops, we will move this code as a part of that */
5288 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305289 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07005290 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
5291
5292 /* GAS Initial Response */
5293 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5294 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305295
Jeff Johnson295189b2012-06-20 16:38:30 -07005296 /* GAS Comeback Request */
5297 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5298 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
5299
5300 /* GAS Comeback Response */
5301 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5302 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
5303
5304 /* P2P Public Action */
5305 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305306 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07005307 P2P_PUBLIC_ACTION_FRAME_SIZE );
5308
5309 /* P2P Action */
5310 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5311 (v_U8_t*)P2P_ACTION_FRAME,
5312 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07005313
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05305314 /* WNM BSS Transition Request frame */
5315 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5316 (v_U8_t*)WNM_BSS_ACTION_FRAME,
5317 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07005318
5319 /* WNM-Notification */
5320 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5321 (v_U8_t*)WNM_NOTIFICATION_FRAME,
5322 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005323}
5324
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05305325void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005326{
Jeff Johnson295189b2012-06-20 16:38:30 -07005327 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5328 /* Register for all P2P action, public action etc frames */
5329 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
5330
Jeff Johnsone7245742012-09-05 17:12:55 -07005331 ENTER();
5332
Jeff Johnson295189b2012-06-20 16:38:30 -07005333 /* Right now we are registering these frame when driver is getting
5334 initialized. Once we will move to 2.6.37 kernel, in which we have
5335 frame register ops, we will move this code as a part of that */
5336 /* GAS Initial Request */
5337
5338 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5339 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
5340
5341 /* GAS Initial Response */
5342 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5343 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305344
Jeff Johnson295189b2012-06-20 16:38:30 -07005345 /* GAS Comeback Request */
5346 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5347 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
5348
5349 /* GAS Comeback Response */
5350 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5351 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
5352
5353 /* P2P Public Action */
5354 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305355 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07005356 P2P_PUBLIC_ACTION_FRAME_SIZE );
5357
5358 /* P2P Action */
5359 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5360 (v_U8_t*)P2P_ACTION_FRAME,
5361 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07005362 /* WNM-Notification */
5363 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5364 (v_U8_t*)WNM_NOTIFICATION_FRAME,
5365 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005366}
5367
5368#ifdef FEATURE_WLAN_WAPI
5369void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
5370 const u8 *mac_addr, u8 *key , int key_Len)
5371{
5372 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5373 tCsrRoamSetKey setKey;
5374 v_BOOL_t isConnected = TRUE;
5375 int status = 0;
5376 v_U32_t roamId= 0xFF;
5377 tANI_U8 *pKeyPtr = NULL;
5378 int n = 0;
5379
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305380 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
5381 __func__, hdd_device_modetoString(pAdapter->device_mode),
5382 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005383
Gopichand Nakkalae7480202013-02-11 15:24:22 +05305384 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07005385 setKey.keyId = key_index; // Store Key ID
5386 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
5387 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
5388 setKey.paeRole = 0 ; // the PAE role
5389 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
5390 {
5391 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
5392 }
5393 else
5394 {
5395 isConnected = hdd_connIsConnected(pHddStaCtx);
5396 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
5397 }
5398 setKey.keyLength = key_Len;
5399 pKeyPtr = setKey.Key;
5400 memcpy( pKeyPtr, key, key_Len);
5401
Arif Hussain6d2a3322013-11-17 19:50:10 -08005402 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07005403 __func__, key_Len);
5404 for (n = 0 ; n < key_Len; n++)
5405 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
5406 __func__,n,setKey.Key[n]);
5407
5408 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5409 if ( isConnected )
5410 {
5411 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
5412 pAdapter->sessionId, &setKey, &roamId );
5413 }
5414 if ( status != 0 )
5415 {
5416 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5417 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5418 __LINE__, status );
5419 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5420 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05305421 /* Need to clear any trace of key value in the memory.
5422 * Thus zero out the memory even though it is local
5423 * variable.
5424 */
5425 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07005426}
5427#endif /* FEATURE_WLAN_WAPI*/
5428
5429#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305430int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005431 beacon_data_t **ppBeacon,
5432 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005433#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305434int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005435 beacon_data_t **ppBeacon,
5436 struct cfg80211_beacon_data *params,
5437 int dtim_period)
5438#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305439{
Jeff Johnson295189b2012-06-20 16:38:30 -07005440 int size;
5441 beacon_data_t *beacon = NULL;
5442 beacon_data_t *old = NULL;
5443 int head_len,tail_len;
5444
Jeff Johnsone7245742012-09-05 17:12:55 -07005445 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07005446 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305447 {
5448 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5449 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005450 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305451 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005452
5453 old = pAdapter->sessionCtx.ap.beacon;
5454
5455 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305456 {
5457 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5458 FL("session(%d) old and new heads points to NULL"),
5459 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005460 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305461 }
5462
5463 if (params->tail && !params->tail_len)
5464 {
5465 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5466 FL("tail_len is zero but tail is not NULL"));
5467 return -EINVAL;
5468 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005469
Jeff Johnson295189b2012-06-20 16:38:30 -07005470#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
5471 /* Kernel 3.0 is not updating dtim_period for set beacon */
5472 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305473 {
5474 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5475 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005476 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305477 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005478#endif
5479
5480 if(params->head)
5481 head_len = params->head_len;
5482 else
5483 head_len = old->head_len;
5484
5485 if(params->tail || !old)
5486 tail_len = params->tail_len;
5487 else
5488 tail_len = old->tail_len;
5489
5490 size = sizeof(beacon_data_t) + head_len + tail_len;
5491
5492 beacon = kzalloc(size, GFP_KERNEL);
5493
5494 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305495 {
5496 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5497 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005498 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305499 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005500
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005501#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07005502 if(params->dtim_period || !old )
5503 beacon->dtim_period = params->dtim_period;
5504 else
5505 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005506#else
5507 if(dtim_period || !old )
5508 beacon->dtim_period = dtim_period;
5509 else
5510 beacon->dtim_period = old->dtim_period;
5511#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305512
Jeff Johnson295189b2012-06-20 16:38:30 -07005513 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
5514 beacon->tail = beacon->head + head_len;
5515 beacon->head_len = head_len;
5516 beacon->tail_len = tail_len;
5517
5518 if(params->head) {
5519 memcpy (beacon->head,params->head,beacon->head_len);
5520 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305521 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07005522 if(old)
5523 memcpy (beacon->head,old->head,beacon->head_len);
5524 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305525
Jeff Johnson295189b2012-06-20 16:38:30 -07005526 if(params->tail) {
5527 memcpy (beacon->tail,params->tail,beacon->tail_len);
5528 }
5529 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305530 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07005531 memcpy (beacon->tail,old->tail,beacon->tail_len);
5532 }
5533
5534 *ppBeacon = beacon;
5535
5536 kfree(old);
5537
5538 return 0;
5539
5540}
Jeff Johnson295189b2012-06-20 16:38:30 -07005541
5542v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
5543{
5544 int left = length;
5545 v_U8_t *ptr = pIes;
5546 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305547
Jeff Johnson295189b2012-06-20 16:38:30 -07005548 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305549 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005550 elem_id = ptr[0];
5551 elem_len = ptr[1];
5552 left -= 2;
5553 if(elem_len > left)
5554 {
5555 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07005556 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005557 eid,elem_len,left);
5558 return NULL;
5559 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305560 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07005561 {
5562 return ptr;
5563 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305564
Jeff Johnson295189b2012-06-20 16:38:30 -07005565 left -= elem_len;
5566 ptr += (elem_len + 2);
5567 }
5568 return NULL;
5569}
5570
Jeff Johnson295189b2012-06-20 16:38:30 -07005571/* Check if rate is 11g rate or not */
5572static int wlan_hdd_rate_is_11g(u8 rate)
5573{
Sanjay Devnani28322e22013-06-21 16:13:40 -07005574 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005575 u8 i;
5576 for (i = 0; i < 8; i++)
5577 {
5578 if(rate == gRateArray[i])
5579 return TRUE;
5580 }
5581 return FALSE;
5582}
5583
5584/* Check for 11g rate and set proper 11g only mode */
5585static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
5586 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
5587{
5588 u8 i, num_rates = pIe[0];
5589
5590 pIe += 1;
5591 for ( i = 0; i < num_rates; i++)
5592 {
5593 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
5594 {
5595 /* If rate set have 11g rate than change the mode to 11G */
5596 *pSapHw_mode = eSAP_DOT11_MODE_11g;
5597 if (pIe[i] & BASIC_RATE_MASK)
5598 {
5599 /* If we have 11g rate as basic rate, it means mode
5600 is 11g only mode.
5601 */
5602 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
5603 *pCheckRatesfor11g = FALSE;
5604 }
5605 }
5606 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
5607 {
5608 *require_ht = TRUE;
5609 }
5610 }
5611 return;
5612}
5613
5614static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
5615{
5616 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
5617 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
5618 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
5619 u8 checkRatesfor11g = TRUE;
5620 u8 require_ht = FALSE;
5621 u8 *pIe=NULL;
5622
5623 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
5624
5625 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
5626 pBeacon->head_len, WLAN_EID_SUPP_RATES);
5627 if (pIe != NULL)
5628 {
5629 pIe += 1;
5630 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
5631 &pConfig->SapHw_mode);
5632 }
5633
5634 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
5635 WLAN_EID_EXT_SUPP_RATES);
5636 if (pIe != NULL)
5637 {
5638
5639 pIe += 1;
5640 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
5641 &pConfig->SapHw_mode);
5642 }
5643
5644 if( pConfig->channel > 14 )
5645 {
5646 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
5647 }
5648
5649 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
5650 WLAN_EID_HT_CAPABILITY);
5651
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305652 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07005653 {
5654 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
5655 if(require_ht)
5656 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
5657 }
5658}
5659
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305660static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
5661 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
5662{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07005663 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305664 v_U8_t *pIe = NULL;
5665 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
5666
5667 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
5668 pBeacon->tail, pBeacon->tail_len);
5669
5670 if (pIe)
5671 {
5672 ielen = pIe[1] + 2;
5673 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
5674 {
5675 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
5676 }
5677 else
5678 {
5679 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
5680 return -EINVAL;
5681 }
5682 *total_ielen += ielen;
5683 }
5684 return 0;
5685}
5686
Arif Hussaine7f3ea52013-09-12 21:56:36 -07005687static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
5688 v_U8_t *genie, v_U8_t *total_ielen)
5689{
5690 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
5691 int left = pBeacon->tail_len;
5692 v_U8_t *ptr = pBeacon->tail;
5693 v_U8_t elem_id, elem_len;
5694 v_U16_t ielen = 0;
5695
5696 if ( NULL == ptr || 0 == left )
5697 return;
5698
5699 while (left >= 2)
5700 {
5701 elem_id = ptr[0];
5702 elem_len = ptr[1];
5703 left -= 2;
5704 if (elem_len > left)
5705 {
5706 hddLog( VOS_TRACE_LEVEL_ERROR,
5707 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
5708 elem_id, elem_len, left);
5709 return;
5710 }
5711 if (IE_EID_VENDOR == elem_id)
5712 {
5713 /* skipping the VSIE's which we don't want to include or
5714 * it will be included by existing code
5715 */
5716 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
5717#ifdef WLAN_FEATURE_WFD
5718 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
5719#endif
5720 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
5721 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
5722 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
5723 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
5724 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
5725 {
5726 ielen = ptr[1] + 2;
5727 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
5728 {
5729 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
5730 *total_ielen += ielen;
5731 }
5732 else
5733 {
5734 hddLog( VOS_TRACE_LEVEL_ERROR,
5735 "IE Length is too big "
5736 "IEs eid=%d elem_len=%d total_ie_lent=%d",
5737 elem_id, elem_len, *total_ielen);
5738 }
5739 }
5740 }
5741
5742 left -= elem_len;
5743 ptr += (elem_len + 2);
5744 }
5745 return;
5746}
5747
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005748#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07005749static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
5750 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005751#else
5752static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
5753 struct cfg80211_beacon_data *params)
5754#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005755{
5756 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305757 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005758 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07005759 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005760
5761 genie = vos_mem_malloc(MAX_GENIE_LEN);
5762
5763 if(genie == NULL) {
5764
5765 return -ENOMEM;
5766 }
5767
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305768 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
5769 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005770 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305771 hddLog(LOGE,
5772 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305773 ret = -EINVAL;
5774 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005775 }
5776
5777#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305778 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
5779 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
5780 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305781 hddLog(LOGE,
5782 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305783 ret = -EINVAL;
5784 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005785 }
5786#endif
5787
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305788 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
5789 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005790 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305791 hddLog(LOGE,
5792 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305793 ret = -EINVAL;
5794 goto done;
5795 }
5796
5797 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
5798 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07005799 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005800 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005801
5802 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5803 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
5804 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
5805 {
5806 hddLog(LOGE,
5807 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005808 ret = -EINVAL;
5809 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005810 }
5811
5812 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5813 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
5814 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
5815 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
5816 ==eHAL_STATUS_FAILURE)
5817 {
5818 hddLog(LOGE,
5819 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005820 ret = -EINVAL;
5821 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005822 }
5823
5824 // Added for ProResp IE
5825 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
5826 {
5827 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
5828 u8 probe_rsp_ie_len[3] = {0};
5829 u8 counter = 0;
5830 /* Check Probe Resp Length if it is greater then 255 then Store
5831 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
5832 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
5833 Store More then 255 bytes into One Variable.
5834 */
5835 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
5836 {
5837 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
5838 {
5839 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
5840 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
5841 }
5842 else
5843 {
5844 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
5845 rem_probe_resp_ie_len = 0;
5846 }
5847 }
5848
5849 rem_probe_resp_ie_len = 0;
5850
5851 if (probe_rsp_ie_len[0] > 0)
5852 {
5853 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5854 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
5855 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
5856 probe_rsp_ie_len[0], NULL,
5857 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5858 {
5859 hddLog(LOGE,
5860 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005861 ret = -EINVAL;
5862 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005863 }
5864 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
5865 }
5866
5867 if (probe_rsp_ie_len[1] > 0)
5868 {
5869 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5870 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
5871 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
5872 probe_rsp_ie_len[1], NULL,
5873 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5874 {
5875 hddLog(LOGE,
5876 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005877 ret = -EINVAL;
5878 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005879 }
5880 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
5881 }
5882
5883 if (probe_rsp_ie_len[2] > 0)
5884 {
5885 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5886 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
5887 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
5888 probe_rsp_ie_len[2], NULL,
5889 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5890 {
5891 hddLog(LOGE,
5892 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005893 ret = -EINVAL;
5894 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005895 }
5896 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
5897 }
5898
5899 if (probe_rsp_ie_len[1] == 0 )
5900 {
5901 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5902 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
5903 eANI_BOOLEAN_FALSE) )
5904 {
5905 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005906 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005907 }
5908 }
5909
5910 if (probe_rsp_ie_len[2] == 0 )
5911 {
5912 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5913 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
5914 eANI_BOOLEAN_FALSE) )
5915 {
5916 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005917 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005918 }
5919 }
5920
5921 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5922 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
5923 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
5924 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
5925 == eHAL_STATUS_FAILURE)
5926 {
5927 hddLog(LOGE,
5928 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005929 ret = -EINVAL;
5930 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005931 }
5932 }
5933 else
5934 {
5935 // Reset WNI_CFG_PROBE_RSP Flags
5936 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
5937
5938 hddLog(VOS_TRACE_LEVEL_INFO,
5939 "%s: No Probe Response IE received in set beacon",
5940 __func__);
5941 }
5942
5943 // Added for AssocResp IE
5944 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
5945 {
5946 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5947 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
5948 params->assocresp_ies_len, NULL,
5949 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5950 {
5951 hddLog(LOGE,
5952 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005953 ret = -EINVAL;
5954 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005955 }
5956
5957 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5958 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
5959 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
5960 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
5961 == eHAL_STATUS_FAILURE)
5962 {
5963 hddLog(LOGE,
5964 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005965 ret = -EINVAL;
5966 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005967 }
5968 }
5969 else
5970 {
5971 hddLog(VOS_TRACE_LEVEL_INFO,
5972 "%s: No Assoc Response IE received in set beacon",
5973 __func__);
5974
5975 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5976 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
5977 eANI_BOOLEAN_FALSE) )
5978 {
5979 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005980 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005981 }
5982 }
5983
Jeff Johnsone7245742012-09-05 17:12:55 -07005984done:
Jeff Johnson295189b2012-06-20 16:38:30 -07005985 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305986 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07005987}
Jeff Johnson295189b2012-06-20 16:38:30 -07005988
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305989/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005990 * FUNCTION: wlan_hdd_validate_operation_channel
5991 * called by wlan_hdd_cfg80211_start_bss() and
5992 * wlan_hdd_cfg80211_set_channel()
5993 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305994 * channel list.
5995 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07005996VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07005997{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305998
Jeff Johnson295189b2012-06-20 16:38:30 -07005999 v_U32_t num_ch = 0;
6000 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6001 u32 indx = 0;
6002 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306003 v_U8_t fValidChannel = FALSE, count = 0;
6004 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306005
Jeff Johnson295189b2012-06-20 16:38:30 -07006006 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6007
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306008 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006009 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306010 /* Validate the channel */
6011 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006012 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306013 if ( channel == rfChannels[count].channelNum )
6014 {
6015 fValidChannel = TRUE;
6016 break;
6017 }
6018 }
6019 if (fValidChannel != TRUE)
6020 {
6021 hddLog(VOS_TRACE_LEVEL_ERROR,
6022 "%s: Invalid Channel [%d]", __func__, channel);
6023 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006024 }
6025 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306026 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006027 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306028 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6029 valid_ch, &num_ch))
6030 {
6031 hddLog(VOS_TRACE_LEVEL_ERROR,
6032 "%s: failed to get valid channel list", __func__);
6033 return VOS_STATUS_E_FAILURE;
6034 }
6035 for (indx = 0; indx < num_ch; indx++)
6036 {
6037 if (channel == valid_ch[indx])
6038 {
6039 break;
6040 }
6041 }
6042
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306043 if (indx >= num_ch)
6044 {
6045 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6046 {
6047 eCsrBand band;
6048 unsigned int freq;
6049
6050 sme_GetFreqBand(hHal, &band);
6051
6052 if (eCSR_BAND_5G == band)
6053 {
6054#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
6055 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
6056 {
6057 freq = ieee80211_channel_to_frequency(channel,
6058 IEEE80211_BAND_2GHZ);
6059 }
6060 else
6061 {
6062 freq = ieee80211_channel_to_frequency(channel,
6063 IEEE80211_BAND_5GHZ);
6064 }
6065#else
6066 freq = ieee80211_channel_to_frequency(channel);
6067#endif
6068 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
6069 return VOS_STATUS_SUCCESS;
6070 }
6071 }
6072
6073 hddLog(VOS_TRACE_LEVEL_ERROR,
6074 "%s: Invalid Channel [%d]", __func__, channel);
6075 return VOS_STATUS_E_FAILURE;
6076 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006077 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306078
Jeff Johnson295189b2012-06-20 16:38:30 -07006079 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306080
Jeff Johnson295189b2012-06-20 16:38:30 -07006081}
6082
Viral Modi3a32cc52013-02-08 11:14:52 -08006083/**
6084 * FUNCTION: wlan_hdd_cfg80211_set_channel
6085 * This function is used to set the channel number
6086 */
6087static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
6088 struct ieee80211_channel *chan,
6089 enum nl80211_channel_type channel_type
6090 )
6091{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306092 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08006093 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07006094 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08006095 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306096 hdd_context_t *pHddCtx;
6097 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006098
6099 ENTER();
6100
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306101
Viral Modi3a32cc52013-02-08 11:14:52 -08006102 if( NULL == dev )
6103 {
6104 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006105 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006106 return -ENODEV;
6107 }
6108 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306109
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306110 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6111 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
6112 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08006113 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306114 "%s: device_mode = %s (%d) freq = %d", __func__,
6115 hdd_device_modetoString(pAdapter->device_mode),
6116 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306117
6118 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6119 status = wlan_hdd_validate_context(pHddCtx);
6120
6121 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08006122 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306123 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6124 "%s: HDD context is not valid", __func__);
6125 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006126 }
6127
6128 /*
6129 * Do freq to chan conversion
6130 * TODO: for 11a
6131 */
6132
6133 channel = ieee80211_frequency_to_channel(freq);
6134
6135 /* Check freq range */
6136 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
6137 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
6138 {
6139 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006140 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08006141 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
6142 WNI_CFG_CURRENT_CHANNEL_STAMAX);
6143 return -EINVAL;
6144 }
6145
6146 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6147
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05306148 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
6149 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08006150 {
6151 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
6152 {
6153 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006154 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08006155 return -EINVAL;
6156 }
6157 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6158 "%s: set channel to [%d] for device mode =%d",
6159 __func__, channel,pAdapter->device_mode);
6160 }
6161 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08006162 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08006163 )
6164 {
6165 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6166 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
6167 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6168
6169 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
6170 {
6171 /* Link is up then return cant set channel*/
6172 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006173 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006174 return -EINVAL;
6175 }
6176
6177 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
6178 pHddStaCtx->conn_info.operationChannel = channel;
6179 pRoamProfile->ChannelInfo.ChannelList =
6180 &pHddStaCtx->conn_info.operationChannel;
6181 }
6182 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08006183 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08006184 )
6185 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306186 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6187 {
6188 if(VOS_STATUS_SUCCESS !=
6189 wlan_hdd_validate_operation_channel(pAdapter,channel))
6190 {
6191 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006192 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306193 return -EINVAL;
6194 }
6195 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
6196 }
6197 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08006198 {
6199 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
6200
6201 /* If auto channel selection is configured as enable/ 1 then ignore
6202 channel set by supplicant
6203 */
6204 if ( cfg_param->apAutoChannelSelection )
6205 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306206 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
6207 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08006208 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306209 "%s: set channel to auto channel (0) for device mode =%s (%d)",
6210 __func__, hdd_device_modetoString(pAdapter->device_mode),
6211 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08006212 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306213 else
6214 {
6215 if(VOS_STATUS_SUCCESS !=
6216 wlan_hdd_validate_operation_channel(pAdapter,channel))
6217 {
6218 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006219 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306220 return -EINVAL;
6221 }
6222 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
6223 }
Viral Modi3a32cc52013-02-08 11:14:52 -08006224 }
6225 }
6226 else
6227 {
6228 hddLog(VOS_TRACE_LEVEL_FATAL,
6229 "%s: Invalid device mode failed to set valid channel", __func__);
6230 return -EINVAL;
6231 }
6232 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306233 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006234}
6235
Jeff Johnson295189b2012-06-20 16:38:30 -07006236#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
6237static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6238 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006239#else
6240static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6241 struct cfg80211_beacon_data *params,
6242 const u8 *ssid, size_t ssid_len,
6243 enum nl80211_hidden_ssid hidden_ssid)
6244#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006245{
6246 tsap_Config_t *pConfig;
6247 beacon_data_t *pBeacon = NULL;
6248 struct ieee80211_mgmt *pMgmt_frame;
6249 v_U8_t *pIe=NULL;
6250 v_U16_t capab_info;
6251 eCsrAuthType RSNAuthType;
6252 eCsrEncryptionType RSNEncryptType;
6253 eCsrEncryptionType mcRSNEncryptType;
6254 int status = VOS_STATUS_SUCCESS;
6255 tpWLAN_SAPEventCB pSapEventCallback;
6256 hdd_hostapd_state_t *pHostapdState;
6257 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
6258 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306259 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006260 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306261 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006262 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08006263 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05306264 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07006265 v_BOOL_t MFPCapable = VOS_FALSE;
6266 v_BOOL_t MFPRequired = VOS_FALSE;
Abhishek Singhf0ac1752014-03-05 17:47:09 +05306267 eHddDot11Mode sapDot11Mode =
6268 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07006269
6270 ENTER();
6271
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306272 iniConfig = pHddCtx->cfg_ini;
6273
Jeff Johnson295189b2012-06-20 16:38:30 -07006274 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
6275
6276 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6277
6278 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6279
6280 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
6281
6282 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
6283
6284 //channel is already set in the set_channel Call back
6285 //pConfig->channel = pCommitConfig->channel;
6286
6287 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306288 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07006289 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
6290
6291 pConfig->dtim_period = pBeacon->dtim_period;
6292
Arif Hussain6d2a3322013-11-17 19:50:10 -08006293 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07006294 pConfig->dtim_period);
6295
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08006296 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07006297 {
6298 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006299 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05306300 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
6301 {
6302 tANI_BOOLEAN restartNeeded;
6303 pConfig->ieee80211d = 1;
6304 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
6305 sme_setRegInfo(hHal, pConfig->countryCode);
6306 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
6307 }
6308 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07006309 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07006310 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006311 pConfig->ieee80211d = 1;
6312 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
6313 sme_setRegInfo(hHal, pConfig->countryCode);
6314 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07006315 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07006316 else
6317 {
6318 pConfig->ieee80211d = 0;
6319 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306320 /*
6321 * If auto channel is configured i.e. channel is 0,
6322 * so skip channel validation.
6323 */
6324 if( AUTO_CHANNEL_SELECT != pConfig->channel )
6325 {
6326 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
6327 {
6328 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006329 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306330 return -EINVAL;
6331 }
6332 }
6333 else
6334 {
6335 if(1 != pHddCtx->is_dynamic_channel_range_set)
6336 {
6337 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
6338 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
6339 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
6340 }
6341 pHddCtx->is_dynamic_channel_range_set = 0;
6342 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006343 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07006344 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006345 {
6346 pConfig->ieee80211d = 0;
6347 }
6348 pConfig->authType = eSAP_AUTO_SWITCH;
6349
6350 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306351
6352 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07006353 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
6354
6355 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
6356
6357 /*Set wps station to configured*/
6358 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
6359
6360 if(pIe)
6361 {
6362 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
6363 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006364 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07006365 return -EINVAL;
6366 }
6367 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
6368 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07006369 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07006370 /* Check 15 bit of WPS IE as it contain information for wps state
6371 * WPS state
6372 */
6373 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
6374 {
6375 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
6376 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
6377 {
6378 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
6379 }
6380 }
6381 }
6382 else
6383 {
6384 pConfig->wps_state = SAP_WPS_DISABLED;
6385 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306386 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07006387
c_hpothufe599e92014-06-16 11:38:55 +05306388 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
6389 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
6390 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
6391 eCSR_ENCRYPT_TYPE_NONE;
6392
Jeff Johnson295189b2012-06-20 16:38:30 -07006393 pConfig->RSNWPAReqIELength = 0;
6394 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306395 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006396 WLAN_EID_RSN);
6397 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306398 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006399 pConfig->RSNWPAReqIELength = pIe[1] + 2;
6400 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
6401 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306402 /* The actual processing may eventually be more extensive than
6403 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07006404 * by the app.
6405 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306406 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07006407 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
6408 &RSNEncryptType,
6409 &mcRSNEncryptType,
6410 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08006411 &MFPCapable,
6412 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07006413 pConfig->pRSNWPAReqIE[1]+2,
6414 pConfig->pRSNWPAReqIE );
6415
6416 if( VOS_STATUS_SUCCESS == status )
6417 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306418 /* Now copy over all the security attributes you have
6419 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07006420 * */
6421 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
6422 pConfig->mcRSNEncryptType = mcRSNEncryptType;
6423 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
6424 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05306425 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08006426 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006427 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
6428 }
6429 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306430
Jeff Johnson295189b2012-06-20 16:38:30 -07006431 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
6432 pBeacon->tail, pBeacon->tail_len);
6433
6434 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
6435 {
6436 if (pConfig->pRSNWPAReqIE)
6437 {
6438 /*Mixed mode WPA/WPA2*/
6439 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
6440 pConfig->RSNWPAReqIELength += pIe[1] + 2;
6441 }
6442 else
6443 {
6444 pConfig->RSNWPAReqIELength = pIe[1] + 2;
6445 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
6446 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306447 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07006448 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
6449 &RSNEncryptType,
6450 &mcRSNEncryptType,
6451 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08006452 &MFPCapable,
6453 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07006454 pConfig->pRSNWPAReqIE[1]+2,
6455 pConfig->pRSNWPAReqIE );
6456
6457 if( VOS_STATUS_SUCCESS == status )
6458 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306459 /* Now copy over all the security attributes you have
6460 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07006461 * */
6462 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
6463 pConfig->mcRSNEncryptType = mcRSNEncryptType;
6464 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
6465 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05306466 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08006467 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006468 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
6469 }
6470 }
6471 }
6472
Jeff Johnson4416a782013-03-25 14:17:50 -07006473 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
6474 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
6475 return -EINVAL;
6476 }
6477
Jeff Johnson295189b2012-06-20 16:38:30 -07006478 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
6479
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006480#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006481 if (params->ssid != NULL)
6482 {
6483 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
6484 pConfig->SSIDinfo.ssid.length = params->ssid_len;
6485 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
6486 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
6487 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006488#else
6489 if (ssid != NULL)
6490 {
6491 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
6492 pConfig->SSIDinfo.ssid.length = ssid_len;
6493 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
6494 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
6495 }
6496#endif
6497
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306498 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07006499 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306500
Jeff Johnson295189b2012-06-20 16:38:30 -07006501 /* default value */
6502 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
6503 pConfig->num_accept_mac = 0;
6504 pConfig->num_deny_mac = 0;
6505
6506 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
6507 pBeacon->tail, pBeacon->tail_len);
6508
6509 /* pIe for black list is following form:
6510 type : 1 byte
6511 length : 1 byte
6512 OUI : 4 bytes
6513 acl type : 1 byte
6514 no of mac addr in black list: 1 byte
6515 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306516 */
6517 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006518 {
6519 pConfig->SapMacaddr_acl = pIe[6];
6520 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08006521 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006522 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05306523 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
6524 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006525 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
6526 for (i = 0; i < pConfig->num_deny_mac; i++)
6527 {
6528 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
6529 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306530 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006531 }
6532 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
6533 pBeacon->tail, pBeacon->tail_len);
6534
6535 /* pIe for white list is following form:
6536 type : 1 byte
6537 length : 1 byte
6538 OUI : 4 bytes
6539 acl type : 1 byte
6540 no of mac addr in white list: 1 byte
6541 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306542 */
6543 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006544 {
6545 pConfig->SapMacaddr_acl = pIe[6];
6546 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08006547 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006548 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05306549 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
6550 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006551 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
6552 for (i = 0; i < pConfig->num_accept_mac; i++)
6553 {
6554 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
6555 acl_entry++;
6556 }
6557 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05306558
Jeff Johnson295189b2012-06-20 16:38:30 -07006559 wlan_hdd_set_sapHwmode(pHostapdAdapter);
6560
Jeff Johnsone7245742012-09-05 17:12:55 -07006561#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08006562 /* Overwrite the hostapd setting for HW mode only for 11ac.
Kiet Lam0f320422013-11-21 19:29:17 +05306563 * This is valid only if mode is set to 11n in hostapd, either AUTO or
6564 * 11ac in .ini and 11ac is supported by both host and firmware.
6565 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
6566 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08006567 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
6568 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Abhishek Singhf0ac1752014-03-05 17:47:09 +05306569 (( sapDot11Mode == eHDD_DOT11_MODE_AUTO ) ||
6570 ( sapDot11Mode == eHDD_DOT11_MODE_11ac ) ||
6571 ( sapDot11Mode == eHDD_DOT11_MODE_11ac_ONLY ) ) &&
6572 (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
6573 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07006574 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05306575 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07006576 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05306577 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07006578
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306579 /* If ACS disable and selected channel <= 14
6580 * OR
6581 * ACS enabled and ACS operating band is choosen as 2.4
6582 * AND
6583 * VHT in 2.4G Disabled
6584 * THEN
6585 * Fallback to 11N mode
6586 */
6587 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
6588 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05306589 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306590 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07006591 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05306592 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
6593 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07006594 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
6595 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006596 }
6597#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306598
Jeff Johnson295189b2012-06-20 16:38:30 -07006599 // ht_capab is not what the name conveys,this is used for protection bitmap
6600 pConfig->ht_capab =
6601 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
6602
6603 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
6604 {
6605 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
6606 return -EINVAL;
6607 }
6608
6609 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306610 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
6612 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306613 pConfig->obssProtEnabled =
6614 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07006615
Chet Lanctot8cecea22014-02-11 19:09:36 -08006616#ifdef WLAN_FEATURE_11W
6617 pConfig->mfpCapable = MFPCapable;
6618 pConfig->mfpRequired = MFPRequired;
6619 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
6620 pConfig->mfpCapable, pConfig->mfpRequired);
6621#endif
6622
Arif Hussain6d2a3322013-11-17 19:50:10 -08006623 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07006624 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08006625 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
6626 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
6627 (int)pConfig->channel);
6628 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
6629 pConfig->SapHw_mode, pConfig->privacy,
6630 pConfig->authType);
6631 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
6632 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
6633 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
6634 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07006635
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306636 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07006637 {
6638 //Bss already started. just return.
6639 //TODO Probably it should update some beacon params.
6640 hddLog( LOGE, "Bss Already started...Ignore the request");
6641 EXIT();
6642 return 0;
6643 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306644
Agarwal Ashish51325b52014-06-16 16:50:49 +05306645 if (vos_max_concurrent_connections_reached()) {
6646 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
6647 return -EINVAL;
6648 }
6649
Jeff Johnson295189b2012-06-20 16:38:30 -07006650 pConfig->persona = pHostapdAdapter->device_mode;
6651
Peng Xu2446a892014-09-05 17:21:18 +05306652 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
6653 if ( NULL != psmeConfig)
6654 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05306655 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +05306656 sme_GetConfigParam(hHal, psmeConfig);
6657 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05306658#ifdef WLAN_FEATURE_AP_HT40_24G
6659 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
6660 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
6661 && pHddCtx->cfg_ini->apHT40_24GEnabled)
6662 {
6663 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
6664 sme_UpdateConfig (hHal, psmeConfig);
6665 }
6666#endif
Peng Xu2446a892014-09-05 17:21:18 +05306667 vos_mem_free(psmeConfig);
6668 }
Peng Xuafc34e32014-09-25 13:23:55 +05306669 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05306670
Jeff Johnson295189b2012-06-20 16:38:30 -07006671 pSapEventCallback = hdd_hostapd_SAPEventCB;
6672 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
6673 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
6674 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006675 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006676 return -EINVAL;
6677 }
6678
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306679 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07006680 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
6681
6682 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306683
Jeff Johnson295189b2012-06-20 16:38:30 -07006684 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306685 {
6686 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006687 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07006688 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07006689 VOS_ASSERT(0);
6690 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306691
Jeff Johnson295189b2012-06-20 16:38:30 -07006692 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05306693 /* Initialize WMM configuation */
6694 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05306695 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006696
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07006697#ifdef WLAN_FEATURE_P2P_DEBUG
6698 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
6699 {
6700 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
6701 {
6702 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
6703 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08006704 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07006705 }
6706 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
6707 {
6708 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
6709 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08006710 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07006711 }
6712 }
6713#endif
6714
Jeff Johnson295189b2012-06-20 16:38:30 -07006715 pHostapdState->bCommit = TRUE;
6716 EXIT();
6717
6718 return 0;
6719}
6720
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006721#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05306722static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306723 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07006724 struct beacon_parameters *params)
6725{
6726 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306727 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306728 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006729
6730 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306731
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306732 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6733 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
6734 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306735 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
6736 hdd_device_modetoString(pAdapter->device_mode),
6737 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006738
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306739 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6740 status = wlan_hdd_validate_context(pHddCtx);
6741
6742 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006743 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306744 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6745 "%s: HDD context is not valid", __func__);
6746 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006747 }
6748
Agarwal Ashish51325b52014-06-16 16:50:49 +05306749 if (vos_max_concurrent_connections_reached()) {
6750 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
6751 return -EINVAL;
6752 }
6753
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306754 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07006755 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07006756 )
6757 {
6758 beacon_data_t *old,*new;
6759
6760 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306761
Jeff Johnson295189b2012-06-20 16:38:30 -07006762 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306763 {
6764 hddLog(VOS_TRACE_LEVEL_WARN,
6765 FL("already beacon info added to session(%d)"),
6766 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006767 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306768 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006769
6770 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
6771
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306772 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07006773 {
6774 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006775 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006776 return -EINVAL;
6777 }
6778
6779 pAdapter->sessionCtx.ap.beacon = new;
6780
6781 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
6782 }
6783
6784 EXIT();
6785 return status;
6786}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306787
Mukul Sharmab0e0a982014-12-15 18:58:53 +05306788static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
6789 struct net_device *dev,
6790 struct beacon_parameters *params)
6791{
6792 int ret;
6793
6794 vos_ssr_protect(__func__);
6795 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
6796 vos_ssr_unprotect(__func__);
6797
6798 return ret;
6799}
6800
6801static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006802 struct net_device *dev,
6803 struct beacon_parameters *params)
6804{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306805 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306806 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6807 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306808 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006809
6810 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306811 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6812 TRACE_CODE_HDD_CFG80211_SET_BEACON,
6813 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
6814 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
6815 __func__, hdd_device_modetoString(pAdapter->device_mode),
6816 pAdapter->device_mode);
6817
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306818 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6819 status = wlan_hdd_validate_context(pHddCtx);
6820
6821 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006822 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306823 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6824 "%s: HDD context is not valid", __func__);
6825 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006826 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306827
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306828 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07006829 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306830 )
Jeff Johnson295189b2012-06-20 16:38:30 -07006831 {
6832 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306833
Jeff Johnson295189b2012-06-20 16:38:30 -07006834 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306835
Jeff Johnson295189b2012-06-20 16:38:30 -07006836 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306837 {
6838 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6839 FL("session(%d) old and new heads points to NULL"),
6840 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006841 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306842 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006843
6844 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
6845
6846 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306847 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006848 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006849 return -EINVAL;
6850 }
6851
6852 pAdapter->sessionCtx.ap.beacon = new;
6853
6854 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
6855 }
6856
6857 EXIT();
6858 return status;
6859}
6860
Mukul Sharmab0e0a982014-12-15 18:58:53 +05306861static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
6862 struct net_device *dev,
6863 struct beacon_parameters *params)
6864{
6865 int ret;
6866
6867 vos_ssr_protect(__func__);
6868 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
6869 vos_ssr_unprotect(__func__);
6870
6871 return ret;
6872}
6873
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006874#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
6875
6876#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05306877static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006878 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006879#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +05306880static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006881 struct net_device *dev)
6882#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006883{
6884 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07006885 hdd_context_t *pHddCtx = NULL;
6886 hdd_scaninfo_t *pScanInfo = NULL;
6887 hdd_adapter_t *staAdapter = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306888 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306889 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006890
6891 ENTER();
6892
6893 if (NULL == pAdapter)
6894 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306895 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006896 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006897 return -ENODEV;
6898 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006899
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306900 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6901 TRACE_CODE_HDD_CFG80211_STOP_AP,
6902 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306903 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6904 status = wlan_hdd_validate_context(pHddCtx);
6905
6906 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006907 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306908 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6909 "%s: HDD context is not valid", __func__);
6910 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07006911 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006912
6913 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
6914 if (NULL == staAdapter)
6915 {
6916 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
6917 if (NULL == staAdapter)
6918 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07006919 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
6920 "%s: HDD adapter context for STA/P2P-CLI is Null",
6921 __func__);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006922 }
6923 }
6924
6925 pScanInfo = &pHddCtx->scan_info;
6926
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306927 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
6928 __func__, hdd_device_modetoString(pAdapter->device_mode),
6929 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006930
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306931 ret = wlan_hdd_scan_abort(pAdapter);
6932
Girish Gowli4bf7a632014-06-12 13:42:11 +05306933 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07006934 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306935 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6936 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306937
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306938 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07006939 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306940 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6941 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08006942
Jeff Johnsone7245742012-09-05 17:12:55 -07006943 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306944 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07006945 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306946 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07006947 }
6948
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05306949 /* Delete all associated STAs before stopping AP/P2P GO */
6950 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05306951 hdd_hostapd_stop(dev);
6952
Jeff Johnson295189b2012-06-20 16:38:30 -07006953 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07006954 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07006955 )
6956 {
6957 beacon_data_t *old;
6958
6959 old = pAdapter->sessionCtx.ap.beacon;
6960
6961 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306962 {
6963 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6964 FL("session(%d) beacon data points to NULL"),
6965 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006966 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306967 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006968
Jeff Johnson295189b2012-06-20 16:38:30 -07006969 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006970
6971 mutex_lock(&pHddCtx->sap_lock);
6972 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
6973 {
Jeff Johnson4416a782013-03-25 14:17:50 -07006974 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006975 {
6976 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
6977
6978 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
6979
6980 if (!VOS_IS_STATUS_SUCCESS(status))
6981 {
6982 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006983 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006984 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306985 }
6986 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006987 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05306988 /* BSS stopped, clear the active sessions for this device mode */
6989 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006990 }
6991 mutex_unlock(&pHddCtx->sap_lock);
6992
6993 if(status != VOS_STATUS_SUCCESS)
6994 {
6995 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006996 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006997 return -EINVAL;
6998 }
6999
Jeff Johnson4416a782013-03-25 14:17:50 -07007000 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007001 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
7002 ==eHAL_STATUS_FAILURE)
7003 {
7004 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007005 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007006 }
7007
Jeff Johnson4416a782013-03-25 14:17:50 -07007008 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007009 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
7010 eANI_BOOLEAN_FALSE) )
7011 {
7012 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007013 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007014 }
7015
7016 // Reset WNI_CFG_PROBE_RSP Flags
7017 wlan_hdd_reset_prob_rspies(pAdapter);
7018
7019 pAdapter->sessionCtx.ap.beacon = NULL;
7020 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007021#ifdef WLAN_FEATURE_P2P_DEBUG
7022 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
7023 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
7024 {
7025 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
7026 "GO got removed");
7027 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
7028 }
7029#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007030 }
7031 EXIT();
7032 return status;
7033}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007034
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307035#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7036static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
7037 struct net_device *dev)
7038{
7039 int ret;
7040
7041 vos_ssr_protect(__func__);
7042 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
7043 vos_ssr_unprotect(__func__);
7044
7045 return ret;
7046}
7047#else
7048static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
7049 struct net_device *dev)
7050{
7051 int ret;
7052
7053 vos_ssr_protect(__func__);
7054 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
7055 vos_ssr_unprotect(__func__);
7056
7057 return ret;
7058}
7059#endif
7060
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007061#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
7062
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307063static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307064 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007065 struct cfg80211_ap_settings *params)
7066{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307067 hdd_adapter_t *pAdapter;
7068 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307069 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007070
7071 ENTER();
7072
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307073 if (NULL == dev)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007074 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307075 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307076 "%s: Device is Null", __func__);
7077 return -ENODEV;
7078 }
7079
7080 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7081 if (NULL == pAdapter)
7082 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307083 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307084 "%s: HDD adapter is Null", __func__);
7085 return -ENODEV;
7086 }
7087
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307088 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7089 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
7090 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307091 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
7092 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307093 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307094 "%s: HDD adapter magic is invalid", __func__);
7095 return -ENODEV;
7096 }
7097
7098 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307099 status = wlan_hdd_validate_context(pHddCtx);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307100
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307101 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307102 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307103 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7104 "%s: HDD context is not valid", __func__);
7105 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307106 }
7107
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307108 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
7109 __func__, hdd_device_modetoString(pAdapter->device_mode),
7110 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307111
7112 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007113 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007114 )
7115 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307116 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007117
7118 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307119
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007120 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307121 {
7122 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7123 FL("already beacon info added to session(%d)"),
7124 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007125 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307126 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007127
7128 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, &params->beacon, params->dtim_period);
7129
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307130 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007131 {
7132 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307133 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007134 return -EINVAL;
7135 }
7136 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08007137#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07007138 wlan_hdd_cfg80211_set_channel(wiphy, dev,
7139#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
7140 params->channel, params->channel_type);
7141#else
7142 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
7143#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08007144#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007145 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
7146 params->ssid_len, params->hidden_ssid);
7147 }
7148
7149 EXIT();
7150 return status;
7151}
7152
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307153static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
7154 struct net_device *dev,
7155 struct cfg80211_ap_settings *params)
7156{
7157 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007158
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307159 vos_ssr_protect(__func__);
7160 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
7161 vos_ssr_unprotect(__func__);
7162
7163 return ret;
7164}
7165
7166static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007167 struct net_device *dev,
7168 struct cfg80211_beacon_data *params)
7169{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307170 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307171 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307172 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007173
7174 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307175
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307176 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7177 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
7178 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007179 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007180 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307181
7182 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7183 status = wlan_hdd_validate_context(pHddCtx);
7184
7185 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007186 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307187 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7188 "%s: HDD context is not valid", __func__);
7189 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007190 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007191
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307192 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007193 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307194 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007195 {
7196 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307197
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007198 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307199
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007200 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307201 {
7202 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7203 FL("session(%d) beacon data points to NULL"),
7204 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007205 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307206 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007207
7208 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
7209
7210 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307211 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007212 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007213 return -EINVAL;
7214 }
7215
7216 pAdapter->sessionCtx.ap.beacon = new;
7217
7218 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
7219 }
7220
7221 EXIT();
7222 return status;
7223}
7224
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307225static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
7226 struct net_device *dev,
7227 struct cfg80211_beacon_data *params)
7228{
7229 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007230
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307231 vos_ssr_protect(__func__);
7232 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
7233 vos_ssr_unprotect(__func__);
7234
7235 return ret;
7236}
7237
7238#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007239
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05307240static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007241 struct net_device *dev,
7242 struct bss_parameters *params)
7243{
7244 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7245
7246 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307247
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307248 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7249 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
7250 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307251 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7252 __func__, hdd_device_modetoString(pAdapter->device_mode),
7253 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007254
7255 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007256 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307257 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007258 {
7259 /* ap_isolate == -1 means that in change bss, upper layer doesn't
7260 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307261 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07007262 {
7263 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307264 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007265 }
7266
7267 EXIT();
7268 return 0;
7269}
7270
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05307271static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
7272 struct net_device *dev,
7273 struct bss_parameters *params)
7274{
7275 int ret;
7276
7277 vos_ssr_protect(__func__);
7278 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
7279 vos_ssr_unprotect(__func__);
7280
7281 return ret;
7282}
Kiet Lam10841362013-11-01 11:36:50 +05307283/* FUNCTION: wlan_hdd_change_country_code_cd
7284* to wait for contry code completion
7285*/
7286void* wlan_hdd_change_country_code_cb(void *pAdapter)
7287{
7288 hdd_adapter_t *call_back_pAdapter = pAdapter;
7289 complete(&call_back_pAdapter->change_country_code);
7290 return NULL;
7291}
7292
Jeff Johnson295189b2012-06-20 16:38:30 -07007293/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05307294 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07007295 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
7296 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05307297int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007298 struct net_device *ndev,
7299 enum nl80211_iftype type,
7300 u32 *flags,
7301 struct vif_params *params
7302 )
7303{
7304 struct wireless_dev *wdev;
7305 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08007306 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07007307 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007308 tCsrRoamProfile *pRoamProfile = NULL;
7309 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307310 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007311 eMib_dot11DesiredBssType connectedBssType;
7312 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307313 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007314
7315 ENTER();
7316
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307317 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08007318 {
7319 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7320 "%s: Adapter context is null", __func__);
7321 return VOS_STATUS_E_FAILURE;
7322 }
7323
7324 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7325 if (!pHddCtx)
7326 {
7327 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7328 "%s: HDD context is null", __func__);
7329 return VOS_STATUS_E_FAILURE;
7330 }
7331
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307332 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7333 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
7334 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307335 status = wlan_hdd_validate_context(pHddCtx);
7336
7337 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007338 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307339 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7340 "%s: HDD context is not valid", __func__);
7341 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007342 }
7343
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307344 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7345 __func__, hdd_device_modetoString(pAdapter->device_mode),
7346 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007347
Agarwal Ashish51325b52014-06-16 16:50:49 +05307348 if (vos_max_concurrent_connections_reached()) {
7349 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7350 return -EINVAL;
7351 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307352 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07007353 wdev = ndev->ieee80211_ptr;
7354
7355#ifdef WLAN_BTAMP_FEATURE
7356 if((NL80211_IFTYPE_P2P_CLIENT == type)||
7357 (NL80211_IFTYPE_ADHOC == type)||
7358 (NL80211_IFTYPE_AP == type)||
7359 (NL80211_IFTYPE_P2P_GO == type))
7360 {
7361 pHddCtx->isAmpAllowed = VOS_FALSE;
7362 // stop AMP traffic
7363 status = WLANBAP_StopAmp();
7364 if(VOS_STATUS_SUCCESS != status )
7365 {
7366 pHddCtx->isAmpAllowed = VOS_TRUE;
7367 hddLog(VOS_TRACE_LEVEL_FATAL,
7368 "%s: Failed to stop AMP", __func__);
7369 return -EINVAL;
7370 }
7371 }
7372#endif //WLAN_BTAMP_FEATURE
7373 /* Reset the current device mode bit mask*/
7374 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
7375
7376 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07007377 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07007378 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07007379 )
7380 {
7381 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08007382 if (!pWextState)
7383 {
7384 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7385 "%s: pWextState is null", __func__);
7386 return VOS_STATUS_E_FAILURE;
7387 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007388 pRoamProfile = &pWextState->roamProfile;
7389 LastBSSType = pRoamProfile->BSSType;
7390
7391 switch (type)
7392 {
7393 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07007394 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07007395 hddLog(VOS_TRACE_LEVEL_INFO,
7396 "%s: setting interface Type to INFRASTRUCTURE", __func__);
7397 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07007398#ifdef WLAN_FEATURE_11AC
7399 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
7400 {
7401 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
7402 }
7403#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307404 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07007405 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007406 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08007407 //Check for sub-string p2p to confirm its a p2p interface
7408 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307409 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08007410 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
7411 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
7412 }
7413 else
7414 {
7415 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07007416 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08007417 }
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05307418#ifdef FEATURE_WLAN_TDLS
7419 /* The open adapter for the p2p shall skip initializations in
7420 * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for
7421 * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke
7422 * tdls_init when the change_iface sets the device mode to
7423 * WLAN_HDD_P2P_CLIENT.
7424 */
7425
7426 if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
7427 {
Agarwal Ashish4b87f922014-06-18 03:03:21 +05307428 if (0 != wlan_hdd_sta_tdls_init (pAdapter))
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05307429 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307430 hddLog(VOS_TRACE_LEVEL_ERROR,
7431 "%s: tdls initialization failed", __func__);
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05307432 return -EINVAL;
7433 }
7434 }
7435#endif
7436
Jeff Johnson295189b2012-06-20 16:38:30 -07007437 break;
7438 case NL80211_IFTYPE_ADHOC:
7439 hddLog(VOS_TRACE_LEVEL_INFO,
7440 "%s: setting interface Type to ADHOC", __func__);
7441 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
7442 pRoamProfile->phyMode =
7443 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07007444 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007445 wdev->iftype = type;
7446 break;
7447
7448 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07007449 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07007450 {
7451 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
7452 "%s: setting interface Type to %s", __func__,
7453 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
7454
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08007455 //Cancel any remain on channel for GO mode
7456 if (NL80211_IFTYPE_P2P_GO == type)
7457 {
7458 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
7459 }
Mohit Khanna0f232092012-09-11 14:46:08 -07007460 if (NL80211_IFTYPE_AP == type)
7461 {
7462 /* As Loading WLAN Driver one interface being created for p2p device
7463 * address. This will take one HW STA and the max number of clients
7464 * that can connect to softAP will be reduced by one. so while changing
7465 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
7466 * interface as it is not required in SoftAP mode.
7467 */
7468
7469 // Get P2P Adapter
7470 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
7471
7472 if (pP2pAdapter)
7473 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307474 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -07007475 hdd_deinit_adapter(pHddCtx, pP2pAdapter);
7476 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
7477 }
7478 }
Swaroop Goltia2e32212014-04-09 23:37:33 +05307479 //Disable IMPS & BMPS for SAP/GO
7480 if(VOS_STATUS_E_FAILURE ==
7481 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
7482 {
7483 //Fail to Exit BMPS
7484 VOS_ASSERT(0);
7485 }
Deepthi Gowri500fc472014-08-11 19:53:10 +05307486
7487 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
7488
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307489#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07007490
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307491 /* A Mutex Lock is introduced while changing the mode to
7492 * protect the concurrent access for the Adapters by TDLS
7493 * module.
7494 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05307495 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307496#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007497 //De-init the adapter.
Jeff Johnson295189b2012-06-20 16:38:30 -07007498 hdd_deinit_adapter( pHddCtx, pAdapter );
7499 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07007500 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
7501 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307502#ifdef FEATURE_WLAN_TDLS
7503 mutex_unlock(&pHddCtx->tdls_lock);
7504#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07007505 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
7506 (pConfig->apRandomBssidEnabled))
7507 {
7508 /* To meet Android requirements create a randomized
7509 MAC address of the form 02:1A:11:Fx:xx:xx */
7510 get_random_bytes(&ndev->dev_addr[3], 3);
7511 ndev->dev_addr[0] = 0x02;
7512 ndev->dev_addr[1] = 0x1A;
7513 ndev->dev_addr[2] = 0x11;
7514 ndev->dev_addr[3] |= 0xF0;
7515 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
7516 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08007517 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
7518 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07007519 }
7520
Jeff Johnson295189b2012-06-20 16:38:30 -07007521 hdd_set_ap_ops( pAdapter->dev );
7522
Kiet Lam10841362013-11-01 11:36:50 +05307523 /* This is for only SAP mode where users can
7524 * control country through ini.
7525 * P2P GO follows station country code
7526 * acquired during the STA scanning. */
7527 if((NL80211_IFTYPE_AP == type) &&
7528 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
7529 {
7530 int status = 0;
7531 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
7532 "%s: setting country code from INI ", __func__);
7533 init_completion(&pAdapter->change_country_code);
7534 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
7535 (void *)(tSmeChangeCountryCallback)
7536 wlan_hdd_change_country_code_cb,
7537 pConfig->apCntryCode, pAdapter,
7538 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05307539 eSIR_FALSE,
7540 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05307541 if (eHAL_STATUS_SUCCESS == status)
7542 {
7543 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307544 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05307545 &pAdapter->change_country_code,
7546 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307547 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05307548 {
7549 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307550 FL("SME Timed out while setting country code %ld"),
7551 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08007552
7553 if (pHddCtx->isLogpInProgress)
7554 {
7555 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7556 "%s: LOGP in Progress. Ignore!!!", __func__);
7557 return -EAGAIN;
7558 }
Kiet Lam10841362013-11-01 11:36:50 +05307559 }
7560 }
7561 else
7562 {
7563 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007564 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05307565 return -EINVAL;
7566 }
7567 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007568 status = hdd_init_ap_mode(pAdapter);
7569 if(status != VOS_STATUS_SUCCESS)
7570 {
7571 hddLog(VOS_TRACE_LEVEL_FATAL,
7572 "%s: Error initializing the ap mode", __func__);
7573 return -EINVAL;
7574 }
7575 hdd_set_conparam(1);
7576
Jeff Johnson295189b2012-06-20 16:38:30 -07007577 /*interface type changed update in wiphy structure*/
7578 if(wdev)
7579 {
7580 wdev->iftype = type;
7581 pHddCtx->change_iface = type;
7582 }
7583 else
7584 {
7585 hddLog(VOS_TRACE_LEVEL_ERROR,
7586 "%s: ERROR !!!! Wireless dev is NULL", __func__);
7587 return -EINVAL;
7588 }
7589 goto done;
7590 }
7591
7592 default:
7593 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
7594 __func__);
7595 return -EOPNOTSUPP;
7596 }
7597 }
7598 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007599 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007600 )
7601 {
7602 switch(type)
7603 {
7604 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07007605 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07007606 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +05307607
7608 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307609#ifdef FEATURE_WLAN_TDLS
7610
7611 /* A Mutex Lock is introduced while changing the mode to
7612 * protect the concurrent access for the Adapters by TDLS
7613 * module.
7614 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05307615 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307616#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07007617 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07007618 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08007619 //Check for sub-string p2p to confirm its a p2p interface
7620 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08007621 {
7622 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
7623 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
7624 }
7625 else
7626 {
7627 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07007628 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08007629 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007630 hdd_set_conparam(0);
7631 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07007632 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
7633 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307634#ifdef FEATURE_WLAN_TDLS
7635 mutex_unlock(&pHddCtx->tdls_lock);
7636#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05307637 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07007638 if( VOS_STATUS_SUCCESS != status )
7639 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07007640 /* In case of JB, for P2P-GO, only change interface will be called,
7641 * This is the right place to enable back bmps_imps()
7642 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05307643 if (pHddCtx->hdd_wlan_suspended)
7644 {
7645 hdd_set_pwrparams(pHddCtx);
7646 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007647 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007648 goto done;
7649 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07007650 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07007651 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07007652 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
7653 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07007654 goto done;
7655 default:
7656 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
7657 __func__);
7658 return -EOPNOTSUPP;
7659
7660 }
7661
7662 }
7663 else
7664 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307665 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
7666 __func__, hdd_device_modetoString(pAdapter->device_mode),
7667 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007668 return -EOPNOTSUPP;
7669 }
7670
7671
7672 if(pRoamProfile)
7673 {
7674 if ( LastBSSType != pRoamProfile->BSSType )
7675 {
7676 /*interface type changed update in wiphy structure*/
7677 wdev->iftype = type;
7678
7679 /*the BSS mode changed, We need to issue disconnect
7680 if connected or in IBSS disconnect state*/
7681 if ( hdd_connGetConnectedBssType(
7682 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
7683 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
7684 {
7685 /*need to issue a disconnect to CSR.*/
7686 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7687 if( eHAL_STATUS_SUCCESS ==
7688 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
7689 pAdapter->sessionId,
7690 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
7691 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307692 ret = wait_for_completion_interruptible_timeout(
7693 &pAdapter->disconnect_comp_var,
7694 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7695 if (ret <= 0)
7696 {
7697 hddLog(VOS_TRACE_LEVEL_ERROR,
7698 FL("wait on disconnect_comp_var failed %ld"), ret);
7699 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007700 }
7701 }
7702 }
7703 }
7704
7705done:
7706 /*set bitmask based on updated value*/
7707 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07007708
7709 /* Only STA mode support TM now
7710 * all other mode, TM feature should be disabled */
7711 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
7712 (~VOS_STA & pHddCtx->concurrency_mode) )
7713 {
7714 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
7715 }
7716
Jeff Johnson295189b2012-06-20 16:38:30 -07007717#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307718 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05307719 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07007720 {
7721 //we are ok to do AMP
7722 pHddCtx->isAmpAllowed = VOS_TRUE;
7723 }
7724#endif //WLAN_BTAMP_FEATURE
7725 EXIT();
7726 return 0;
7727}
7728
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05307729/*
7730 * FUNCTION: wlan_hdd_cfg80211_change_iface
7731 * wrapper function to protect the actual implementation from SSR.
7732 */
7733int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
7734 struct net_device *ndev,
7735 enum nl80211_iftype type,
7736 u32 *flags,
7737 struct vif_params *params
7738 )
7739{
7740 int ret;
7741
7742 vos_ssr_protect(__func__);
7743 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
7744 vos_ssr_unprotect(__func__);
7745
7746 return ret;
7747}
7748
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007749#ifdef FEATURE_WLAN_TDLS
7750static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
7751 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
7752{
7753 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7754 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7755 VOS_STATUS status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007756 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307757 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05307758 tANI_U16 numCurrTdlsPeers;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007759
7760 ENTER();
7761
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05307762 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007763 {
7764 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7765 "Invalid arguments");
7766 return -EINVAL;
7767 }
Hoonki Lee27511902013-03-14 18:19:06 -07007768
7769 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
7770 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
7771 {
7772 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7773 "%s: TDLS mode is disabled OR not enabled in FW."
7774 MAC_ADDRESS_STR " Request declined.",
7775 __func__, MAC_ADDR_ARRAY(mac));
7776 return -ENOTSUPP;
7777 }
7778
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007779 if (pHddCtx->isLogpInProgress)
7780 {
7781 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7782 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +05307783 wlan_hdd_tdls_set_link_status(pAdapter,
7784 mac,
7785 eTDLS_LINK_IDLE,
7786 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007787 return -EBUSY;
7788 }
7789
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05307790 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007791
7792 if ( NULL == pTdlsPeer ) {
7793 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7794 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
7795 __func__, MAC_ADDR_ARRAY(mac), update);
7796 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007797 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007798
7799 /* in add station, we accept existing valid staId if there is */
7800 if ((0 == update) &&
7801 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
7802 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007803 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007804 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007805 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007806 " link_status %d. staId %d. add station ignored.",
7807 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
7808 return 0;
7809 }
7810 /* in change station, we accept only when staId is valid */
7811 if ((1 == update) &&
7812 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
7813 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
7814 {
7815 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7816 "%s: " MAC_ADDRESS_STR
7817 " link status %d. staId %d. change station %s.",
7818 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
7819 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
7820 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007821 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007822
7823 /* when others are on-going, we want to change link_status to idle */
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307824 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007825 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007826 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7827 "%s: " MAC_ADDRESS_STR
7828 " TDLS setup is ongoing. Request declined.",
7829 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07007830 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007831 }
7832
7833 /* first to check if we reached to maximum supported TDLS peer.
7834 TODO: for now, return -EPERM looks working fine,
7835 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05307836 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
7837 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007838 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007839 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7840 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05307841 " TDLS Max peer already connected. Request declined."
7842 " Num of peers (%d), Max allowed (%d).",
7843 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
7844 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007845 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007846 }
7847 else
7848 {
7849 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307850 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007851 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007852 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007853 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7854 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
7855 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007856 return -EPERM;
7857 }
7858 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007859 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +05307860 wlan_hdd_tdls_set_link_status(pAdapter,
7861 mac,
7862 eTDLS_LINK_CONNECTING,
7863 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007864
Jeff Johnsond75fe012013-04-06 10:53:06 -07007865 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05307866 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007867 {
7868 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7869 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07007870 if(StaParams->htcap_present)
7871 {
7872 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7873 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
7874 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7875 "ht_capa->extended_capabilities: %0x",
7876 StaParams->HTCap.extendedHtCapInfo);
7877 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007878 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7879 "params->capability: %0x",StaParams->capability);
7880 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007881 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07007882 if(StaParams->vhtcap_present)
7883 {
7884 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7885 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
7886 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
7887 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
7888 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007889 {
7890 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007891 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007892 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
7893 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7894 "[%d]: %x ", i, StaParams->supported_rates[i]);
7895 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07007896 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05307897 else if ((1 == update) && (NULL == StaParams))
7898 {
7899 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7900 "%s : update is true, but staParams is NULL. Error!", __func__);
7901 return -EPERM;
7902 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007903
7904 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
7905
7906 if (!update)
7907 {
7908 status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
7909 pAdapter->sessionId, mac);
7910 }
7911 else
7912 {
7913 status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
7914 pAdapter->sessionId, mac, StaParams);
7915 }
7916
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307917 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007918 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
7919
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307920 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007921 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007922 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307923 "%s: timeout waiting for tdls add station indication %ld",
7924 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007925 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007926 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307927
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007928 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
7929 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007931 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007932 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007933 }
7934
7935 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07007936
7937error:
Atul Mittal115287b2014-07-08 13:26:33 +05307938 wlan_hdd_tdls_set_link_status(pAdapter,
7939 mac,
7940 eTDLS_LINK_IDLE,
7941 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007942 return -EPERM;
7943
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007944}
7945#endif
7946
Jeff Johnson295189b2012-06-20 16:38:30 -07007947static int wlan_hdd_change_station(struct wiphy *wiphy,
7948 struct net_device *dev,
7949 u8 *mac,
7950 struct station_parameters *params)
7951{
7952 VOS_STATUS status = VOS_STATUS_SUCCESS;
7953 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkala29149562013-05-10 21:43:41 +05307954 hdd_context_t *pHddCtx;
7955 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007956 v_MACADDR_t STAMacAddress;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07007957#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007958 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007959 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05307960 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07007961#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07007962 ENTER();
7963
Gopichand Nakkala29149562013-05-10 21:43:41 +05307964 if ((NULL == pAdapter))
7965 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05307967 "invalid adapter ");
7968 return -EINVAL;
7969 }
7970
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307971 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7972 TRACE_CODE_HDD_CHANGE_STATION,
7973 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05307974 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7975 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7976
7977 if ((NULL == pHddCtx) || (NULL == pHddStaCtx))
7978 {
7979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7980 "invalid HDD state or HDD station context");
7981 return -EINVAL;
7982 }
7983
7984 if (pHddCtx->isLogpInProgress)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007985 {
7986 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7987 "%s:LOGP in Progress. Ignore!!!", __func__);
7988 return -EAGAIN;
7989 }
7990
Jeff Johnson295189b2012-06-20 16:38:30 -07007991 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
7992
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007993 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
7994 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07007995 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007996 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07007997 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307998 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07007999 WLANTL_STA_AUTHENTICATED);
8000
Gopichand Nakkala29149562013-05-10 21:43:41 +05308001 if (status != VOS_STATUS_SUCCESS)
8002 {
8003 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8004 "%s: Not able to change TL state to AUTHENTICATED", __func__);
8005 return -EINVAL;
8006 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008007 }
8008 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07008009 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
8010 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05308011#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008012 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
8013 StaParams.capability = params->capability;
8014 StaParams.uapsd_queues = params->uapsd_queues;
8015 StaParams.max_sp = params->max_sp;
8016
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308017 /* Convert (first channel , number of channels) tuple to
8018 * the total list of channels. This goes with the assumption
8019 * that if the first channel is < 14, then the next channels
8020 * are an incremental of 1 else an incremental of 4 till the number
8021 * of channels.
8022 */
8023 if (0 != params->supported_channels_len) {
8024 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
8025 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
8026 {
8027 int wifi_chan_index;
8028 StaParams.supported_channels[j] = params->supported_channels[i];
8029 wifi_chan_index =
8030 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
8031 no_of_channels = params->supported_channels[i+1];
8032 for(k=1; k <= no_of_channels; k++)
8033 {
8034 StaParams.supported_channels[j+1] =
8035 StaParams.supported_channels[j] + wifi_chan_index;
8036 j+=1;
8037 }
8038 }
8039 StaParams.supported_channels_len = j;
8040 }
8041 vos_mem_copy(StaParams.supported_oper_classes,
8042 params->supported_oper_classes,
8043 params->supported_oper_classes_len);
8044 StaParams.supported_oper_classes_len =
8045 params->supported_oper_classes_len;
8046
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008047 if (0 != params->ext_capab_len)
8048 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
8049 sizeof(StaParams.extn_capability));
8050
8051 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008052 {
8053 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008054 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008055 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008056
8057 StaParams.supported_rates_len = params->supported_rates_len;
8058
8059 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
8060 * The supported_rates array , for all the structures propogating till Add Sta
8061 * to the firmware has to be modified , if the supplicant (ieee80211) is
8062 * modified to send more rates.
8063 */
8064
8065 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
8066 */
8067 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
8068 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
8069
8070 if (0 != StaParams.supported_rates_len) {
8071 int i = 0;
8072 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
8073 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008074 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008075 "Supported Rates with Length %d", StaParams.supported_rates_len);
8076 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008077 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008078 "[%d]: %0x", i, StaParams.supported_rates[i]);
8079 }
8080
8081 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008082 {
8083 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008084 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008085 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008086
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008087 if (0 != params->ext_capab_len ) {
8088 /*Define A Macro : TODO Sunil*/
8089 if ((1<<4) & StaParams.extn_capability[3]) {
8090 isBufSta = 1;
8091 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308092 /* TDLS Channel Switching Support */
8093 if ((1<<6) & StaParams.extn_capability[3]) {
8094 isOffChannelSupported = 1;
8095 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008096 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308097 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
8098 &StaParams, isBufSta,
8099 isOffChannelSupported);
8100
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308101 if (VOS_STATUS_SUCCESS != status) {
8102 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8103 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
8104 return -EINVAL;
8105 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008106 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
8107
8108 if (VOS_STATUS_SUCCESS != status) {
8109 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8110 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
8111 return -EINVAL;
8112 }
8113 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008114#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05308115 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008116 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008117 return status;
8118}
8119
8120/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308121 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -07008122 * This function is used to initialize the key information
8123 */
8124#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308125static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008126 struct net_device *ndev,
8127 u8 key_index, bool pairwise,
8128 const u8 *mac_addr,
8129 struct key_params *params
8130 )
8131#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308132static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008133 struct net_device *ndev,
8134 u8 key_index, const u8 *mac_addr,
8135 struct key_params *params
8136 )
8137#endif
8138{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008139 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07008140 tCsrRoamSetKey setKey;
8141 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308142 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008143 v_U32_t roamId= 0xFF;
8144 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008145 hdd_hostapd_state_t *pHostapdState;
8146 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008147 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308148 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008149
8150 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308151
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308152 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8153 TRACE_CODE_HDD_CFG80211_ADD_KEY,
8154 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308155 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8156 status = wlan_hdd_validate_context(pHddCtx);
8157
8158 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008159 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308160 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8161 "%s: HDD context is not valid", __func__);
8162 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008163 }
8164
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308165 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8166 __func__, hdd_device_modetoString(pAdapter->device_mode),
8167 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008168
8169 if (CSR_MAX_NUM_KEY <= key_index)
8170 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008171 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008172 key_index);
8173
8174 return -EINVAL;
8175 }
8176
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008177 if (CSR_MAX_KEY_LEN < params->key_len)
8178 {
8179 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
8180 params->key_len);
8181
8182 return -EINVAL;
8183 }
8184
8185 hddLog(VOS_TRACE_LEVEL_INFO,
8186 "%s: called with key index = %d & key length %d",
8187 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07008188
8189 /*extract key idx, key len and key*/
8190 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8191 setKey.keyId = key_index;
8192 setKey.keyLength = params->key_len;
8193 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
8194
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008195 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07008196 {
8197 case WLAN_CIPHER_SUITE_WEP40:
8198 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
8199 break;
8200
8201 case WLAN_CIPHER_SUITE_WEP104:
8202 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
8203 break;
8204
8205 case WLAN_CIPHER_SUITE_TKIP:
8206 {
8207 u8 *pKey = &setKey.Key[0];
8208 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
8209
8210 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
8211
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008212 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07008213
8214 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008215 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07008216 |--------------|----------|----------|
8217 <---16bytes---><--8bytes--><--8bytes-->
8218
8219 */
8220 /*Sme expects the 32 bytes key to be in the below order
8221
8222 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008223 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07008224 |--------------|----------|----------|
8225 <---16bytes---><--8bytes--><--8bytes-->
8226 */
8227 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008228 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07008229
8230 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008231 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07008232
8233 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008234 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07008235
8236
8237 break;
8238 }
8239
8240 case WLAN_CIPHER_SUITE_CCMP:
8241 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
8242 break;
8243
8244#ifdef FEATURE_WLAN_WAPI
8245 case WLAN_CIPHER_SUITE_SMS4:
8246 {
8247 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8248 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
8249 params->key, params->key_len);
8250 return 0;
8251 }
8252#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07008253
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008254#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008255 case WLAN_CIPHER_SUITE_KRK:
8256 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
8257 break;
8258#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07008259
8260#ifdef WLAN_FEATURE_11W
8261 case WLAN_CIPHER_SUITE_AES_CMAC:
8262 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07008263 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07008264#endif
8265
Jeff Johnson295189b2012-06-20 16:38:30 -07008266 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008267 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07008268 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308269 status = -EOPNOTSUPP;
8270 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07008271 }
8272
8273 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
8274 __func__, setKey.encType);
8275
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008276 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07008277#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8278 (!pairwise)
8279#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008280 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07008281#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008282 )
8283 {
8284 /* set group key*/
8285 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8286 "%s- %d: setting Broadcast key",
8287 __func__, __LINE__);
8288 setKey.keyDirection = eSIR_RX_ONLY;
8289 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
8290 }
8291 else
8292 {
8293 /* set pairwise key*/
8294 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8295 "%s- %d: setting pairwise key",
8296 __func__, __LINE__);
8297 setKey.keyDirection = eSIR_TX_RX;
8298 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
8299 }
8300 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
8301 {
8302 setKey.keyDirection = eSIR_TX_RX;
8303 /*Set the group key*/
8304 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
8305 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008306
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008307 if ( 0 != status )
8308 {
8309 hddLog(VOS_TRACE_LEVEL_ERROR,
8310 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308311 status = -EINVAL;
8312 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008313 }
8314 /*Save the keys here and call sme_RoamSetKey for setting
8315 the PTK after peer joins the IBSS network*/
8316 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
8317 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308318 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008319 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05308320 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
8321 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
8322 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008323 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008324 if( pHostapdState->bssState == BSS_START )
8325 {
c_hpothu7c55da62014-01-23 18:34:02 +05308326 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8327 vos_status = wlan_hdd_check_ula_done(pAdapter);
8328
8329 if ( vos_status != VOS_STATUS_SUCCESS )
8330 {
8331 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8332 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
8333 __LINE__, vos_status );
8334
8335 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
8336
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308337 status = -EINVAL;
8338 goto end;
c_hpothu7c55da62014-01-23 18:34:02 +05308339 }
8340
Jeff Johnson295189b2012-06-20 16:38:30 -07008341 status = WLANSAP_SetKeySta( pVosContext, &setKey);
8342
8343 if ( status != eHAL_STATUS_SUCCESS )
8344 {
8345 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8346 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
8347 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308348 status = -EINVAL;
8349 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07008350 }
8351 }
8352
8353 /* Saving WEP keys */
8354 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
8355 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
8356 {
8357 //Save the wep key in ap context. Issue setkey after the BSS is started.
8358 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
8359 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
8360 }
8361 else
8362 {
8363 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008364 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008365 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
8366 }
8367 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008368 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
8369 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008370 {
8371 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8372 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8373
Gopichand Nakkala3d295922013-05-07 16:19:14 +05308374#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8375 if (!pairwise)
8376#else
8377 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
8378#endif
8379 {
8380 /* set group key*/
8381 if (pHddStaCtx->roam_info.deferKeyComplete)
8382 {
8383 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8384 "%s- %d: Perform Set key Complete",
8385 __func__, __LINE__);
8386 hdd_PerformRoamSetKeyComplete(pAdapter);
8387 }
8388 }
8389
Jeff Johnson295189b2012-06-20 16:38:30 -07008390 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
8391
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08008392 pWextState->roamProfile.Keys.defaultIndex = key_index;
8393
8394
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008395 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07008396 params->key, params->key_len);
8397
Gopichand Nakkala3d295922013-05-07 16:19:14 +05308398
Jeff Johnson295189b2012-06-20 16:38:30 -07008399 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
8400
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308401 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07008402 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308403 __func__, setKey.peerMac[0], setKey.peerMac[1],
8404 setKey.peerMac[2], setKey.peerMac[3],
8405 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07008406 setKey.keyDirection);
8407
8408 vos_status = wlan_hdd_check_ula_done(pAdapter);
8409
8410 if ( vos_status != VOS_STATUS_SUCCESS )
8411 {
8412 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8413 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
8414 __LINE__, vos_status );
8415
8416 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
8417
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308418 status = -EINVAL;
8419 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07008420
8421 }
8422
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008423#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05308424 /* The supplicant may attempt to set the PTK once pre-authentication
8425 is done. Save the key in the UMAC and include it in the ADD BSS
8426 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008427 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05308428 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008429 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05308430 hddLog(VOS_TRACE_LEVEL_INFO_MED,
8431 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308432 status = 0;
8433 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +05308434 }
8435 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
8436 {
8437 hddLog(VOS_TRACE_LEVEL_ERROR,
8438 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308439 status = -EINVAL;
8440 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008441 }
8442#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07008443
8444 /* issue set key request to SME*/
8445 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
8446 pAdapter->sessionId, &setKey, &roamId );
8447
8448 if ( 0 != status )
8449 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308450 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07008451 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
8452 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308453 status = -EINVAL;
8454 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07008455 }
8456
8457
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308458 /* in case of IBSS as there was no information available about WEP keys during
8459 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07008460 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308461 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
8462 !( ( IW_AUTH_KEY_MGMT_802_1X
8463 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07008464 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
8465 )
8466 &&
8467 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
8468 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
8469 )
8470 )
8471 {
8472 setKey.keyDirection = eSIR_RX_ONLY;
8473 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
8474
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308475 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07008476 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308477 __func__, setKey.peerMac[0], setKey.peerMac[1],
8478 setKey.peerMac[2], setKey.peerMac[3],
8479 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07008480 setKey.keyDirection);
8481
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308482 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07008483 pAdapter->sessionId, &setKey, &roamId );
8484
8485 if ( 0 != status )
8486 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308487 hddLog(VOS_TRACE_LEVEL_ERROR,
8488 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008489 __func__, status);
8490 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308491 status = -EINVAL;
8492 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07008493 }
8494 }
8495 }
8496
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308497end:
8498 /* Need to clear any trace of key value in the memory.
8499 * Thus zero out the memory even though it is local
8500 * variable.
8501 */
8502 vos_mem_zero(&setKey, sizeof(setKey));
8503
8504 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008505}
8506
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308507#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8508static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
8509 struct net_device *ndev,
8510 u8 key_index, bool pairwise,
8511 const u8 *mac_addr,
8512 struct key_params *params
8513 )
8514#else
8515static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
8516 struct net_device *ndev,
8517 u8 key_index, const u8 *mac_addr,
8518 struct key_params *params
8519 )
8520#endif
8521{
8522 int ret;
8523 vos_ssr_protect(__func__);
8524#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8525 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
8526 mac_addr, params);
8527#else
8528 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
8529 params);
8530#endif
8531 vos_ssr_unprotect(__func__);
8532
8533 return ret;
8534}
8535
Jeff Johnson295189b2012-06-20 16:38:30 -07008536/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308537 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -07008538 * This function is used to get the key information
8539 */
8540#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308541static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308542 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008543 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308544 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07008545 const u8 *mac_addr, void *cookie,
8546 void (*callback)(void *cookie, struct key_params*)
8547 )
8548#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308549static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308550 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008551 struct net_device *ndev,
8552 u8 key_index, const u8 *mac_addr, void *cookie,
8553 void (*callback)(void *cookie, struct key_params*)
8554 )
8555#endif
8556{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308557 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308558 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8559 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008560 struct key_params params;
8561
8562 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308563
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308564 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8565 __func__, hdd_device_modetoString(pAdapter->device_mode),
8566 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308567
Jeff Johnson295189b2012-06-20 16:38:30 -07008568 memset(&params, 0, sizeof(params));
8569
8570 if (CSR_MAX_NUM_KEY <= key_index)
8571 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308572 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07008573 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008575
8576 switch(pRoamProfile->EncryptionType.encryptionType[0])
8577 {
8578 case eCSR_ENCRYPT_TYPE_NONE:
8579 params.cipher = IW_AUTH_CIPHER_NONE;
8580 break;
8581
8582 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
8583 case eCSR_ENCRYPT_TYPE_WEP40:
8584 params.cipher = WLAN_CIPHER_SUITE_WEP40;
8585 break;
8586
8587 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
8588 case eCSR_ENCRYPT_TYPE_WEP104:
8589 params.cipher = WLAN_CIPHER_SUITE_WEP104;
8590 break;
8591
8592 case eCSR_ENCRYPT_TYPE_TKIP:
8593 params.cipher = WLAN_CIPHER_SUITE_TKIP;
8594 break;
8595
8596 case eCSR_ENCRYPT_TYPE_AES:
8597 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
8598 break;
8599
8600 default:
8601 params.cipher = IW_AUTH_CIPHER_NONE;
8602 break;
8603 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308604
c_hpothuaaf19692014-05-17 17:01:48 +05308605 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8606 TRACE_CODE_HDD_CFG80211_GET_KEY,
8607 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308608
Jeff Johnson295189b2012-06-20 16:38:30 -07008609 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
8610 params.seq_len = 0;
8611 params.seq = NULL;
8612 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
8613 callback(cookie, &params);
8614 return 0;
8615}
8616
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308617#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8618static int wlan_hdd_cfg80211_get_key(
8619 struct wiphy *wiphy,
8620 struct net_device *ndev,
8621 u8 key_index, bool pairwise,
8622 const u8 *mac_addr, void *cookie,
8623 void (*callback)(void *cookie, struct key_params*)
8624 )
8625#else
8626static int wlan_hdd_cfg80211_get_key(
8627 struct wiphy *wiphy,
8628 struct net_device *ndev,
8629 u8 key_index, const u8 *mac_addr, void *cookie,
8630 void (*callback)(void *cookie, struct key_params*)
8631 )
8632#endif
8633{
8634 int ret;
8635
8636 vos_ssr_protect(__func__);
8637#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8638 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
8639 mac_addr, cookie, callback);
8640#else
8641 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
8642 callback);
8643#endif
8644 vos_ssr_unprotect(__func__);
8645
8646 return ret;
8647}
8648
Jeff Johnson295189b2012-06-20 16:38:30 -07008649/*
8650 * FUNCTION: wlan_hdd_cfg80211_del_key
8651 * This function is used to delete the key information
8652 */
8653#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308654static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008655 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308656 u8 key_index,
8657 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07008658 const u8 *mac_addr
8659 )
8660#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308661static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008662 struct net_device *ndev,
8663 u8 key_index,
8664 const u8 *mac_addr
8665 )
8666#endif
8667{
8668 int status = 0;
8669
8670 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308671 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07008672 //it is observed that this is invalidating peer
8673 //key index whenever re-key is done. This is affecting data link.
8674 //It should be ok to ignore del_key.
8675#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308676 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
8677 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008678 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
8679 tCsrRoamSetKey setKey;
8680 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308681
Jeff Johnson295189b2012-06-20 16:38:30 -07008682 ENTER();
8683
8684 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
8685 __func__,pAdapter->device_mode);
8686
8687 if (CSR_MAX_NUM_KEY <= key_index)
8688 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308689 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008690 key_index);
8691
8692 return -EINVAL;
8693 }
8694
8695 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8696 setKey.keyId = key_index;
8697
8698 if (mac_addr)
8699 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
8700 else
8701 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
8702
8703 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
8704
8705 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008706 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308707 )
8708 {
8709
8710 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07008711 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
8712 if( pHostapdState->bssState == BSS_START)
8713 {
8714 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308715
Jeff Johnson295189b2012-06-20 16:38:30 -07008716 if ( status != eHAL_STATUS_SUCCESS )
8717 {
8718 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8719 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
8720 __LINE__, status );
8721 }
8722 }
8723 }
8724 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308725 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07008726 )
8727 {
8728 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8729
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308730 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
8731
8732 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07008733 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308734 __func__, setKey.peerMac[0], setKey.peerMac[1],
8735 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07008736 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308737 if(pAdapter->sessionCtx.station.conn_info.connState ==
8738 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07008739 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308740 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07008741 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308742
Jeff Johnson295189b2012-06-20 16:38:30 -07008743 if ( 0 != status )
8744 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308745 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07008746 "%s: sme_RoamSetKey failure, returned %d",
8747 __func__, status);
8748 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
8749 return -EINVAL;
8750 }
8751 }
8752 }
8753#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008754 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008755 return status;
8756}
8757
8758/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308759 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -07008760 * This function is used to set the default tx key index
8761 */
8762#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308763static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008764 struct net_device *ndev,
8765 u8 key_index,
8766 bool unicast, bool multicast)
8767#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308768static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008769 struct net_device *ndev,
8770 u8 key_index)
8771#endif
8772{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308773 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308774 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308775 hdd_wext_state_t *pWextState;
8776 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308777 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008778
8779 ENTER();
8780
Gopichand Nakkala29149562013-05-10 21:43:41 +05308781 if ((NULL == pAdapter))
8782 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308783 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05308784 "invalid adapter");
8785 return -EINVAL;
8786 }
8787
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308788 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8789 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
8790 pAdapter->sessionId, key_index));
8791
Gopichand Nakkala29149562013-05-10 21:43:41 +05308792 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8793 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8794
8795 if ((NULL == pWextState) || (NULL == pHddStaCtx))
8796 {
8797 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8798 "invalid Wext state or HDD context");
8799 return -EINVAL;
8800 }
8801
Arif Hussain6d2a3322013-11-17 19:50:10 -08008802 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008803 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308804
Jeff Johnson295189b2012-06-20 16:38:30 -07008805 if (CSR_MAX_NUM_KEY <= key_index)
8806 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308807 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008808 key_index);
8809
8810 return -EINVAL;
8811 }
8812
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308813 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8814 status = wlan_hdd_validate_context(pHddCtx);
8815
8816 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008817 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308818 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8819 "%s: HDD context is not valid", __func__);
8820 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008821 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308822
Jeff Johnson295189b2012-06-20 16:38:30 -07008823 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07008824 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308825 )
Jeff Johnson295189b2012-06-20 16:38:30 -07008826 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05308827 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08008828 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308829 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08008830 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008831 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308832 {
8833 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07008834 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308835
Jeff Johnson295189b2012-06-20 16:38:30 -07008836 tCsrRoamSetKey setKey;
8837 v_U32_t roamId= 0xFF;
8838 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308839
8840 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008841 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308842
Jeff Johnson295189b2012-06-20 16:38:30 -07008843 Keys->defaultIndex = (u8)key_index;
8844 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8845 setKey.keyId = key_index;
8846 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308847
8848 vos_mem_copy(&setKey.Key[0],
8849 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07008850 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308851
Gopichand Nakkala29149562013-05-10 21:43:41 +05308852 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308853
8854 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07008855 &pHddStaCtx->conn_info.bssId[0],
8856 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308857
Gopichand Nakkala29149562013-05-10 21:43:41 +05308858 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
8859 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
8860 eCSR_ENCRYPT_TYPE_WEP104)
8861 {
8862 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
8863 even though ap is configured for WEP-40 encryption. In this canse the key length
8864 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
8865 type(104) and switching encryption type to 40*/
8866 pWextState->roamProfile.EncryptionType.encryptionType[0] =
8867 eCSR_ENCRYPT_TYPE_WEP40;
8868 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
8869 eCSR_ENCRYPT_TYPE_WEP40;
8870 }
8871
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308872 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07008873 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308874
Jeff Johnson295189b2012-06-20 16:38:30 -07008875 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308876 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07008877 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308878
Jeff Johnson295189b2012-06-20 16:38:30 -07008879 if ( 0 != status )
8880 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308881 hddLog(VOS_TRACE_LEVEL_ERROR,
8882 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008883 status);
8884 return -EINVAL;
8885 }
8886 }
8887 }
8888
8889 /* In SoftAp mode setting key direction for default mode */
8890 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
8891 {
8892 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
8893 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
8894 (eCSR_ENCRYPT_TYPE_AES !=
8895 pWextState->roamProfile.EncryptionType.encryptionType[0])
8896 )
8897 {
8898 /* Saving key direction for default key index to TX default */
8899 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
8900 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
8901 }
8902 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308903
Jeff Johnson295189b2012-06-20 16:38:30 -07008904 return status;
8905}
8906
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308907#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8908static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
8909 struct net_device *ndev,
8910 u8 key_index,
8911 bool unicast, bool multicast)
8912#else
8913static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
8914 struct net_device *ndev,
8915 u8 key_index)
8916#endif
8917{
8918 int ret;
8919 vos_ssr_protect(__func__);
8920#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8921 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
8922 multicast);
8923#else
8924 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
8925#endif
8926 vos_ssr_unprotect(__func__);
8927
8928 return ret;
8929}
8930
Jeff Johnson295189b2012-06-20 16:38:30 -07008931/*
8932 * FUNCTION: wlan_hdd_cfg80211_inform_bss
8933 * This function is used to inform the BSS details to nl80211 interface.
8934 */
8935static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
8936 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
8937{
8938 struct net_device *dev = pAdapter->dev;
8939 struct wireless_dev *wdev = dev->ieee80211_ptr;
8940 struct wiphy *wiphy = wdev->wiphy;
8941 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
8942 int chan_no;
8943 int ie_length;
8944 const char *ie;
8945 unsigned int freq;
8946 struct ieee80211_channel *chan;
8947 int rssi = 0;
8948 struct cfg80211_bss *bss = NULL;
8949
8950 ENTER();
8951
8952 if( NULL == pBssDesc )
8953 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008954 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008955 return bss;
8956 }
8957
8958 chan_no = pBssDesc->channelId;
8959 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
8960 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
8961
8962 if( NULL == ie )
8963 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008964 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008965 return bss;
8966 }
8967
8968#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
8969 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
8970 {
8971 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
8972 }
8973 else
8974 {
8975 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
8976 }
8977#else
8978 freq = ieee80211_channel_to_frequency(chan_no);
8979#endif
8980
8981 chan = __ieee80211_get_channel(wiphy, freq);
8982
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +05308983 if (!chan) {
8984 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
8985 return NULL;
8986 }
8987
Abhishek Singhaee43942014-06-16 18:55:47 +05308988 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -07008989
Abhishek Singhaee43942014-06-16 18:55:47 +05308990 return cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308991 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07008992 pBssDesc->capabilityInfo,
8993 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +05308994 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008995}
8996
8997
8998
8999/*
9000 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
9001 * This function is used to inform the BSS details to nl80211 interface.
9002 */
9003struct cfg80211_bss*
9004wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
9005 tSirBssDescription *bss_desc
9006 )
9007{
9008 /*
9009 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
9010 already exists in bss data base of cfg80211 for that particular BSS ID.
9011 Using cfg80211_inform_bss_frame to update the bss entry instead of
9012 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
9013 now there is no possibility to get the mgmt(probe response) frame from PE,
9014 converting bss_desc to ieee80211_mgmt(probe response) and passing to
9015 cfg80211_inform_bss_frame.
9016 */
9017 struct net_device *dev = pAdapter->dev;
9018 struct wireless_dev *wdev = dev->ieee80211_ptr;
9019 struct wiphy *wiphy = wdev->wiphy;
9020 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009021#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
9022 qcom_ie_age *qie_age = NULL;
9023 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
9024#else
Jeff Johnson295189b2012-06-20 16:38:30 -07009025 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009026#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009027 const char *ie =
9028 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
9029 unsigned int freq;
9030 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05309031 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009032 struct cfg80211_bss *bss_status = NULL;
9033 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
9034 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07009035 hdd_context_t *pHddCtx;
9036 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07009037#ifdef WLAN_OPEN_SOURCE
9038 struct timespec ts;
9039#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009040
Wilson Yangf80a0542013-10-07 13:02:37 -07009041 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9042 status = wlan_hdd_validate_context(pHddCtx);
9043
9044 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +05309045 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -07009046 {
9047 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9048 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
9049 return NULL;
9050 }
9051
9052
9053 if (0 != status)
9054 {
9055 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9056 "%s: HDD context is not valid", __func__);
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07009057 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07009058 }
9059
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05309060 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -07009061 if (!mgmt)
9062 {
9063 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9064 "%s: memory allocation failed ", __func__);
9065 return NULL;
9066 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07009067
Jeff Johnson295189b2012-06-20 16:38:30 -07009068 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07009069
9070#ifdef WLAN_OPEN_SOURCE
9071 /* Android does not want the timestamp from the frame.
9072 Instead it wants a monotonic increasing value */
9073 get_monotonic_boottime(&ts);
9074 mgmt->u.probe_resp.timestamp =
9075 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
9076#else
9077 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07009078 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
9079 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07009080
9081#endif
9082
Jeff Johnson295189b2012-06-20 16:38:30 -07009083 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
9084 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009085
9086#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
9087 /* GPS Requirement: need age ie per entry. Using vendor specific. */
9088 /* Assuming this is the last IE, copy at the end */
9089 ie_length -=sizeof(qcom_ie_age);
9090 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
9091 qie_age->element_id = QCOM_VENDOR_IE_ID;
9092 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
9093 qie_age->oui_1 = QCOM_OUI1;
9094 qie_age->oui_2 = QCOM_OUI2;
9095 qie_age->oui_3 = QCOM_OUI3;
9096 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
9097 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
9098#endif
9099
Jeff Johnson295189b2012-06-20 16:38:30 -07009100 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05309101 if (bss_desc->fProbeRsp)
9102 {
9103 mgmt->frame_control |=
9104 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
9105 }
9106 else
9107 {
9108 mgmt->frame_control |=
9109 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
9110 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009111
9112#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309113 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009114 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
9115 {
9116 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
9117 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309118 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009119 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
9120
9121 {
9122 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
9123 }
9124 else
9125 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309126 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
9127 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -07009128 kfree(mgmt);
9129 return NULL;
9130 }
9131#else
9132 freq = ieee80211_channel_to_frequency(chan_no);
9133#endif
9134 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08009135 /*when the band is changed on the fly using the GUI, three things are done
9136 * 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)
9137 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
9138 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
9139 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
9140 * and discards the channels correponding to previous band and calls back with zero bss results.
9141 * 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
9142 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
9143 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
9144 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
9145 * So drop the bss and continue to next bss.
9146 */
9147 if(chan == NULL)
9148 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309149 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07009150 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08009151 return NULL;
9152 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009153 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309154 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07009155 * */
9156 if (( eConnectionState_Associated ==
9157 pAdapter->sessionCtx.station.conn_info.connState ) &&
9158 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
9159 pAdapter->sessionCtx.station.conn_info.bssId,
9160 WNI_CFG_BSSID_LEN)))
9161 {
9162 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
9163 rssi = (pAdapter->rssi * 100);
9164 }
9165 else
9166 {
9167 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
9168 }
9169
Nirav Shah20ac06f2013-12-12 18:14:06 +05309170 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
9171 "RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
9172 chan->center_freq, (int)(rssi/100));
9173
Jeff Johnson295189b2012-06-20 16:38:30 -07009174 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
9175 frame_len, rssi, GFP_KERNEL);
9176 kfree(mgmt);
9177 return bss_status;
9178}
9179
9180/*
9181 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
9182 * This function is used to update the BSS data base of CFG8011
9183 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309184struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07009185 tCsrRoamInfo *pRoamInfo
9186 )
9187{
9188 tCsrRoamConnectedProfile roamProfile;
9189 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9190 struct cfg80211_bss *bss = NULL;
9191
9192 ENTER();
9193
9194 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
9195 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
9196
9197 if (NULL != roamProfile.pBssDesc)
9198 {
Girish Gowlif4b68022014-08-28 23:18:57 +05309199 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
9200 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009201
9202 if (NULL == bss)
9203 {
9204 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
9205 __func__);
9206 }
9207
9208 sme_RoamFreeConnectProfile(hHal, &roamProfile);
9209 }
9210 else
9211 {
9212 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
9213 __func__);
9214 }
9215 return bss;
9216}
9217
9218/*
9219 * FUNCTION: wlan_hdd_cfg80211_update_bss
9220 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309221static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
9222 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07009223 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309224{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309225 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009226 tCsrScanResultInfo *pScanResult;
9227 eHalStatus status = 0;
9228 tScanResultHandle pResult;
9229 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07009230 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009231
9232 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309233
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309234 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9235 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
9236 NO_SESSION, pAdapter->sessionId));
9237
Wilson Yangf80a0542013-10-07 13:02:37 -07009238 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9239
9240 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -07009241 {
Wilson Yangf80a0542013-10-07 13:02:37 -07009242 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9243 "%s:LOGP in Progress. Ignore!!!",__func__);
9244 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07009245 }
9246
Wilson Yangf80a0542013-10-07 13:02:37 -07009247
9248 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +05309249 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -07009250 {
9251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9252 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
9253 return VOS_STATUS_E_PERM;
9254 }
9255
9256
Jeff Johnson295189b2012-06-20 16:38:30 -07009257 /*
9258 * start getting scan results and populate cgf80211 BSS database
9259 */
9260 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
9261
9262 /* no scan results */
9263 if (NULL == pResult)
9264 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309265 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
9266 __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07009267 return status;
9268 }
9269
9270 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
9271
9272 while (pScanResult)
9273 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309274 /*
9275 * cfg80211_inform_bss() is not updating ie field of bss entry, if
9276 * entry already exists in bss data base of cfg80211 for that
9277 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
9278 * bss entry instead of cfg80211_inform_bss, But this call expects
9279 * mgmt packet as input. As of now there is no possibility to get
9280 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07009281 * ieee80211_mgmt(probe response) and passing to c
9282 * fg80211_inform_bss_frame.
9283 * */
9284
9285 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
9286 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309287
Jeff Johnson295189b2012-06-20 16:38:30 -07009288
9289 if (NULL == bss_status)
9290 {
9291 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009292 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009293 }
9294 else
9295 {
Yue Maf49ba872013-08-19 12:04:25 -07009296 cfg80211_put_bss(
9297#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9298 wiphy,
9299#endif
9300 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07009301 }
9302
9303 pScanResult = sme_ScanResultGetNext(hHal, pResult);
9304 }
9305
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309306 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07009307
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309308 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009309}
9310
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009311void
9312hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
9313{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309314 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -08009315 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009316} /****** end hddPrintMacAddr() ******/
9317
9318void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07009319hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009320{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309321 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009322 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07009323 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
9324 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
9325 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009326} /****** end hddPrintPmkId() ******/
9327
9328//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
9329//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
9330
9331//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
9332//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
9333
9334#define dump_bssid(bssid) \
9335 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07009336 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
9337 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009338 }
9339
9340#define dump_pmkid(pMac, pmkid) \
9341 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07009342 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
9343 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009344 }
9345
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07009346#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009347/*
9348 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
9349 * This function is used to notify the supplicant of a new PMKSA candidate.
9350 */
9351int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309352 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009353 int index, bool preauth )
9354{
Jeff Johnsone7245742012-09-05 17:12:55 -07009355#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009356 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07009357 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009358
9359 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07009360 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009361
9362 if( NULL == pRoamInfo )
9363 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009364 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009365 return -EINVAL;
9366 }
9367
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07009368 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
9369 {
9370 dump_bssid(pRoamInfo->bssid);
9371 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009372 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07009373 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009374#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309375 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009376}
9377#endif //FEATURE_WLAN_LFR
9378
Yue Maef608272013-04-08 23:09:17 -07009379#ifdef FEATURE_WLAN_LFR_METRICS
9380/*
9381 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
9382 * 802.11r/LFR metrics reporting function to report preauth initiation
9383 *
9384 */
9385#define MAX_LFR_METRICS_EVENT_LENGTH 100
9386VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
9387 tCsrRoamInfo *pRoamInfo)
9388{
9389 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
9390 union iwreq_data wrqu;
9391
9392 ENTER();
9393
9394 if (NULL == pAdapter)
9395 {
9396 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
9397 return VOS_STATUS_E_FAILURE;
9398 }
9399
9400 /* create the event */
9401 memset(&wrqu, 0, sizeof(wrqu));
9402 memset(metrics_notification, 0, sizeof(metrics_notification));
9403
9404 wrqu.data.pointer = metrics_notification;
9405 wrqu.data.length = scnprintf(metrics_notification,
9406 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
9407 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
9408
9409 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
9410
9411 EXIT();
9412
9413 return VOS_STATUS_SUCCESS;
9414}
9415
9416/*
9417 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
9418 * 802.11r/LFR metrics reporting function to report preauth completion
9419 * or failure
9420 */
9421VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
9422 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
9423{
9424 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
9425 union iwreq_data wrqu;
9426
9427 ENTER();
9428
9429 if (NULL == pAdapter)
9430 {
9431 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
9432 return VOS_STATUS_E_FAILURE;
9433 }
9434
9435 /* create the event */
9436 memset(&wrqu, 0, sizeof(wrqu));
9437 memset(metrics_notification, 0, sizeof(metrics_notification));
9438
9439 scnprintf(metrics_notification, sizeof(metrics_notification),
9440 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
9441 MAC_ADDR_ARRAY(pRoamInfo->bssid));
9442
9443 if (1 == preauth_status)
9444 strncat(metrics_notification, " TRUE", 5);
9445 else
9446 strncat(metrics_notification, " FALSE", 6);
9447
9448 wrqu.data.pointer = metrics_notification;
9449 wrqu.data.length = strlen(metrics_notification);
9450
9451 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
9452
9453 EXIT();
9454
9455 return VOS_STATUS_SUCCESS;
9456}
9457
9458/*
9459 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
9460 * 802.11r/LFR metrics reporting function to report handover initiation
9461 *
9462 */
9463VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
9464 tCsrRoamInfo *pRoamInfo)
9465{
9466 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
9467 union iwreq_data wrqu;
9468
9469 ENTER();
9470
9471 if (NULL == pAdapter)
9472 {
9473 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
9474 return VOS_STATUS_E_FAILURE;
9475 }
9476
9477 /* create the event */
9478 memset(&wrqu, 0, sizeof(wrqu));
9479 memset(metrics_notification, 0, sizeof(metrics_notification));
9480
9481 wrqu.data.pointer = metrics_notification;
9482 wrqu.data.length = scnprintf(metrics_notification,
9483 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
9484 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
9485
9486 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
9487
9488 EXIT();
9489
9490 return VOS_STATUS_SUCCESS;
9491}
9492#endif
9493
Jeff Johnson295189b2012-06-20 16:38:30 -07009494/*
9495 * FUNCTION: hdd_cfg80211_scan_done_callback
9496 * scanning callback function, called after finishing scan
9497 *
9498 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309499static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -07009500 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
9501{
9502 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309503 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009504 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009505 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9506 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07009507 struct cfg80211_scan_request *req = NULL;
9508 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05309509 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309510 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +05309511 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07009512
9513 ENTER();
9514
9515 hddLog(VOS_TRACE_LEVEL_INFO,
9516 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -08009517 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009518 __func__, halHandle, pContext, (int) scanId, (int) status);
9519
Kiet Lamac06e2c2013-10-23 16:25:07 +05309520 pScanInfo->mScanPendingCounter = 0;
9521
Jeff Johnson295189b2012-06-20 16:38:30 -07009522 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309523 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -07009524 &pScanInfo->scan_req_completion_event,
9525 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309526 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07009527 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309528 hddLog(VOS_TRACE_LEVEL_ERROR,
9529 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -07009530 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07009531 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07009532 }
9533
Yue Maef608272013-04-08 23:09:17 -07009534 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07009535 {
9536 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07009537 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07009538 }
9539
9540 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309541 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -07009542 {
9543 hddLog(VOS_TRACE_LEVEL_INFO,
9544 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -08009545 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -07009546 (int) scanId);
9547 }
9548
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309549 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009550 pAdapter);
9551
9552 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309553 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009554
9555
9556 /* If any client wait scan result through WEXT
9557 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009558 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07009559 {
9560 /* The other scan request waiting for current scan finish
9561 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009562 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07009563 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009564 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07009565 }
9566 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009567 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07009568 {
9569 struct net_device *dev = pAdapter->dev;
9570 union iwreq_data wrqu;
9571 int we_event;
9572 char *msg;
9573
9574 memset(&wrqu, '\0', sizeof(wrqu));
9575 we_event = SIOCGIWSCAN;
9576 msg = NULL;
9577 wireless_send_event(dev, we_event, &wrqu, msg);
9578 }
9579 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009580 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009581
9582 /* Get the Scan Req */
9583 req = pAdapter->request;
9584
9585 if (!req)
9586 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009587 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07009588 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07009589 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07009590 }
9591
Jeff Johnson295189b2012-06-20 16:38:30 -07009592 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07009593 /* Scan is no longer pending */
9594 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009595
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +05309596 /* last_scan_timestamp is used to decide if new scan
9597 * is needed or not on station interface. If last station
9598 * scan time and new station scan time is less then
9599 * last_scan_timestamp ; driver will return cached scan.
9600 */
9601 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
9602 {
9603 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
9604
9605 if ( req->n_channels )
9606 {
9607 for (i = 0; i < req->n_channels ; i++ )
9608 {
9609 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
9610 }
9611 /* store no of channel scanned */
9612 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
9613 }
9614
9615 }
9616
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -07009617 /*
9618 * cfg80211_scan_done informing NL80211 about completion
9619 * of scanning
9620 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05309621 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
9622 {
9623 aborted = true;
9624 }
9625 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08009626 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07009627
Siddharth Bhal76972212014-10-15 16:22:51 +05309628 if (pHddCtx->spoofMacAddr.isEnabled || pHddCtx->spoofMacAddr.isReqDeferred) {
9629 /* Generate new random mac addr for next scan */
9630 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
9631 hdd_processSpoofMacAddrRequest(pHddCtx);
9632 }
9633
Jeff Johnsone7245742012-09-05 17:12:55 -07009634allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07009635 /* release the wake lock at the end of the scan*/
9636 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07009637
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07009638 /* Acquire wakelock to handle the case where APP's tries to suspend
9639 * immediatly after the driver gets connect request(i.e after scan)
9640 * from supplicant, this result in app's is suspending and not able
9641 * to process the connect request to AP */
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05309642 hdd_prevent_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07009643
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07009644#ifdef FEATURE_WLAN_TDLS
c_hpothu3c8f8e82014-06-02 18:01:50 +05309645 if (!(eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode))
9646 {
9647 wlan_hdd_tdls_scan_done_callback(pAdapter);
9648 }
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07009649#endif
9650
Jeff Johnson295189b2012-06-20 16:38:30 -07009651 EXIT();
9652 return 0;
9653}
9654
9655/*
Rashmi Ramannab1429032014-04-26 14:59:09 +05309656 * FUNCTION: hdd_isConnectionInProgress
9657 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009658 *
9659 */
Ganesh Kondabattiniaeb7b772014-08-11 20:00:36 +05309660v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx, v_BOOL_t isRoC )
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009661{
9662 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
9663 hdd_station_ctx_t *pHddStaCtx = NULL;
9664 hdd_adapter_t *pAdapter = NULL;
9665 VOS_STATUS status = 0;
9666 v_U8_t staId = 0;
9667 v_U8_t *staMac = NULL;
9668
c_hpothu9b781ba2013-12-30 20:57:45 +05309669 if (TRUE == pHddCtx->btCoexModeSet)
9670 {
9671 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +05309672 FL("BTCoex Mode operation in progress"));
9673 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +05309674 }
9675
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009676 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
9677
9678 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
9679 {
9680 pAdapter = pAdapterNode->pAdapter;
9681
9682 if( pAdapter )
9683 {
9684 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309685 "%s: Adapter with device mode %s (%d) exists",
9686 __func__, hdd_device_modetoString(pAdapter->device_mode),
9687 pAdapter->device_mode);
Ganesh Kondabattiniaeb7b772014-08-11 20:00:36 +05309688 if ((((!isRoC) && (WLAN_HDD_INFRA_STATION == pAdapter->device_mode)) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +05309689 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
9690 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
9691 (eConnectionState_Connecting ==
9692 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
9693 {
9694 hddLog(VOS_TRACE_LEVEL_ERROR,
9695 "%s: %p(%d) Connection is in progress", __func__,
9696 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
9697 return VOS_TRUE;
9698 }
Ganesh Kondabattiniaeb7b772014-08-11 20:00:36 +05309699 if (((!isRoC) && (WLAN_HDD_INFRA_STATION == pAdapter->device_mode)) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309700 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
9701 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009702 {
9703 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9704 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309705 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009706 {
9707 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
9708 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08009709 "%s: client " MAC_ADDRESS_STR
9710 " is in the middle of WPS/EAPOL exchange.", __func__,
9711 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +05309712 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009713 }
9714 }
9715 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
9716 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
9717 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05309718 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
9719 ptSapContext pSapCtx = NULL;
9720 pSapCtx = VOS_GET_SAP_CB(pVosContext);
9721 if(pSapCtx == NULL){
9722 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9723 FL("psapCtx is NULL"));
9724 return VOS_FALSE;
9725 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009726 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
9727 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05309728 if ((pSapCtx->aStaInfo[staId].isUsed) &&
9729 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009730 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05309731 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009732
9733 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08009734 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
9735 "middle of WPS/EAPOL exchange.", __func__,
9736 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +05309737 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009738 }
9739 }
9740 }
9741 }
9742 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
9743 pAdapterNode = pNext;
9744 }
Rashmi Ramannab1429032014-04-26 14:59:09 +05309745 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309746}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009747
9748/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05309749 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -07009750 * this scan respond to scan trigger and update cfg80211 scan database
9751 * later, scan dump command can be used to recieve scan results
9752 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05309753int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009754#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
9755 struct net_device *dev,
9756#endif
9757 struct cfg80211_scan_request *request)
9758{
Siddharth Bhal0c162d02014-05-06 19:50:42 +05309759 hdd_adapter_t *pAdapter = NULL;
9760 hdd_context_t *pHddCtx = NULL;
9761 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309762 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009763 tCsrScanRequest scanRequest;
9764 tANI_U8 *channelList = NULL, i;
9765 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309766 int status;
9767 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009768 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +05309769 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009770
Siddharth Bhal0c162d02014-05-06 19:50:42 +05309771#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
9772 struct net_device *dev = NULL;
9773 if (NULL == request)
9774 {
9775 hddLog(VOS_TRACE_LEVEL_ERROR,
9776 "%s: scan req param null", __func__);
9777 return -EINVAL;
9778 }
9779 dev = request->wdev->netdev;
9780#endif
9781
9782 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
9783 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
9784 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9785
Jeff Johnson295189b2012-06-20 16:38:30 -07009786 ENTER();
9787
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309788
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309789 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9790 __func__, hdd_device_modetoString(pAdapter->device_mode),
9791 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309792
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309793 status = wlan_hdd_validate_context(pHddCtx);
9794
9795 if (0 != status)
9796 {
9797 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9798 "%s: HDD context is not valid", __func__);
9799 return status;
9800 }
9801
Siddharth Bhal0c162d02014-05-06 19:50:42 +05309802 if (NULL == pwextBuf)
9803 {
9804 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
9805 __func__);
9806 return -EIO;
9807 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309808 cfg_param = pHddCtx->cfg_ini;
9809 pScanInfo = &pHddCtx->scan_info;
9810
Jeff Johnson295189b2012-06-20 16:38:30 -07009811#ifdef WLAN_BTAMP_FEATURE
9812 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009813 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -07009814 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08009815 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009816 "%s: No scanning when AMP is on", __func__);
9817 return -EOPNOTSUPP;
9818 }
9819#endif
9820 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009821 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009822 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009823 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309824 "%s: Not scanning on device_mode = %s (%d)",
9825 __func__, hdd_device_modetoString(pAdapter->device_mode),
9826 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009827 return -EOPNOTSUPP;
9828 }
9829
9830 if (TRUE == pScanInfo->mScanPending)
9831 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05309832 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
9833 {
9834 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
9835 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009836 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07009837 }
9838
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309839 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -07009840 //Channel and action frame is pending
9841 //Otherwise Cancel Remain On Channel and allow Scan
9842 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009843 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -07009844 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05309845 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009846 return -EBUSY;
9847 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009848#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07009849 /* if tdls disagree scan right now, return immediately.
9850 tdls will schedule the scan when scan is allowed. (return SUCCESS)
9851 or will reject the scan if any TDLS is in progress. (return -EBUSY)
9852 */
9853 status = wlan_hdd_tdls_scan_callback (pAdapter,
9854 wiphy,
9855#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
9856 dev,
Gopichand Nakkalac3c42b92013-03-20 19:42:34 -07009857#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07009858 request);
9859 if(status <= 0)
9860 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309861 if(!status)
9862 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
9863 "scan rejected %d", __func__, status);
9864 else
9865 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
9866 __func__, status);
9867
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07009868 return status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009869 }
9870#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07009871
Jeff Johnson295189b2012-06-20 16:38:30 -07009872 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
9873 {
9874 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -08009875 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009876 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309877 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009878 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
9879 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309880 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009881 "%s: MAX TM Level Scan not allowed", __func__);
9882 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309883 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07009884 }
9885 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
9886
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009887 /* Check if scan is allowed at this point of time.
9888 */
Ganesh Kondabattiniaeb7b772014-08-11 20:00:36 +05309889 if (hdd_isConnectionInProgress(pHddCtx, VOS_FALSE))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009890 {
9891 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
9892 return -EBUSY;
9893 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309894
Jeff Johnson295189b2012-06-20 16:38:30 -07009895 vos_mem_zero( &scanRequest, sizeof(scanRequest));
9896
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309897 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
9898 (int)request->n_ssids);
9899
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +05309900
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309901 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
9902 * Becasue of this, driver is assuming that this is not wildcard scan and so
9903 * is not aging out the scan results.
9904 */
9905 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07009906 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309907 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009908 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309909
9910 if ((request->ssids) && (0 < request->n_ssids))
9911 {
9912 tCsrSSIDInfo *SsidInfo;
9913 int j;
9914 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
9915 /* Allocate num_ssid tCsrSSIDInfo structure */
9916 SsidInfo = scanRequest.SSIDs.SSIDList =
9917 ( tCsrSSIDInfo *)vos_mem_malloc(
9918 request->n_ssids*sizeof(tCsrSSIDInfo));
9919
9920 if(NULL == scanRequest.SSIDs.SSIDList)
9921 {
9922 hddLog(VOS_TRACE_LEVEL_ERROR,
9923 "%s: memory alloc failed SSIDInfo buffer", __func__);
9924 return -ENOMEM;
9925 }
9926
9927 /* copy all the ssid's and their length */
9928 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
9929 {
9930 /* get the ssid length */
9931 SsidInfo->SSID.length = request->ssids[j].ssid_len;
9932 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
9933 SsidInfo->SSID.length);
9934 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
9935 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
9936 j, SsidInfo->SSID.ssId);
9937 }
9938 /* set the scan type to active */
9939 scanRequest.scanType = eSIR_ACTIVE_SCAN;
9940 }
9941 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07009942 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +05309943 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9944 TRACE_CODE_HDD_CFG80211_SCAN,
9945 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07009946 /* set the scan type to active */
9947 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07009948 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309949 else
9950 {
9951 /*Set the scan type to default type, in this case it is ACTIVE*/
9952 scanRequest.scanType = pScanInfo->scan_mode;
9953 }
9954 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
9955 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07009956
9957 /* set BSSType to default type */
9958 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
9959
9960 /*TODO: scan the requested channels only*/
9961
9962 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309963 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -07009964 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309965 hddLog(VOS_TRACE_LEVEL_WARN,
9966 "No of Scan Channels exceeded limit: %d", request->n_channels);
9967 request->n_channels = MAX_CHANNEL;
9968 }
9969
9970 hddLog(VOS_TRACE_LEVEL_INFO,
9971 "No of Scan Channels: %d", request->n_channels);
9972
9973
9974 if( request->n_channels )
9975 {
9976 char chList [(request->n_channels*5)+1];
9977 int len;
9978 channelList = vos_mem_malloc( request->n_channels );
9979 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +05309980 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309981 hddLog(VOS_TRACE_LEVEL_ERROR,
9982 "%s: memory alloc failed channelList", __func__);
9983 status = -ENOMEM;
9984 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +05309985 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309986
9987 for( i = 0, len = 0; i < request->n_channels ; i++ )
9988 {
9989 channelList[i] = request->channels[i]->hw_value;
9990 len += snprintf(chList+len, 5, "%d ", channelList[i]);
9991 }
9992
Nirav Shah20ac06f2013-12-12 18:14:06 +05309993 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309994 "Channel-List: %s ", chList);
9995 }
c_hpothu53512302014-04-15 18:49:53 +05309996
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309997 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
9998 scanRequest.ChannelInfo.ChannelList = channelList;
9999
10000 /* set requestType to full scan */
10001 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
10002
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010003 /* if there is back to back scan happening in driver with in
10004 * nDeferScanTimeInterval interval driver should defer new scan request
10005 * and should provide last cached scan results instead of new channel list.
10006 * This rule is not applicable if scan is p2p scan.
10007 * This condition will work only in case when last request no of channels
10008 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053010009 * This should be done only in connected state
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010010 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010011
Agarwal Ashish57e84372014-12-05 18:26:53 +053010012 if ((VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
10013 {
10014 if ( pScanInfo->last_scan_timestamp !=0 &&
10015 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
10016 {
10017 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
10018 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
10019 vos_mem_compare(pScanInfo->last_scan_channelList,
10020 channelList, pScanInfo->last_scan_numChannels))
10021 {
10022 hddLog(VOS_TRACE_LEVEL_WARN,
10023 " New and old station scan time differ is less then %u",
10024 pHddCtx->cfg_ini->nDeferScanTimeInterval);
10025
10026 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010027 pAdapter);
10028
Agarwal Ashish57e84372014-12-05 18:26:53 +053010029 hddLog(VOS_TRACE_LEVEL_WARN,
10030 "Return old cached scan as all channels"
10031 "and no of channles are same");
10032 if (0 > ret)
10033 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010034
Agarwal Ashish57e84372014-12-05 18:26:53 +053010035 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
10036 return eHAL_STATUS_SUCCESS ;
10037 }
10038 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010039 }
10040
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010041 /* Flush the scan results(only p2p beacons) for STA scan and P2P
10042 * search (Flush on both full scan and social scan but not on single
10043 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
10044 */
10045
10046 /* Supplicant does single channel scan after 8-way handshake
10047 * and in that case driver shoudnt flush scan results. If
10048 * driver flushes the scan results here and unfortunately if
10049 * the AP doesnt respond to our probe req then association
10050 * fails which is not desired
10051 */
10052
10053 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
10054 {
10055 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
10056 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
10057 pAdapter->sessionId );
10058 }
10059
10060 if( request->ie_len )
10061 {
10062 /* save this for future association (join requires this) */
10063 /*TODO: Array needs to be converted to dynamic allocation,
10064 * as multiple ie.s can be sent in cfg80211_scan_request structure
10065 * CR 597966
10066 */
10067 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
10068 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
10069 pScanInfo->scanAddIE.length = request->ie_len;
10070
10071 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
10072 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10073 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070010074 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010075 if ( request->ie_len <= SIR_MAC_MAX_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070010076 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010077 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
10078 memcpy( pwextBuf->roamProfile.addIEScan,
10079 request->ie, request->ie_len);
10080 }
10081 else
10082 {
10083 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
10084 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070010085 }
10086
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010087 }
10088 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
10089 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
10090
10091 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
10092 request->ie_len);
10093 if (pP2pIe != NULL)
10094 {
10095#ifdef WLAN_FEATURE_P2P_DEBUG
10096 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
10097 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
10098 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053010099 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010100 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
10101 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
10102 "Go nego completed to Connection is started");
10103 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
10104 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053010105 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010106 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
10107 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070010108 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010109 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
10110 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
10111 "Disconnected state to Connection is started");
10112 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
10113 "for 4way Handshake");
10114 }
10115#endif
10116
10117 /* no_cck will be set during p2p find to disable 11b rates */
10118 if(TRUE == request->no_cck)
10119 {
10120 hddLog(VOS_TRACE_LEVEL_INFO,
10121 "%s: This is a P2P Search", __func__);
10122 scanRequest.p2pSearch = 1;
10123
10124 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053010125 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010126 /* set requestType to P2P Discovery */
10127 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
10128 }
10129
10130 /*
10131 Skip Dfs Channel in case of P2P Search
10132 if it is set in ini file
10133 */
10134 if(cfg_param->skipDfsChnlInP2pSearch)
10135 {
10136 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053010137 }
10138 else
10139 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010140 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053010141 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010142
Agarwal Ashish4f616132013-12-30 23:32:50 +053010143 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010144 }
10145 }
10146
10147 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
10148
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010149 /* acquire the wakelock to avoid the apps suspend during the scan. To
10150 * address the following issues.
10151 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
10152 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
10153 * for long time, this result in apps running at full power for long time.
10154 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
10155 * be stuck in full power because of resume BMPS
10156 */
10157 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -070010158
Nirav Shah20ac06f2013-12-12 18:14:06 +053010159 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
10160 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010161 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
10162 scanRequest.requestType, scanRequest.scanType,
10163 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053010164 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
10165
Siddharth Bhal76972212014-10-15 16:22:51 +053010166 if (pHddCtx->spoofMacAddr.isEnabled)
10167 {
10168 hddLog(VOS_TRACE_LEVEL_INFO,
10169 "%s: MAC Spoofing enabled for current scan", __func__);
10170 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
10171 * to fill TxBds for probe request during current scan
10172 */
10173 WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
10174 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
10175 }
10176
Jeff Johnsone7245742012-09-05 17:12:55 -070010177 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070010178 pAdapter->sessionId, &scanRequest, &scanId,
10179 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070010180
Jeff Johnson295189b2012-06-20 16:38:30 -070010181 if (eHAL_STATUS_SUCCESS != status)
10182 {
10183 hddLog(VOS_TRACE_LEVEL_ERROR,
10184 "%s: sme_ScanRequest returned error %d", __func__, status);
10185 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070010186 if(eHAL_STATUS_RESOURCES == status)
10187 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010188 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
10189 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070010190 status = -EBUSY;
10191 } else {
10192 status = -EIO;
10193 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010194 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -070010195 goto free_mem;
10196 }
10197
10198 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010199 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010200 pAdapter->request = request;
10201 pScanInfo->scanId = scanId;
10202
10203 complete(&pScanInfo->scan_req_completion_event);
10204
10205free_mem:
10206 if( scanRequest.SSIDs.SSIDList )
10207 {
10208 vos_mem_free(scanRequest.SSIDs.SSIDList);
10209 }
10210
10211 if( channelList )
10212 vos_mem_free( channelList );
10213
10214 EXIT();
10215
10216 return status;
10217}
10218
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010219int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
10220#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10221 struct net_device *dev,
10222#endif
10223 struct cfg80211_scan_request *request)
10224{
10225 int ret;
10226
10227 vos_ssr_protect(__func__);
10228 ret = __wlan_hdd_cfg80211_scan(wiphy,
10229#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10230 dev,
10231#endif
10232 request);
10233 vos_ssr_unprotect(__func__);
10234
10235 return ret;
10236}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010237
10238void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
10239{
10240 v_U8_t iniDot11Mode =
10241 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
10242 eHddDot11Mode hddDot11Mode = iniDot11Mode;
10243
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053010244 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
10245 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010246 switch ( iniDot11Mode )
10247 {
10248 case eHDD_DOT11_MODE_AUTO:
10249 case eHDD_DOT11_MODE_11ac:
10250 case eHDD_DOT11_MODE_11ac_ONLY:
10251#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053010252 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
10253 sme_IsFeatureSupportedByFW(DOT11AC) )
10254 hddDot11Mode = eHDD_DOT11_MODE_11ac;
10255 else
10256 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010257#else
10258 hddDot11Mode = eHDD_DOT11_MODE_11n;
10259#endif
10260 break;
10261 case eHDD_DOT11_MODE_11n:
10262 case eHDD_DOT11_MODE_11n_ONLY:
10263 hddDot11Mode = eHDD_DOT11_MODE_11n;
10264 break;
10265 default:
10266 hddDot11Mode = iniDot11Mode;
10267 break;
10268 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053010269#ifdef WLAN_FEATURE_AP_HT40_24G
10270 if (operationChannel > SIR_11B_CHANNEL_END)
10271#endif
10272 {
10273 /* This call decides required channel bonding mode */
10274 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010275 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
10276 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053010277 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010278}
10279
Jeff Johnson295189b2012-06-20 16:38:30 -070010280/*
10281 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010282 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070010283 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010284int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -070010285 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070010286{
10287 int status = 0;
10288 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080010289 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010290 v_U32_t roamId;
10291 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070010292 eCsrAuthType RSNAuthType;
10293
10294 ENTER();
10295
10296 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080010297 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10298
10299 status = wlan_hdd_validate_context(pHddCtx);
10300 if (status)
10301 {
10302 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10303 "%s: HDD context is not valid!", __func__);
10304 return status;
10305 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010306
Jeff Johnson295189b2012-06-20 16:38:30 -070010307 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
10308 {
10309 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
10310 return -EINVAL;
10311 }
10312
10313 pRoamProfile = &pWextState->roamProfile;
10314
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010315 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070010316 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010317 hdd_station_ctx_t *pHddStaCtx;
10318 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010319
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010320 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070010321 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
10322 {
10323 /*QoS not enabled in cfg file*/
10324 pRoamProfile->uapsd_mask = 0;
10325 }
10326 else
10327 {
10328 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010329 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070010330 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
10331 }
10332
10333 pRoamProfile->SSIDs.numOfSSIDs = 1;
10334 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
10335 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010336 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070010337 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
10338 ssid, ssid_len);
10339
10340 if (bssid)
10341 {
10342 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
10343 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
10344 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010345 /* Save BSSID in seperate variable as well, as RoamProfile
10346 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070010347 case of join failure we should send valid BSSID to supplicant
10348 */
10349 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
10350 WNI_CFG_BSSID_LEN);
10351 }
Dhanashri Atre51981c62013-06-13 11:47:57 -070010352 else
10353 {
10354 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
10355 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010356
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053010357 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
10358 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070010359 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
10360 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010361 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010362 /*set gen ie*/
10363 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
10364 /*set auth*/
10365 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
10366 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010367#ifdef FEATURE_WLAN_WAPI
10368 if (pAdapter->wapi_info.nWapiMode)
10369 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010370 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010371 switch (pAdapter->wapi_info.wapiAuthMode)
10372 {
10373 case WAPI_AUTH_MODE_PSK:
10374 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010375 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070010376 pAdapter->wapi_info.wapiAuthMode);
10377 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
10378 break;
10379 }
10380 case WAPI_AUTH_MODE_CERT:
10381 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010382 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070010383 pAdapter->wapi_info.wapiAuthMode);
10384 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
10385 break;
10386 }
10387 } // End of switch
10388 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
10389 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
10390 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010391 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010392 pRoamProfile->AuthType.numEntries = 1;
10393 pRoamProfile->EncryptionType.numEntries = 1;
10394 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
10395 pRoamProfile->mcEncryptionType.numEntries = 1;
10396 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
10397 }
10398 }
10399#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010400#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053010401 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010402 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
10403 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
10404 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053010405 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
10406 sizeof (tSirGtkOffloadParams));
10407 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010408 }
10409#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010410 pRoamProfile->csrPersona = pAdapter->device_mode;
10411
Jeff Johnson32d95a32012-09-10 13:15:23 -070010412 if( operatingChannel )
10413 {
10414 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
10415 pRoamProfile->ChannelInfo.numOfChannels = 1;
10416 }
Chet Lanctot186b5732013-03-18 10:26:30 -070010417 else
10418 {
10419 pRoamProfile->ChannelInfo.ChannelList = NULL;
10420 pRoamProfile->ChannelInfo.numOfChannels = 0;
10421 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010422 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
10423 {
10424 hdd_select_cbmode(pAdapter,operatingChannel);
10425 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053010426
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080010427 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
10428 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010429 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080010430 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080010431 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
10432 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053010433 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
10434 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053010435 {
10436 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10437 "%s: Set HDD connState to eConnectionState_Connecting",
10438 __func__);
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080010439 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
10440 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053010441 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010442 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070010443 pAdapter->sessionId, pRoamProfile, &roamId);
10444
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053010445 if ((eHAL_STATUS_SUCCESS != status) &&
10446 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
10447 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053010448
10449 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080010450 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
10451 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
10452 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053010453 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080010454 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053010455 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080010456
10457 pRoamProfile->ChannelInfo.ChannelList = NULL;
10458 pRoamProfile->ChannelInfo.numOfChannels = 0;
10459
Jeff Johnson295189b2012-06-20 16:38:30 -070010460 }
10461 else
10462 {
10463 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
10464 return -EINVAL;
10465 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080010466 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010467 return status;
10468}
10469
10470/*
10471 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
10472 * This function is used to set the authentication type (OPEN/SHARED).
10473 *
10474 */
10475static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
10476 enum nl80211_auth_type auth_type)
10477{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010478 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010479 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10480
10481 ENTER();
10482
10483 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010484 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070010485 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010486 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053010487 hddLog(VOS_TRACE_LEVEL_INFO,
10488 "%s: set authentication type to AUTOSWITCH", __func__);
10489 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
10490 break;
10491
10492 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070010493#ifdef WLAN_FEATURE_VOWIFI_11R
10494 case NL80211_AUTHTYPE_FT:
10495#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010496 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070010497 "%s: set authentication type to OPEN", __func__);
10498 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
10499 break;
10500
10501 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010502 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070010503 "%s: set authentication type to SHARED", __func__);
10504 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
10505 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010506#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010507 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010508 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070010509 "%s: set authentication type to CCKM WPA", __func__);
10510 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
10511 break;
10512#endif
10513
10514
10515 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010516 hddLog(VOS_TRACE_LEVEL_ERROR,
10517 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070010518 auth_type);
10519 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
10520 return -EINVAL;
10521 }
10522
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010523 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070010524 pHddStaCtx->conn_info.authType;
10525 return 0;
10526}
10527
10528/*
10529 * FUNCTION: wlan_hdd_set_akm_suite
10530 * This function is used to set the key mgmt type(PSK/8021x).
10531 *
10532 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010533static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070010534 u32 key_mgmt
10535 )
10536{
10537 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10538 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053010539 /* Should be in ieee802_11_defs.h */
10540#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
10541#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070010542 /*set key mgmt type*/
10543 switch(key_mgmt)
10544 {
10545 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053010546 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053010547#ifdef WLAN_FEATURE_VOWIFI_11R
10548 case WLAN_AKM_SUITE_FT_PSK:
10549#endif
10550 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070010551 __func__);
10552 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
10553 break;
10554
10555 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053010556 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053010557#ifdef WLAN_FEATURE_VOWIFI_11R
10558 case WLAN_AKM_SUITE_FT_8021X:
10559#endif
10560 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070010561 __func__);
10562 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
10563 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010564#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010565#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
10566#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
10567 case WLAN_AKM_SUITE_CCKM:
10568 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
10569 __func__);
10570 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
10571 break;
10572#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070010573#ifndef WLAN_AKM_SUITE_OSEN
10574#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
10575 case WLAN_AKM_SUITE_OSEN:
10576 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
10577 __func__);
10578 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
10579 break;
10580#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010581
10582 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010583 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010584 __func__, key_mgmt);
10585 return -EINVAL;
10586
10587 }
10588 return 0;
10589}
10590
10591/*
10592 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010593 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070010594 * (NONE/WEP40/WEP104/TKIP/CCMP).
10595 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010596static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
10597 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070010598 bool ucast
10599 )
10600{
10601 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010602 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010603 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10604
10605 ENTER();
10606
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010607 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070010608 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010609 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070010610 __func__, cipher);
10611 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
10612 }
10613 else
10614 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010615
Jeff Johnson295189b2012-06-20 16:38:30 -070010616 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010617 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070010618 {
10619 case IW_AUTH_CIPHER_NONE:
10620 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
10621 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010622
Jeff Johnson295189b2012-06-20 16:38:30 -070010623 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053010624 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070010625 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010626
Jeff Johnson295189b2012-06-20 16:38:30 -070010627 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053010628 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070010629 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010630
Jeff Johnson295189b2012-06-20 16:38:30 -070010631 case WLAN_CIPHER_SUITE_TKIP:
10632 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
10633 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010634
Jeff Johnson295189b2012-06-20 16:38:30 -070010635 case WLAN_CIPHER_SUITE_CCMP:
10636 encryptionType = eCSR_ENCRYPT_TYPE_AES;
10637 break;
10638#ifdef FEATURE_WLAN_WAPI
10639 case WLAN_CIPHER_SUITE_SMS4:
10640 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
10641 break;
10642#endif
10643
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010644#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010645 case WLAN_CIPHER_SUITE_KRK:
10646 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
10647 break;
10648#endif
10649 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010650 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010651 __func__, cipher);
10652 return -EOPNOTSUPP;
10653 }
10654 }
10655
10656 if (ucast)
10657 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010658 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010659 __func__, encryptionType);
10660 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
10661 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010662 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070010663 encryptionType;
10664 }
10665 else
10666 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010667 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010668 __func__, encryptionType);
10669 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
10670 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
10671 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
10672 }
10673
10674 return 0;
10675}
10676
10677
10678/*
10679 * FUNCTION: wlan_hdd_cfg80211_set_ie
10680 * This function is used to parse WPA/RSN IE's.
10681 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010682int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
10683 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -070010684 size_t ie_len
10685 )
10686{
10687 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10688 u8 *genie = ie;
10689 v_U16_t remLen = ie_len;
10690#ifdef FEATURE_WLAN_WAPI
10691 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
10692 u16 *tmp;
10693 v_U16_t akmsuiteCount;
10694 int *akmlist;
10695#endif
10696 ENTER();
10697
10698 /* clear previous assocAddIE */
10699 pWextState->assocAddIE.length = 0;
10700 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070010701 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010702
10703 while (remLen >= 2)
10704 {
10705 v_U16_t eLen = 0;
10706 v_U8_t elementId;
10707 elementId = *genie++;
10708 eLen = *genie++;
10709 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010710
Arif Hussain6d2a3322013-11-17 19:50:10 -080010711 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070010712 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010713
10714 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070010715 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010716 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010717 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 -070010718 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010719 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010720 "%s: Invalid WPA IE", __func__);
10721 return -EINVAL;
10722 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010723 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070010724 {
10725 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010726 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070010727 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010728
Jeff Johnson295189b2012-06-20 16:38:30 -070010729 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
10730 {
Jeff Johnson902c9832012-12-10 14:28:09 -080010731 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
10732 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070010733 VOS_ASSERT(0);
10734 return -ENOMEM;
10735 }
10736 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
10737 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
10738 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010739
Jeff Johnson295189b2012-06-20 16:38:30 -070010740 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
10741 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
10742 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
10743 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010744 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
10745 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010746 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
10747 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
10748 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
10749 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
10750 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
10751 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010752 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053010753 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070010754 {
10755 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010756 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070010757 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010758
Jeff Johnson295189b2012-06-20 16:38:30 -070010759 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
10760 {
Jeff Johnson902c9832012-12-10 14:28:09 -080010761 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
10762 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070010763 VOS_ASSERT(0);
10764 return -ENOMEM;
10765 }
10766 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
10767 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
10768 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010769
Jeff Johnson295189b2012-06-20 16:38:30 -070010770 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
10771 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
10772 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010773#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010774 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
10775 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070010776 /*Consider WFD IE, only for P2P Client */
10777 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
10778 {
10779 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010780 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070010781 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010782
Jeff Johnson295189b2012-06-20 16:38:30 -070010783 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
10784 {
Jeff Johnson902c9832012-12-10 14:28:09 -080010785 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
10786 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070010787 VOS_ASSERT(0);
10788 return -ENOMEM;
10789 }
10790 // WFD IE is saved to Additional IE ; it should be accumulated to handle
10791 // WPS IE + P2P IE + WFD IE
10792 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
10793 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010794
Jeff Johnson295189b2012-06-20 16:38:30 -070010795 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
10796 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
10797 }
10798#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010799 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010800 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070010801 HS20_OUI_TYPE_SIZE)) )
10802 {
10803 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010804 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070010805 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010806
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070010807 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
10808 {
Jeff Johnson902c9832012-12-10 14:28:09 -080010809 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
10810 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070010811 VOS_ASSERT(0);
10812 return -ENOMEM;
10813 }
10814 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
10815 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010816
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070010817 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
10818 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
10819 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070010820 /* Appending OSEN Information Element in Assiciation Request */
10821 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
10822 OSEN_OUI_TYPE_SIZE)) )
10823 {
10824 v_U16_t curAddIELen = pWextState->assocAddIE.length;
10825 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
10826 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010827
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070010828 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
10829 {
10830 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
10831 "Need bigger buffer space");
10832 VOS_ASSERT(0);
10833 return -ENOMEM;
10834 }
10835 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
10836 pWextState->assocAddIE.length += eLen + 2;
10837
10838 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
10839 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
10840 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
10841 }
10842
10843 break;
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070010844 if (WLAN_HDD_IBSS == pAdapter->device_mode) {
10845
10846 /* populating as ADDIE in beacon frames */
10847 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
10848 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
10849 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
10850 {
10851 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
10852 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
10853 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
10854 {
10855 hddLog(LOGE,
10856 "Coldn't pass "
10857 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
10858 }
10859 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
10860 else
10861 hddLog(LOGE,
10862 "Could not pass on "
10863 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
10864
10865 /* IBSS mode doesn't contain params->proberesp_ies still
10866 beaconIE's need to be populated in probe response frames */
10867 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
10868 {
10869 u16 rem_probe_resp_ie_len = eLen + 2;
10870 u8 probe_rsp_ie_len[3] = {0};
10871 u8 counter = 0;
10872
10873 /* Check Probe Resp Length if it is greater then 255 then
10874 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
10875 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
10876 not able Store More then 255 bytes into One Variable */
10877
10878 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
10879 {
10880 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
10881 {
10882 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
10883 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
10884 }
10885 else
10886 {
10887 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
10888 rem_probe_resp_ie_len = 0;
10889 }
10890 }
10891
10892 rem_probe_resp_ie_len = 0;
10893
10894 if (probe_rsp_ie_len[0] > 0)
10895 {
10896 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
10897 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
10898 (tANI_U8*)(genie - 2),
10899 probe_rsp_ie_len[0], NULL,
10900 eANI_BOOLEAN_FALSE)
10901 == eHAL_STATUS_FAILURE)
10902 {
10903 hddLog(LOGE,
10904 "Could not pass"
10905 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
10906 }
10907 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
10908 }
10909
10910 if (probe_rsp_ie_len[1] > 0)
10911 {
10912 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
10913 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
10914 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
10915 probe_rsp_ie_len[1], NULL,
10916 eANI_BOOLEAN_FALSE)
10917 == eHAL_STATUS_FAILURE)
10918 {
10919 hddLog(LOGE,
10920 "Could not pass"
10921 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
10922 }
10923 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
10924 }
10925
10926 if (probe_rsp_ie_len[2] > 0)
10927 {
10928 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
10929 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
10930 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
10931 probe_rsp_ie_len[2], NULL,
10932 eANI_BOOLEAN_FALSE)
10933 == eHAL_STATUS_FAILURE)
10934 {
10935 hddLog(LOGE,
10936 "Could not pass"
10937 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
10938 }
10939 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
10940 }
10941
10942 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
10943 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
10944 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
10945 {
10946 hddLog(LOGE,
10947 "Could not pass"
10948 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
10949 }
10950 }
10951 else
10952 {
10953 // Reset WNI_CFG_PROBE_RSP Flags
10954 wlan_hdd_reset_prob_rspies(pAdapter);
10955
10956 hddLog(VOS_TRACE_LEVEL_INFO,
10957 "%s: No Probe Response IE received in set beacon",
10958 __func__);
10959 }
10960 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070010961 break;
10962 case DOT11F_EID_RSN:
10963 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
10964 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
10965 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
10966 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
10967 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
10968 break;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010969 /* Appending Extended Capabilities with Interworking bit set in Assoc Req */
10970 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010971 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010972 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010973 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010974 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010975
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010976 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
10977 {
Jeff Johnson902c9832012-12-10 14:28:09 -080010978 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
10979 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010980 VOS_ASSERT(0);
10981 return -ENOMEM;
10982 }
10983 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
10984 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010985
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010986 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
10987 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
10988 break;
10989 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010990#ifdef FEATURE_WLAN_WAPI
10991 case WLAN_EID_WAPI:
10992 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070010993 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070010994 pAdapter->wapi_info.nWapiMode);
10995 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010996 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070010997 akmsuiteCount = WPA_GET_LE16(tmp);
10998 tmp = tmp + 1;
10999 akmlist = (int *)(tmp);
11000 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
11001 {
11002 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
11003 }
11004 else
11005 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011006 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070011007 VOS_ASSERT(0);
11008 return -EINVAL;
11009 }
11010
11011 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
11012 {
11013 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011014 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011015 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011016 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011017 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011018 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011019 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011020 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011021 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
11022 }
11023 break;
11024#endif
11025 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011026 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011027 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011028 /* when Unknown IE is received we should break and continue
11029 * to the next IE in the buffer instead we were returning
11030 * so changing this to break */
11031 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011032 }
11033 genie += eLen;
11034 remLen -= eLen;
11035 }
11036 EXIT();
11037 return 0;
11038}
11039
11040/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053011041 * FUNCTION: hdd_isWPAIEPresent
11042 * Parse the received IE to find the WPA IE
11043 *
11044 */
11045static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
11046{
11047 v_U8_t eLen = 0;
11048 v_U16_t remLen = ie_len;
11049 v_U8_t elementId = 0;
11050
11051 while (remLen >= 2)
11052 {
11053 elementId = *ie++;
11054 eLen = *ie++;
11055 remLen -= 2;
11056 if (eLen > remLen)
11057 {
11058 hddLog(VOS_TRACE_LEVEL_ERROR,
11059 "%s: IE length is wrong %d", __func__, eLen);
11060 return FALSE;
11061 }
11062 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
11063 {
11064 /* OUI - 0x00 0X50 0XF2
11065 WPA Information Element - 0x01
11066 WPA version - 0x01*/
11067 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
11068 return TRUE;
11069 }
11070 ie += eLen;
11071 remLen -= eLen;
11072 }
11073 return FALSE;
11074}
11075
11076/*
Jeff Johnson295189b2012-06-20 16:38:30 -070011077 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011078 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070011079 * parameters during connect operation.
11080 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011081int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011082 struct cfg80211_connect_params *req
11083 )
11084{
11085 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011086 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011087 ENTER();
11088
11089 /*set wpa version*/
11090 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11091
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011092 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070011093 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053011094 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070011095 {
11096 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
11097 }
11098 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
11099 {
11100 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
11101 }
11102 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011103
11104 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011105 pWextState->wpaVersion);
11106
11107 /*set authentication type*/
11108 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
11109
11110 if (0 > status)
11111 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011112 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011113 "%s: failed to set authentication type ", __func__);
11114 return status;
11115 }
11116
11117 /*set key mgmt type*/
11118 if (req->crypto.n_akm_suites)
11119 {
11120 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
11121 if (0 > status)
11122 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011123 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070011124 __func__);
11125 return status;
11126 }
11127 }
11128
11129 /*set pairwise cipher type*/
11130 if (req->crypto.n_ciphers_pairwise)
11131 {
11132 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
11133 req->crypto.ciphers_pairwise[0], true);
11134 if (0 > status)
11135 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011136 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011137 "%s: failed to set unicast cipher type", __func__);
11138 return status;
11139 }
11140 }
11141 else
11142 {
11143 /*Reset previous cipher suite to none*/
11144 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
11145 if (0 > status)
11146 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011147 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011148 "%s: failed to set unicast cipher type", __func__);
11149 return status;
11150 }
11151 }
11152
11153 /*set group cipher type*/
11154 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
11155 false);
11156
11157 if (0 > status)
11158 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011159 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070011160 __func__);
11161 return status;
11162 }
11163
Chet Lanctot186b5732013-03-18 10:26:30 -070011164#ifdef WLAN_FEATURE_11W
11165 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
11166#endif
11167
Jeff Johnson295189b2012-06-20 16:38:30 -070011168 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
11169 if (req->ie_len)
11170 {
11171 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
11172 if ( 0 > status)
11173 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011174 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070011175 __func__);
11176 return status;
11177 }
11178 }
11179
11180 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011181 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070011182 {
11183 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
11184 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
11185 )
11186 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011187 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070011188 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
11189 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011190 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070011191 __func__);
11192 return -EOPNOTSUPP;
11193 }
11194 else
11195 {
11196 u8 key_len = req->key_len;
11197 u8 key_idx = req->key_idx;
11198
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011199 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070011200 && (CSR_MAX_NUM_KEY > key_idx)
11201 )
11202 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011203 hddLog(VOS_TRACE_LEVEL_INFO,
11204 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011205 __func__, key_idx, key_len);
11206 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011207 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070011208 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011209 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011210 (u8)key_len;
11211 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
11212 }
11213 }
11214 }
11215 }
11216
11217 return status;
11218}
11219
11220/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053011221 * FUNCTION: wlan_hdd_try_disconnect
11222 * This function is used to disconnect from previous
11223 * connection
11224 */
11225static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
11226{
11227 long ret = 0;
11228 hdd_station_ctx_t *pHddStaCtx;
11229 eMib_dot11DesiredBssType connectedBssType;
11230
11231 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11232
11233 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
11234
11235 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
11236 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
11237 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
11238 {
11239 /* Issue disconnect to CSR */
11240 INIT_COMPLETION(pAdapter->disconnect_comp_var);
11241 if( eHAL_STATUS_SUCCESS ==
11242 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
11243 pAdapter->sessionId,
11244 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
11245 {
11246 ret = wait_for_completion_interruptible_timeout(
11247 &pAdapter->disconnect_comp_var,
11248 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
11249 if (0 >= ret)
11250 {
11251 hddLog(LOGE, FL("Failed to receive disconnect event"));
11252 return -EALREADY;
11253 }
11254 }
11255 }
11256 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
11257 {
11258 ret = wait_for_completion_interruptible_timeout(
11259 &pAdapter->disconnect_comp_var,
11260 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
11261 if (0 >= ret)
11262 {
11263 hddLog(LOGE, FL("Failed to receive disconnect event"));
11264 return -EALREADY;
11265 }
11266 }
11267
11268 return 0;
11269}
11270
11271/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053011272 * FUNCTION: __wlan_hdd_cfg80211_connect
11273 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070011274 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011275static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011276 struct net_device *ndev,
11277 struct cfg80211_connect_params *req
11278 )
11279{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011280 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011281 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070011282 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053011283 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011284
11285 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011286
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011287 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11288 TRACE_CODE_HDD_CFG80211_CONNECT,
11289 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011290 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011291 "%s: device_mode = %s (%d)", __func__,
11292 hdd_device_modetoString(pAdapter->device_mode),
11293 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011294
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011295 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080011296 if (!pHddCtx)
11297 {
11298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11299 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053011300 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080011301 }
11302
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011303 status = wlan_hdd_validate_context(pHddCtx);
11304
11305 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070011306 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011307 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11308 "%s: HDD context is not valid", __func__);
11309 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011310 }
11311
Agarwal Ashish51325b52014-06-16 16:50:49 +053011312 if (vos_max_concurrent_connections_reached()) {
11313 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
11314 return -ECONNREFUSED;
11315 }
11316
Jeff Johnson295189b2012-06-20 16:38:30 -070011317#ifdef WLAN_BTAMP_FEATURE
11318 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011319 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070011320 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011321 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011322 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080011323 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011324 }
11325#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053011326
11327 //If Device Mode is Station Concurrent Sessions Exit BMps
11328 //P2P Mode will be taken care in Open/close adapter
11329 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053011330 (vos_concurrent_open_sessions_running())) {
11331 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
11332 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053011333 }
11334
11335 /*Try disconnecting if already in connected state*/
11336 status = wlan_hdd_try_disconnect(pAdapter);
11337 if ( 0 > status)
11338 {
11339 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
11340 " connection"));
11341 return -EALREADY;
11342 }
11343
Jeff Johnson295189b2012-06-20 16:38:30 -070011344 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011345 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070011346
11347 if ( 0 > status)
11348 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011349 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070011350 __func__);
11351 return status;
11352 }
Mohit Khanna765234a2012-09-11 15:08:35 -070011353 if ( req->channel )
11354 {
11355 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
11356 req->ssid_len, req->bssid,
11357 req->channel->hw_value);
11358 }
11359 else
11360 {
11361 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011362 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -070011363 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011364
11365 if (0 > status)
11366 {
11367 //ReEnable BMPS if disabled
11368 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
11369 (NULL != pHddCtx))
11370 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053011371 if (pHddCtx->hdd_wlan_suspended)
11372 {
11373 hdd_set_pwrparams(pHddCtx);
11374 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011375 //ReEnable Bmps and Imps back
11376 hdd_enable_bmps_imps(pHddCtx);
11377 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053011378 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011379 return status;
11380 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011381 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011382 EXIT();
11383 return status;
11384}
11385
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011386static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
11387 struct net_device *ndev,
11388 struct cfg80211_connect_params *req)
11389{
11390 int ret;
11391 vos_ssr_protect(__func__);
11392 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
11393 vos_ssr_unprotect(__func__);
11394
11395 return ret;
11396}
Jeff Johnson295189b2012-06-20 16:38:30 -070011397
11398/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011399 * FUNCTION: wlan_hdd_disconnect
11400 * This function is used to issue a disconnect request to SME
11401 */
11402int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
11403{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053011404 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011405 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011406 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011407 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011408
11409 status = wlan_hdd_validate_context(pHddCtx);
11410
11411 if (0 != status)
11412 {
11413 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11414 "%s: HDD context is not valid", __func__);
11415 return status;
11416 }
11417
11418 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053011419
Agarwal Ashish47d18112014-08-04 19:55:07 +053011420 /* Need to apply spin lock before decreasing active sessions
11421 * as there can be chance for double decrement if context switch
11422 * Calls hdd_DisConnectHandler.
11423 */
11424
11425 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053011426 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
11427 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053011428 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
11429 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053011430 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
11431 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053011432
Abhishek Singhf4669da2014-05-26 15:07:49 +053011433 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053011434 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
11435
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011436 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011437
Mihir Shete182a0b22014-08-18 16:08:48 +053011438 /*
11439 * stop tx queues before deleting STA/BSS context from the firmware.
11440 * tx has to be disabled because the firmware can get busy dropping
11441 * the tx frames after BSS/STA has been deleted and will not send
11442 * back a response resulting in WDI timeout
11443 */
11444 netif_tx_disable(pAdapter->dev);
11445 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011446
Mihir Shete182a0b22014-08-18 16:08:48 +053011447 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011448 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
11449 pAdapter->sessionId, reason);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011450 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
11451 {
11452 hddLog(VOS_TRACE_LEVEL_INFO,
11453 FL("status = %d, already disconnected"),
11454 (int)status );
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011455
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011456 }
11457 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011458 {
11459 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011460 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011461 __func__, (int)status );
Abhishek Singh6ab864d2014-11-27 12:10:10 +053011462 result = -EINVAL;
11463 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011464 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011465 ret = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011466 &pAdapter->disconnect_comp_var,
11467 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011468 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status ))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011469 {
11470 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053011471 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053011472 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053011473 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011474 else if (ret == -ERESTARTSYS)
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053011475 {
11476 hddLog(VOS_TRACE_LEVEL_ERROR,
11477 "%s: Failed to disconnect, wait interrupted", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053011478 result = -ERESTARTSYS;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011479 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053011480disconnected:
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011481 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11482 FL("Set HDD connState to eConnectionState_NotConnected"));
11483 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
11484
Abhishek Singh6ab864d2014-11-27 12:10:10 +053011485 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011486}
11487
11488
11489/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011490 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070011491 * This function is used to issue a disconnect request to SME
11492 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011493static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011494 struct net_device *dev,
11495 u16 reason
11496 )
11497{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011498 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011499 tCsrRoamProfile *pRoamProfile =
11500 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011501 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011502 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11503 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053011504#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080011505 tANI_U8 staIdx;
11506#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011507
Jeff Johnson295189b2012-06-20 16:38:30 -070011508 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011509
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011510 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11511 TRACE_CODE_HDD_CFG80211_DISCONNECT,
11512 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011513 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
11514 __func__, hdd_device_modetoString(pAdapter->device_mode),
11515 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011516
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011517 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
11518 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070011519
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011520 status = wlan_hdd_validate_context(pHddCtx);
11521
11522 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070011523 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011524 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11525 "%s: HDD context is not valid", __func__);
11526 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011527 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011528
Jeff Johnson295189b2012-06-20 16:38:30 -070011529 if (NULL != pRoamProfile)
11530 {
11531 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053011532 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
11533 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070011534 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011535 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070011536 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053011537 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070011538 switch(reason)
11539 {
11540 case WLAN_REASON_MIC_FAILURE:
11541 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
11542 break;
11543
11544 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
11545 case WLAN_REASON_DISASSOC_AP_BUSY:
11546 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
11547 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
11548 break;
11549
11550 case WLAN_REASON_PREV_AUTH_NOT_VALID:
11551 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053011552 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070011553 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
11554 break;
11555
Jeff Johnson295189b2012-06-20 16:38:30 -070011556 default:
11557 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
11558 break;
11559 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053011560 pScanInfo = &pHddCtx->scan_info;
11561 if (pScanInfo->mScanPending)
11562 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053011563 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053011564 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053011565 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053011566 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053011567 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011568
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080011569#ifdef FEATURE_WLAN_TDLS
11570 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080011571 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080011572 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080011573 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
11574 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080011575 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080011576 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080011577 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080011578 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011579 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080011580 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011581 MAC_ADDR_ARRAY(mac));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080011582 sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala4327a152013-03-04 23:22:42 -080011583 pAdapter->sessionId,
11584 mac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080011585 }
11586 }
11587#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011588 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011589 status = wlan_hdd_disconnect(pAdapter, reasonCode);
11590 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070011591 {
11592 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011593 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011594 __func__, (int)status );
11595 return -EINVAL;
11596 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011597 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053011598 else
11599 {
11600 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
11601 "called while in %d state", __func__,
11602 pHddStaCtx->conn_info.connState);
11603 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011604 }
11605 else
11606 {
11607 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
11608 }
11609
11610 return status;
11611}
11612
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011613static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
11614 struct net_device *dev,
11615 u16 reason
11616 )
11617{
11618 int ret;
11619 vos_ssr_protect(__func__);
11620 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
11621 vos_ssr_unprotect(__func__);
11622
11623 return ret;
11624}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011625
Jeff Johnson295189b2012-06-20 16:38:30 -070011626/*
11627 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011628 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070011629 * settings in IBSS mode.
11630 */
11631static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011632 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011633 struct cfg80211_ibss_params *params
11634 )
11635{
11636 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011637 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011638 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11639 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011640
Jeff Johnson295189b2012-06-20 16:38:30 -070011641 ENTER();
11642
11643 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070011644 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070011645
11646 if (params->ie_len && ( NULL != params->ie) )
11647 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070011648 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
11649 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070011650 {
11651 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
11652 encryptionType = eCSR_ENCRYPT_TYPE_AES;
11653 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070011654 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070011655 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011656 tDot11fIEWPA dot11WPAIE;
11657 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070011658 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011659
Wilson Yang00256342013-10-10 23:13:38 -070011660 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070011661 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
11662 params->ie_len, DOT11F_EID_WPA);
11663 if ( NULL != ie )
11664 {
11665 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
11666 // Unpack the WPA IE
11667 //Skip past the EID byte and length byte - and four byte WiFi OUI
11668 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
11669 &ie[2+4],
11670 ie[1] - 4,
11671 &dot11WPAIE);
11672 /*Extract the multicast cipher, the encType for unicast
11673 cipher for wpa-none is none*/
11674 encryptionType =
11675 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
11676 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011677 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070011678
Jeff Johnson295189b2012-06-20 16:38:30 -070011679 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
11680
11681 if (0 > status)
11682 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011683 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070011684 __func__);
11685 return status;
11686 }
11687 }
11688
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011689 pWextState->roamProfile.AuthType.authType[0] =
11690 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070011691 eCSR_AUTH_TYPE_OPEN_SYSTEM;
11692
11693 if (params->privacy)
11694 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011695 /* Security enabled IBSS, At this time there is no information available
11696 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070011697 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011698 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070011699 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011700 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070011701 *enable privacy bit in beacons */
11702
11703 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
11704 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011705 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
11706 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011707 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
11708 pWextState->roamProfile.EncryptionType.numEntries = 1;
11709 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070011710 return status;
11711}
11712
11713/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011714 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011715 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070011716 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011717static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011718 struct net_device *dev,
11719 struct cfg80211_ibss_params *params
11720 )
11721{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011722 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070011723 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11724 tCsrRoamProfile *pRoamProfile;
11725 int status;
krunal sonie9002db2013-11-25 14:24:17 -080011726 bool alloc_bssid = VOS_FALSE;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011727 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11728 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011729
11730 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011731
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011732 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11733 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
11734 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011735 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011736 "%s: device_mode = %s (%d)", __func__,
11737 hdd_device_modetoString(pAdapter->device_mode),
11738 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011739
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011740 status = wlan_hdd_validate_context(pHddCtx);
11741
11742 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070011743 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011744 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11745 "%s: HDD context is not valid", __func__);
11746 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011747 }
11748
11749 if (NULL == pWextState)
11750 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011751 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070011752 __func__);
11753 return -EIO;
11754 }
11755
Agarwal Ashish51325b52014-06-16 16:50:49 +053011756 if (vos_max_concurrent_connections_reached()) {
11757 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
11758 return -ECONNREFUSED;
11759 }
11760
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053011761 /*Try disconnecting if already in connected state*/
11762 status = wlan_hdd_try_disconnect(pAdapter);
11763 if ( 0 > status)
11764 {
11765 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
11766 " IBSS connection"));
11767 return -EALREADY;
11768 }
11769
Jeff Johnson295189b2012-06-20 16:38:30 -070011770 pRoamProfile = &pWextState->roamProfile;
11771
11772 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
11773 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011774 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011775 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011776 return -EINVAL;
11777 }
11778
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070011779 /* BSSID is provided by upper layers hence no need to AUTO generate */
11780 if (NULL != params->bssid) {
11781 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
11782 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
11783 hddLog (VOS_TRACE_LEVEL_ERROR,
11784 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
11785 return -EIO;
11786 }
11787 }
krunal sonie9002db2013-11-25 14:24:17 -080011788 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
11789 {
11790 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
11791 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
11792 {
11793 hddLog (VOS_TRACE_LEVEL_ERROR,
11794 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
11795 return -EIO;
11796 }
11797 params->bssid = vos_mem_malloc(sizeof(VOS_MAC_ADDR_SIZE));
11798 if (!params->bssid)
11799 {
11800 hddLog (VOS_TRACE_LEVEL_ERROR,
11801 "%s:Failed memory allocation", __func__);
11802 return -EIO;
11803 }
11804 vos_mem_copy((v_U8_t *)params->bssid,
11805 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
11806 VOS_MAC_ADDR_SIZE);
11807 alloc_bssid = VOS_TRUE;
11808 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070011809
Jeff Johnson295189b2012-06-20 16:38:30 -070011810 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070011811 if (NULL !=
11812#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
11813 params->chandef.chan)
11814#else
11815 params->channel)
11816#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011817 {
11818 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011819 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
11820 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
11821 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11822 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011823
11824 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011825 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070011826 ieee80211_frequency_to_channel(
11827#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
11828 params->chandef.chan->center_freq);
11829#else
11830 params->channel->center_freq);
11831#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011832
11833 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
11834 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070011835 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011836 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
11837 __func__);
11838 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070011839 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011840
11841 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070011842 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011843 if (channelNum == validChan[indx])
11844 {
11845 break;
11846 }
11847 }
11848 if (indx >= numChans)
11849 {
11850 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011851 __func__, channelNum);
11852 return -EINVAL;
11853 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011854 /* Set the Operational Channel */
11855 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
11856 channelNum);
11857 pRoamProfile->ChannelInfo.numOfChannels = 1;
11858 pHddStaCtx->conn_info.operationChannel = channelNum;
11859 pRoamProfile->ChannelInfo.ChannelList =
11860 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070011861 }
11862
11863 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011864 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070011865 if (status < 0)
11866 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011867 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070011868 __func__);
11869 return status;
11870 }
11871
11872 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011873 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011874 params->ssid_len, params->bssid,
11875 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070011876
11877 if (0 > status)
11878 {
11879 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
11880 return status;
11881 }
11882
krunal sonie9002db2013-11-25 14:24:17 -080011883 if (NULL != params->bssid &&
11884 pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 &&
11885 alloc_bssid == VOS_TRUE)
11886 {
11887 vos_mem_free(params->bssid);
11888 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011889 return 0;
11890}
11891
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011892static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
11893 struct net_device *dev,
11894 struct cfg80211_ibss_params *params
11895 )
11896{
11897 int ret = 0;
11898
11899 vos_ssr_protect(__func__);
11900 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
11901 vos_ssr_unprotect(__func__);
11902
11903 return ret;
11904}
11905
Jeff Johnson295189b2012-06-20 16:38:30 -070011906/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011907 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011908 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070011909 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011910static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011911 struct net_device *dev
11912 )
11913{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011914 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011915 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11916 tCsrRoamProfile *pRoamProfile;
11917 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011918 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011919
11920 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011921
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011922 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11923 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
11924 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011925 status = wlan_hdd_validate_context(pHddCtx);
11926
11927 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011928 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011929 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11930 "%s: HDD context is not valid", __func__);
11931 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011932 }
11933
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011934 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
11935 hdd_device_modetoString(pAdapter->device_mode),
11936 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011937 if (NULL == pWextState)
11938 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011939 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070011940 __func__);
11941 return -EIO;
11942 }
11943
11944 pRoamProfile = &pWextState->roamProfile;
11945
11946 /* Issue disconnect only if interface type is set to IBSS */
11947 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
11948 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011949 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070011950 __func__);
11951 return -EINVAL;
11952 }
11953
11954 /* Issue Disconnect request */
11955 INIT_COMPLETION(pAdapter->disconnect_comp_var);
11956 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
11957 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
11958
11959 return 0;
11960}
11961
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011962static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
11963 struct net_device *dev
11964 )
11965{
11966 int ret = 0;
11967
11968 vos_ssr_protect(__func__);
11969 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
11970 vos_ssr_unprotect(__func__);
11971
11972 return ret;
11973}
11974
Jeff Johnson295189b2012-06-20 16:38:30 -070011975/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053011976 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070011977 * This function is used to set the phy parameters
11978 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
11979 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053011980static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011981 u32 changed)
11982{
11983 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
11984 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011985 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011986
11987 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011988 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11989 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
11990 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011991 status = wlan_hdd_validate_context(pHddCtx);
11992
11993 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011994 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011995 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11996 "%s: HDD context is not valid", __func__);
11997 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011998 }
11999
Jeff Johnson295189b2012-06-20 16:38:30 -070012000 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
12001 {
12002 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
12003 WNI_CFG_RTS_THRESHOLD_STAMAX :
12004 wiphy->rts_threshold;
12005
12006 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012007 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070012008 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012009 hddLog(VOS_TRACE_LEVEL_ERROR,
12010 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012011 __func__, rts_threshold);
12012 return -EINVAL;
12013 }
12014
12015 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
12016 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012017 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012018 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012019 hddLog(VOS_TRACE_LEVEL_ERROR,
12020 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012021 __func__, rts_threshold);
12022 return -EIO;
12023 }
12024
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012025 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012026 rts_threshold);
12027 }
12028
12029 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
12030 {
12031 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
12032 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
12033 wiphy->frag_threshold;
12034
12035 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012036 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012037 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012038 hddLog(VOS_TRACE_LEVEL_ERROR,
12039 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012040 frag_threshold);
12041 return -EINVAL;
12042 }
12043
12044 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
12045 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012046 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012047 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012048 hddLog(VOS_TRACE_LEVEL_ERROR,
12049 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012050 __func__, frag_threshold);
12051 return -EIO;
12052 }
12053
12054 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
12055 frag_threshold);
12056 }
12057
12058 if ((changed & WIPHY_PARAM_RETRY_SHORT)
12059 || (changed & WIPHY_PARAM_RETRY_LONG))
12060 {
12061 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
12062 wiphy->retry_short :
12063 wiphy->retry_long;
12064
12065 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
12066 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
12067 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012068 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012069 __func__, retry_value);
12070 return -EINVAL;
12071 }
12072
12073 if (changed & WIPHY_PARAM_RETRY_SHORT)
12074 {
12075 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
12076 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012077 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012078 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012079 hddLog(VOS_TRACE_LEVEL_ERROR,
12080 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012081 __func__, retry_value);
12082 return -EIO;
12083 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012084 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012085 __func__, retry_value);
12086 }
12087 else if (changed & WIPHY_PARAM_RETRY_SHORT)
12088 {
12089 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
12090 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012091 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012092 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012093 hddLog(VOS_TRACE_LEVEL_ERROR,
12094 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012095 __func__, retry_value);
12096 return -EIO;
12097 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012098 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012099 __func__, retry_value);
12100 }
12101 }
12102
12103 return 0;
12104}
12105
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012106static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
12107 u32 changed)
12108{
12109 int ret;
12110
12111 vos_ssr_protect(__func__);
12112 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
12113 vos_ssr_unprotect(__func__);
12114
12115 return ret;
12116}
12117
Jeff Johnson295189b2012-06-20 16:38:30 -070012118/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012119 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070012120 * This function is used to set the txpower
12121 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012122static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070012123#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12124 struct wireless_dev *wdev,
12125#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012126#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012127 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070012128#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012129 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070012130#endif
12131 int dbm)
12132{
12133 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012134 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012135 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
12136 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012137 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012138
12139 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012140 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12141 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
12142 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012143 status = wlan_hdd_validate_context(pHddCtx);
12144
12145 if (0 != status)
12146 {
12147 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12148 "%s: HDD context is not valid", __func__);
12149 return status;
12150 }
12151
12152 hHal = pHddCtx->hHal;
12153
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012154 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
12155 dbm, ccmCfgSetCallback,
12156 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012157 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012158 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012159 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
12160 return -EIO;
12161 }
12162
12163 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
12164 dbm);
12165
12166 switch(type)
12167 {
12168 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
12169 /* Fall through */
12170 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
12171 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
12172 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012173 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
12174 __func__);
12175 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070012176 }
12177 break;
12178 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012179 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070012180 __func__);
12181 return -EOPNOTSUPP;
12182 break;
12183 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012184 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
12185 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070012186 return -EIO;
12187 }
12188
12189 return 0;
12190}
12191
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012192static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
12193#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12194 struct wireless_dev *wdev,
12195#endif
12196#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
12197 enum tx_power_setting type,
12198#else
12199 enum nl80211_tx_power_setting type,
12200#endif
12201 int dbm)
12202{
12203 int ret;
12204 vos_ssr_protect(__func__);
12205 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
12206#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12207 wdev,
12208#endif
12209#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
12210 type,
12211#else
12212 type,
12213#endif
12214 dbm);
12215 vos_ssr_unprotect(__func__);
12216
12217 return ret;
12218}
12219
Jeff Johnson295189b2012-06-20 16:38:30 -070012220/*
12221 * FUNCTION: wlan_hdd_cfg80211_get_txpower
12222 * This function is used to read the txpower
12223 */
Yue Maf49ba872013-08-19 12:04:25 -070012224static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
12225#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12226 struct wireless_dev *wdev,
12227#endif
12228 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070012229{
12230
12231 hdd_adapter_t *pAdapter;
12232 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012233 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012234
Jeff Johnsone7245742012-09-05 17:12:55 -070012235 ENTER();
12236
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012237 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070012238
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012239 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012240 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012241 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12242 "%s: HDD context is not valid", __func__);
12243 *dbm = 0;
12244 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012245 }
12246
Jeff Johnson295189b2012-06-20 16:38:30 -070012247 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
12248 if (NULL == pAdapter)
12249 {
12250 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
12251 return -ENOENT;
12252 }
12253
12254 wlan_hdd_get_classAstats(pAdapter);
12255 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
12256
Jeff Johnsone7245742012-09-05 17:12:55 -070012257 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012258 return 0;
12259}
12260
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012261static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070012262 u8* mac, struct station_info *sinfo)
12263{
12264 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
12265 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12266 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053012267 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070012268
12269 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
12270 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070012271
12272 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
12273 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
12274 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
12275 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
12276 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
12277 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
12278 tANI_U16 maxRate = 0;
12279 tANI_U16 myRate;
12280 tANI_U16 currentRate = 0;
12281 tANI_U8 maxSpeedMCS = 0;
12282 tANI_U8 maxMCSIdx = 0;
12283 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053012284 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070012285 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012286 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012287
Leo Chang6f8870f2013-03-26 18:11:36 -070012288#ifdef WLAN_FEATURE_11AC
12289 tANI_U32 vht_mcs_map;
12290 eDataRate11ACMaxMcs vhtMaxMcs;
12291#endif /* WLAN_FEATURE_11AC */
12292
Jeff Johnsone7245742012-09-05 17:12:55 -070012293 ENTER();
12294
Jeff Johnson295189b2012-06-20 16:38:30 -070012295 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
12296 (0 == ssidlen))
12297 {
12298 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
12299 " Invalid ssidlen, %d", __func__, ssidlen);
12300 /*To keep GUI happy*/
12301 return 0;
12302 }
12303
Mukul Sharma811205f2014-07-09 21:07:30 +053012304 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
12305 {
12306 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12307 "%s: Roaming in progress, so unable to proceed this request", __func__);
12308 return 0;
12309 }
12310
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012311 status = wlan_hdd_validate_context(pHddCtx);
12312
12313 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012314 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012315 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12316 "%s: HDD context is not valid", __func__);
12317 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012318 }
12319
Jeff Johnson295189b2012-06-20 16:38:30 -070012320
Kiet Lam3b17fc82013-09-27 05:24:08 +053012321 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
12322 sinfo->filled |= STATION_INFO_SIGNAL;
12323
c_hpothu09f19542014-05-30 21:53:31 +053012324 wlan_hdd_get_station_stats(pAdapter);
12325 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
12326
12327 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053012328 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
12329 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053012330 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053012331 {
12332 rate_flags = pAdapter->maxRateFlags;
12333 }
c_hpothu44ff4e02014-05-08 00:13:57 +053012334
Jeff Johnson295189b2012-06-20 16:38:30 -070012335 //convert to the UI units of 100kbps
12336 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
12337
12338#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070012339 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 -070012340 sinfo->signal,
12341 pCfg->reportMaxLinkSpeed,
12342 myRate,
12343 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070012344 (int) pCfg->linkSpeedRssiMid,
12345 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070012346 (int) rate_flags,
12347 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070012348#endif //LINKSPEED_DEBUG_ENABLED
12349
12350 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
12351 {
12352 // we do not want to necessarily report the current speed
12353 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
12354 {
12355 // report the max possible speed
12356 rssidx = 0;
12357 }
12358 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
12359 {
12360 // report the max possible speed with RSSI scaling
12361 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
12362 {
12363 // report the max possible speed
12364 rssidx = 0;
12365 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070012366 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070012367 {
12368 // report middle speed
12369 rssidx = 1;
12370 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070012371 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
12372 {
12373 // report middle speed
12374 rssidx = 2;
12375 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012376 else
12377 {
12378 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070012379 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070012380 }
12381 }
12382 else
12383 {
12384 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
12385 hddLog(VOS_TRACE_LEVEL_ERROR,
12386 "%s: Invalid value for reportMaxLinkSpeed: %u",
12387 __func__, pCfg->reportMaxLinkSpeed);
12388 rssidx = 0;
12389 }
12390
12391 maxRate = 0;
12392
12393 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053012394 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
12395 OperationalRates, &ORLeng))
12396 {
12397 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
12398 /*To keep GUI happy*/
12399 return 0;
12400 }
12401
Jeff Johnson295189b2012-06-20 16:38:30 -070012402 for (i = 0; i < ORLeng; i++)
12403 {
Jeff Johnsone7245742012-09-05 17:12:55 -070012404 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070012405 {
12406 /* Validate Rate Set */
12407 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
12408 {
12409 currentRate = supported_data_rate[j].supported_rate[rssidx];
12410 break;
12411 }
12412 }
12413 /* Update MAX rate */
12414 maxRate = (currentRate > maxRate)?currentRate:maxRate;
12415 }
12416
12417 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053012418 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
12419 ExtendedRates, &ERLeng))
12420 {
12421 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
12422 /*To keep GUI happy*/
12423 return 0;
12424 }
12425
Jeff Johnson295189b2012-06-20 16:38:30 -070012426 for (i = 0; i < ERLeng; i++)
12427 {
Jeff Johnsone7245742012-09-05 17:12:55 -070012428 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070012429 {
12430 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
12431 {
12432 currentRate = supported_data_rate[j].supported_rate[rssidx];
12433 break;
12434 }
12435 }
12436 /* Update MAX rate */
12437 maxRate = (currentRate > maxRate)?currentRate:maxRate;
12438 }
c_hpothu79aab322014-07-14 21:11:01 +053012439
Kiet Lamb69f8dc2013-11-15 15:34:27 +053012440 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053012441 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053012442 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053012443 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070012444 {
c_hpothu79aab322014-07-14 21:11:01 +053012445 if (rate_flags & eHAL_TX_RATE_VHT80)
12446 mode = 2;
12447 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
12448 mode = 1;
12449 else
12450 mode = 0;
12451
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053012452 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
12453 MCSRates, &MCSLeng))
12454 {
12455 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
12456 /*To keep GUI happy*/
12457 return 0;
12458 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012459 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070012460#ifdef WLAN_FEATURE_11AC
12461 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012462 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070012463 {
Leo Chang6f8870f2013-03-26 18:11:36 -070012464 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012465 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070012466 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070012467 {
Leo Chang6f8870f2013-03-26 18:11:36 -070012468 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070012469 }
Leo Chang6f8870f2013-03-26 18:11:36 -070012470 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070012471 {
Leo Chang6f8870f2013-03-26 18:11:36 -070012472 maxMCSIdx = 7;
12473 }
12474 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
12475 {
12476 maxMCSIdx = 8;
12477 }
12478 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
12479 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012480 //VHT20 is supporting 0~8
12481 if (rate_flags & eHAL_TX_RATE_VHT20)
12482 maxMCSIdx = 8;
12483 else
12484 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070012485 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012486
c_hpothu79aab322014-07-14 21:11:01 +053012487 if (0 != rssidx)/*check for scaled */
12488 {
12489 //get middle rate MCS index if rssi=1/2
12490 for (i=0; i <= maxMCSIdx; i++)
12491 {
12492 if (sinfo->signal <= rssiMcsTbl[mode][i])
12493 {
12494 maxMCSIdx = i;
12495 break;
12496 }
12497 }
12498 }
12499
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012500 if (rate_flags & eHAL_TX_RATE_VHT80)
12501 {
12502 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
12503 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
12504 }
12505 else if (rate_flags & eHAL_TX_RATE_VHT40)
12506 {
12507 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
12508 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
12509 }
12510 else if (rate_flags & eHAL_TX_RATE_VHT20)
12511 {
12512 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
12513 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
12514 }
12515
Leo Chang6f8870f2013-03-26 18:11:36 -070012516 maxSpeedMCS = 1;
12517 if (currentRate > maxRate)
12518 {
12519 maxRate = currentRate;
12520 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012521
Leo Chang6f8870f2013-03-26 18:11:36 -070012522 }
12523 else
12524#endif /* WLAN_FEATURE_11AC */
12525 {
12526 if (rate_flags & eHAL_TX_RATE_HT40)
12527 {
12528 rateFlag |= 1;
12529 }
12530 if (rate_flags & eHAL_TX_RATE_SGI)
12531 {
12532 rateFlag |= 2;
12533 }
12534
Girish Gowli01abcee2014-07-31 20:18:55 +053012535 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053012536 if (rssidx == 1 || rssidx == 2)
12537 {
12538 //get middle rate MCS index if rssi=1/2
12539 for (i=0; i <= 7; i++)
12540 {
12541 if (sinfo->signal <= rssiMcsTbl[mode][i])
12542 {
12543 temp = i+1;
12544 break;
12545 }
12546 }
12547 }
c_hpothu79aab322014-07-14 21:11:01 +053012548
12549 for (i = 0; i < MCSLeng; i++)
12550 {
Leo Chang6f8870f2013-03-26 18:11:36 -070012551 for (j = 0; j < temp; j++)
12552 {
12553 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
12554 {
12555 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
12556 break;
12557 }
12558 }
12559 if ((j < temp) && (currentRate > maxRate))
12560 {
12561 maxRate = currentRate;
12562 maxSpeedMCS = 1;
12563 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
12564 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012565 }
12566 }
12567 }
12568
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012569 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
12570 {
12571 maxRate = myRate;
12572 maxSpeedMCS = 1;
12573 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
12574 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012575 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053012576 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070012577 {
12578 maxRate = myRate;
12579 if (rate_flags & eHAL_TX_RATE_LEGACY)
12580 {
12581 maxSpeedMCS = 0;
12582 }
12583 else
12584 {
12585 maxSpeedMCS = 1;
12586 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
12587 }
12588 }
12589
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012590 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070012591 {
12592 sinfo->txrate.legacy = maxRate;
12593#ifdef LINKSPEED_DEBUG_ENABLED
12594 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
12595#endif //LINKSPEED_DEBUG_ENABLED
12596 }
12597 else
12598 {
12599 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070012600#ifdef WLAN_FEATURE_11AC
12601 sinfo->txrate.nss = 1;
12602 if (rate_flags & eHAL_TX_RATE_VHT80)
12603 {
12604 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012605 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070012606 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012607 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070012608 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012609 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
12610 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
12611 }
12612 else if (rate_flags & eHAL_TX_RATE_VHT20)
12613 {
12614 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
12615 }
12616#endif /* WLAN_FEATURE_11AC */
12617 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
12618 {
12619 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
12620 if (rate_flags & eHAL_TX_RATE_HT40)
12621 {
12622 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
12623 }
Leo Chang6f8870f2013-03-26 18:11:36 -070012624 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012625 if (rate_flags & eHAL_TX_RATE_SGI)
12626 {
12627 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
12628 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012629
Jeff Johnson295189b2012-06-20 16:38:30 -070012630#ifdef LINKSPEED_DEBUG_ENABLED
12631 pr_info("Reporting MCS rate %d flags %x\n",
12632 sinfo->txrate.mcs,
12633 sinfo->txrate.flags );
12634#endif //LINKSPEED_DEBUG_ENABLED
12635 }
12636 }
12637 else
12638 {
12639 // report current rate instead of max rate
12640
12641 if (rate_flags & eHAL_TX_RATE_LEGACY)
12642 {
12643 //provide to the UI in units of 100kbps
12644 sinfo->txrate.legacy = myRate;
12645#ifdef LINKSPEED_DEBUG_ENABLED
12646 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
12647#endif //LINKSPEED_DEBUG_ENABLED
12648 }
12649 else
12650 {
12651 //must be MCS
12652 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070012653#ifdef WLAN_FEATURE_11AC
12654 sinfo->txrate.nss = 1;
12655 if (rate_flags & eHAL_TX_RATE_VHT80)
12656 {
12657 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
12658 }
12659 else
12660#endif /* WLAN_FEATURE_11AC */
12661 {
12662 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
12663 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012664 if (rate_flags & eHAL_TX_RATE_SGI)
12665 {
12666 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
12667 }
12668 if (rate_flags & eHAL_TX_RATE_HT40)
12669 {
12670 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
12671 }
Leo Chang6f8870f2013-03-26 18:11:36 -070012672#ifdef WLAN_FEATURE_11AC
12673 else if (rate_flags & eHAL_TX_RATE_VHT80)
12674 {
12675 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
12676 }
12677#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070012678#ifdef LINKSPEED_DEBUG_ENABLED
12679 pr_info("Reporting actual MCS rate %d flags %x\n",
12680 sinfo->txrate.mcs,
12681 sinfo->txrate.flags );
12682#endif //LINKSPEED_DEBUG_ENABLED
12683 }
12684 }
12685 sinfo->filled |= STATION_INFO_TX_BITRATE;
12686
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070012687 sinfo->tx_packets =
12688 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
12689 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
12690 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
12691 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
12692
12693 sinfo->tx_retries =
12694 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
12695 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
12696 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
12697 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
12698
12699 sinfo->tx_failed =
12700 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
12701 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
12702 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
12703 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
12704
12705 sinfo->filled |=
12706 STATION_INFO_TX_PACKETS |
12707 STATION_INFO_TX_RETRIES |
12708 STATION_INFO_TX_FAILED;
12709
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012710 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12711 TRACE_CODE_HDD_CFG80211_GET_STA,
12712 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070012713 EXIT();
12714 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012715}
12716
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012717static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
12718 u8* mac, struct station_info *sinfo)
12719{
12720 int ret;
12721
12722 vos_ssr_protect(__func__);
12723 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
12724 vos_ssr_unprotect(__func__);
12725
12726 return ret;
12727}
12728
12729static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070012730 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070012731{
12732 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053012733 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012734 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012735 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012736
Jeff Johnsone7245742012-09-05 17:12:55 -070012737 ENTER();
12738
Jeff Johnson295189b2012-06-20 16:38:30 -070012739 if (NULL == pAdapter)
12740 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012741 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012742 return -ENODEV;
12743 }
12744
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012745 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12746 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
12747 pAdapter->sessionId, timeout));
12748
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053012749 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012750 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053012751
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012752 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012753 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012754 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12755 "%s: HDD context is not valid", __func__);
12756 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012757 }
12758
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053012759 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
12760 (TRUE == pHddCtx->hdd_wlan_suspended) &&
12761 (pHddCtx->cfg_ini->fhostArpOffload) &&
12762 (eConnectionState_Associated ==
12763 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
12764 {
Amar Singhald53568e2013-09-26 11:03:45 -070012765
12766 hddLog(VOS_TRACE_LEVEL_INFO,
12767 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053012768 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053012769 if (!VOS_IS_STATUS_SUCCESS(vos_status))
12770 {
12771 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012772 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053012773 __func__, vos_status);
12774 }
12775 }
12776
Jeff Johnson295189b2012-06-20 16:38:30 -070012777 /**The get power cmd from the supplicant gets updated by the nl only
12778 *on successful execution of the function call
12779 *we are oppositely mapped w.r.t mode in the driver
12780 **/
12781 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
12782
Jeff Johnsone7245742012-09-05 17:12:55 -070012783 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012784 if (VOS_STATUS_E_FAILURE == vos_status)
12785 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012786 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12787 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012788 return -EINVAL;
12789 }
12790 return 0;
12791}
12792
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012793static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
12794 struct net_device *dev, bool mode, int timeout)
12795{
12796 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070012797
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012798 vos_ssr_protect(__func__);
12799 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
12800 vos_ssr_unprotect(__func__);
12801
12802 return ret;
12803}
Jeff Johnson295189b2012-06-20 16:38:30 -070012804#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12805static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
12806 struct net_device *netdev,
12807 u8 key_index)
12808{
Jeff Johnsone7245742012-09-05 17:12:55 -070012809 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070012810 return 0;
12811}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012812#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070012813
12814#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
12815static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
12816 struct net_device *dev,
12817 struct ieee80211_txq_params *params)
12818{
Jeff Johnsone7245742012-09-05 17:12:55 -070012819 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070012820 return 0;
12821}
12822#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12823static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
12824 struct ieee80211_txq_params *params)
12825{
Jeff Johnsone7245742012-09-05 17:12:55 -070012826 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070012827 return 0;
12828}
12829#endif //LINUX_VERSION_CODE
12830
Naresh Jayaram69e3f282014-10-14 12:29:12 +053012831static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012832 struct net_device *dev,
12833 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070012834{
12835 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012836 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012837 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012838 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012839 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012840 v_CONTEXT_t pVosContext = NULL;
12841 ptSapContext pSapCtx = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -070012842 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012843
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012844 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070012845 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012846 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012847 return -EINVAL;
12848 }
12849
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012850 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12851 TRACE_CODE_HDD_CFG80211_DEL_STA,
12852 pAdapter->sessionId, pAdapter->device_mode));
12853
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012854 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12855 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070012856
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012857 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012858 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012859 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12860 "%s: HDD context is not valid", __func__);
12861 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012862 }
12863
Jeff Johnson295189b2012-06-20 16:38:30 -070012864 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070012865 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070012866 )
12867 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012868 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
12869 pSapCtx = VOS_GET_SAP_CB(pVosContext);
12870 if(pSapCtx == NULL){
12871 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12872 FL("psapCtx is NULL"));
12873 return -ENOENT;
12874 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012875 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070012876 {
12877 v_U16_t i;
12878 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
12879 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012880 if ((pSapCtx->aStaInfo[i].isUsed) &&
12881 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070012882 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012883 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012884 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012885 ETHER_ADDR_LEN);
12886
Jeff Johnson295189b2012-06-20 16:38:30 -070012887 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080012888 "%s: Delete STA with MAC::"
12889 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012890 __func__,
12891 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
12892 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070012893 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012894 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012895 }
12896 }
12897 }
12898 else
12899 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012900
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012901 vos_status = hdd_softap_GetStaId(pAdapter,
12902 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012903 if (!VOS_IS_STATUS_SUCCESS(vos_status))
12904 {
12905 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080012906 "%s: Skip this DEL STA as this is not used::"
12907 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012908 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012909 return -ENOENT;
12910 }
12911
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012912 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012913 {
12914 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080012915 "%s: Skip this DEL STA as deauth is in progress::"
12916 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012917 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012918 return -ENOENT;
12919 }
12920
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012921 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012922
Jeff Johnson295189b2012-06-20 16:38:30 -070012923 hddLog(VOS_TRACE_LEVEL_INFO,
12924 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080012925 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012926 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012927 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012928
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012929 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012930 if (!VOS_IS_STATUS_SUCCESS(vos_status))
12931 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012932 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012933 hddLog(VOS_TRACE_LEVEL_INFO,
12934 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080012935 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012936 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012937 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012938 return -ENOENT;
12939 }
12940
Jeff Johnson295189b2012-06-20 16:38:30 -070012941 }
12942 }
12943
12944 EXIT();
12945
12946 return 0;
12947}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053012948
12949#ifdef CFG80211_DEL_STA_V2
12950static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
12951 struct net_device *dev,
12952 struct station_del_parameters *param)
12953#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012954static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
12955 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053012956#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012957{
12958 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012959 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070012960
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012961 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012962
Naresh Jayaram69e3f282014-10-14 12:29:12 +053012963#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012964 if (NULL == param) {
12965 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
12966 return -EINVAL;
12967 }
12968
12969 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
12970 param->subtype, &delStaParams);
12971
Naresh Jayaram69e3f282014-10-14 12:29:12 +053012972#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053012973 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012974 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053012975#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012976 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
12977
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012978 vos_ssr_unprotect(__func__);
12979
12980 return ret;
12981}
12982
12983static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012984 struct net_device *dev, u8 *mac, struct station_parameters *params)
12985{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012986 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalab977a972013-02-18 19:15:09 -080012987 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012988#ifdef FEATURE_WLAN_TDLS
12989 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012990 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012991
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012992 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12993 TRACE_CODE_HDD_CFG80211_ADD_STA,
12994 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012995 mask = params->sta_flags_mask;
12996
12997 set = params->sta_flags_set;
12998
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012999#ifdef WLAN_FEATURE_TDLS_DEBUG
13000 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13001 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
13002 __func__, mask, set, MAC_ADDR_ARRAY(mac));
13003#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013004
13005 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
13006 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013007 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013008 }
13009 }
13010#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013011 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013012}
13013
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013014static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
13015 struct net_device *dev, u8 *mac, struct station_parameters *params)
13016{
13017 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013018
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013019 vos_ssr_protect(__func__);
13020 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
13021 vos_ssr_unprotect(__func__);
13022
13023 return ret;
13024}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013025#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070013026
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013027static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070013028 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013029{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013030 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13031 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013032 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013033 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013034 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013035 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070013036
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013037 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013038 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013039 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013040 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013041 return -EINVAL;
13042 }
13043
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013044 if (!pmksa) {
13045 hddLog(LOGE, FL("pmksa is NULL"));
13046 return -EINVAL;
13047 }
13048
13049 if (!pmksa->bssid || !pmksa->pmkid) {
13050 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
13051 pmksa->bssid, pmksa->pmkid);
13052 return -EINVAL;
13053 }
13054
13055 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
13056 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
13057
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013058 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13059 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013060
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013061 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013062 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013063 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13064 "%s: HDD context is not valid", __func__);
13065 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013066 }
13067
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013068 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013069 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
13070
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013071 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
13072 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013073
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013074 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013075 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013076 &pmk_id, 1, FALSE);
13077
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013078 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13079 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
13080 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013081
13082 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013083}
13084
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013085static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
13086 struct cfg80211_pmksa *pmksa)
13087{
13088 int ret;
13089
13090 vos_ssr_protect(__func__);
13091 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
13092 vos_ssr_unprotect(__func__);
13093
13094 return ret;
13095}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013096
Wilson Yang6507c4e2013-10-01 20:11:19 -070013097
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013098static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070013099 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013100{
Wilson Yang6507c4e2013-10-01 20:11:19 -070013101 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13102 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013103 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080013104 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013105
Wilson Yang6507c4e2013-10-01 20:11:19 -070013106 /* Validate pAdapter */
13107 if (NULL == pAdapter)
13108 {
13109 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
13110 return -EINVAL;
13111 }
13112
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013113 if (!pmksa) {
13114 hddLog(LOGE, FL("pmksa is NULL"));
13115 return -EINVAL;
13116 }
13117
13118 if (!pmksa->bssid) {
13119 hddLog(LOGE, FL("pmksa->bssid is NULL"));
13120 return -EINVAL;
13121 }
13122
Kiet Lam98c46a12014-10-31 15:34:57 -070013123 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
13124 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
13125
Wilson Yang6507c4e2013-10-01 20:11:19 -070013126 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13127 status = wlan_hdd_validate_context(pHddCtx);
13128
13129 if (0 != status)
13130 {
13131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13132 "%s: HDD context is not valid", __func__);
13133 return status;
13134 }
13135
13136 /*Retrieve halHandle*/
13137 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
13138
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013139 /* Delete the PMKID CSR cache */
13140 if (eHAL_STATUS_SUCCESS !=
13141 sme_RoamDelPMKIDfromCache(halHandle,
13142 pAdapter->sessionId, pmksa->bssid, FALSE)) {
13143 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
13144 MAC_ADDR_ARRAY(pmksa->bssid));
13145 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013146 }
13147
Wilson Yangef657d32014-01-15 19:19:23 -080013148 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013149}
13150
Wilson Yang6507c4e2013-10-01 20:11:19 -070013151
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013152static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
13153 struct cfg80211_pmksa *pmksa)
13154{
13155 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013156
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013157 vos_ssr_protect(__func__);
13158 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
13159 vos_ssr_unprotect(__func__);
13160
13161 return ret;
13162
13163}
13164
13165static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013166{
Wilson Yang6507c4e2013-10-01 20:11:19 -070013167 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13168 tHalHandle halHandle;
13169 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080013170 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013171
13172 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__);
13173
13174 /* Validate pAdapter */
13175 if (NULL == pAdapter)
13176 {
13177 hddLog(VOS_TRACE_LEVEL_ERROR,
13178 "%s: Invalid Adapter" ,__func__);
13179 return -EINVAL;
13180 }
13181
13182 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13183 status = wlan_hdd_validate_context(pHddCtx);
13184
13185 if (0 != status)
13186 {
13187 hddLog(VOS_TRACE_LEVEL_ERROR,
13188 "%s: HDD context is not valid", __func__);
13189 return status;
13190 }
13191
13192 /*Retrieve halHandle*/
13193 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
13194
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013195 /* Flush the PMKID cache in CSR */
13196 if (eHAL_STATUS_SUCCESS !=
13197 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
13198 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
13199 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013200 }
13201
Wilson Yangef657d32014-01-15 19:19:23 -080013202 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013203}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013204
13205static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
13206{
13207 int ret;
13208
13209 vos_ssr_protect(__func__);
13210 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
13211 vos_ssr_unprotect(__func__);
13212
13213 return ret;
13214}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013215#endif
13216
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013217#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013218static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
13219 struct net_device *dev,
13220 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013221{
13222 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13223 hdd_station_ctx_t *pHddStaCtx;
13224
13225 if (NULL == pAdapter)
13226 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013227 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013228 return -ENODEV;
13229 }
13230
13231 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13232
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013233 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13234 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
13235 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013236 // Added for debug on reception of Re-assoc Req.
13237 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
13238 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013239 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013240 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080013241 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013242 }
13243
13244#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080013245 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013246 ftie->ie_len);
13247#endif
13248
13249 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053013250 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
13251 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013252 ftie->ie_len);
13253 return 0;
13254}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013255
13256static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
13257 struct net_device *dev,
13258 struct cfg80211_update_ft_ies_params *ftie)
13259{
13260 int ret;
13261
13262 vos_ssr_protect(__func__);
13263 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
13264 vos_ssr_unprotect(__func__);
13265
13266 return ret;
13267}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013268#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013269
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013270#ifdef FEATURE_WLAN_SCAN_PNO
13271
13272void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
13273 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
13274{
13275 int ret;
13276 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
13277 hdd_context_t *pHddCtx;
13278
Nirav Shah80830bf2013-12-31 16:35:12 +053013279 ENTER();
13280
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013281 if (NULL == pAdapter)
13282 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053013283 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013284 "%s: HDD adapter is Null", __func__);
13285 return ;
13286 }
13287
13288 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13289 if (NULL == pHddCtx)
13290 {
13291 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13292 "%s: HDD context is Null!!!", __func__);
13293 return ;
13294 }
13295
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013296 spin_lock(&pHddCtx->schedScan_lock);
13297 if (TRUE == pHddCtx->isWiphySuspended)
13298 {
13299 pHddCtx->isSchedScanUpdatePending = TRUE;
13300 spin_unlock(&pHddCtx->schedScan_lock);
13301 hddLog(VOS_TRACE_LEVEL_INFO,
13302 "%s: Update cfg80211 scan database after it resume", __func__);
13303 return ;
13304 }
13305 spin_unlock(&pHddCtx->schedScan_lock);
13306
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013307 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
13308
13309 if (0 > ret)
13310 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
13311
13312 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13314 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013315}
13316
13317/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013318 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053013319 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013320 */
13321static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
13322{
13323 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
13324 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053013325 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013326 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13327 int status = 0;
13328 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
13329
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053013330 /* The current firmware design does not allow PNO during any
13331 * active sessions. Hence, determine the active sessions
13332 * and return a failure.
13333 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013334 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
13335 {
13336 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053013337 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013338
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053013339 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
13340 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
13341 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
13342 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
13343 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053013344 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053013345 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013346 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053013347 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013348 }
13349 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
13350 pAdapterNode = pNext;
13351 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053013352 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013353}
13354
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013355void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
13356{
13357 hdd_adapter_t *pAdapter = callbackContext;
13358 hdd_context_t *pHddCtx;
13359
13360 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
13361 {
13362 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13363 FL("Invalid adapter or adapter has invalid magic"));
13364 return;
13365 }
13366
13367 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13368 if (0 != wlan_hdd_validate_context(pHddCtx))
13369 {
13370 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13371 FL("HDD context is not valid"));
13372 return;
13373 }
13374
c_hpothub53c45d2014-08-18 16:53:14 +053013375 if (VOS_STATUS_SUCCESS != status)
13376 {
13377 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013378 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053013379 pHddCtx->isPnoEnable = FALSE;
13380 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013381
13382 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
13383 complete(&pAdapter->pno_comp_var);
13384}
13385
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013386/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053013387 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
13388 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013389 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053013390static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013391 struct net_device *dev, struct cfg80211_sched_scan_request *request)
13392{
13393 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13394 tpSirPNOScanReq pPnoRequest = NULL;
13395 hdd_context_t *pHddCtx;
13396 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053013397 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053013398 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
13399 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013400 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
13401 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013402 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053013403 hdd_config_t *pConfig = NULL;
13404 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013405
13406 if (NULL == pAdapter)
13407 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013408 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013409 "%s: HDD adapter is Null", __func__);
13410 return -ENODEV;
13411 }
13412
13413 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013414 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013415
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013416 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013417 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053013418 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13419 "%s: HDD context is not valid", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013420 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013421 }
13422
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053013423 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013424 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
13425 if (NULL == hHal)
13426 {
13427 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13428 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013429 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013430 }
Sushant Kaushik2fe89932014-09-03 10:58:09 +053013431 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053013432 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053013433 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053013434 {
13435 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13436 "%s: aborting the existing scan is unsuccessfull", __func__);
13437 return -EBUSY;
13438 }
13439
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053013440 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013441 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053013442 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053013443 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013444 return -EBUSY;
13445 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013446
c_hpothu37f21312014-04-09 21:49:54 +053013447 if (TRUE == pHddCtx->isPnoEnable)
13448 {
13449 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
13450 FL("already PNO is enabled"));
13451 return -EBUSY;
13452 }
c_hpothu225aa7c2014-10-22 17:45:13 +053013453
13454 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
13455 {
13456 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13457 "%s: abort ROC failed ", __func__);
13458 return -EBUSY;
13459 }
13460
c_hpothu37f21312014-04-09 21:49:54 +053013461 pHddCtx->isPnoEnable = TRUE;
13462
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013463 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
13464 if (NULL == pPnoRequest)
13465 {
13466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
13467 "%s: vos_mem_malloc failed", __func__);
c_hpothu37f21312014-04-09 21:49:54 +053013468 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013469 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013470 }
13471
Madan Mohan Koyyalamudic3f04352013-09-26 19:21:48 +053013472 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013473 pPnoRequest->enable = 1; /*Enable PNO */
13474 pPnoRequest->ucNetworksCount = request->n_match_sets;
13475
13476 if (( !pPnoRequest->ucNetworksCount ) ||
13477 ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
13478 {
13479 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053013480 "%s: Network input is not correct %d Max Network supported is %d",
13481 __func__, pPnoRequest->ucNetworksCount,
13482 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013483 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013484 goto error;
13485 }
13486
13487 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
13488 {
13489 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053013490 "%s: Incorrect number of channels %d",
13491 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013492 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013493 goto error;
13494 }
13495
13496 /* Framework provides one set of channels(all)
13497 * common for all saved profile */
13498 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
13499 channels_allowed, &num_channels_allowed))
13500 {
13501 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13502 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013503 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013504 goto error;
13505 }
13506 /* Checking each channel against allowed channel list */
13507 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053013508 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013509 {
Nirav Shah80830bf2013-12-31 16:35:12 +053013510 char chList [(request->n_channels*5)+1];
13511 int len;
13512 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013513 {
Nirav Shah80830bf2013-12-31 16:35:12 +053013514 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013515 {
Nirav Shah80830bf2013-12-31 16:35:12 +053013516 if (request->channels[i]->hw_value == channels_allowed[indx])
13517 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053013518 if ((!pConfig->enableDFSPnoChnlScan) &&
13519 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
13520 {
13521 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13522 "%s : Dropping DFS channel : %d",
13523 __func__,channels_allowed[indx]);
13524 num_ignore_dfs_ch++;
13525 break;
13526 }
13527
Nirav Shah80830bf2013-12-31 16:35:12 +053013528 valid_ch[num_ch++] = request->channels[i]->hw_value;
13529 len += snprintf(chList+len, 5, "%d ",
13530 request->channels[i]->hw_value);
13531 break ;
13532 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013533 }
13534 }
Nirav Shah80830bf2013-12-31 16:35:12 +053013535 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013536
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053013537 /*If all channels are DFS and dropped, then ignore the PNO request*/
13538 if (num_ignore_dfs_ch == request->n_channels)
13539 {
13540 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13541 "%s : All requested channels are DFS channels", __func__);
13542 ret = -EINVAL;
13543 goto error;
13544 }
13545 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013546 /* Filling per profile params */
13547 for (i = 0; i < pPnoRequest->ucNetworksCount; i++)
13548 {
13549 pPnoRequest->aNetworks[i].ssId.length =
13550 request->match_sets[i].ssid.ssid_len;
13551
13552 if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) ||
13553 ( pPnoRequest->aNetworks[i].ssId.length > 32 ) )
13554 {
13555 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053013556 "%s: SSID Len %d is not correct for network %d",
13557 __func__, pPnoRequest->aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013558 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013559 goto error;
13560 }
13561
13562 memcpy(pPnoRequest->aNetworks[i].ssId.ssId,
13563 request->match_sets[i].ssid.ssid,
13564 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053013565 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13566 "%s: SSID of network %d is %s ", __func__,
13567 i, pPnoRequest->aNetworks[i].ssId.ssId);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013568 pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
13569 pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/
13570 pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
13571
13572 /*Copying list of valid channel into request */
13573 memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch);
13574 pPnoRequest->aNetworks[i].ucChannelCount = num_ch;
13575
13576 pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value
13577 }
13578
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053013579 for (i = 0; i < request->n_ssids; i++)
13580 {
13581 j = 0;
13582 while (j < pPnoRequest->ucNetworksCount)
13583 {
13584 if ((pPnoRequest->aNetworks[j].ssId.length ==
13585 request->ssids[i].ssid_len) &&
13586 (0 == memcmp(pPnoRequest->aNetworks[j].ssId.ssId,
13587 request->ssids[i].ssid,
13588 pPnoRequest->aNetworks[j].ssId.length)))
13589 {
13590 pPnoRequest->aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
13591 break;
13592 }
13593 j++;
13594 }
13595 }
13596 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13597 "Number of hidden networks being Configured = %d",
13598 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053013599 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080013600 "request->ie_len = %zu", request->ie_len);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053013601 if ((0 < request->ie_len) && (NULL != request->ie))
13602 {
13603 pPnoRequest->us24GProbeTemplateLen = request->ie_len;
13604 memcpy(&pPnoRequest->p24GProbeTemplate, request->ie,
13605 pPnoRequest->us24GProbeTemplateLen);
13606
13607 pPnoRequest->us5GProbeTemplateLen = request->ie_len;
13608 memcpy(&pPnoRequest->p5GProbeTemplate, request->ie,
13609 pPnoRequest->us5GProbeTemplateLen);
13610 }
13611
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053013612 /* Driver gets only one time interval which is hardcoded in
13613 * supplicant for 10000ms. Taking power consumption into account 6 timers
13614 * will be used, Timervalue is increased exponentially i.e 10,20,40,
13615 * 80,160,320 secs. And number of scan cycle for each timer
13616 * is configurable through INI param gPNOScanTimerRepeatValue.
13617 * If it is set to 0 only one timer will be used and PNO scan cycle
13618 * will be repeated after each interval specified by supplicant
13619 * till PNO is disabled.
13620 */
13621 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
13622 pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
13623 else
13624 pPnoRequest->scanTimers.ucScanTimersCount =
13625 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
13626
13627 tempInterval = (request->interval)/1000;
13628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13629 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
13630 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
13631 for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++)
13632 {
13633 pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat =
13634 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
13635 pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval;
13636 tempInterval *= 2;
13637 }
13638 //Repeat last timer until pno disabled.
13639 pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
13640
Madan Mohan Koyyalamudid206c7b2013-09-26 22:54:51 +053013641 pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013642
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013643 INIT_COMPLETION(pAdapter->pno_comp_var);
13644 pPnoRequest->statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
13645 pPnoRequest->callbackContext = pAdapter;
13646 pAdapter->pno_req_status = 0;
13647
Nirav Shah80830bf2013-12-31 16:35:12 +053013648 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13649 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
13650 pAdapter->sessionId, pPnoRequest->enable, pPnoRequest->modePNO,
13651 pPnoRequest->scanTimers.ucScanTimersCount);
13652
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013653 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
13654 pPnoRequest, pAdapter->sessionId,
13655 hdd_cfg80211_sched_scan_done_callback, pAdapter);
13656 if (eHAL_STATUS_SUCCESS != status)
13657 {
13658 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053013659 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013660 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013661 goto error;
13662 }
13663
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013664 ret = wait_for_completion_timeout(
13665 &pAdapter->pno_comp_var,
13666 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
13667 if (0 >= ret)
13668 {
13669 // Did not receive the response for PNO enable in time.
13670 // Assuming the PNO enable was success.
13671 // Returning error from here, because we timeout, results
13672 // in side effect of Wifi (Wifi Setting) not to work.
13673 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13674 FL("Timed out waiting for PNO to be Enabled"));
13675 ret = 0;
13676 goto error;
13677 }
13678
c_hpothu3c986b22014-07-09 14:45:09 +053013679 vos_mem_free(pPnoRequest);
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013680 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053013681 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013682
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013683error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013684 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13685 FL("PNO scanRequest offloaded ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013686 vos_mem_free(pPnoRequest);
c_hpothu37f21312014-04-09 21:49:54 +053013687 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013688 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013689}
13690
13691/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053013692 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
13693 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013694 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053013695static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
13696 struct net_device *dev, struct cfg80211_sched_scan_request *request)
13697{
13698 int ret;
13699
13700 vos_ssr_protect(__func__);
13701 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
13702 vos_ssr_unprotect(__func__);
13703
13704 return ret;
13705}
13706
13707/*
13708 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
13709 * Function to disable PNO
13710 */
13711static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013712 struct net_device *dev)
13713{
13714 eHalStatus status = eHAL_STATUS_FAILURE;
13715 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13716 hdd_context_t *pHddCtx;
13717 tHalHandle hHal;
13718 tpSirPNOScanReq pPnoRequest = NULL;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013719 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013720
13721 ENTER();
13722
13723 if (NULL == pAdapter)
13724 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013725 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013726 "%s: HDD adapter is Null", __func__);
13727 return -ENODEV;
13728 }
13729
13730 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013731
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013732 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013733 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053013734 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013735 "%s: HDD context is Null", __func__);
13736 return -ENODEV;
13737 }
13738
13739 /* The return 0 is intentional when isLogpInProgress and
13740 * isLoadUnloadInProgress. We did observe a crash due to a return of
13741 * failure in sched_scan_stop , especially for a case where the unload
13742 * of the happens at the same time. The function __cfg80211_stop_sched_scan
13743 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
13744 * success. If it returns a failure , then its next invocation due to the
13745 * clean up of the second interface will have the dev pointer corresponding
13746 * to the first one leading to a crash.
13747 */
13748 if (pHddCtx->isLogpInProgress)
13749 {
13750 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13751 "%s: LOGP in Progress. Ignore!!!", __func__);
13752 return ret;
13753 }
13754
Mihir Shete18156292014-03-11 15:38:30 +053013755 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013756 {
13757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13758 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
13759 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013760 }
13761
13762 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
13763 if (NULL == hHal)
13764 {
13765 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13766 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013767 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013768 }
13769
13770 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
13771 if (NULL == pPnoRequest)
13772 {
13773 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
13774 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013775 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013776 }
13777
13778 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
13779 pPnoRequest->enable = 0; /* Disable PNO */
13780 pPnoRequest->ucNetworksCount = 0;
13781
13782 status = sme_SetPreferredNetworkList(hHal, pPnoRequest,
13783 pAdapter->sessionId,
13784 NULL, pAdapter);
13785 if (eHAL_STATUS_SUCCESS != status)
13786 {
13787 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13788 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013789 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013790 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013791 }
c_hpothu37f21312014-04-09 21:49:54 +053013792 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013793
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013794error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013795 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013796 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013797 vos_mem_free(pPnoRequest);
13798
13799 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013800 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013801}
13802
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053013803/*
13804 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
13805 * NL interface to disable PNO
13806 */
13807static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
13808 struct net_device *dev)
13809{
13810 int ret;
13811
13812 vos_ssr_protect(__func__);
13813 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
13814 vos_ssr_unprotect(__func__);
13815
13816 return ret;
13817}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013818#endif /*FEATURE_WLAN_SCAN_PNO*/
13819
13820
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013821#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053013822#if TDLS_MGMT_VERSION2
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013823static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
13824 u8 *peer, u8 action_code, u8 dialog_token,
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053013825 u16 status_code, u32 peer_capability, const u8 *buf, size_t len)
13826#else
13827static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
13828 u8 *peer, u8 action_code, u8 dialog_token,
13829 u16 status_code, const u8 *buf, size_t len)
13830#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013831{
13832
13833 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13834 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013835 u8 peerMac[6];
13836 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070013837 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080013838 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070013839 long rc;
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053013840#if !(TDLS_MGMT_VERSION2)
13841 u32 peer_capability = 0;
13842#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053013843 tANI_U16 numCurrTdlsPeers;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013844
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013845 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13846 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
13847 pAdapter->sessionId, action_code));
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013848 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013849 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013850 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013851 "Invalid arguments");
13852 return -EINVAL;
13853 }
13854
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080013855 if (pHddCtx->isLogpInProgress)
13856 {
13857 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13858 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053013859 wlan_hdd_tdls_set_link_status(pAdapter,
13860 peer,
13861 eTDLS_LINK_IDLE,
13862 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080013863 return -EBUSY;
13864 }
13865
Hoonki Lee27511902013-03-14 18:19:06 -070013866 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013867 {
Hoonki Lee27511902013-03-14 18:19:06 -070013868 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
13869 "%s: TDLS mode is disabled OR not enabled in FW."
13870 MAC_ADDRESS_STR " action %d declined.",
13871 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013872 return -ENOTSUPP;
13873 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080013874
Hoonki Lee27511902013-03-14 18:19:06 -070013875 /* other than teardown frame, other mgmt frames are not sent if disabled */
13876 if (SIR_MAC_TDLS_TEARDOWN != action_code)
13877 {
13878 /* if tdls_mode is disabled to respond to peer's request */
13879 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
13880 {
13881 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
13882 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070013883 " TDLS mode is disabled. action %d declined.",
13884 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070013885
13886 return -ENOTSUPP;
13887 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053013888
13889 if (vos_max_concurrent_connections_reached())
13890 {
13891 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
13892 return -EINVAL;
13893 }
Hoonki Lee27511902013-03-14 18:19:06 -070013894 }
13895
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013896 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
13897 {
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053013898 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013899 {
13900 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013901 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070013902 " TDLS setup is ongoing. action %d declined.",
13903 __func__, MAC_ADDR_ARRAY(peer), action_code);
13904 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013905 }
13906 }
13907
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013908 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
13909 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080013910 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053013911 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
13912 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080013913 {
13914 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
13915 we return error code at 'add_station()'. Hence we have this
13916 check again in addtion to add_station().
13917 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013918 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080013919 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013920 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13921 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053013922 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
13923 __func__, MAC_ADDR_ARRAY(peer), action_code,
13924 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053013925 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080013926 }
13927 else
13928 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013929 /* maximum reached. tweak to send error code to peer and return
13930 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080013931 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013932 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13933 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053013934 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
13935 __func__, MAC_ADDR_ARRAY(peer), status_code,
13936 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070013937 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013938 /* fall through to send setup resp with failure status
13939 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080013940 }
13941 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013942 else
13943 {
13944 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053013945 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013946 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013947 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013948 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070013949 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
13950 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013951 return -EPERM;
13952 }
13953 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080013954 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013955 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013956
Hoonki Lee1090c6a2013-01-16 17:40:54 -080013957#ifdef WLAN_FEATURE_TDLS_DEBUG
13958 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053013959 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013960 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
13961 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -080013962#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013963
Hoonki Leea34dd892013-02-05 22:56:02 -080013964 /*Except teardown responder will not be used so just make 0*/
13965 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013966 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080013967 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070013968
13969 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053013970 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070013971
13972 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
13973 responder = pTdlsPeer->is_responder;
13974 else
Hoonki Leea34dd892013-02-05 22:56:02 -080013975 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070013976 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053013977 "%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 -070013978 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
13979 dialog_token, status_code, len);
13980 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080013981 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013982 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013983
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053013984 /* For explicit trigger of DIS_REQ come out of BMPS for
13985 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070013986 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053013987 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
13988 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070013989 {
13990 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
13991 {
13992 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053013993 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Hoonki Lee14621352013-04-16 17:51:19 -070013994 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
13995 }
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053013996 if (SIR_MAC_TDLS_DIS_REQ != action_code)
13997 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
Hoonki Lee14621352013-04-16 17:51:19 -070013998 }
13999
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014000 /* make sure doesn't call send_mgmt() while it is pending */
14001 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
14002 {
14003 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080014004 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014005 __func__, MAC_ADDR_ARRAY(peer), action_code);
14006 return -EBUSY;
14007 }
14008
14009 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014010 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
14011
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014012 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +053014013 peerMac, action_code, dialog_token, status_code, peer_capability, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014014
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014015 if (VOS_STATUS_SUCCESS != status)
14016 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014017 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14018 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014019 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -070014020 wlan_hdd_tdls_check_bmps(pAdapter);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053014021 return -EINVAL;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014022 }
14023
Hoonki Leed37cbb32013-04-20 00:31:14 -070014024 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
14025 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
14026
14027 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014028 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070014029 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070014030 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070014031 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014032 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080014033
14034 if (pHddCtx->isLogpInProgress)
14035 {
14036 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14037 "%s: LOGP in Progress. Ignore!!!", __func__);
14038 return -EAGAIN;
14039 }
14040
Hoonki Leed37cbb32013-04-20 00:31:14 -070014041 wlan_hdd_tdls_check_bmps(pAdapter);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053014042 return -EINVAL;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014043 }
14044
Gopichand Nakkala05922802013-03-14 12:23:19 -070014045 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070014046 {
14047 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -070014048 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070014049 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014050
Hoonki Leea34dd892013-02-05 22:56:02 -080014051 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
14052 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080014053 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -080014054 }
14055 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
14056 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080014057 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -080014058 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014059
14060 return 0;
14061}
14062
Atul Mittal115287b2014-07-08 13:26:33 +053014063
14064int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
14065 u8 *peer,
14066 cfg80211_exttdls_callback callback)
14067{
14068
14069 hddTdlsPeer_t *pTdlsPeer;
14070 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14072 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
14073 __func__, MAC_ADDR_ARRAY(peer));
14074
14075 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
14076 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
14077
14078 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14079 " %s TDLS External control and Implicit Trigger not enabled ",
14080 __func__);
14081 return -ENOTSUPP;
14082 }
14083
14084 /* To cater the requirement of establishing the TDLS link
14085 * irrespective of the data traffic , get an entry of TDLS peer.
14086 */
14087 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
14088 if (pTdlsPeer == NULL) {
14089 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14090 "%s: peer " MAC_ADDRESS_STR " not existing",
14091 __func__, MAC_ADDR_ARRAY(peer));
14092 return -EINVAL;
14093 }
14094
14095 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
14096
14097 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14098 " %s TDLS Add Force Peer Failed",
14099 __func__);
14100 return -EINVAL;
14101 }
14102 /*EXT TDLS*/
14103
14104 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
14105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14106 " %s TDLS set callback Failed",
14107 __func__);
14108 return -EINVAL;
14109 }
14110
14111 return(0);
14112
14113}
14114
14115int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter, u8 *peer)
14116{
14117
14118 hddTdlsPeer_t *pTdlsPeer;
14119 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14120 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14121 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
14122 __func__, MAC_ADDR_ARRAY(peer));
14123
14124 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
14125 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
14126
14127 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14128 " %s TDLS External control and Implicit Trigger not enabled ",
14129 __func__);
14130 return -ENOTSUPP;
14131 }
14132
14133
14134 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
14135
14136 if ( NULL == pTdlsPeer ) {
14137 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
14138 " peer not exsting",
14139 __func__, MAC_ADDR_ARRAY(peer));
14140 return -EINVAL;
14141 }
14142 else {
14143 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
14144 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
14145 }
14146
14147 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) )
14148 return -EINVAL;
14149
14150 /*EXT TDLS*/
14151
14152 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
14153
14154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14155 " %s TDLS set callback Failed",
14156 __func__);
14157 return -EINVAL;
14158 }
14159 return(0);
14160
14161}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014162static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014163 u8 *peer, enum nl80211_tdls_operation oper)
14164{
14165 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14166 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014167 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014168 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014169
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014170 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14171 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
14172 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014173 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014174 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014175 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070014176 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014177 return -EINVAL;
14178 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080014179
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014180 status = wlan_hdd_validate_context(pHddCtx);
14181
14182 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080014183 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014184 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14185 "%s: HDD context is not valid", __func__);
14186 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080014187 }
14188
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014189
14190 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080014191 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014192 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080014193 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070014194 "TDLS Disabled in INI OR not enabled in FW. "
14195 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014196 return -ENOTSUPP;
14197 }
14198
14199 switch (oper) {
14200 case NL80211_TDLS_ENABLE_LINK:
14201 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014202 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014203 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053014204 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014205
Sunil Dutt41de4e22013-11-14 18:09:02 +053014206 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
14207
14208 if ( NULL == pTdlsPeer ) {
14209 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
14210 " (oper %d) not exsting. ignored",
14211 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
14212 return -EINVAL;
14213 }
14214
14215 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14216 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
14217 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
14218 "NL80211_TDLS_ENABLE_LINK");
14219
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070014220 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
14221 {
14222 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
14223 MAC_ADDRESS_STR " failed",
14224 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
14225 return -EINVAL;
14226 }
14227
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014228 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014229 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053014230 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053014231
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053014232 if (0 != wlan_hdd_tdls_get_link_establish_params(
14233 pAdapter, peer,&tdlsLinkEstablishParams)) {
14234 return -EINVAL;
14235 }
14236 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053014237
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053014238 sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter),
14239 pAdapter->sessionId, peer, &tdlsLinkEstablishParams);
14240 /* Send TDLS peer UAPSD capabilities to the firmware and
14241 * register with the TL on after the response for this operation
14242 * is received .
14243 */
14244 ret = wait_for_completion_interruptible_timeout(
14245 &pAdapter->tdls_link_establish_req_comp,
14246 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
14247 if (ret <= 0)
14248 {
14249 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14250 "%s: Link Establish Request Faled Status %ld",
14251 __func__, ret);
14252 return -EINVAL;
14253 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053014254 }
Atul Mittal115287b2014-07-08 13:26:33 +053014255 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
14256 eTDLS_LINK_CONNECTED,
14257 eTDLS_LINK_SUCCESS);
Gopichand Nakkala471708b2013-06-04 20:03:01 +053014258 /* Mark TDLS client Authenticated .*/
14259 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
14260 pTdlsPeer->staId,
14261 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070014262 if (VOS_STATUS_SUCCESS == status)
14263 {
Hoonki Lee14621352013-04-16 17:51:19 -070014264 if (pTdlsPeer->is_responder == 0)
14265 {
14266 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
14267
14268 wlan_hdd_tdls_timer_restart(pAdapter,
14269 &pTdlsPeer->initiatorWaitTimeoutTimer,
14270 WAIT_TIME_TDLS_INITIATOR);
14271 /* suspend initiator TX until it receives direct packet from the
14272 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
14273 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
14274 &staId, NULL);
14275 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070014276 wlan_hdd_tdls_increment_peer_count(pAdapter);
14277 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014278 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053014279
14280 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053014281 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
14282 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053014283 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053014284 int ac;
14285 uint8 ucAc[4] = { WLANTL_AC_VO,
14286 WLANTL_AC_VI,
14287 WLANTL_AC_BK,
14288 WLANTL_AC_BE };
14289 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
14290 for(ac=0; ac < 4; ac++)
14291 {
14292 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
14293 pTdlsPeer->staId, ucAc[ac],
14294 tlTid[ac], tlTid[ac], 0, 0,
14295 WLANTL_BI_DIR );
14296 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053014297 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014298 }
14299
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014300 }
14301 break;
14302 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080014303 {
Sunil Dutt41de4e22013-11-14 18:09:02 +053014304 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
14305
14306 if ( NULL == pTdlsPeer ) {
14307 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
14308 " (oper %d) not exsting. ignored",
14309 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
14310 return -EINVAL;
14311 }
14312
14313 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14314 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
14315 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
14316 "NL80211_TDLS_DISABLE_LINK");
14317
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014318 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080014319 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070014320 long status;
14321
Atul Mittal271a7652014-09-12 13:18:22 +053014322
14323 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
14324 eTDLS_LINK_TEARING,
14325 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
14326 eTDLS_LINK_UNSPECIFIED:
14327 eTDLS_LINK_DROPPED_BY_REMOTE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070014328 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
14329
Lee Hoonkic1262f22013-01-24 21:59:00 -080014330 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
14331 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070014332
14333 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
14334 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Atul Mittal271a7652014-09-12 13:18:22 +053014335 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053014336 eTDLS_LINK_IDLE,
14337 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070014338 if (status <= 0)
14339 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070014340 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14341 "%s: Del station failed status %ld",
14342 __func__, status);
14343 return -EPERM;
14344 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080014345 }
14346 else
14347 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014348 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14349 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080014350 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080014351 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014352 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014353 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053014354 {
Atul Mittal115287b2014-07-08 13:26:33 +053014355 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053014356
Atul Mittal115287b2014-07-08 13:26:33 +053014357 if (0 != status)
14358 {
14359 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14360 "%s: Error in TDLS Teardown", __func__);
14361 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053014362 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053014363 break;
14364 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014365 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053014366 {
Atul Mittal115287b2014-07-08 13:26:33 +053014367 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
14368 peer,
14369 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053014370
Atul Mittal115287b2014-07-08 13:26:33 +053014371 if (0 != status)
14372 {
14373 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14374 "%s: Error in TDLS Setup", __func__);
14375 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053014376 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053014377 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053014378 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014379 case NL80211_TDLS_DISCOVERY_REQ:
14380 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014381 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
14382 "%s: We don't support in-driver setup/teardown/discovery "
14383 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014384 return -ENOTSUPP;
14385 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014386 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14387 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014388 return -ENOTSUPP;
14389 }
14390 return 0;
14391}
Chilam NG571c65a2013-01-19 12:27:36 +053014392
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014393static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
14394 u8 *peer, enum nl80211_tdls_operation oper)
14395{
14396 int ret;
14397
14398 vos_ssr_protect(__func__);
14399 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
14400 vos_ssr_unprotect(__func__);
14401
14402 return ret;
14403}
14404
Chilam NG571c65a2013-01-19 12:27:36 +053014405int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
14406 struct net_device *dev, u8 *peer)
14407{
Arif Hussaina7c8e412013-11-20 11:06:42 -080014408 hddLog(VOS_TRACE_LEVEL_INFO,
14409 "tdls send discover req: "MAC_ADDRESS_STR,
14410 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053014411
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014412#if TDLS_MGMT_VERSION2
14413 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
14414 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
14415#else
Chilam NG571c65a2013-01-19 12:27:36 +053014416 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
14417 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014418#endif
Chilam NG571c65a2013-01-19 12:27:36 +053014419}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014420#endif
14421
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014422#ifdef WLAN_FEATURE_GTK_OFFLOAD
14423/*
14424 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
14425 * Callback rountine called upon receiving response for
14426 * get offload info
14427 */
14428void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
14429 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
14430{
14431
14432 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014433 tANI_U8 tempReplayCounter[8];
14434 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014435
14436 ENTER();
14437
14438 if (NULL == pAdapter)
14439 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053014440 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014441 "%s: HDD adapter is Null", __func__);
14442 return ;
14443 }
14444
14445 if (NULL == pGtkOffloadGetInfoRsp)
14446 {
14447 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14448 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
14449 return ;
14450 }
14451
14452 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
14453 {
14454 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14455 "%s: wlan Failed to get replay counter value",
14456 __func__);
14457 return ;
14458 }
14459
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014460 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14461 /* Update replay counter */
14462 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
14463 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
14464
14465 {
14466 /* changing from little to big endian since supplicant
14467 * works on big endian format
14468 */
14469 int i;
14470 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
14471
14472 for (i = 0; i < 8; i++)
14473 {
14474 tempReplayCounter[7-i] = (tANI_U8)p[i];
14475 }
14476 }
14477
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014478 /* Update replay counter to NL */
14479 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014480 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014481}
14482
14483/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014484 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014485 * This function is used to offload GTK rekeying job to the firmware.
14486 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014487int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014488 struct cfg80211_gtk_rekey_data *data)
14489{
14490 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14491 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
14492 hdd_station_ctx_t *pHddStaCtx;
14493 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014494 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014495 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014496 eHalStatus status = eHAL_STATUS_FAILURE;
14497
14498 ENTER();
14499
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014500
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014501 if (NULL == pAdapter)
14502 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014503 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014504 "%s: HDD adapter is Null", __func__);
14505 return -ENODEV;
14506 }
14507
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014508 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14509 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
14510 pAdapter->sessionId, pAdapter->device_mode));
14511
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014512 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014513
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014514 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014515 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014516 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14517 "%s: HDD context is not valid", __func__);
14518 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014519 }
14520
14521 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14522 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14523 if (NULL == hHal)
14524 {
14525 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14526 "%s: HAL context is Null!!!", __func__);
14527 return -EAGAIN;
14528 }
14529
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014530 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
14531 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
14532 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
14533 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014534 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014535 {
14536 /* changing from big to little endian since driver
14537 * works on little endian format
14538 */
14539 tANI_U8 *p =
14540 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
14541 int i;
14542
14543 for (i = 0; i < 8; i++)
14544 {
14545 p[7-i] = data->replay_ctr[i];
14546 }
14547 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014548
14549 if (TRUE == pHddCtx->hdd_wlan_suspended)
14550 {
14551 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014552 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
14553 sizeof (tSirGtkOffloadParams));
14554 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014555 pAdapter->sessionId);
14556
14557 if (eHAL_STATUS_SUCCESS != status)
14558 {
14559 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14560 "%s: sme_SetGTKOffload failed, returned %d",
14561 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053014562
14563 /* Need to clear any trace of key value in the memory.
14564 * Thus zero out the memory even though it is local
14565 * variable.
14566 */
14567 vos_mem_zero(&hddGtkOffloadReqParams,
14568 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014569 return status;
14570 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014571 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14572 "%s: sme_SetGTKOffload successfull", __func__);
14573 }
14574 else
14575 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14577 "%s: wlan not suspended GTKOffload request is stored",
14578 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014579 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014580
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053014581 /* Need to clear any trace of key value in the memory.
14582 * Thus zero out the memory even though it is local
14583 * variable.
14584 */
14585 vos_mem_zero(&hddGtkOffloadReqParams,
14586 sizeof(hddGtkOffloadReqParams));
14587
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014588 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014589}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014590
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014591int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
14592 struct cfg80211_gtk_rekey_data *data)
14593{
14594 int ret;
14595
14596 vos_ssr_protect(__func__);
14597 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
14598 vos_ssr_unprotect(__func__);
14599
14600 return ret;
14601}
14602#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014603/*
14604 * FUNCTION: wlan_hdd_cfg80211_set_mac_acl
14605 * This function is used to set access control policy
14606 */
14607static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
14608 struct net_device *dev, const struct cfg80211_acl_data *params)
14609{
14610 int i;
14611 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14612 hdd_hostapd_state_t *pHostapdState;
14613 tsap_Config_t *pConfig;
14614 v_CONTEXT_t pVosContext = NULL;
14615 hdd_context_t *pHddCtx;
14616 int status;
14617
14618 ENTER();
14619
14620 if (NULL == pAdapter)
14621 {
14622 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14623 "%s: HDD adapter is Null", __func__);
14624 return -ENODEV;
14625 }
14626
14627 if (NULL == params)
14628 {
14629 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14630 "%s: params is Null", __func__);
14631 return -EINVAL;
14632 }
14633
14634 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14635 status = wlan_hdd_validate_context(pHddCtx);
14636
14637 if (0 != status)
14638 {
14639 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14640 "%s: HDD context is not valid", __func__);
14641 return status;
14642 }
14643
14644 pVosContext = pHddCtx->pvosContext;
14645 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
14646
14647 if (NULL == pHostapdState)
14648 {
14649 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14650 "%s: pHostapdState is Null", __func__);
14651 return -EINVAL;
14652 }
14653
14654 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
14655 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
14656
14657 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
14658 {
14659 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
14660
14661 /* default value */
14662 pConfig->num_accept_mac = 0;
14663 pConfig->num_deny_mac = 0;
14664
14665 /**
14666 * access control policy
14667 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
14668 * listed in hostapd.deny file.
14669 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
14670 * listed in hostapd.accept file.
14671 */
14672 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
14673 {
14674 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
14675 }
14676 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
14677 {
14678 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
14679 }
14680 else
14681 {
14682 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14683 "%s:Acl Policy : %d is not supported",
14684 __func__, params->acl_policy);
14685 return -ENOTSUPP;
14686 }
14687
14688 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
14689 {
14690 pConfig->num_accept_mac = params->n_acl_entries;
14691 for (i = 0; i < params->n_acl_entries; i++)
14692 {
14693 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14694 "** Add ACL MAC entry %i in WhiletList :"
14695 MAC_ADDRESS_STR, i,
14696 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
14697
14698 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
14699 sizeof(qcmacaddr));
14700 }
14701 }
14702 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
14703 {
14704 pConfig->num_deny_mac = params->n_acl_entries;
14705 for (i = 0; i < params->n_acl_entries; i++)
14706 {
14707 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14708 "** Add ACL MAC entry %i in BlackList :"
14709 MAC_ADDRESS_STR, i,
14710 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
14711
14712 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
14713 sizeof(qcmacaddr));
14714 }
14715 }
14716
14717 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
14718 {
14719 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14720 "%s: SAP Set Mac Acl fail", __func__);
14721 return -EINVAL;
14722 }
14723 }
14724 else
14725 {
14726 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053014727 "%s: Invalid device_mode = %s (%d)",
14728 __func__, hdd_device_modetoString(pAdapter->device_mode),
14729 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014730 return -EINVAL;
14731 }
14732
14733 return 0;
14734}
14735
Leo Chang9056f462013-08-01 19:21:11 -070014736#ifdef WLAN_NL80211_TESTMODE
14737#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070014738void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070014739(
14740 void *pAdapter,
14741 void *indCont
14742)
14743{
Leo Changd9df8aa2013-09-26 13:32:26 -070014744 tSirLPHBInd *lphbInd;
14745 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053014746 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070014747
14748 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070014749 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070014750
c_hpothu73f35e62014-04-18 13:40:08 +053014751 if (pAdapter == NULL)
14752 {
14753 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14754 "%s: pAdapter is NULL\n",__func__);
14755 return;
14756 }
14757
Leo Chang9056f462013-08-01 19:21:11 -070014758 if (NULL == indCont)
14759 {
14760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070014761 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070014762 return;
14763 }
14764
c_hpothu73f35e62014-04-18 13:40:08 +053014765 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070014766 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070014767 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053014768 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070014769 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070014770 GFP_ATOMIC);
14771 if (!skb)
14772 {
14773 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14774 "LPHB timeout, NL buffer alloc fail");
14775 return;
14776 }
14777
Leo Changac3ba772013-10-07 09:47:04 -070014778 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070014779 {
14780 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14781 "WLAN_HDD_TM_ATTR_CMD put fail");
14782 goto nla_put_failure;
14783 }
Leo Changac3ba772013-10-07 09:47:04 -070014784 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070014785 {
14786 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14787 "WLAN_HDD_TM_ATTR_TYPE put fail");
14788 goto nla_put_failure;
14789 }
Leo Changac3ba772013-10-07 09:47:04 -070014790 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070014791 sizeof(tSirLPHBInd), lphbInd))
14792 {
14793 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14794 "WLAN_HDD_TM_ATTR_DATA put fail");
14795 goto nla_put_failure;
14796 }
Leo Chang9056f462013-08-01 19:21:11 -070014797 cfg80211_testmode_event(skb, GFP_ATOMIC);
14798 return;
14799
14800nla_put_failure:
14801 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14802 "NLA Put fail");
14803 kfree_skb(skb);
14804
14805 return;
14806}
14807#endif /* FEATURE_WLAN_LPHB */
14808
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014809static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070014810{
14811 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
14812 int err = 0;
14813#ifdef FEATURE_WLAN_LPHB
14814 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070014815 eHalStatus smeStatus;
Leo Chang9056f462013-08-01 19:21:11 -070014816#endif /* FEATURE_WLAN_LPHB */
14817
14818 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
14819 if (err)
14820 {
14821 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14822 "%s Testmode INV ATTR", __func__);
14823 return err;
14824 }
14825
14826 if (!tb[WLAN_HDD_TM_ATTR_CMD])
14827 {
14828 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14829 "%s Testmode INV CMD", __func__);
14830 return -EINVAL;
14831 }
14832
14833 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
14834 {
14835#ifdef FEATURE_WLAN_LPHB
14836 /* Low Power Heartbeat configuration request */
14837 case WLAN_HDD_TM_CMD_WLAN_HB:
14838 {
14839 int buf_len;
14840 void *buf;
14841 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080014842 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070014843
14844 if (!tb[WLAN_HDD_TM_ATTR_DATA])
14845 {
14846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14847 "%s Testmode INV DATA", __func__);
14848 return -EINVAL;
14849 }
14850
14851 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
14852 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080014853
14854 hb_params_temp =(tSirLPHBReq *)buf;
14855 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
14856 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
14857 return -EINVAL;
14858
Leo Chang9056f462013-08-01 19:21:11 -070014859 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
14860 if (NULL == hb_params)
14861 {
14862 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14863 "%s Request Buffer Alloc Fail", __func__);
14864 return -EINVAL;
14865 }
14866
14867 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070014868 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
14869 hb_params,
14870 wlan_hdd_cfg80211_lphb_ind_handler);
14871 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070014872 {
Leo Changd9df8aa2013-09-26 13:32:26 -070014873 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14874 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070014875 vos_mem_free(hb_params);
14876 }
Leo Chang9056f462013-08-01 19:21:11 -070014877 return 0;
14878 }
14879#endif /* FEATURE_WLAN_LPHB */
14880 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014881 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14882 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070014883 return -EOPNOTSUPP;
14884 }
14885
14886 return err;
14887}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014888
14889static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
14890{
14891 int ret;
14892
14893 vos_ssr_protect(__func__);
14894 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
14895 vos_ssr_unprotect(__func__);
14896
14897 return ret;
14898}
Leo Chang9056f462013-08-01 19:21:11 -070014899#endif /* CONFIG_NL80211_TESTMODE */
14900
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014901static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014902 struct net_device *dev,
14903 int idx, struct survey_info *survey)
14904{
14905 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14906 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053014907 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014908 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053014909 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014910 v_S7_t snr,rssi;
14911 int status, i, j, filled = 0;
14912
14913 ENTER();
14914
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014915 if (NULL == pAdapter)
14916 {
14917 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14918 "%s: HDD adapter is Null", __func__);
14919 return -ENODEV;
14920 }
14921
14922 if (NULL == wiphy)
14923 {
14924 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14925 "%s: wiphy is Null", __func__);
14926 return -ENODEV;
14927 }
14928
14929 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14930 status = wlan_hdd_validate_context(pHddCtx);
14931
14932 if (0 != status)
14933 {
14934 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14935 "%s: HDD context is not valid", __func__);
14936 return status;
14937 }
14938
Mihir Sheted9072e02013-08-21 17:02:29 +053014939 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14940
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014941 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053014942 0 != pAdapter->survey_idx ||
14943 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014944 {
14945 /* The survey dump ops when implemented completely is expected to
14946 * return a survey of all channels and the ops is called by the
14947 * kernel with incremental values of the argument 'idx' till it
14948 * returns -ENONET. But we can only support the survey for the
14949 * operating channel for now. survey_idx is used to track
14950 * that the ops is called only once and then return -ENONET for
14951 * the next iteration
14952 */
14953 pAdapter->survey_idx = 0;
14954 return -ENONET;
14955 }
14956
14957 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14958
14959 wlan_hdd_get_snr(pAdapter, &snr);
14960 wlan_hdd_get_rssi(pAdapter, &rssi);
14961
14962 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
14963 hdd_wlan_get_freq(channel, &freq);
14964
14965
14966 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
14967 {
14968 if (NULL == wiphy->bands[i])
14969 {
14970 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
14971 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
14972 continue;
14973 }
14974
14975 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
14976 {
14977 struct ieee80211_supported_band *band = wiphy->bands[i];
14978
14979 if (band->channels[j].center_freq == (v_U16_t)freq)
14980 {
14981 survey->channel = &band->channels[j];
14982 /* The Rx BDs contain SNR values in dB for the received frames
14983 * while the supplicant expects noise. So we calculate and
14984 * return the value of noise (dBm)
14985 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
14986 */
14987 survey->noise = rssi - snr;
14988 survey->filled = SURVEY_INFO_NOISE_DBM;
14989 filled = 1;
14990 }
14991 }
14992 }
14993
14994 if (filled)
14995 pAdapter->survey_idx = 1;
14996 else
14997 {
14998 pAdapter->survey_idx = 0;
14999 return -ENONET;
15000 }
15001
15002 return 0;
15003}
15004
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015005static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
15006 struct net_device *dev,
15007 int idx, struct survey_info *survey)
15008{
15009 int ret;
15010
15011 vos_ssr_protect(__func__);
15012 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
15013 vos_ssr_unprotect(__func__);
15014
15015 return ret;
15016}
15017
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053015018/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053015019 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053015020 * this is called when cfg80211 driver resume
15021 * driver updates latest sched_scan scan result(if any) to cfg80211 database
15022 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053015023int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053015024{
15025 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
15026 hdd_adapter_t *pAdapter;
15027 hdd_adapter_list_node_t *pAdapterNode, *pNext;
15028 VOS_STATUS status = VOS_STATUS_SUCCESS;
15029
15030 ENTER();
15031
15032 if ( NULL == pHddCtx )
15033 {
15034 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15035 "%s: HddCtx validation failed", __func__);
15036 return 0;
15037 }
15038
15039 if (pHddCtx->isLogpInProgress)
15040 {
15041 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15042 "%s: LOGP in Progress. Ignore!!!", __func__);
15043 return 0;
15044 }
15045
Mihir Shete18156292014-03-11 15:38:30 +053015046 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053015047 {
15048 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15049 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
15050 return 0;
15051 }
15052
15053 spin_lock(&pHddCtx->schedScan_lock);
15054 pHddCtx->isWiphySuspended = FALSE;
15055 if (TRUE != pHddCtx->isSchedScanUpdatePending)
15056 {
15057 spin_unlock(&pHddCtx->schedScan_lock);
15058 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15059 "%s: Return resume is not due to PNO indication", __func__);
15060 return 0;
15061 }
15062 // Reset flag to avoid updatating cfg80211 data old results again
15063 pHddCtx->isSchedScanUpdatePending = FALSE;
15064 spin_unlock(&pHddCtx->schedScan_lock);
15065
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053015066
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053015067 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
15068
15069 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
15070 {
15071 pAdapter = pAdapterNode->pAdapter;
15072 if ( (NULL != pAdapter) &&
15073 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
15074 {
15075 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053015076 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053015077 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
15078 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053015079 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053015080 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053015081 {
15082 /* Acquire wakelock to handle the case where APP's tries to
15083 * suspend immediately after updating the scan results. Whis
15084 * results in app's is in suspended state and not able to
15085 * process the connect request to AP
15086 */
15087 hdd_prevent_suspend_timeout(2000);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053015088 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053015089 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053015090
15091 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15092 "%s : cfg80211 scan result database updated", __func__);
15093
15094 return 0;
15095
15096 }
15097 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
15098 pAdapterNode = pNext;
15099 }
15100
15101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15102 "%s: Failed to find Adapter", __func__);
15103 return 0;
15104}
15105
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053015106int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
15107{
15108 int ret;
15109
15110 vos_ssr_protect(__func__);
15111 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
15112 vos_ssr_unprotect(__func__);
15113
15114 return ret;
15115}
15116
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053015117/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053015118 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053015119 * this is called when cfg80211 driver suspends
15120 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053015121int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053015122 struct cfg80211_wowlan *wow)
15123{
15124 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
15125
15126 ENTER();
15127 if (NULL == pHddCtx)
15128 {
15129 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15130 "%s: HddCtx validation failed", __func__);
15131 return 0;
15132 }
15133
15134 pHddCtx->isWiphySuspended = TRUE;
15135
15136 EXIT();
15137
15138 return 0;
15139}
15140
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053015141int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
15142 struct cfg80211_wowlan *wow)
15143{
15144 int ret;
15145
15146 vos_ssr_protect(__func__);
15147 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
15148 vos_ssr_unprotect(__func__);
15149
15150 return ret;
15151}
Jeff Johnson295189b2012-06-20 16:38:30 -070015152/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015153static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070015154{
15155 .add_virtual_intf = wlan_hdd_add_virtual_intf,
15156 .del_virtual_intf = wlan_hdd_del_virtual_intf,
15157 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
15158 .change_station = wlan_hdd_change_station,
15159#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
15160 .add_beacon = wlan_hdd_cfg80211_add_beacon,
15161 .del_beacon = wlan_hdd_cfg80211_del_beacon,
15162 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015163#else
15164 .start_ap = wlan_hdd_cfg80211_start_ap,
15165 .change_beacon = wlan_hdd_cfg80211_change_beacon,
15166 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070015167#endif
15168 .change_bss = wlan_hdd_cfg80211_change_bss,
15169 .add_key = wlan_hdd_cfg80211_add_key,
15170 .get_key = wlan_hdd_cfg80211_get_key,
15171 .del_key = wlan_hdd_cfg80211_del_key,
15172 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080015173#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070015174 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080015175#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015176 .scan = wlan_hdd_cfg80211_scan,
15177 .connect = wlan_hdd_cfg80211_connect,
15178 .disconnect = wlan_hdd_cfg80211_disconnect,
15179 .join_ibss = wlan_hdd_cfg80211_join_ibss,
15180 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
15181 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
15182 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
15183 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070015184 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
15185 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053015186 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070015187#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
15188 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
15189 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
15190 .set_txq_params = wlan_hdd_set_txq_params,
15191#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015192 .get_station = wlan_hdd_cfg80211_get_station,
15193 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
15194 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015195 .add_station = wlan_hdd_cfg80211_add_station,
15196#ifdef FEATURE_WLAN_LFR
15197 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
15198 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
15199 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
15200#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070015201#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
15202 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
15203#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015204#ifdef FEATURE_WLAN_TDLS
15205 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
15206 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
15207#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015208#ifdef WLAN_FEATURE_GTK_OFFLOAD
15209 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
15210#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015211#ifdef FEATURE_WLAN_SCAN_PNO
15212 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
15213 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
15214#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053015215 .resume = wlan_hdd_cfg80211_resume_wlan,
15216 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015217 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070015218#ifdef WLAN_NL80211_TESTMODE
15219 .testmode_cmd = wlan_hdd_cfg80211_testmode,
15220#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015221 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070015222};
15223