blob: 61f999f62b832c477238a48e7cf3ea3eb6497498 [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;
838
Sunil Duttc69bccb2014-05-26 21:30:20 +0530839 if (FALSE == put_wifi_interface_info(
840 &pWifiIfaceStat->info,
841 vendor_event))
842 {
843 hddLog(VOS_TRACE_LEVEL_ERROR,
844 FL("QCA_WLAN_VENDOR_ATTR put fail") );
845 return FALSE;
846
847 }
Dino Mycle3b9536d2014-07-09 22:05:24 +0530848 pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *)
849 vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType));
850 if (NULL == pWifiIfaceStatTL)
851 {
852 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
853 return FALSE;
854 }
855
856
857 if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED)
858 {
859 if (VOS_STATUS_SUCCESS ==
860 WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
861 pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL))
862 {
863 /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are
864 * obtained from TL structure
865 */
866
867 pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx +
868 pWifiIfaceStatTL->mgmtRx;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530869 pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData;
870
Srinivas Dasari98947432014-11-07 19:41:24 +0530871 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMcast
872 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMcast;
873 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMcast
874 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMcast;
875 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMcast
876 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMcast;
877 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMcast
878 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMcast;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530879
Srinivas Dasari98947432014-11-07 19:41:24 +0530880 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMpdu
881 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMpdu;
882 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMpdu
883 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMpdu;
884 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMpdu
885 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMpdu;
886 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMpdu
887 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530888
Srinivas Dasari98947432014-11-07 19:41:24 +0530889 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxAmpdu
890 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxAmpdu;
891 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxAmpdu
892 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxAmpdu;
893 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxAmpdu
894 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxAmpdu;
895 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxAmpdu
896 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxAmpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530897 }
898 else
899 {
900 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL"));
901 }
902
Dino Mycle3b9536d2014-07-09 22:05:24 +0530903 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast =
904 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO];
905 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast =
906 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI];
907 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast =
908 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE];
909 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast =
910 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK];
911 }
912 else
913 {
914 hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated"));
915 }
916
917
Sunil Duttc69bccb2014-05-26 21:30:20 +0530918
919 if (nla_put_u32(vendor_event,
920 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
921 pWifiIfaceStat->beaconRx) ||
922 nla_put_u32(vendor_event,
923 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
924 pWifiIfaceStat->mgmtRx) ||
925 nla_put_u32(vendor_event,
926 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
927 pWifiIfaceStat->mgmtActionRx) ||
928 nla_put_u32(vendor_event,
929 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
930 pWifiIfaceStat->mgmtActionTx) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +0530931 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530932 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
933 pWifiIfaceStat->rssiMgmt) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +0530934 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530935 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
936 pWifiIfaceStat->rssiData) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +0530937 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530938 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
939 pWifiIfaceStat->rssiAck))
940 {
941 hddLog(VOS_TRACE_LEVEL_ERROR,
942 FL("QCA_WLAN_VENDOR_ATTR put fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +0530943 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +0530944 return FALSE;
945 }
946
947 wmmInfo = nla_nest_start(vendor_event,
948 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
949 for (i = 0; i < WIFI_AC_MAX; i++)
950 {
951 struct nlattr *wmmStats;
952 wmmStats = nla_nest_start(vendor_event, i);
953 if (FALSE == put_wifi_wmm_ac_stat(
954 &pWifiIfaceStat->AccessclassStats[i],
955 vendor_event))
956 {
957 hddLog(VOS_TRACE_LEVEL_ERROR,
958 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +0530959 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +0530960 return FALSE;
961 }
962
963 nla_nest_end(vendor_event, wmmStats);
964 }
965 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +0530966 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +0530967 return TRUE;
968}
969
970static tSirWifiInterfaceMode
971 hdd_map_device_to_ll_iface_mode ( int deviceMode )
972{
973 switch (deviceMode)
974 {
975 case WLAN_HDD_INFRA_STATION:
976 return WIFI_INTERFACE_STA;
977 case WLAN_HDD_SOFTAP:
978 return WIFI_INTERFACE_SOFTAP;
979 case WLAN_HDD_P2P_CLIENT:
980 return WIFI_INTERFACE_P2P_CLIENT;
981 case WLAN_HDD_P2P_GO:
982 return WIFI_INTERFACE_P2P_GO;
983 case WLAN_HDD_IBSS:
984 return WIFI_INTERFACE_IBSS;
985 default:
Dino Myclec8f3f332014-07-21 16:48:27 +0530986 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530987 }
988}
989
990static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
991 tpSirWifiInterfaceInfo pInfo)
992{
993 v_U8_t *staMac = NULL;
994 hdd_station_ctx_t *pHddStaCtx;
995 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
996 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
997
998 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
999
1000 vos_mem_copy(pInfo->macAddr,
1001 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1002
1003 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1004 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
1005 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
1006 {
1007 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1008 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
1009 {
1010 pInfo->state = WIFI_DISCONNECTED;
1011 }
1012 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
1013 {
1014 hddLog(VOS_TRACE_LEVEL_ERROR,
1015 "%s: Session ID %d, Connection is in progress", __func__,
1016 pAdapter->sessionId);
1017 pInfo->state = WIFI_ASSOCIATING;
1018 }
1019 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1020 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
1021 {
1022 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
1023 hddLog(VOS_TRACE_LEVEL_ERROR,
1024 "%s: client " MAC_ADDRESS_STR
1025 " is in the middle of WPS/EAPOL exchange.", __func__,
1026 MAC_ADDR_ARRAY(staMac));
1027 pInfo->state = WIFI_AUTHENTICATING;
1028 }
1029 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1030 {
1031 pInfo->state = WIFI_ASSOCIATED;
1032 vos_mem_copy(pInfo->bssid,
1033 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
1034 vos_mem_copy(pInfo->ssid,
1035 pHddStaCtx->conn_info.SSID.SSID.ssId,
1036 pHddStaCtx->conn_info.SSID.SSID.length);
1037 //NULL Terminate the string.
1038 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
1039 }
1040 }
1041 vos_mem_copy(pInfo->countryStr,
1042 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1043
1044 vos_mem_copy(pInfo->apCountryStr,
1045 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1046
1047 return TRUE;
1048}
1049
1050/*
1051 * hdd_link_layer_process_peer_stats () - This function is called after
1052 * receiving Link Layer Peer statistics from FW.This function converts
1053 * the firmware data to the NL data and sends the same to the kernel/upper
1054 * layers.
1055 */
1056static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
1057 v_VOID_t *pData)
1058{
1059 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1060 tpSirWifiRateStat pWifiRateStat;
1061 tpSirWifiPeerStat pWifiPeerStat;
1062 tpSirWifiPeerInfo pWifiPeerInfo;
1063 struct nlattr *peerInfo;
1064 struct sk_buff *vendor_event;
1065 int status, i;
1066
1067 status = wlan_hdd_validate_context(pHddCtx);
1068 if (0 != status)
1069 {
1070 hddLog(VOS_TRACE_LEVEL_ERROR,
1071 FL("HDD context is not valid") );
1072 return;
1073 }
1074
1075 pWifiPeerStat = (tpSirWifiPeerStat) pData;
1076
1077 hddLog(VOS_TRACE_LEVEL_INFO,
1078 "LL_STATS_PEER_ALL : numPeers %u",
1079 pWifiPeerStat->numPeers);
1080 {
1081 for (i = 0; i < pWifiPeerStat->numPeers; i++)
1082 {
1083 pWifiPeerInfo = (tpSirWifiPeerInfo)
1084 ((uint8 *)pWifiPeerStat->peerInfo +
1085 ( i * sizeof(tSirWifiPeerInfo)));
1086
Dasari Srinivas1be0c4e2014-10-19 13:03:41 +05301087 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) {
1088 pWifiPeerInfo->type = WIFI_PEER_AP;
1089 }
1090 if (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) {
1091 pWifiPeerInfo->type = WIFI_PEER_P2P_GO;
1092 }
1093
Sunil Duttc69bccb2014-05-26 21:30:20 +05301094 hddLog(VOS_TRACE_LEVEL_INFO,
1095 " %d) LL_STATS Channel Stats "
1096 " Peer Type %u "
1097 " peerMacAddress %pM "
1098 " capabilities 0x%x "
1099 " numRate %u ",
1100 i,
1101 pWifiPeerInfo->type,
1102 pWifiPeerInfo->peerMacAddress,
1103 pWifiPeerInfo->capabilities,
1104 pWifiPeerInfo->numRate);
1105 {
1106 int j;
1107 for (j = 0; j < pWifiPeerInfo->numRate; j++)
1108 {
1109 pWifiRateStat = (tpSirWifiRateStat)
1110 ((tANI_U8 *) pWifiPeerInfo->rateStats +
1111 ( j * sizeof(tSirWifiRateStat)));
1112
1113 hddLog(VOS_TRACE_LEVEL_INFO,
1114 " peer Rate Stats "
1115 " preamble %u "
1116 " nss %u "
1117 " bw %u "
1118 " rateMcsIdx %u "
1119 " reserved %u "
1120 " bitrate %u "
1121 " txMpdu %u "
1122 " rxMpdu %u "
1123 " mpduLost %u "
1124 " retries %u "
1125 " retriesShort %u "
1126 " retriesLong %u",
1127 pWifiRateStat->rate.preamble,
1128 pWifiRateStat->rate.nss,
1129 pWifiRateStat->rate.bw,
1130 pWifiRateStat->rate.rateMcsIdx,
1131 pWifiRateStat->rate.reserved,
1132 pWifiRateStat->rate.bitrate,
1133 pWifiRateStat->txMpdu,
1134 pWifiRateStat->rxMpdu,
1135 pWifiRateStat->mpduLost,
1136 pWifiRateStat->retries,
1137 pWifiRateStat->retriesShort,
1138 pWifiRateStat->retriesLong);
1139 }
1140 }
1141 }
1142 }
1143
1144 /*
1145 * Allocate a size of 4096 for the peer stats comprising
1146 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1147 * sizeof (tSirWifiRateStat).Each field is put with an
1148 * NL attribute.The size of 4096 is considered assuming
1149 * that number of rates shall not exceed beyond 50 with
1150 * the sizeof (tSirWifiRateStat) being 32.
1151 */
1152 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1153 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1154 QCA_NL80211_VENDOR_SUBCMD_LL_PEER_INFO_STATS_INDEX,
1155 GFP_KERNEL);
1156 if (!vendor_event)
1157 {
1158 hddLog(VOS_TRACE_LEVEL_ERROR,
1159 "%s: cfg80211_vendor_event_alloc failed",
1160 __func__);
1161 return;
1162 }
1163 if (nla_put_u32(vendor_event,
1164 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1165 pWifiPeerStat->numPeers))
1166 {
1167 hddLog(VOS_TRACE_LEVEL_ERROR,
1168 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1169 kfree_skb(vendor_event);
1170 return;
1171 }
1172
1173 peerInfo = nla_nest_start(vendor_event,
1174 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
1175
1176 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1177 pWifiPeerStat->peerInfo);
1178
1179 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1180 {
1181 struct nlattr *peers = nla_nest_start(vendor_event, i);
1182 int numRate = pWifiPeerInfo->numRate;
1183
1184 if (FALSE == put_wifi_peer_info(
1185 pWifiPeerInfo, vendor_event))
1186 {
1187 hddLog(VOS_TRACE_LEVEL_ERROR,
1188 "%s: put_wifi_peer_info put fail", __func__);
1189 kfree_skb(vendor_event);
1190 return;
1191 }
1192
1193 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1194 pWifiPeerStat->peerInfo +
1195 (i * sizeof(tSirWifiPeerInfo)) +
1196 (numRate * sizeof (tSirWifiRateStat)));
1197 nla_nest_end(vendor_event, peers);
1198 }
1199 nla_nest_end(vendor_event, peerInfo);
1200 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
1201}
1202
1203/*
1204 * hdd_link_layer_process_iface_stats () - This function is called after
1205 * receiving Link Layer Interface statistics from FW.This function converts
1206 * the firmware data to the NL data and sends the same to the kernel/upper
1207 * layers.
1208 */
1209static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1210 v_VOID_t *pData)
1211{
1212 tpSirWifiIfaceStat pWifiIfaceStat;
1213 struct sk_buff *vendor_event;
1214 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1215 int status;
1216
1217 status = wlan_hdd_validate_context(pHddCtx);
1218 if (0 != status)
1219 {
1220 hddLog(VOS_TRACE_LEVEL_ERROR,
1221 FL("HDD context is not valid") );
1222 return;
1223 }
1224 /*
1225 * Allocate a size of 4096 for the interface stats comprising
1226 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1227 * assuming that all these fit with in the limit.Please take
1228 * a call on the limit based on the data requirements on
1229 * interface statistics.
1230 */
1231 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1232 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1233 QCA_NL80211_VENDOR_SUBCMD_LL_IFACE_STATS_INDEX,
1234 GFP_KERNEL);
1235 if (!vendor_event)
1236 {
1237 hddLog(VOS_TRACE_LEVEL_ERROR,
1238 FL("cfg80211_vendor_event_alloc failed") );
1239 return;
1240 }
1241
1242 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1243
Dino Mycle3b9536d2014-07-09 22:05:24 +05301244
1245 if (FALSE == hdd_get_interface_info( pAdapter,
1246 &pWifiIfaceStat->info))
1247 {
1248 hddLog(VOS_TRACE_LEVEL_ERROR,
1249 FL("hdd_get_interface_info get fail") );
1250 kfree_skb(vendor_event);
1251 return;
1252 }
1253
1254 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
1255 vendor_event))
1256 {
1257 hddLog(VOS_TRACE_LEVEL_ERROR,
1258 FL("put_wifi_iface_stats fail") );
1259 kfree_skb(vendor_event);
1260 return;
1261 }
1262
Sunil Duttc69bccb2014-05-26 21:30:20 +05301263 hddLog(VOS_TRACE_LEVEL_INFO,
1264 "WMI_LINK_STATS_IFACE Data");
1265
1266 hddLog(VOS_TRACE_LEVEL_INFO,
1267 "LL_STATS_IFACE: "
1268 " Mode %u "
1269 " MAC %pM "
1270 " State %u "
1271 " Roaming %u "
1272 " capabilities 0x%x "
1273 " SSID %s "
1274 " BSSID %pM",
1275 pWifiIfaceStat->info.mode,
1276 pWifiIfaceStat->info.macAddr,
1277 pWifiIfaceStat->info.state,
1278 pWifiIfaceStat->info.roaming,
1279 pWifiIfaceStat->info.capabilities,
1280 pWifiIfaceStat->info.ssid,
1281 pWifiIfaceStat->info.bssid);
1282
1283 hddLog(VOS_TRACE_LEVEL_INFO,
1284 " AP country str: %c%c%c",
1285 pWifiIfaceStat->info.apCountryStr[0],
1286 pWifiIfaceStat->info.apCountryStr[1],
1287 pWifiIfaceStat->info.apCountryStr[2]);
1288
1289
1290 hddLog(VOS_TRACE_LEVEL_INFO,
1291 " Country Str Association: %c%c%c",
1292 pWifiIfaceStat->info.countryStr[0],
1293 pWifiIfaceStat->info.countryStr[1],
1294 pWifiIfaceStat->info.countryStr[2]);
1295
1296 hddLog(VOS_TRACE_LEVEL_INFO,
1297 " beaconRx %u "
1298 " mgmtRx %u "
1299 " mgmtActionRx %u "
1300 " mgmtActionTx %u "
Dino Mycle3b9536d2014-07-09 22:05:24 +05301301 " rssiMgmt %d "
1302 " rssiData %d "
1303 " rssiAck %d",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301304 pWifiIfaceStat->beaconRx,
1305 pWifiIfaceStat->mgmtRx,
1306 pWifiIfaceStat->mgmtActionRx,
1307 pWifiIfaceStat->mgmtActionTx,
1308 pWifiIfaceStat->rssiMgmt,
1309 pWifiIfaceStat->rssiData,
1310 pWifiIfaceStat->rssiAck );
1311
1312
1313 {
1314 int i;
1315 for (i = 0 ; i < WIFI_AC_MAX; i ++)
1316 {
1317 hddLog(VOS_TRACE_LEVEL_INFO,
1318
1319 " %d) LL_STATS IFACE: "
1320 " ac: %u txMpdu: %u "
1321 " rxMpdu: %u txMcast: %u "
1322 " rxMcast: %u rxAmpdu: %u "
1323 " txAmpdu: %u mpduLost: %u "
1324 " retries: %u retriesShort: %u "
1325 " retriesLong: %u contentionTimeMin: %u "
1326 " contentionTimeMax: %u contentionTimeAvg: %u "
1327 " contentionNumSamples: %u",
1328 i,
1329 pWifiIfaceStat->AccessclassStats[i].ac,
1330 pWifiIfaceStat->AccessclassStats[i].txMpdu,
1331 pWifiIfaceStat->AccessclassStats[i].rxMpdu,
1332 pWifiIfaceStat->AccessclassStats[i].txMcast,
1333 pWifiIfaceStat->AccessclassStats[i].rxMcast,
1334 pWifiIfaceStat->AccessclassStats[i].rxAmpdu,
1335 pWifiIfaceStat->AccessclassStats[i].txAmpdu,
1336 pWifiIfaceStat->AccessclassStats[i].mpduLost,
1337 pWifiIfaceStat->AccessclassStats[i].retries,
1338 pWifiIfaceStat->
1339 AccessclassStats[i].retriesShort,
1340 pWifiIfaceStat->AccessclassStats[i].retriesLong,
1341 pWifiIfaceStat->
1342 AccessclassStats[i].contentionTimeMin,
1343 pWifiIfaceStat->
1344 AccessclassStats[i].contentionTimeMax,
1345 pWifiIfaceStat->
1346 AccessclassStats[i].contentionTimeAvg,
1347 pWifiIfaceStat->
1348 AccessclassStats[i].contentionNumSamples);
1349
1350 }
1351 }
1352
Sunil Duttc69bccb2014-05-26 21:30:20 +05301353 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
1354}
1355
1356/*
1357 * hdd_link_layer_process_radio_stats () - This function is called after
1358 * receiving Link Layer Radio statistics from FW.This function converts
1359 * the firmware data to the NL data and sends the same to the kernel/upper
1360 * layers.
1361 */
1362static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1363 v_VOID_t *pData)
1364{
1365 int status, i;
1366 tpSirWifiRadioStat pWifiRadioStat;
1367 tpSirWifiChannelStats pWifiChannelStats;
1368 struct sk_buff *vendor_event;
1369 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1370 struct nlattr *chList;
1371
1372 status = wlan_hdd_validate_context(pHddCtx);
1373 if (0 != status)
1374 {
1375 hddLog(VOS_TRACE_LEVEL_ERROR,
1376 FL("HDD context is not valid") );
1377 return;
1378 }
1379 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1380
1381 hddLog(VOS_TRACE_LEVEL_INFO,
1382 "LL_STATS_RADIO"
1383 " radio is %d onTime is %u "
1384 " txTime is %u rxTime is %u "
1385 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05301386 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05301387 " onTimePnoScan is %u onTimeHs20 is %u "
1388 " numChannels is %u",
1389 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1390 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1391 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301392 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301393 pWifiRadioStat->onTimeRoamScan,
1394 pWifiRadioStat->onTimePnoScan,
1395 pWifiRadioStat->onTimeHs20,
1396 pWifiRadioStat->numChannels);
1397 /*
1398 * Allocate a size of 4096 for the Radio stats comprising
1399 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1400 * (tSirWifiChannelStats).Each channel data is put with an
1401 * NL attribute.The size of 4096 is considered assuming that
1402 * number of channels shall not exceed beyond 60 with the
1403 * sizeof (tSirWifiChannelStats) being 24 bytes.
1404 */
1405
1406 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1407 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN ,
1408 QCA_NL80211_VENDOR_SUBCMD_LL_RADIO_STATS_INDEX,
1409 GFP_KERNEL);
1410
1411 if (!vendor_event)
1412 {
1413 hddLog(VOS_TRACE_LEVEL_ERROR,
1414 FL("cfg80211_vendor_event_alloc failed") );
1415 return;
1416 }
1417
1418 if (nla_put_u32(vendor_event,
1419 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1420 pWifiRadioStat->radio) ||
1421 nla_put_u32(vendor_event,
1422 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1423 pWifiRadioStat->onTime) ||
1424 nla_put_u32(vendor_event,
1425 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1426 pWifiRadioStat->txTime) ||
1427 nla_put_u32(vendor_event,
1428 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1429 pWifiRadioStat->rxTime) ||
1430 nla_put_u32(vendor_event,
1431 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1432 pWifiRadioStat->onTimeScan) ||
1433 nla_put_u32(vendor_event,
1434 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1435 pWifiRadioStat->onTimeNbd) ||
1436 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301437 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
1438 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05301439 nla_put_u32(vendor_event,
1440 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1441 pWifiRadioStat->onTimeRoamScan) ||
1442 nla_put_u32(vendor_event,
1443 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1444 pWifiRadioStat->onTimePnoScan) ||
1445 nla_put_u32(vendor_event,
1446 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1447 pWifiRadioStat->onTimeHs20) ||
1448 nla_put_u32(vendor_event,
1449 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1450 pWifiRadioStat->numChannels))
1451 {
1452 hddLog(VOS_TRACE_LEVEL_ERROR,
1453 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1454 kfree_skb(vendor_event);
1455 return ;
1456 }
1457
1458 chList = nla_nest_start(vendor_event,
1459 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
1460 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1461 {
1462 struct nlattr *chInfo;
1463
1464 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1465 pWifiRadioStat->channels +
1466 (i * sizeof(tSirWifiChannelStats)));
1467
1468 hddLog(VOS_TRACE_LEVEL_INFO,
1469 " %d) Channel Info"
1470 " width is %u "
1471 " CenterFreq %u "
1472 " CenterFreq0 %u "
1473 " CenterFreq1 %u "
1474 " onTime %u "
1475 " ccaBusyTime %u",
1476 i,
1477 pWifiChannelStats->channel.width,
1478 pWifiChannelStats->channel.centerFreq,
1479 pWifiChannelStats->channel.centerFreq0,
1480 pWifiChannelStats->channel.centerFreq1,
1481 pWifiChannelStats->onTime,
1482 pWifiChannelStats->ccaBusyTime);
1483
1484
1485 chInfo = nla_nest_start(vendor_event, i);
1486
1487 if (nla_put_u32(vendor_event,
1488 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1489 pWifiChannelStats->channel.width) ||
1490 nla_put_u32(vendor_event,
1491 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1492 pWifiChannelStats->channel.centerFreq) ||
1493 nla_put_u32(vendor_event,
1494 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1495 pWifiChannelStats->channel.centerFreq0) ||
1496 nla_put_u32(vendor_event,
1497 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1498 pWifiChannelStats->channel.centerFreq1) ||
1499 nla_put_u32(vendor_event,
1500 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1501 pWifiChannelStats->onTime) ||
1502 nla_put_u32(vendor_event,
1503 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1504 pWifiChannelStats->ccaBusyTime))
1505 {
1506 hddLog(VOS_TRACE_LEVEL_ERROR,
1507 FL("cfg80211_vendor_event_alloc failed") );
1508 kfree_skb(vendor_event);
1509 return ;
1510 }
1511 nla_nest_end(vendor_event, chInfo);
1512 }
1513 nla_nest_end(vendor_event, chList);
1514
1515 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
1516 return;
1517}
1518
1519/*
1520 * hdd_link_layer_stats_ind_callback () - This function is called after
1521 * receiving Link Layer indications from FW.This callback converts the firmware
1522 * data to the NL data and send the same to the kernel/upper layers.
1523 */
1524static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1525 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05301526 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301527{
Dino Mycled3d50022014-07-07 12:58:25 +05301528 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
1529 hdd_adapter_t *pAdapter = NULL;
1530 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301531 int status;
1532
1533 status = wlan_hdd_validate_context(pHddCtx);
1534
1535 if (0 != status)
1536 {
1537 hddLog(VOS_TRACE_LEVEL_ERROR,
1538 FL("HDD context is not valid"));
1539 return;
1540 }
1541
Dino Mycled3d50022014-07-07 12:58:25 +05301542
1543
1544 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
1545 if (NULL == pAdapter)
1546 {
1547 hddLog(VOS_TRACE_LEVEL_ERROR,
1548 FL(" MAC address %pM does not exist with host"),
1549 macAddr);
1550 return;
1551 }
1552
Sunil Duttc69bccb2014-05-26 21:30:20 +05301553 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301554 "%s: Interface: %s LLStats indType: %d", __func__,
1555 pAdapter->dev->name, indType);
1556
Sunil Duttc69bccb2014-05-26 21:30:20 +05301557 switch (indType)
1558 {
1559 case SIR_HAL_LL_STATS_RESULTS_RSP:
1560 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301561 hddLog(VOS_TRACE_LEVEL_INFO,
1562 FL("RESPONSE SIR_HAL_LL_STATS_RESULTS_RSP") );
1563 hddLog(VOS_TRACE_LEVEL_INFO,
1564 "LL_STATS RESULTS RESPONSE paramID = 0x%x",
1565 linkLayerStatsResults->paramId);
1566 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301567 "LL_STATS RESULTS RESPONSE ifaceId = %u MAC: %pM",
1568 linkLayerStatsResults->ifaceId, macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301569 hddLog(VOS_TRACE_LEVEL_INFO,
1570 "LL_STATS RESULTS RESPONSE respId = %u",
1571 linkLayerStatsResults->respId);
1572 hddLog(VOS_TRACE_LEVEL_INFO,
1573 "LL_STATS RESULTS RESPONSE moreResultToFollow = %u",
1574 linkLayerStatsResults->moreResultToFollow);
1575 hddLog(VOS_TRACE_LEVEL_INFO,
1576 "LL_STATS RESULTS RESPONSE result = %p",
1577 linkLayerStatsResults->result);
1578 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1579 {
1580 hdd_link_layer_process_radio_stats(pAdapter,
1581 (v_VOID_t *)linkLayerStatsResults->result);
1582 }
1583 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1584 {
1585 hdd_link_layer_process_iface_stats(pAdapter,
1586 (v_VOID_t *)linkLayerStatsResults->result);
1587 }
1588 else if ( linkLayerStatsResults->paramId &
1589 WMI_LINK_STATS_ALL_PEER )
1590 {
1591 hdd_link_layer_process_peer_stats(pAdapter,
1592 (v_VOID_t *)linkLayerStatsResults->result);
1593 } /* WMI_LINK_STATS_ALL_PEER */
1594 else
1595 {
1596 hddLog(VOS_TRACE_LEVEL_ERROR,
1597 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1598 }
1599
1600 break;
1601 }
1602 default:
1603 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1604 break;
1605 }
1606 return;
1607}
1608
1609const struct
1610nla_policy
1611qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1612{
1613 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1614 { .type = NLA_U32 },
1615 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1616 { .type = NLA_U32 },
1617};
1618
1619static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1620 struct wireless_dev *wdev,
1621 void *data,
1622 int data_len)
1623{
1624 int status;
1625 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301626 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301627 struct net_device *dev = wdev->netdev;
1628 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1629 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Srinivas Dasari98947432014-11-07 19:41:24 +05301630 hdd_station_ctx_t *pHddStaCtx;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301631
1632 status = wlan_hdd_validate_context(pHddCtx);
1633 if (0 != status)
1634 {
1635 hddLog(VOS_TRACE_LEVEL_ERROR,
1636 FL("HDD context is not valid"));
1637 return -EINVAL;
1638 }
1639
1640 if (NULL == pAdapter)
1641 {
1642 hddLog(VOS_TRACE_LEVEL_ERROR,
1643 FL("HDD adapter is Null"));
1644 return -ENODEV;
1645 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301646 /* check the LLStats Capability */
1647 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1648 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1649 {
1650 hddLog(VOS_TRACE_LEVEL_ERROR,
1651 FL("Link Layer Statistics not supported by Firmware"));
1652 return -EINVAL;
1653 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301654
1655 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1656 (struct nlattr *)data,
1657 data_len, qca_wlan_vendor_ll_set_policy))
1658 {
1659 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1660 return -EINVAL;
1661 }
1662 if (!tb_vendor
1663 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1664 {
1665 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1666 return -EINVAL;
1667 }
1668 if (!tb_vendor[
1669 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1670 {
1671 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1672 return -EINVAL;
1673 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301674 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301675 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301676
Dino Mycledf0a5d92014-07-04 09:41:55 +05301677 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301678 nla_get_u32(
1679 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1680
Dino Mycledf0a5d92014-07-04 09:41:55 +05301681 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301682 nla_get_u32(
1683 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1684
Dino Mycled3d50022014-07-07 12:58:25 +05301685 vos_mem_copy(linkLayerStatsSetReq.macAddr,
1686 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301687
1688
1689 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301690 "LL_STATS_SET reqId = %d", linkLayerStatsSetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301691 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301692 "LL_STATS_SET MAC = %pM", linkLayerStatsSetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301693 hddLog(VOS_TRACE_LEVEL_INFO,
1694 "LL_STATS_SET mpduSizeThreshold = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301695 linkLayerStatsSetReq.mpduSizeThreshold);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301696 hddLog(VOS_TRACE_LEVEL_INFO,
1697 "LL_STATS_SET aggressive Statistics Gathering = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301698 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301699
1700 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1701 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05301702 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301703 {
1704 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1705 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301706 return -EINVAL;
1707
1708 }
Srinivas Dasari98947432014-11-07 19:41:24 +05301709
1710 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1711 if (VOS_STATUS_SUCCESS !=
1712 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1713 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE))
1714 {
1715 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1716 "WLANTL_ClearInterfaceStats Failed", __func__);
1717 return -EINVAL;
1718 }
1719
1720 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1721 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1722 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1723 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1724
Sunil Duttc69bccb2014-05-26 21:30:20 +05301725 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301726 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301727 {
1728 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1729 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301730 return -EINVAL;
1731 }
1732
1733 pAdapter->isLinkLayerStatsSet = 1;
1734
1735 return 0;
1736}
1737
1738const struct
1739nla_policy
1740qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1741{
1742 /* Unsigned 32bit value provided by the caller issuing the GET stats
1743 * command. When reporting
1744 * the stats results, the driver uses the same value to indicate
1745 * which GET request the results
1746 * correspond to.
1747 */
1748 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1749
1750 /* Unsigned 32bit value . bit mask to identify what statistics are
1751 requested for retrieval */
1752 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1753};
1754
1755static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1756 struct wireless_dev *wdev,
1757 void *data,
1758 int data_len)
1759{
1760 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1761 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301762 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301763 struct net_device *dev = wdev->netdev;
1764 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1765 int status;
1766
1767 status = wlan_hdd_validate_context(pHddCtx);
1768 if (0 != status)
1769 {
1770 hddLog(VOS_TRACE_LEVEL_ERROR,
1771 FL("HDD context is not valid"));
1772 return -EINVAL ;
1773 }
1774
1775 if (NULL == pAdapter)
1776 {
1777 hddLog(VOS_TRACE_LEVEL_FATAL,
1778 "%s: HDD adapter is Null", __func__);
1779 return -ENODEV;
1780 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301781 /* check the LLStats Capability */
1782 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1783 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1784 {
1785 hddLog(VOS_TRACE_LEVEL_ERROR,
1786 FL("Link Layer Statistics not supported by Firmware"));
1787 return -EINVAL;
1788 }
1789
Sunil Duttc69bccb2014-05-26 21:30:20 +05301790
1791 if (!pAdapter->isLinkLayerStatsSet)
1792 {
1793 hddLog(VOS_TRACE_LEVEL_FATAL,
1794 "%s: isLinkLayerStatsSet : %d",
1795 __func__, pAdapter->isLinkLayerStatsSet);
1796 return -EINVAL;
1797 }
1798
1799 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
1800 (struct nlattr *)data,
1801 data_len, qca_wlan_vendor_ll_get_policy))
1802 {
1803 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1804 return -EINVAL;
1805 }
1806
1807 if (!tb_vendor
1808 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
1809 {
1810 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
1811 return -EINVAL;
1812 }
1813
1814 if (!tb_vendor
1815 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
1816 {
1817 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
1818 return -EINVAL;
1819 }
1820
Sunil Duttc69bccb2014-05-26 21:30:20 +05301821
Dino Mycledf0a5d92014-07-04 09:41:55 +05301822 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301823 nla_get_u32( tb_vendor[
1824 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05301825 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301826 nla_get_u32( tb_vendor[
1827 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
1828
Dino Mycled3d50022014-07-07 12:58:25 +05301829 vos_mem_copy(linkLayerStatsGetReq.macAddr,
1830 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301831
1832 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301833 "LL_STATS_GET reqId = %d", linkLayerStatsGetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301834 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301835 "LL_STATS_GET MAC = %pM", linkLayerStatsGetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301836 hddLog(VOS_TRACE_LEVEL_INFO,
1837 "LL_STATS_GET paramIdMask = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301838 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301839
1840 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301841 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301842 {
1843 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1844 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301845 return -EINVAL;
1846 }
1847 return 0;
1848}
1849
1850const struct
1851nla_policy
1852qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
1853{
1854 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
1855 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
1856 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
1857 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
1858};
1859
1860static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
1861 struct wireless_dev *wdev,
1862 void *data,
1863 int data_len)
1864{
1865 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1866 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301867 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301868 struct net_device *dev = wdev->netdev;
1869 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1870 u32 statsClearReqMask;
1871 u8 stopReq;
1872 int status;
1873
1874 status = wlan_hdd_validate_context(pHddCtx);
1875 if (0 != status)
1876 {
1877 hddLog(VOS_TRACE_LEVEL_ERROR,
1878 FL("HDD context is not valid"));
1879 return -EINVAL;
1880 }
1881
1882 if (NULL == pAdapter)
1883 {
1884 hddLog(VOS_TRACE_LEVEL_FATAL,
1885 "%s: HDD adapter is Null", __func__);
1886 return -ENODEV;
1887 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301888 /* check the LLStats Capability */
1889 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1890 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1891 {
1892 hddLog(VOS_TRACE_LEVEL_ERROR,
1893 FL("Enable LLStats Capability"));
1894 return -EINVAL;
1895 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301896
1897 if (!pAdapter->isLinkLayerStatsSet)
1898 {
1899 hddLog(VOS_TRACE_LEVEL_FATAL,
1900 "%s: isLinkLayerStatsSet : %d",
1901 __func__, pAdapter->isLinkLayerStatsSet);
1902 return -EINVAL;
1903 }
1904
1905 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
1906 (struct nlattr *)data,
1907 data_len, qca_wlan_vendor_ll_clr_policy))
1908 {
1909 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1910 return -EINVAL;
1911 }
1912
1913 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
1914
1915 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
1916 {
1917 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
1918 return -EINVAL;
1919
1920 }
1921
Sunil Duttc69bccb2014-05-26 21:30:20 +05301922
Dino Mycledf0a5d92014-07-04 09:41:55 +05301923 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301924 nla_get_u32(
1925 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
1926
Dino Mycledf0a5d92014-07-04 09:41:55 +05301927 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301928 nla_get_u8(
1929 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
1930
1931 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301932 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301933
Dino Mycled3d50022014-07-07 12:58:25 +05301934 vos_mem_copy(linkLayerStatsClearReq.macAddr,
1935 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301936
1937 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301938 "LL_STATS_CLEAR reqId = %d", linkLayerStatsClearReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301939 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301940 "LL_STATS_CLEAR MAC = %pM", linkLayerStatsClearReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301941 hddLog(VOS_TRACE_LEVEL_INFO,
1942 "LL_STATS_CLEAR statsClearReqMask = 0x%X",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301943 linkLayerStatsClearReq.statsClearReqMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301944 hddLog(VOS_TRACE_LEVEL_INFO,
1945 "LL_STATS_CLEAR stopReq = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301946 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301947
1948 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301949 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301950 {
1951 struct sk_buff *temp_skbuff;
Srinivas Dasari98947432014-11-07 19:41:24 +05301952 hdd_station_ctx_t *pHddStaCtx;
1953
1954 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1955 if (VOS_STATUS_SUCCESS !=
1956 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1957 pHddStaCtx->conn_info.staId[0], statsClearReqMask))
1958 {
1959 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1960 "WLANTL_ClearInterfaceStats Failed", __func__);
1961 return -EINVAL;
1962 }
1963 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
1964 (statsClearReqMask & WIFI_STATS_IFACE)) {
1965 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1966 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1967 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1968 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1969 }
1970
Sunil Duttc69bccb2014-05-26 21:30:20 +05301971 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
1972 2 * sizeof(u32) +
1973 NLMSG_HDRLEN);
1974
1975 if (temp_skbuff != NULL)
1976 {
1977
1978 if (nla_put_u32(temp_skbuff,
1979 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
1980 statsClearReqMask) ||
1981 nla_put_u32(temp_skbuff,
1982 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
1983 stopReq))
1984 {
1985 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
1986 kfree_skb(temp_skbuff);
1987 return -EINVAL;
1988 }
1989 /* If the ask is to stop the stats collection as part of clear
1990 * (stopReq = 1) , ensure that no further requests of get
1991 * go to the firmware by having isLinkLayerStatsSet set to 0.
1992 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301993 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05301994 * case the firmware is just asked to clear the statistics.
1995 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05301996 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301997 pAdapter->isLinkLayerStatsSet = 0;
1998 return cfg80211_vendor_cmd_reply(temp_skbuff);
1999 }
2000 return -ENOMEM;
2001 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302002 return -EINVAL;
2003}
2004#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2005
Dino Mycle6fb96c12014-06-10 11:52:40 +05302006#ifdef WLAN_FEATURE_EXTSCAN
2007static const struct nla_policy
2008wlan_hdd_extscan_config_policy
2009 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
2010{
2011 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
2012 { .type = NLA_U32 },
2013 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
2014 { .type = NLA_U32 },
2015 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
2016 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
2017 { .type = NLA_U32 },
2018 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
2019 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
2020
2021 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
2022 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
2023 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
2024 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
2025 { .type = NLA_U8 },
2026 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
2027 { .type = NLA_U32 },
2028 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
2029 { .type = NLA_U32 },
2030 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
2031 { .type = NLA_U32 },
2032 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD] =
2033 { .type = NLA_U8 },
2034 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
2035 { .type = NLA_U8 },
2036 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
2037 { .type = NLA_U8 },
2038
2039 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
2040 { .type = NLA_U32 },
2041 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] =
2042 { .type = NLA_UNSPEC },
2043 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
2044 { .type = NLA_S32 },
2045 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
2046 { .type = NLA_S32 },
2047 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
2048 { .type = NLA_U32 },
2049 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
2050 { .type = NLA_U32 },
2051 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE] =
2052 { .type = NLA_U32 },
2053 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]
2054 = { .type = NLA_U32 },
2055 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING] =
2056 { .type = NLA_U32 },
2057 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP] = { .type =
2058 NLA_U32 },
2059};
2060
2061static void wlan_hdd_cfg80211_extscan_get_capabilities_ind(void *ctx, void *pMsg)
2062{
2063 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2064 struct sk_buff *skb = NULL;
2065 tpSirEXTScanCapabilitiesEvent pData =
2066 (tpSirEXTScanCapabilitiesEvent) pMsg;
2067
2068 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2069 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2070 "or pData(%p) is null"), pData);
2071 return;
2072 }
2073
2074 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2075 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2076 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES_INDEX,
2077 GFP_KERNEL);
2078
2079 if (!skb) {
2080 hddLog(VOS_TRACE_LEVEL_ERROR,
2081 FL("cfg80211_vendor_event_alloc failed"));
2082 return;
2083 }
2084
2085 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2086 hddLog(VOS_TRACE_LEVEL_INFO, "Scan cache size (%u)", pData->scanCacheSize);
2087 hddLog(VOS_TRACE_LEVEL_INFO, "Scan buckets (%u)", pData->scanBuckets);
2088 hddLog(VOS_TRACE_LEVEL_INFO, "Max AP per scan (%u)", pData->maxApPerScan);
2089 hddLog(VOS_TRACE_LEVEL_INFO, "maxRssiSampleSize (%u)",
2090 pData->maxRssiSampleSize);
2091 hddLog(VOS_TRACE_LEVEL_INFO, "maxScanReportingThreshold (%u)",
2092 pData->maxScanReportingThreshold);
2093 hddLog(VOS_TRACE_LEVEL_INFO, "maxHotlistAPs (%u)", pData->maxHotlistAPs);
2094 hddLog(VOS_TRACE_LEVEL_INFO, "maxSignificantWifiChangeAPs (%u)",
2095 pData->maxSignificantWifiChangeAPs);
2096 hddLog(VOS_TRACE_LEVEL_INFO, "maxBsidHistoryEntries (%u)",
2097 pData->maxBsidHistoryEntries);
2098
2099 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2100 pData->requestId) ||
2101 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status) ||
2102 nla_put_u32(skb,
2103 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE,
2104 pData->scanCacheSize) ||
2105 nla_put_u32(skb,
2106 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS,
2107 pData->scanBuckets) ||
2108 nla_put_u32(skb,
2109 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN,
2110 pData->maxApPerScan) ||
2111 nla_put_u32(skb,
2112 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE,
2113 pData->maxRssiSampleSize) ||
2114 nla_put_u32(skb,
2115 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD,
2116 pData->maxScanReportingThreshold) ||
2117 nla_put_u32(skb,
2118 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_APS,
2119 pData->maxHotlistAPs) ||
2120 nla_put_u32(skb,
2121 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS,
2122 pData->maxSignificantWifiChangeAPs) ||
2123 nla_put_u32(skb,
2124 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES,
2125 pData->maxBsidHistoryEntries)) {
2126 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2127 goto nla_put_failure;
2128 }
2129
2130 cfg80211_vendor_event(skb, GFP_KERNEL);
2131 return;
2132
2133nla_put_failure:
2134 kfree_skb(skb);
2135 return;
2136}
2137
2138
2139static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg)
2140{
2141 tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg;
2142 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2143 struct sk_buff *skb = NULL;
2144 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
2145
2146
2147 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2148 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2149 "or pData(%p) is null"), pData);
2150 return;
2151 }
2152
2153 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2154 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2155 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START_INDEX,
2156 GFP_KERNEL);
2157
2158 if (!skb) {
2159 hddLog(VOS_TRACE_LEVEL_ERROR,
2160 FL("cfg80211_vendor_event_alloc failed"));
2161 return;
2162 }
2163 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2164 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2165 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2166
2167 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2168 pData->requestId) ||
2169 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2170 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2171 goto nla_put_failure;
2172 }
2173
2174 /*
2175 * Store the Request ID for comparing with the requestID obtained
2176 * in other requests.HDD shall return a failure is the extscan_stop
2177 * request is issued with a different requestId as that of the
2178 * extscan_start request. Also, This requestId shall be used while
2179 * indicating the full scan results to the upper layers.
2180 * The requestId is stored with the assumption that the firmware
2181 * shall return the ext scan start request's requestId in ext scan
2182 * start response.
2183 */
2184 if (pData->status == 0)
2185 pMac->sme.extScanStartReqId = pData->requestId;
2186
2187
2188 cfg80211_vendor_event(skb, GFP_KERNEL);
2189 return;
2190
2191nla_put_failure:
2192 kfree_skb(skb);
2193 return;
2194}
2195
2196
2197static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
2198{
2199 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
2200 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2201 struct sk_buff *skb = NULL;
2202
2203 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2204 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2205 "or pData(%p) is null"), pData);
2206 return;
2207 }
2208
2209 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2210 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2211 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP_INDEX,
2212 GFP_KERNEL);
2213
2214 if (!skb) {
2215 hddLog(VOS_TRACE_LEVEL_ERROR,
2216 FL("cfg80211_vendor_event_alloc failed"));
2217 return;
2218 }
2219 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2220 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2221
2222 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2223 pData->requestId) ||
2224 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2225 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2226 goto nla_put_failure;
2227 }
2228
2229 cfg80211_vendor_event(skb, GFP_KERNEL);
2230 return;
2231
2232nla_put_failure:
2233 kfree_skb(skb);
2234 return;
2235}
2236
2237
2238static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
2239 void *pMsg)
2240{
2241 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2242 struct sk_buff *skb = NULL;
2243 tpSirEXTScanSetBssidHotListRspParams pData =
2244 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
2245
2246 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2247 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2248 "or pData(%p) is null"), pData);
2249 return;
2250 }
2251 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2252 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2253 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST_INDEX,
2254 GFP_KERNEL);
2255
2256 if (!skb) {
2257 hddLog(VOS_TRACE_LEVEL_ERROR,
2258 FL("cfg80211_vendor_event_alloc failed"));
2259 return;
2260 }
2261 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2262 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2263 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2264
2265 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2266 pData->requestId) ||
2267 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2268 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2269 goto nla_put_failure;
2270 }
2271
2272 cfg80211_vendor_event(skb, GFP_KERNEL);
2273 return;
2274
2275nla_put_failure:
2276 kfree_skb(skb);
2277 return;
2278}
2279
2280static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
2281 void *pMsg)
2282{
2283 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2284 struct sk_buff *skb = NULL;
2285 tpSirEXTScanResetBssidHotlistRspParams pData =
2286 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
2287
2288 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2289 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2290 "or pData(%p) is null"), pData);
2291 return;
2292 }
2293
2294 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2295 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2296 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST_INDEX,
2297 GFP_KERNEL);
2298
2299 if (!skb) {
2300 hddLog(VOS_TRACE_LEVEL_ERROR,
2301 FL("cfg80211_vendor_event_alloc failed"));
2302 return;
2303 }
2304 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2305 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2306
2307 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2308 pData->requestId) ||
2309 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2310 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2311 goto nla_put_failure;
2312 }
2313
2314 cfg80211_vendor_event(skb, GFP_KERNEL);
2315 return;
2316
2317nla_put_failure:
2318 kfree_skb(skb);
2319 return;
2320}
2321
2322
2323static void wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(void *ctx,
2324 void *pMsg)
2325{
2326 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2327 struct sk_buff *skb = NULL;
2328 tpSirEXTScanSetSignificantChangeRspParams pData =
2329 (tpSirEXTScanSetSignificantChangeRspParams) pMsg;
2330
2331 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2332 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2333 "or pData(%p) is null"), pData);
2334 return;
2335 }
2336
2337 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2338 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2339 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE_INDEX,
2340 GFP_KERNEL);
2341
2342 if (!skb) {
2343 hddLog(VOS_TRACE_LEVEL_ERROR,
2344 FL("cfg80211_vendor_event_alloc failed"));
2345 return;
2346 }
2347 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2348 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2349 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2350
2351 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2352 pData->requestId) ||
2353 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2354 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2355 goto nla_put_failure;
2356 }
2357
2358 cfg80211_vendor_event(skb, GFP_KERNEL);
2359 return;
2360
2361nla_put_failure:
2362 kfree_skb(skb);
2363 return;
2364}
2365
2366
2367static void wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(void *ctx,
2368 void *pMsg)
2369{
2370 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2371 struct sk_buff *skb = NULL;
2372 tpSirEXTScanResetSignificantChangeRspParams pData =
2373 (tpSirEXTScanResetSignificantChangeRspParams) pMsg;
2374
2375 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2376 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2377 "or pData(%p) is null"), pData);
2378 return;
2379 }
2380
2381 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2382 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2383 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE_INDEX,
2384 GFP_KERNEL);
2385
2386 if (!skb) {
2387 hddLog(VOS_TRACE_LEVEL_ERROR,
2388 FL("cfg80211_vendor_event_alloc failed"));
2389 return;
2390 }
2391 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2392 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2393 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2394
2395 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2396 pData->requestId) ||
2397 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2398 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2399 goto nla_put_failure;
2400 }
2401
2402 cfg80211_vendor_event(skb, GFP_KERNEL);
2403 return;
2404
2405nla_put_failure:
2406 kfree_skb(skb);
2407 return;
2408}
2409
2410static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
2411 void *pMsg)
2412{
2413 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2414 struct sk_buff *skb = NULL;
2415 tANI_U32 i = 0, j, resultsPerEvent;
2416 tANI_S32 totalResults;
2417 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2418 tpSirWifiScanResult pSirWifiScanResult;
2419
2420 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2421 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2422 "or pData(%p) is null"), pData);
2423 return;
2424 }
2425 totalResults = pData->numOfAps;
2426 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2427 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2428 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2429
2430 do{
2431 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
2432 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
2433 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
2434
2435 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2436 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2437 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS_INDEX,
2438 GFP_KERNEL);
2439
2440 if (!skb) {
2441 hddLog(VOS_TRACE_LEVEL_ERROR,
2442 FL("cfg80211_vendor_event_alloc failed"));
2443 return;
2444 }
2445
2446 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
2447
2448 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2449 pData->requestId) ||
2450 nla_put_u32(skb,
2451 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2452 resultsPerEvent)) {
2453 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2454 goto fail;
2455 }
2456 if (nla_put_u8(skb,
2457 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2458 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
2459 {
2460 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2461 goto fail;
2462 }
2463
2464 if (resultsPerEvent) {
2465 struct nlattr *aps;
2466
2467 aps = nla_nest_start(skb,
2468 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2469 if (!aps)
2470 {
2471 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2472 goto fail;
2473 }
2474
2475 for (j = 0; j < resultsPerEvent; j++, i++) {
2476 struct nlattr *ap;
2477 pSirWifiScanResult = (tpSirWifiScanResult) ((tANI_U8 *)
2478 pData->ap + ( i* sizeof(tSirWifiScanResult)));
2479
2480 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
2481 "Ssid (%s)"
2482 "Bssid: %pM "
2483 "Channel (%u)"
2484 "Rssi (%d)"
2485 "RTT (%u)"
2486 "RTT_SD (%u)",
2487 i,
2488 pSirWifiScanResult->ts,
2489 pSirWifiScanResult->ssid,
2490 pSirWifiScanResult->bssid,
2491 pSirWifiScanResult->channel,
2492 pSirWifiScanResult->rssi,
2493 pSirWifiScanResult->rtt,
2494 pSirWifiScanResult->rtt_sd);
2495
2496 ap = nla_nest_start(skb, j + 1);
2497 if (!ap)
2498 {
2499 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2500 goto fail;
2501 }
2502
2503 if (nla_put_u64(skb,
2504 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2505 pSirWifiScanResult->ts) )
2506 {
2507 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2508 goto fail;
2509 }
2510 if (nla_put(skb,
2511 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2512 sizeof(pSirWifiScanResult->ssid),
2513 pSirWifiScanResult->ssid) )
2514 {
2515 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2516 goto fail;
2517 }
2518 if (nla_put(skb,
2519 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2520 sizeof(pSirWifiScanResult->bssid),
2521 pSirWifiScanResult->bssid) )
2522 {
2523 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2524 goto fail;
2525 }
2526 if (nla_put_u32(skb,
2527 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2528 pSirWifiScanResult->channel) )
2529 {
2530 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2531 goto fail;
2532 }
Dasari Srinivas90747d72014-10-08 12:16:15 +05302533 if (nla_put_s32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302534 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2535 pSirWifiScanResult->rssi) )
2536 {
2537 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2538 goto fail;
2539 }
2540 if (nla_put_u32(skb,
2541 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2542 pSirWifiScanResult->rtt) )
2543 {
2544 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2545 goto fail;
2546 }
2547 if (nla_put_u32(skb,
2548 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2549 pSirWifiScanResult->rtt_sd))
2550 {
2551 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2552 goto fail;
2553 }
2554
2555 nla_nest_end(skb, ap);
2556 }
2557 nla_nest_end(skb, aps);
2558
2559 }
2560 cfg80211_vendor_event(skb, GFP_KERNEL);
2561 } while (totalResults > 0);
2562
2563 return;
2564fail:
2565 kfree_skb(skb);
2566 return;
2567}
2568
2569static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
2570 void *pMsg)
2571{
2572 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2573 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2574 struct sk_buff *skb = NULL;
2575 tANI_U32 i;
2576
2577 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2578 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2579 "or pData(%p) is null"), pData);
2580 return;
2581 }
2582
2583 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2584 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2585 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX,
2586 GFP_KERNEL);
2587
2588 if (!skb) {
2589 hddLog(VOS_TRACE_LEVEL_ERROR,
2590 FL("cfg80211_vendor_event_alloc failed"));
2591 return;
2592 }
2593 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2594 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2595 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2596 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2597
2598 for (i = 0; i < pData->numOfAps; i++) {
2599 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
2600 "Ssid (%s) "
2601 "Bssid (" MAC_ADDRESS_STR ") "
2602 "Channel (%u) "
2603 "Rssi (%d) "
2604 "RTT (%u) "
2605 "RTT_SD (%u) ",
2606 i,
2607 pData->ap[i].ts,
2608 pData->ap[i].ssid,
2609 MAC_ADDR_ARRAY(pData->ap[i].bssid),
2610 pData->ap[i].channel,
2611 pData->ap[i].rssi,
2612 pData->ap[i].rtt,
2613 pData->ap[i].rtt_sd);
2614 }
2615
2616 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2617 pData->requestId) ||
2618 nla_put_u32(skb,
2619 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2620 pData->numOfAps)) {
2621 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2622 goto fail;
2623 }
2624 if (pData->numOfAps) {
2625 struct nlattr *aps;
2626
2627 aps = nla_nest_start(skb,
2628 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2629 if (!aps)
2630 goto fail;
2631
2632 for (i = 0; i < pData->numOfAps; i++) {
2633 struct nlattr *ap;
2634
2635 ap = nla_nest_start(skb, i + 1);
2636 if (!ap)
2637 goto fail;
2638
2639 if (nla_put_u64(skb,
2640 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2641 pData->ap[i].ts) ||
2642 nla_put(skb,
2643 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2644 sizeof(pData->ap[i].ssid),
2645 pData->ap[i].ssid) ||
2646 nla_put(skb,
2647 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2648 sizeof(pData->ap[i].bssid),
2649 pData->ap[i].bssid) ||
2650 nla_put_u32(skb,
2651 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2652 pData->ap[i].channel) ||
2653 nla_put_s32(skb,
2654 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2655 pData->ap[i].rssi) ||
2656 nla_put_u32(skb,
2657 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2658 pData->ap[i].rtt) ||
2659 nla_put_u32(skb,
2660 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2661 pData->ap[i].rtt_sd))
2662 goto fail;
2663
2664 nla_nest_end(skb, ap);
2665 }
2666 nla_nest_end(skb, aps);
2667
2668 if (nla_put_u8(skb,
2669 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2670 pData->moreData))
2671 goto fail;
2672 }
2673
2674 cfg80211_vendor_event(skb, GFP_KERNEL);
2675 return;
2676
2677fail:
2678 kfree_skb(skb);
2679 return;
2680
2681}
2682static void wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(void *ctx,
2683 void *pMsg)
2684{
2685 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2686 struct sk_buff *skb = NULL;
2687 tANI_U32 i, j;
2688 tpSirWifiSignificantChangeEvent pData =
2689 (tpSirWifiSignificantChangeEvent) pMsg;
2690
2691 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2692 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2693 "or pData(%p) is null"), pData);
2694 return;
2695 }
2696 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2697 EXTSCAN_EVENT_BUF_SIZE,
2698 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE_INDEX,
2699 GFP_KERNEL);
2700
2701 if (!skb) {
2702 hddLog(VOS_TRACE_LEVEL_ERROR,
2703 FL("cfg80211_vendor_event_alloc failed"));
2704 return;
2705 }
2706 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2707 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2708 hddLog(VOS_TRACE_LEVEL_INFO, "total List Size %u ", pData->numSigRssiBss);
2709 hddLog(VOS_TRACE_LEVEL_INFO, " CUrrent List size (%u)",
2710 pData->numSigRssiBss);
2711 hddLog(VOS_TRACE_LEVEL_INFO, "moreData (%u)", pData->moreData);
2712
2713 for (i = 0; i < pData->numSigRssiBss; i++) {
2714 hddLog(VOS_TRACE_LEVEL_INFO , "Rssi List [%d] BSSID: (%pM) Channel %u "
2715 " num RSSI %u ",
2716 i, pData->sigRssiResult[i].bssid,
2717 pData->sigRssiResult[i].channel,
2718 pData->sigRssiResult[i].numRssi);
2719
2720 for (j = 0; j < pData->sigRssiResult[i].numRssi; j++){
2721
2722 hddLog(VOS_TRACE_LEVEL_INFO,
2723 " [%d]",
Dino Myclec8f3f332014-07-21 16:48:27 +05302724 pData->sigRssiResult[i].rssi[j]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302725
2726 }
2727 }
2728
2729
2730 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2731 pData->requestId) ||
2732 nla_put_u32(skb,
2733 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2734 pData->numSigRssiBss)) {
2735 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2736 goto fail;
2737 }
2738
2739 if (pData->numSigRssiBss) {
2740 struct nlattr *aps;
2741 aps = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2742 if (!aps)
2743 goto fail;
2744 for (i = 0; i < pData->numSigRssiBss; i++) {
2745 struct nlattr *ap;
2746
2747 ap = nla_nest_start(skb, i);
2748 if (!ap)
2749 goto fail;
2750 if (nla_put(skb,
2751 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_BSSID,
2752 sizeof(tSirMacAddr), pData->sigRssiResult[i].bssid) ||
2753 nla_put_u32(skb,
2754 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_CHANNEL,
2755 pData->sigRssiResult[i].channel) ||
2756 nla_put_u32(skb,
2757 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_NUM_RSSI,
2758 pData->sigRssiResult[i].numRssi) ||
2759 nla_put(skb,
2760 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_RSSI_LIST,
2761 sizeof(s32) * pData->sigRssiResult[i].numRssi,
2762 pData->sigRssiResult[i].rssi))
2763 goto fail;
2764 nla_nest_end(skb, ap);
2765 }
2766 nla_nest_end(skb, aps);
2767 if (nla_put_u8(skb,
2768 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2769 pData->moreData))
2770 goto fail;
2771 }
2772 cfg80211_vendor_event(skb, GFP_KERNEL);
2773 return;
2774fail:
2775 kfree_skb(skb);
2776 return;
2777}
2778
2779static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
2780 void *pMsg)
2781{
2782 struct sk_buff *skb;
2783 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2784 tpSirWifiFullScanResultEvent pData =
2785 (tpSirWifiFullScanResultEvent) (pMsg);
2786
2787 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2788 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2789 "or pData(%p) is null"), pData);
2790 return;
2791 }
2792
2793 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2794 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2795 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
2796 GFP_KERNEL);
2797
2798 if (!skb) {
2799 hddLog(VOS_TRACE_LEVEL_ERROR,
2800 FL("cfg80211_vendor_event_alloc failed"));
2801 return;
2802 }
2803
2804 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2805 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
2806 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
2807 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
2808 "Ssid (%s)"
2809 "Bssid (" MAC_ADDRESS_STR ")"
2810 "Channel (%u)"
2811 "Rssi (%d)"
2812 "RTT (%u)"
2813 "RTT_SD (%u)"),
2814 pData->ap.ts,
2815 pData->ap.ssid,
2816 MAC_ADDR_ARRAY(pData->ap.bssid),
2817 pData->ap.channel,
2818 pData->ap.rssi,
2819 pData->ap.rtt,
2820 pData->ap.rtt_sd);
2821 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
2822 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2823 pData->requestId) ||
2824 nla_put_u64(skb,
2825 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2826 pData->ap.ts) ||
2827 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2828 sizeof(pData->ap.ssid),
2829 pData->ap.ssid) ||
2830 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2831 WNI_CFG_BSSID_LEN,
2832 pData->ap.bssid) ||
2833 nla_put_u32(skb,
2834 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2835 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05302836 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302837 pData->ap.rssi) ||
2838 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2839 pData->ap.rtt) ||
2840 nla_put_u32(skb,
2841 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2842 pData->ap.rtt_sd) ||
2843 nla_put_u16(skb,
2844 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
2845 pData->ap.beaconPeriod) ||
2846 nla_put_u16(skb,
2847 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
2848 pData->ap.capability) ||
2849 nla_put_u32(skb,
2850 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
2851 pData->ieLength))
2852 {
2853 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2854 goto nla_put_failure;
2855 }
2856 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
2857 pData->ieLength,
2858 pData->ie))
2859 {
2860 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2861 goto nla_put_failure;
2862 }
2863
2864 cfg80211_vendor_event(skb, GFP_KERNEL);
2865 return;
2866
2867nla_put_failure:
2868 kfree_skb(skb);
2869 return;
2870}
2871
2872static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
2873 void *pMsg)
2874{
2875 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2876 struct sk_buff *skb = NULL;
2877 tpSirEXTScanResultsAvailableIndParams pData =
2878 (tpSirEXTScanResultsAvailableIndParams) pMsg;
2879
2880 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2881 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2882 "or pData(%p) is null"), pData);
2883 return;
2884 }
2885
2886 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2887 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2888 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
2889 GFP_KERNEL);
2890
2891 if (!skb) {
2892 hddLog(VOS_TRACE_LEVEL_ERROR,
2893 FL("cfg80211_vendor_event_alloc failed"));
2894 return;
2895 }
2896
2897 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2898 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2899 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
2900 pData->numResultsAvailable);
2901 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2902 pData->requestId) ||
2903 nla_put_u32(skb,
2904 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2905 pData->numResultsAvailable)) {
2906 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2907 goto nla_put_failure;
2908 }
2909
2910 cfg80211_vendor_event(skb, GFP_KERNEL);
2911 return;
2912
2913nla_put_failure:
2914 kfree_skb(skb);
2915 return;
2916}
2917
2918static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
2919{
2920 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2921 struct sk_buff *skb = NULL;
2922 tpSirEXTScanProgressIndParams pData =
2923 (tpSirEXTScanProgressIndParams) pMsg;
2924
2925 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2926 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2927 "or pData(%p) is null"), pData);
2928 return;
2929 }
2930
2931 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2932 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2933 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
2934 GFP_KERNEL);
2935
2936 if (!skb) {
2937 hddLog(VOS_TRACE_LEVEL_ERROR,
2938 FL("cfg80211_vendor_event_alloc failed"));
2939 return;
2940 }
2941 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2942 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
2943 pData->extScanEventType);
2944 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
2945 pData->status);
2946
2947 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
2948 pData->extScanEventType) ||
2949 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05302950 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2951 pData->requestId) ||
2952 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302953 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
2954 pData->status)) {
2955 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2956 goto nla_put_failure;
2957 }
2958
2959 cfg80211_vendor_event(skb, GFP_KERNEL);
2960 return;
2961
2962nla_put_failure:
2963 kfree_skb(skb);
2964 return;
2965}
2966
2967void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
2968 void *pMsg)
2969{
2970 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2971
2972 if (wlan_hdd_validate_context(pHddCtx)) {
Dasari Srinivasb46ed1d2014-10-08 13:03:08 +05302973 hddLog(VOS_TRACE_LEVEL_INFO, FL("HDD context is not valid"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302974 return;
2975 }
2976
2977 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
2978
2979
2980 switch(evType) {
2981 case SIR_HAL_EXTSCAN_START_RSP:
2982 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
2983 break;
2984
2985 case SIR_HAL_EXTSCAN_STOP_RSP:
2986 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
2987 break;
2988 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
2989 /* There is no need to send this response to upper layer
2990 Just log the message */
2991 hddLog(VOS_TRACE_LEVEL_INFO,
2992 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
2993 break;
2994 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
2995 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
2996 break;
2997
2998 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
2999 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
3000 break;
3001
3002 case SIR_HAL_EXTSCAN_SET_SIGNF_RSSI_CHANGE_RSP:
3003 wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(ctx, pMsg);
3004 break;
3005
3006 case SIR_HAL_EXTSCAN_RESET_SIGNF_RSSI_CHANGE_RSP:
3007 wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(ctx, pMsg);
3008 break;
3009 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
3010 wlan_hdd_cfg80211_extscan_get_capabilities_ind(ctx, pMsg);
3011 break;
3012 case SIR_HAL_EXTSCAN_PROGRESS_IND:
3013 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
3014 break;
3015 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
3016 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
3017 break;
3018 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
3019 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
3020 break;
3021 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
3022 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
3023 break;
3024 case SIR_HAL_EXTSCAN_SIGNF_WIFI_CHANGE_IND:
3025 wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(ctx, pMsg);
3026 break;
3027 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
3028 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
3029 break;
3030 default:
3031 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
3032 break;
3033 }
3034}
3035
3036static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3037 struct wireless_dev *wdev,
3038 void *data, int dataLen)
3039{
Dino Myclee8843b32014-07-04 14:21:45 +05303040 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303041 struct net_device *dev = wdev->netdev;
3042 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3043 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3044 struct nlattr
3045 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3046 eHalStatus status;
3047
3048 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering"));
3049 status = wlan_hdd_validate_context(pHddCtx);
3050 if (0 != status)
3051 {
3052 hddLog(VOS_TRACE_LEVEL_ERROR,
3053 FL("HDD context is not valid"));
3054 return -EINVAL;
3055 }
Dino Myclee8843b32014-07-04 14:21:45 +05303056 /* check the EXTScan Capability */
3057 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3058 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3059 {
3060 hddLog(VOS_TRACE_LEVEL_ERROR,
3061 FL("EXTScan not enabled/supported by Firmware"));
3062 return -EINVAL;
3063 }
3064
Dino Mycle6fb96c12014-06-10 11:52:40 +05303065 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3066 data, dataLen,
3067 wlan_hdd_extscan_config_policy)) {
3068 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3069 return -EINVAL;
3070 }
3071
3072 /* Parse and fetch request Id */
3073 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3074 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3075 return -EINVAL;
3076 }
3077
Dino Mycle6fb96c12014-06-10 11:52:40 +05303078
Dino Myclee8843b32014-07-04 14:21:45 +05303079 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303080 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303081 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303082
Dino Myclee8843b32014-07-04 14:21:45 +05303083 reqMsg.sessionId = pAdapter->sessionId;
3084 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303085
Dino Myclee8843b32014-07-04 14:21:45 +05303086 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303087 if (!HAL_STATUS_SUCCESS(status)) {
3088 hddLog(VOS_TRACE_LEVEL_ERROR,
3089 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303090 return -EINVAL;
3091 }
3092
3093 return 0;
3094}
3095
3096
3097static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3098 struct wireless_dev *wdev,
3099 void *data, int dataLen)
3100{
Dino Myclee8843b32014-07-04 14:21:45 +05303101 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303102 struct net_device *dev = wdev->netdev;
3103 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3104 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3105 struct nlattr
3106 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3107 eHalStatus status;
3108
3109 status = wlan_hdd_validate_context(pHddCtx);
3110 if (0 != status)
3111 {
3112 hddLog(VOS_TRACE_LEVEL_ERROR,
3113 FL("HDD context is not valid"));
3114 return -EINVAL;
3115 }
Dino Myclee8843b32014-07-04 14:21:45 +05303116 /* check the EXTScan Capability */
3117 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3118 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3119 {
3120 hddLog(VOS_TRACE_LEVEL_ERROR,
3121 FL("EXTScan not enabled/supported by Firmware"));
3122 return -EINVAL;
3123 }
3124
Dino Mycle6fb96c12014-06-10 11:52:40 +05303125 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3126 data, dataLen,
3127 wlan_hdd_extscan_config_policy)) {
3128 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3129 return -EINVAL;
3130 }
3131 /* Parse and fetch request Id */
3132 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3133 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3134 return -EINVAL;
3135 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303136
Dino Myclee8843b32014-07-04 14:21:45 +05303137 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303138 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3139
Dino Myclee8843b32014-07-04 14:21:45 +05303140 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303141
Dino Myclee8843b32014-07-04 14:21:45 +05303142 reqMsg.sessionId = pAdapter->sessionId;
3143 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303144
3145 /* Parse and fetch flush parameter */
3146 if (!tb
3147 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3148 {
3149 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3150 goto failed;
3151 }
Dino Myclee8843b32014-07-04 14:21:45 +05303152 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303153 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3154
Dino Myclee8843b32014-07-04 14:21:45 +05303155 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303156
Dino Myclee8843b32014-07-04 14:21:45 +05303157 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303158 if (!HAL_STATUS_SUCCESS(status)) {
3159 hddLog(VOS_TRACE_LEVEL_ERROR,
3160 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303161 return -EINVAL;
3162 }
3163 return 0;
3164
3165failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303166 return -EINVAL;
3167}
3168
3169static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3170 struct wireless_dev *wdev,
3171 void *data, int dataLen)
3172{
3173 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3174 struct net_device *dev = wdev->netdev;
3175 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3176 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3177 struct nlattr
3178 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3179 struct nlattr
3180 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3181 struct nlattr *apTh;
3182 eHalStatus status;
3183 tANI_U8 i = 0;
3184 int rem;
3185
3186 status = wlan_hdd_validate_context(pHddCtx);
3187 if (0 != status)
3188 {
3189 hddLog(VOS_TRACE_LEVEL_ERROR,
3190 FL("HDD context is not valid"));
3191 return -EINVAL;
3192 }
Dino Myclee8843b32014-07-04 14:21:45 +05303193 /* check the EXTScan Capability */
3194 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3195 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3196 {
3197 hddLog(VOS_TRACE_LEVEL_ERROR,
3198 FL("EXTScan not enabled/supported by Firmware"));
3199 return -EINVAL;
3200 }
3201
Dino Mycle6fb96c12014-06-10 11:52:40 +05303202 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3203 data, dataLen,
3204 wlan_hdd_extscan_config_policy)) {
3205 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3206 return -EINVAL;
3207 }
3208
3209 /* Parse and fetch request Id */
3210 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3211 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3212 return -EINVAL;
3213 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303214 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3215 vos_mem_malloc(sizeof(*pReqMsg));
3216 if (!pReqMsg) {
3217 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3218 return -ENOMEM;
3219 }
3220
Dino Myclee8843b32014-07-04 14:21:45 +05303221
Dino Mycle6fb96c12014-06-10 11:52:40 +05303222 pReqMsg->requestId = nla_get_u32(
3223 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3224 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3225
3226 /* Parse and fetch number of APs */
3227 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3228 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3229 goto fail;
3230 }
3231
3232 pReqMsg->sessionId = pAdapter->sessionId;
3233 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3234
3235 pReqMsg->numAp = nla_get_u32(
3236 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
3237 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3238
3239 nla_for_each_nested(apTh,
3240 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3241 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3242 nla_data(apTh), nla_len(apTh),
3243 NULL)) {
3244 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3245 goto fail;
3246 }
3247
3248 /* Parse and fetch MAC address */
3249 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3250 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3251 goto fail;
3252 }
3253 memcpy(pReqMsg->ap[i].bssid, nla_data(
3254 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3255 sizeof(tSirMacAddr));
3256 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3257
3258 /* Parse and fetch low RSSI */
3259 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3260 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3261 goto fail;
3262 }
3263 pReqMsg->ap[i].low = nla_get_s32(
3264 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3265 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3266
3267 /* Parse and fetch high RSSI */
3268 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3269 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3270 goto fail;
3271 }
3272 pReqMsg->ap[i].high = nla_get_s32(
3273 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3274 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3275 pReqMsg->ap[i].high);
3276
3277 /* Parse and fetch channel */
3278 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3279 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3280 goto fail;
3281 }
3282 pReqMsg->ap[i].channel = nla_get_u32(
3283 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3284 hddLog(VOS_TRACE_LEVEL_INFO,
3285 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3286 i++;
3287 }
3288 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3289 if (!HAL_STATUS_SUCCESS(status)) {
3290 hddLog(VOS_TRACE_LEVEL_ERROR,
3291 FL("sme_SetBssHotlist failed(err=%d)"), status);
3292 vos_mem_free(pReqMsg);
3293 return -EINVAL;
3294 }
3295
Dino Myclee8843b32014-07-04 14:21:45 +05303296 vos_mem_free(pReqMsg);
3297
Dino Mycle6fb96c12014-06-10 11:52:40 +05303298 return 0;
3299
3300fail:
3301 vos_mem_free(pReqMsg);
3302 return -EINVAL;
3303}
3304
3305static int wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
3306 struct wireless_dev *wdev,
3307 void *data, int dataLen)
3308{
3309 tpSirEXTScanSetSignificantChangeReqParams pReqMsg = NULL;
3310 struct net_device *dev = wdev->netdev;
3311 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3312 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3313 struct nlattr
3314 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3315 struct nlattr
3316 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3317 struct nlattr *apTh;
3318 eHalStatus status;
3319 int i = 0;
3320 int rem;
3321
3322 status = wlan_hdd_validate_context(pHddCtx);
3323 if (0 != status)
3324 {
3325 hddLog(VOS_TRACE_LEVEL_ERROR,
3326 FL("HDD context is not valid"));
3327 return -EINVAL;
3328 }
Dino Myclee8843b32014-07-04 14:21:45 +05303329 /* check the EXTScan Capability */
3330 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3331 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3332 {
3333 hddLog(VOS_TRACE_LEVEL_ERROR,
3334 FL("EXTScan not enabled/supported by Firmware"));
3335 return -EINVAL;
3336 }
3337
Dino Mycle6fb96c12014-06-10 11:52:40 +05303338 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3339 data, dataLen,
3340 wlan_hdd_extscan_config_policy)) {
3341 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3342 return -EINVAL;
3343 }
3344
3345 /* Parse and fetch request Id */
3346 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3347 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3348 return -EINVAL;
3349 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303350 pReqMsg = (tpSirEXTScanSetSignificantChangeReqParams)
Dino Myclee8843b32014-07-04 14:21:45 +05303351 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303352 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05303353 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3354 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303355 }
3356
Dino Myclee8843b32014-07-04 14:21:45 +05303357
3358
Dino Mycle6fb96c12014-06-10 11:52:40 +05303359 pReqMsg->requestId = nla_get_u32(
3360 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3361 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3362
3363 /* Parse and fetch RSSI sample size */
3364 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE])
3365 {
3366 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr RSSI sample size failed"));
3367 goto fail;
3368 }
3369 pReqMsg->rssiSampleSize = nla_get_u32(
3370 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE]);
3371 hddLog(VOS_TRACE_LEVEL_INFO,
3372 FL("RSSI sample size (%u)"), pReqMsg->rssiSampleSize);
3373
3374 /* Parse and fetch lost AP sample size */
3375 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE])
3376 {
3377 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr lost AP sample size failed"));
3378 goto fail;
3379 }
3380 pReqMsg->lostApSampleSize = nla_get_u32(
3381 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]);
3382 hddLog(VOS_TRACE_LEVEL_INFO,
3383 FL("Lost AP sample size (%u)"), pReqMsg->lostApSampleSize);
3384 /* Parse and fetch minimum Breaching */
3385 if (!tb
3386 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]) {
3387 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr minBreaching failed"));
3388 goto fail;
3389 }
3390 pReqMsg->minBreaching = nla_get_u32(
3391 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]);
3392 hddLog(VOS_TRACE_LEVEL_INFO, FL(" Breaching (%d)"), pReqMsg->minBreaching);
3393
3394 /* Parse and fetch number of APs */
3395 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]) {
3396 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3397 goto fail;
3398 }
3399 pReqMsg->numAp = nla_get_u32(
3400 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]);
3401 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3402
3403 pReqMsg->sessionId = pAdapter->sessionId;
3404 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3405
3406 nla_for_each_nested(apTh,
3407 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3408 if(nla_parse(tb2,
3409 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3410 nla_data(apTh), nla_len(apTh),
3411 NULL)) {
3412 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3413 goto fail;
3414 }
3415
3416 /* Parse and fetch MAC address */
3417 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3418 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3419 goto fail;
3420 }
3421 memcpy(pReqMsg->ap[i].bssid, nla_data(
3422 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3423 sizeof(tSirMacAddr));
3424
3425 /* Parse and fetch low RSSI */
3426 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3427 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3428 goto fail;
3429 }
3430 pReqMsg->ap[i].low = nla_get_s32(
3431 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3432 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3433
3434 /* Parse and fetch high RSSI */
3435 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3436 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3437 goto fail;
3438 }
3439 pReqMsg->ap[i].high = nla_get_s32(
3440 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3441 hddLog(VOS_TRACE_LEVEL_INFO,
3442 FL("RSSI High (%d)"), pReqMsg->ap[i].high);
3443
3444 /* Parse and fetch channel */
3445 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3446 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3447 goto fail;
3448 }
3449 pReqMsg->ap[i].channel = nla_get_u32(
3450 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3451 hddLog(VOS_TRACE_LEVEL_INFO,
3452 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3453 i++;
3454 }
3455
3456 status = sme_SetSignificantChange(pHddCtx->hHal, pReqMsg);
3457 if (!HAL_STATUS_SUCCESS(status)) {
3458 hddLog(VOS_TRACE_LEVEL_ERROR,
3459 FL("sme_SetSignificantChange failed(err=%d)"), status);
3460 vos_mem_free(pReqMsg);
3461 return -EINVAL;
3462 }
Dino Myclee8843b32014-07-04 14:21:45 +05303463 vos_mem_free(pReqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303464 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Exiting"));
3465 return 0;
3466
3467fail:
3468 vos_mem_free(pReqMsg);
3469 return -EINVAL;
3470}
3471
3472static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
3473 struct wireless_dev *wdev,
3474 void *data, int dataLen)
3475{
3476 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3477 tANI_U32 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
3478 tANI_U8 numChannels = 0;
3479 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3480 tANI_U32 requestId;
3481 tWifiBand wifiBand;
3482 eHalStatus status;
3483 struct sk_buff *replySkb;
3484 tANI_U8 i;
3485
3486 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering"));
3487 status = wlan_hdd_validate_context(pHddCtx);
3488 if (0 != status)
3489 {
3490 hddLog(VOS_TRACE_LEVEL_ERROR,
3491 FL("HDD context is not valid"));
3492 return -EINVAL;
3493 }
Dino Myclee8843b32014-07-04 14:21:45 +05303494 /* check the EXTScan Capability */
3495 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3496 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3497 {
3498 hddLog(VOS_TRACE_LEVEL_ERROR,
3499 FL("EXTScan not enabled/supported by Firmware"));
3500 return -EINVAL;
3501 }
3502
Dino Mycle6fb96c12014-06-10 11:52:40 +05303503 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3504 data, dataLen,
3505 wlan_hdd_extscan_config_policy)) {
3506 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3507 return -EINVAL;
3508 }
3509
3510 /* Parse and fetch request Id */
3511 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3512 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3513 return -EINVAL;
3514 }
3515 requestId = nla_get_u32(
3516 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3517 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
3518
3519 /* Parse and fetch wifi band */
3520 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
3521 {
3522 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
3523 return -EINVAL;
3524 }
3525 wifiBand = nla_get_u32(
3526 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
3527 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
3528
3529 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
3530 wifiBand, ChannelList,
3531 &numChannels);
3532 if (eHAL_STATUS_SUCCESS != status) {
3533 hddLog(VOS_TRACE_LEVEL_ERROR,
3534 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
3535 return -EINVAL;
3536 }
3537 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of channels (%d)"), numChannels);
3538 for (i = 0; i < numChannels; i++)
3539 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %u ", ChannelList[i]);
3540
3541 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
3542 sizeof(u32) * numChannels +
3543 NLMSG_HDRLEN);
3544
3545 if (!replySkb) {
3546 hddLog(VOS_TRACE_LEVEL_ERROR,
3547 FL("valid channels: buffer alloc fail"));
3548 return -EINVAL;
3549 }
3550 if (nla_put_u32(replySkb,
3551 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
3552 numChannels) ||
3553 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
3554 sizeof(u32) * numChannels, ChannelList)) {
3555
3556 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3557 kfree_skb(replySkb);
3558 return -EINVAL;
3559 }
3560
3561 return cfg80211_vendor_cmd_reply(replySkb);
3562}
3563
3564static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
3565 struct wireless_dev *wdev,
3566 void *data, int dataLen)
3567{
Dino Myclee8843b32014-07-04 14:21:45 +05303568 tpSirEXTScanStartReqParams pReqMsg = NULL;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303569 struct net_device *dev = wdev->netdev;
3570 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3571 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3572 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3573 struct nlattr *bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3574 struct nlattr *channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3575 struct nlattr *buckets;
3576 struct nlattr *channels;
3577 int rem1;
3578 int rem2;
3579 eHalStatus status;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303580 tANI_U32 j = 0, index = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303581
3582 status = wlan_hdd_validate_context(pHddCtx);
3583 if (0 != status)
3584 {
3585 hddLog(VOS_TRACE_LEVEL_ERROR,
3586 FL("HDD context is not valid"));
3587 return -EINVAL;
3588 }
Dino Myclee8843b32014-07-04 14:21:45 +05303589 /* check the EXTScan Capability */
3590 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3591 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3592 {
3593 hddLog(VOS_TRACE_LEVEL_ERROR,
3594 FL("EXTScan not enabled/supported by Firmware"));
3595 return -EINVAL;
3596 }
3597
Dino Mycle6fb96c12014-06-10 11:52:40 +05303598 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3599 data, dataLen,
3600 wlan_hdd_extscan_config_policy)) {
3601 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3602 return -EINVAL;
3603 }
3604
3605 /* Parse and fetch request Id */
3606 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3607 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3608 return -EINVAL;
3609 }
3610
Dino Myclee8843b32014-07-04 14:21:45 +05303611 pReqMsg = (tpSirEXTScanStartReqParams)
3612 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303613 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05303614 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3615 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303616 }
3617
3618 pReqMsg->requestId = nla_get_u32(
3619 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3620 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3621
3622 pReqMsg->sessionId = pAdapter->sessionId;
3623 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3624
3625 /* Parse and fetch base period */
3626 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]) {
3627 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
3628 goto fail;
3629 }
3630 pReqMsg->basePeriod = nla_get_u32(
3631 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]);
3632 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
3633 pReqMsg->basePeriod);
3634
3635 /* Parse and fetch max AP per scan */
3636 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]) {
3637 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
3638 goto fail;
3639 }
3640 pReqMsg->maxAPperScan = nla_get_u32(
3641 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]);
3642 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
3643 pReqMsg->maxAPperScan);
3644
3645 /* Parse and fetch report threshold */
3646 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]) {
3647 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
3648 goto fail;
3649 }
3650 pReqMsg->reportThreshold = nla_get_u8(
3651 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]);
3652 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
3653 pReqMsg->reportThreshold);
3654
3655 /* Parse and fetch number of buckets */
3656 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]) {
3657 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
3658 goto fail;
3659 }
3660 pReqMsg->numBuckets = nla_get_u8(
3661 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]);
3662 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
3663 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
3664 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
3665 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
3666 }
3667 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
3668 pReqMsg->numBuckets);
3669 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
3670 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
3671 goto fail;
3672 }
3673
3674 nla_for_each_nested(buckets,
3675 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
3676 if(nla_parse(bucket,
3677 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3678 nla_data(buckets), nla_len(buckets), NULL)) { //policy
3679 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3680 goto fail;
3681 }
3682
3683 /* Parse and fetch bucket spec */
3684 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
3685 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket index failed"));
3686 goto fail;
3687 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303688
3689 pReqMsg->buckets[index].bucket = nla_get_u8(
3690 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
3691
3692 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bucket spec Index (%d)"),
3693 pReqMsg->buckets[index].bucket);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303694
3695 /* Parse and fetch wifi band */
3696 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
3697 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
3698 goto fail;
3699 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303700 pReqMsg->buckets[index].band = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303701 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
3702 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303703 pReqMsg->buckets[index].band);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303704
3705 /* Parse and fetch period */
3706 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
3707 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr period failed"));
3708 goto fail;
3709 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303710 pReqMsg->buckets[index].period = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303711 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
3712 hddLog(VOS_TRACE_LEVEL_INFO, FL("period (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303713 pReqMsg->buckets[index].period);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303714
3715 /* Parse and fetch report events */
3716 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
3717 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report events failed"));
3718 goto fail;
3719 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303720 pReqMsg->buckets[index].reportEvents = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303721 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
3722 hddLog(VOS_TRACE_LEVEL_INFO, FL("report events (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303723 pReqMsg->buckets[index].reportEvents);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303724
3725 /* Parse and fetch number of channels */
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303726 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS])
3727 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303728 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr num channels failed"));
3729 goto fail;
3730 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303731 pReqMsg->buckets[index].numChannels = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303732 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
3733 hddLog(VOS_TRACE_LEVEL_INFO, FL("num channels (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303734 pReqMsg->buckets[index].numChannels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303735
3736 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
3737 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel spec failed"));
3738 goto fail;
3739 }
3740
3741 j = 0;
3742 nla_for_each_nested(channels,
3743 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
3744 if(nla_parse(channel,
3745 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3746 nla_data(channels), nla_len(channels),
3747 NULL)) { //wlan_hdd_extscan_config_policy here
3748 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3749 goto fail;
3750 }
3751
3752 /* Parse and fetch channel */
3753 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
3754 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3755 goto fail;
3756 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303757 pReqMsg->buckets[index].channels[j].channel = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303758 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
3759 hddLog(VOS_TRACE_LEVEL_INFO, FL("channel (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303760 pReqMsg->buckets[index].channels[j].channel);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303761
3762 /* Parse and fetch dwell time */
3763 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
3764 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dwelltime failed"));
3765 goto fail;
3766 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303767 pReqMsg->buckets[index].channels[j].dwellTimeMs = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303768 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
3769 hddLog(VOS_TRACE_LEVEL_INFO, FL("Dwell time (%u ms)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303770 pReqMsg->buckets[index].channels[j].dwellTimeMs);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303771
3772 /* Parse and fetch channel spec passive */
3773 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
3774 hddLog(VOS_TRACE_LEVEL_ERROR,
3775 FL("attr channel spec passive failed"));
3776 goto fail;
3777 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303778 pReqMsg->buckets[index].channels[j].passive = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303779 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
3780 hddLog(VOS_TRACE_LEVEL_INFO, FL("Chnl spec passive (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303781 pReqMsg->buckets[index].channels[j].passive);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303782 j++;
3783 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303784 index++;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303785 }
3786 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
3787 if (!HAL_STATUS_SUCCESS(status)) {
3788 hddLog(VOS_TRACE_LEVEL_ERROR,
3789 FL("sme_EXTScanStart failed(err=%d)"), status);
3790 vos_mem_free(pReqMsg);
3791 return -EINVAL;
3792 }
3793
Dino Myclee8843b32014-07-04 14:21:45 +05303794 vos_mem_free(pReqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303795 return 0;
3796
3797fail:
3798 vos_mem_free(pReqMsg);
3799 return -EINVAL;
3800}
3801
3802static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
3803 struct wireless_dev *wdev,
3804 void *data, int dataLen)
3805{
Dino Myclee8843b32014-07-04 14:21:45 +05303806 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303807 struct net_device *dev = wdev->netdev;
3808 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3809 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3810 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3811 eHalStatus status;
3812
3813 status = wlan_hdd_validate_context(pHddCtx);
3814 if (0 != status)
3815 {
3816 hddLog(VOS_TRACE_LEVEL_ERROR,
3817 FL("HDD context is not valid"));
3818 return -EINVAL;
3819 }
Dino Myclee8843b32014-07-04 14:21:45 +05303820 /* check the EXTScan Capability */
3821 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3822 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3823 {
3824 hddLog(VOS_TRACE_LEVEL_ERROR,
3825 FL("EXTScan not enabled/supported by Firmware"));
3826 return -EINVAL;
3827 }
3828
Dino Mycle6fb96c12014-06-10 11:52:40 +05303829 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3830 data, dataLen,
3831 wlan_hdd_extscan_config_policy)) {
3832 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3833 return -EINVAL;
3834 }
3835
3836 /* Parse and fetch request Id */
3837 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3838 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3839 return -EINVAL;
3840 }
3841
Dino Myclee8843b32014-07-04 14:21:45 +05303842 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303843 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303844 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303845
Dino Myclee8843b32014-07-04 14:21:45 +05303846 reqMsg.sessionId = pAdapter->sessionId;
3847 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303848
Dino Myclee8843b32014-07-04 14:21:45 +05303849 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303850 if (!HAL_STATUS_SUCCESS(status)) {
3851 hddLog(VOS_TRACE_LEVEL_ERROR,
3852 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303853 return -EINVAL;
3854 }
3855
3856 return 0;
3857}
3858
3859static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
3860 struct wireless_dev *wdev,
3861 void *data, int dataLen)
3862{
Dino Myclee8843b32014-07-04 14:21:45 +05303863 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303864 struct net_device *dev = wdev->netdev;
3865 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3866 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3867 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3868 eHalStatus status;
3869
3870 status = wlan_hdd_validate_context(pHddCtx);
3871 if (0 != status)
3872 {
3873 hddLog(VOS_TRACE_LEVEL_ERROR,
3874 FL("HDD context is not valid"));
3875 return -EINVAL;
3876 }
Dino Myclee8843b32014-07-04 14:21:45 +05303877 /* check the EXTScan Capability */
3878 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3879 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3880 {
3881 hddLog(VOS_TRACE_LEVEL_ERROR,
3882 FL("EXTScan not enabled/supported by Firmware"));
3883 return -EINVAL;
3884 }
3885
Dino Mycle6fb96c12014-06-10 11:52:40 +05303886 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3887 data, dataLen,
3888 wlan_hdd_extscan_config_policy)) {
3889 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3890 return -EINVAL;
3891 }
3892
3893 /* Parse and fetch request Id */
3894 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3895 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3896 return -EINVAL;
3897 }
3898
Dino Myclee8843b32014-07-04 14:21:45 +05303899 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303900 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303901 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303902
Dino Myclee8843b32014-07-04 14:21:45 +05303903 reqMsg.sessionId = pAdapter->sessionId;
3904 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303905
Dino Myclee8843b32014-07-04 14:21:45 +05303906 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303907 if (!HAL_STATUS_SUCCESS(status)) {
3908 hddLog(VOS_TRACE_LEVEL_ERROR,
3909 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303910 return -EINVAL;
3911 }
3912
3913 return 0;
3914}
3915
3916static int wlan_hdd_cfg80211_extscan_reset_significant_change(
3917 struct wiphy *wiphy,
3918 struct wireless_dev *wdev,
3919 void *data, int dataLen)
3920{
Dino Myclee8843b32014-07-04 14:21:45 +05303921 tSirEXTScanResetSignificantChangeReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303922 struct net_device *dev = wdev->netdev;
3923 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3924 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3925 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3926 eHalStatus status;
3927
3928 hddLog(VOS_TRACE_LEVEL_INFO, FL(" Entering"));
3929 status = wlan_hdd_validate_context(pHddCtx);
3930 if (0 != status)
3931 {
3932 hddLog(VOS_TRACE_LEVEL_ERROR,
3933 FL("HDD context is not valid"));
3934 return -EINVAL;
3935 }
Dino Myclee8843b32014-07-04 14:21:45 +05303936 /* check the EXTScan Capability */
3937 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3938 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3939 {
3940 hddLog(VOS_TRACE_LEVEL_ERROR,
3941 FL("EXTScan not enabled/supported by Firmware"));
3942 return -EINVAL;
3943 }
3944
Dino Mycle6fb96c12014-06-10 11:52:40 +05303945 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3946 data, dataLen,
3947 wlan_hdd_extscan_config_policy)) {
3948 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3949 return -EINVAL;
3950 }
3951
3952 /* Parse and fetch request Id */
3953 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3954 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3955 return -EINVAL;
3956 }
3957
Dino Mycle6fb96c12014-06-10 11:52:40 +05303958
Dino Myclee8843b32014-07-04 14:21:45 +05303959 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303960 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303961 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303962
Dino Myclee8843b32014-07-04 14:21:45 +05303963 reqMsg.sessionId = pAdapter->sessionId;
3964 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303965
Dino Myclee8843b32014-07-04 14:21:45 +05303966 status = sme_ResetSignificantChange(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303967 if (!HAL_STATUS_SUCCESS(status)) {
3968 hddLog(VOS_TRACE_LEVEL_ERROR,
3969 FL("sme_ResetSignificantChange failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303970 return -EINVAL;
3971 }
3972
3973 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Exiting"));
3974 return 0;
3975}
3976
3977#endif /* WLAN_FEATURE_EXTSCAN */
3978
Atul Mittal115287b2014-07-08 13:26:33 +05303979/*EXT TDLS*/
3980static const struct nla_policy
3981wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
3982{
3983 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
3984 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
3985 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
3986 {.type = NLA_S32 },
3987 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
3988 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
3989
3990};
3991
3992static const struct nla_policy
3993wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
3994{
3995 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
3996
3997};
3998
3999static const struct nla_policy
4000wlan_hdd_tdls_config_state_change_policy[
4001 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
4002{
4003 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
4004 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
4005 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304006 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
4007 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
4008 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304009
4010};
4011
4012static const struct nla_policy
4013wlan_hdd_tdls_config_get_status_policy[
4014 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
4015{
4016 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
4017 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
4018 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304019 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
4020 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
4021 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304022
4023};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304024
4025static const struct nla_policy
4026wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
4027{
4028 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
4029};
4030
4031static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
4032 struct wireless_dev *wdev,
4033 void *data,
4034 int data_len)
4035{
4036
4037 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4038 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
4039
4040 if (0 != wlan_hdd_validate_context(pHddCtx)){
4041 hddLog(VOS_TRACE_LEVEL_ERROR, FL("hdd Ctx invalid while spoof macAddr"));
4042 return -EINVAL;
4043 }
4044 if (FALSE == pHddCtx->cfg_ini->enableMacSpoofing) {
4045 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MAC_SPOOFED_SCAN disabled in ini"));
4046 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05304047 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304048 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
4049 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MAC_SPOOFED_SCAN not supported by FW"));
4050 return -ENOTSUPP;
4051 }
4052
4053 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
4054 data, data_len, wlan_hdd_mac_config)) {
4055 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4056 return -EINVAL;
4057 }
4058
4059 /* Parse and fetch mac address */
4060 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
4061 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4062 return -EINVAL;
4063 }
4064
4065 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
4066 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4067 VOS_MAC_ADDR_LAST_3_BYTES);
4068
Siddharth Bhal76972212014-10-15 16:22:51 +05304069 pHddCtx->spoofMacAddr.isEnabled = TRUE;
4070
4071 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304072 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4073 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05304074 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
4075 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
4076 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
4077 {
4078 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
4079 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
4080 VOS_MAC_ADDRESS_LEN);
4081 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304082 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304083
Siddharth Bhal76972212014-10-15 16:22:51 +05304084 if (VOS_STATUS_SUCCESS != hdd_processSpoofMacAddrRequest(pHddCtx))
4085 {
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304086 hddLog(LOGE, FL("Failed to send Spoof Mac Addr to FW"));
4087 }
4088
4089 return 0;
4090}
4091
Atul Mittal115287b2014-07-08 13:26:33 +05304092static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
4093 struct wireless_dev *wdev,
4094 void *data,
4095 int data_len)
4096{
4097 u8 peer[6] = {0};
4098 struct net_device *dev = wdev->netdev;
4099 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4100 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4101 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
4102 eHalStatus ret;
4103 tANI_S32 state;
4104 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304105 tANI_S32 global_operating_class = 0;
4106 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05304107 struct sk_buff *skb = NULL;
4108
4109 ret = wlan_hdd_validate_context(pHddCtx);
4110 if (0 != ret) {
4111
4112 return -EINVAL;
4113 }
4114 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
4115
4116 return -ENOTSUPP;
4117 }
4118 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
4119 data, data_len,
4120 wlan_hdd_tdls_config_get_status_policy)) {
4121 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4122 return -EINVAL;
4123 }
4124
4125 /* Parse and fetch mac address */
4126 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
4127 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4128 return -EINVAL;
4129 }
4130
4131 memcpy(peer, nla_data(
4132 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
4133 sizeof(peer));
4134 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4135
4136 ret = wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
4137
4138 if (0 != ret) {
4139 hddLog(VOS_TRACE_LEVEL_ERROR,
4140 FL("get status Failed"));
4141 return -EINVAL;
4142 }
4143 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304144 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05304145 NLMSG_HDRLEN);
4146
4147 if (!skb) {
4148 hddLog(VOS_TRACE_LEVEL_ERROR,
4149 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
4150 return -EINVAL;
4151 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304152 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 +05304153 reason,
4154 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304155 global_operating_class,
4156 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05304157 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304158 if (nla_put_s32(skb,
4159 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
4160 state) ||
4161 nla_put_s32(skb,
4162 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
4163 reason) ||
4164 nla_put_s32(skb,
4165 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
4166 global_operating_class) ||
4167 nla_put_s32(skb,
4168 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
4169 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05304170
4171 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4172 goto nla_put_failure;
4173 }
4174
4175 return cfg80211_vendor_cmd_reply(skb);
4176
4177nla_put_failure:
4178 kfree_skb(skb);
4179 return -EINVAL;
4180}
4181
4182static int wlan_hdd_cfg80211_exttdls_callback(tANI_U8* mac,
4183 tANI_S32 state,
4184 tANI_S32 reason,
4185 void *ctx)
4186{
4187 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
4188 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4189 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304190 tANI_S32 global_operating_class = 0;
4191 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05304192
4193 if (wlan_hdd_validate_context(pHddCtx)) {
4194 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "));
4195 return -EINVAL;
4196 }
4197
4198 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
4199
4200 return -ENOTSUPP;
4201 }
4202 skb = cfg80211_vendor_event_alloc(
4203 pHddCtx->wiphy,
4204 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
4205 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
4206 GFP_KERNEL);
4207
4208 if (!skb) {
4209 hddLog(VOS_TRACE_LEVEL_ERROR,
4210 FL("cfg80211_vendor_event_alloc failed"));
4211 return -EINVAL;
4212 }
4213 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304214 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
4215 reason,
4216 state,
4217 global_operating_class,
4218 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05304219 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
4220 MAC_ADDR_ARRAY(mac));
4221
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304222 if (nla_put(skb,
4223 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
4224 VOS_MAC_ADDR_SIZE, mac) ||
4225 nla_put_s32(skb,
4226 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
4227 state) ||
4228 nla_put_s32(skb,
4229 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
4230 reason) ||
4231 nla_put_s32(skb,
4232 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
4233 channel) ||
4234 nla_put_s32(skb,
4235 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
4236 global_operating_class)
4237 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05304238 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4239 goto nla_put_failure;
4240 }
4241
4242 cfg80211_vendor_event(skb, GFP_KERNEL);
4243 return (0);
4244
4245nla_put_failure:
4246 kfree_skb(skb);
4247 return -EINVAL;
4248}
4249
4250static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
4251 struct wireless_dev *wdev,
4252 void *data,
4253 int data_len)
4254{
4255 u8 peer[6] = {0};
4256 struct net_device *dev = wdev->netdev;
4257 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4258 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4259 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
4260 eHalStatus status;
4261 tdls_req_params_t pReqMsg = {0};
4262
4263 status = wlan_hdd_validate_context(pHddCtx);
4264 if (0 != status) {
4265 hddLog(VOS_TRACE_LEVEL_ERROR,
4266 FL("HDD context is not valid"));
4267 return -EINVAL;
4268 }
4269 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
4270
4271 return -ENOTSUPP;
4272 }
4273 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
4274 data, data_len,
4275 wlan_hdd_tdls_config_enable_policy)) {
4276 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4277 return -EINVAL;
4278 }
4279
4280 /* Parse and fetch mac address */
4281 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
4282 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4283 return -EINVAL;
4284 }
4285
4286 memcpy(peer, nla_data(
4287 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
4288 sizeof(peer));
4289 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4290
4291 /* Parse and fetch channel */
4292 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
4293 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4294 return -EINVAL;
4295 }
4296 pReqMsg.channel = nla_get_s32(
4297 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
4298 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
4299
4300 /* Parse and fetch global operating class */
4301 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
4302 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
4303 return -EINVAL;
4304 }
4305 pReqMsg.global_operating_class = nla_get_s32(
4306 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
4307 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
4308 pReqMsg.global_operating_class);
4309
4310 /* Parse and fetch latency ms */
4311 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
4312 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
4313 return -EINVAL;
4314 }
4315 pReqMsg.max_latency_ms = nla_get_s32(
4316 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
4317 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
4318 pReqMsg.max_latency_ms);
4319
4320 /* Parse and fetch required bandwidth kbps */
4321 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
4322 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
4323 return -EINVAL;
4324 }
4325
4326 pReqMsg.min_bandwidth_kbps = nla_get_s32(
4327 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
4328 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
4329 pReqMsg.min_bandwidth_kbps);
4330
4331 return (wlan_hdd_tdls_extctrl_config_peer(pAdapter,
4332 peer,
4333 wlan_hdd_cfg80211_exttdls_callback));
4334}
4335
4336static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
4337 struct wireless_dev *wdev,
4338 void *data,
4339 int data_len)
4340{
4341 u8 peer[6] = {0};
4342 struct net_device *dev = wdev->netdev;
4343 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4344 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4345 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
4346 eHalStatus status;
4347
4348 status = wlan_hdd_validate_context(pHddCtx);
4349 if (0 != status) {
4350 hddLog(VOS_TRACE_LEVEL_ERROR,
4351 FL("HDD context is not valid"));
4352 return -EINVAL;
4353 }
4354 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
4355
4356 return -ENOTSUPP;
4357 }
4358 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
4359 data, data_len,
4360 wlan_hdd_tdls_config_disable_policy)) {
4361 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4362 return -EINVAL;
4363 }
4364 /* Parse and fetch mac address */
4365 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
4366 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4367 return -EINVAL;
4368 }
4369
4370 memcpy(peer, nla_data(
4371 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
4372 sizeof(peer));
4373 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4374
4375 return (wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer));
4376}
4377
Dasari Srinivas7875a302014-09-26 17:50:57 +05304378static int
4379wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
4380 struct wireless_dev *wdev,
4381 void *data, int data_len)
4382{
4383 struct net_device *dev = wdev->netdev;
4384 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4385 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4386 struct sk_buff *skb = NULL;
4387 tANI_U32 fset = 0;
4388
4389 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
4390 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
4391 fset |= WIFI_FEATURE_INFRA;
4392 }
4393
4394 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
4395 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
4396 fset |= WIFI_FEATURE_INFRA_5G;
4397 }
4398
4399#ifdef WLAN_FEATURE_P2P
4400 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
4401 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
4402 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
4403 fset |= WIFI_FEATURE_P2P;
4404 }
4405#endif
4406
4407 /* Soft-AP is supported currently by default */
4408 fset |= WIFI_FEATURE_SOFT_AP;
4409
4410#ifdef WLAN_FEATURE_EXTSCAN
4411 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
4412 sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) {
4413 hddLog(LOG1, FL("EXTScan is supported by firmware"));
4414 fset |= WIFI_FEATURE_EXTSCAN;
4415 }
4416#endif
4417
4418#ifdef WLAN_FEATURE_NAN
4419 if (sme_IsFeatureSupportedByFW(NAN)) {
4420 hddLog(LOG1, FL("NAN is supported by firmware"));
4421 fset |= WIFI_FEATURE_NAN;
4422 }
4423#endif
4424
4425 /* D2D RTT is not supported currently by default */
4426 if (sme_IsFeatureSupportedByFW(RTT)) {
4427 hddLog(LOG1, FL("RTT is supported by firmware"));
4428 fset |= WIFI_FEATURE_D2AP_RTT;
4429 }
4430
4431#ifdef FEATURE_WLAN_BATCH_SCAN
4432 if (fset & WIFI_FEATURE_EXTSCAN) {
4433 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
4434 fset &= ~WIFI_FEATURE_BATCH_SCAN;
4435 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
4436 hddLog(LOG1, FL("Batch scan is supported by firmware"));
4437 fset |= WIFI_FEATURE_BATCH_SCAN;
4438 }
4439#endif
4440
4441#ifdef FEATURE_WLAN_SCAN_PNO
4442 if (pHddCtx->cfg_ini->configPNOScanSupport &&
4443 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
4444 hddLog(LOG1, FL("PNO is supported by firmware"));
4445 fset |= WIFI_FEATURE_PNO;
4446 }
4447#endif
4448
4449 /* STA+STA is supported currently by default */
4450 fset |= WIFI_FEATURE_ADDITIONAL_STA;
4451
4452#ifdef FEATURE_WLAN_TDLS
4453 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
4454 sme_IsFeatureSupportedByFW(TDLS)) {
4455 hddLog(LOG1, FL("TDLS is supported by firmware"));
4456 fset |= WIFI_FEATURE_TDLS;
4457 }
4458
4459 /* TDLS_OFFCHANNEL is not supported currently by default */
4460#endif
4461
4462#ifdef WLAN_AP_STA_CONCURRENCY
4463 /* AP+STA concurrency is supported currently by default */
4464 fset |= WIFI_FEATURE_AP_STA;
4465#endif
4466
4467 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
4468 NLMSG_HDRLEN);
4469
4470 if (!skb) {
4471 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
4472 return -EINVAL;
4473 }
4474 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
4475
4476 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
4477 hddLog(LOGE, FL("nla put fail"));
4478 goto nla_put_failure;
4479 }
4480
4481 return cfg80211_vendor_cmd_reply(skb);
4482
4483nla_put_failure:
4484 kfree_skb(skb);
4485 return -EINVAL;
4486}
4487
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05304488static int
4489wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
4490 struct wireless_dev *wdev,
4491 void *data, int data_len)
4492{
4493 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
4494 uint8_t i, feature_sets, max_feature_sets;
4495 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX + 1];
4496 struct sk_buff *reply_skb;
4497
4498 ENTER();
4499
4500 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX,
4501 data, data_len, NULL)) {
4502 hddLog(LOGE, FL("Invalid ATTR"));
4503 return -EINVAL;
4504 }
4505
4506 /* Parse and fetch max feature set */
4507 if (!tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
4508 hddLog(LOGE, FL("Attr max feature set size failed"));
4509 return -EINVAL;
4510 }
4511 max_feature_sets = nla_get_u32(
4512 tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
4513 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
4514
4515 /* Fill feature combination matrix */
4516 feature_sets = 0;
4517 if (feature_sets >= WLAN_HDD_MAX_FEATURE_SET) goto max_buffer_err;
4518 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
4519 WIFI_FEATURE_P2P;
4520
4521 if (feature_sets >= WLAN_HDD_MAX_FEATURE_SET) goto max_buffer_err;
4522 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
4523 WIFI_FEATURE_SOFT_AP;
4524
4525 if (feature_sets >= WLAN_HDD_MAX_FEATURE_SET) goto max_buffer_err;
4526 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
4527 WIFI_FEATURE_SOFT_AP;
4528
4529 if (feature_sets >= WLAN_HDD_MAX_FEATURE_SET) goto max_buffer_err;
4530 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
4531 WIFI_FEATURE_SOFT_AP |
4532 WIFI_FEATURE_P2P;
4533
4534 /* Add more feature combinations here */
4535
4536 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
4537 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
4538 hddLog(LOG1, "Feature set matrix");
4539 for (i = 0; i < feature_sets; i++)
4540 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
4541
4542 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
4543 sizeof(u32) * feature_sets +
4544 NLMSG_HDRLEN);
4545
4546 if (reply_skb) {
4547 if (nla_put_u32(reply_skb,
4548 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
4549 feature_sets) ||
4550 nla_put(reply_skb,
4551 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
4552 sizeof(u32) * feature_sets, feature_set_matrix)) {
4553 hddLog(LOGE, FL("nla put fail"));
4554 kfree_skb(reply_skb);
4555 return -EINVAL;
4556 }
4557
4558 return cfg80211_vendor_cmd_reply(reply_skb);
4559 }
4560 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
4561 return -ENOMEM;
4562
4563max_buffer_err:
4564 hddLog(LOGE, FL("Feature set max buffer size reached. feature_sets(%d) max(%d)"),
4565 feature_sets, WLAN_HDD_MAX_FEATURE_SET);
4566 return -EINVAL;
4567}
4568
Agarwal Ashish738843c2014-09-25 12:27:56 +05304569static const struct nla_policy
4570wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
4571 +1] =
4572{
4573 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
4574};
4575
4576static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
4577 struct wireless_dev *wdev,
4578 void *data,
4579 int data_len)
4580{
4581 struct net_device *dev = wdev->netdev;
4582 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4583 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4584 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4585 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
4586 eHalStatus status;
4587 u32 dfsFlag = 0;
4588
4589 status = wlan_hdd_validate_context(pHddCtx);
4590 if (0 != status) {
4591 hddLog(VOS_TRACE_LEVEL_ERROR,
4592 FL("HDD context is not valid"));
4593 return -EINVAL;
4594 }
4595 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
4596 data, data_len,
4597 wlan_hdd_set_no_dfs_flag_config_policy)) {
4598 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4599 return -EINVAL;
4600 }
4601
4602 /* Parse and fetch required bandwidth kbps */
4603 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
4604 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
4605 return -EINVAL;
4606 }
4607
4608 dfsFlag = nla_get_u32(
4609 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
4610 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
4611 dfsFlag);
4612
4613 pHddCtx->disable_dfs_flag = dfsFlag;
4614
4615 sme_disable_dfs_channel(hHal, dfsFlag);
4616 sme_FilterScanResults(hHal, pAdapter->sessionId);
4617 return 0;
4618}
Atul Mittal115287b2014-07-08 13:26:33 +05304619
Mukul Sharma2a271632014-10-13 14:59:01 +05304620const struct
4621nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
4622{
4623 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
4624 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
4625};
4626
4627static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
4628 struct wireless_dev *wdev, void *data, int data_len)
4629{
4630
4631 u8 bssid[6] = {0};
4632 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4633 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
4634 eHalStatus status = eHAL_STATUS_SUCCESS;
4635 v_U32_t isFwrRoamEnabled = FALSE;
4636 int ret;
4637
4638 if (NULL == pHddCtx) {
4639 hddLog(VOS_TRACE_LEVEL_ERROR,
4640 FL("HDD context is not valid"));
4641 return -EINVAL;
4642 }
4643
4644 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
4645 data, data_len,
4646 qca_wlan_vendor_attr);
4647 if (ret){
4648 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4649 return -EINVAL;
4650 }
4651
4652 /* Parse and fetch Enable flag */
4653 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
4654 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
4655 return -EINVAL;
4656 }
4657
4658 isFwrRoamEnabled = nla_get_u32(
4659 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
4660
4661 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
4662
4663 /* Parse and fetch bssid */
4664 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
4665 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
4666 return -EINVAL;
4667 }
4668
4669 memcpy(bssid, nla_data(
4670 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
4671 sizeof(bssid));
4672 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
4673
4674 //Update roaming
4675 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
4676 return status;
4677}
4678
Sunil Duttc69bccb2014-05-26 21:30:20 +05304679const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
4680{
Mukul Sharma2a271632014-10-13 14:59:01 +05304681 {
4682 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4683 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
4684 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4685 WIPHY_VENDOR_CMD_NEED_NETDEV |
4686 WIPHY_VENDOR_CMD_NEED_RUNNING,
4687 .doit = wlan_hdd_cfg80211_firmware_roaming
4688 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05304689#ifdef WLAN_FEATURE_LINK_LAYER_STATS
4690 {
4691 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4692 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
4693 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4694 WIPHY_VENDOR_CMD_NEED_NETDEV |
4695 WIPHY_VENDOR_CMD_NEED_RUNNING,
4696 .doit = wlan_hdd_cfg80211_ll_stats_clear
4697 },
4698
4699 {
4700 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4701 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
4702 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4703 WIPHY_VENDOR_CMD_NEED_NETDEV |
4704 WIPHY_VENDOR_CMD_NEED_RUNNING,
4705 .doit = wlan_hdd_cfg80211_ll_stats_set
4706 },
4707
4708 {
4709 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4710 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
4711 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4712 WIPHY_VENDOR_CMD_NEED_NETDEV |
4713 WIPHY_VENDOR_CMD_NEED_RUNNING,
4714 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05304715 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05304716#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05304717#ifdef WLAN_FEATURE_EXTSCAN
4718 {
4719 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4720 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
4721 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4722 WIPHY_VENDOR_CMD_NEED_NETDEV |
4723 WIPHY_VENDOR_CMD_NEED_RUNNING,
4724 .doit = wlan_hdd_cfg80211_extscan_start
4725 },
4726 {
4727 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4728 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
4729 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4730 WIPHY_VENDOR_CMD_NEED_NETDEV |
4731 WIPHY_VENDOR_CMD_NEED_RUNNING,
4732 .doit = wlan_hdd_cfg80211_extscan_stop
4733 },
4734 {
4735 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4736 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
4737 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4738 WIPHY_VENDOR_CMD_NEED_NETDEV,
4739 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
4740 },
4741 {
4742 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4743 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
4744 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4745 WIPHY_VENDOR_CMD_NEED_NETDEV |
4746 WIPHY_VENDOR_CMD_NEED_RUNNING,
4747 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
4748 },
4749 {
4750 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4751 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
4752 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4753 WIPHY_VENDOR_CMD_NEED_NETDEV |
4754 WIPHY_VENDOR_CMD_NEED_RUNNING,
4755 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
4756 },
4757 {
4758 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4759 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
4760 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4761 WIPHY_VENDOR_CMD_NEED_NETDEV |
4762 WIPHY_VENDOR_CMD_NEED_RUNNING,
4763 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
4764 },
4765 {
4766 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4767 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
4768 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4769 WIPHY_VENDOR_CMD_NEED_NETDEV |
4770 WIPHY_VENDOR_CMD_NEED_RUNNING,
4771 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
4772 },
4773 {
4774 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4775 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE,
4776 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4777 WIPHY_VENDOR_CMD_NEED_NETDEV |
4778 WIPHY_VENDOR_CMD_NEED_RUNNING,
4779 .doit = wlan_hdd_cfg80211_extscan_set_significant_change
4780 },
4781 {
4782 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4783 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE,
4784 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4785 WIPHY_VENDOR_CMD_NEED_NETDEV |
4786 WIPHY_VENDOR_CMD_NEED_RUNNING,
4787 .doit = wlan_hdd_cfg80211_extscan_reset_significant_change
4788 },
4789#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05304790/*EXT TDLS*/
4791 {
4792 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4793 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
4794 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4795 WIPHY_VENDOR_CMD_NEED_NETDEV |
4796 WIPHY_VENDOR_CMD_NEED_RUNNING,
4797 .doit = wlan_hdd_cfg80211_exttdls_enable
4798 },
4799 {
4800 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4801 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
4802 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4803 WIPHY_VENDOR_CMD_NEED_NETDEV |
4804 WIPHY_VENDOR_CMD_NEED_RUNNING,
4805 .doit = wlan_hdd_cfg80211_exttdls_disable
4806 },
4807 {
4808 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4809 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
4810 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4811 WIPHY_VENDOR_CMD_NEED_NETDEV,
4812 .doit = wlan_hdd_cfg80211_exttdls_get_status
4813 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05304814 {
4815 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4816 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
4817 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4818 WIPHY_VENDOR_CMD_NEED_NETDEV,
4819 .doit = wlan_hdd_cfg80211_get_supported_features
4820 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05304821 {
4822 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4823 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
4824 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4825 WIPHY_VENDOR_CMD_NEED_NETDEV,
4826 .doit = wlan_hdd_cfg80211_disable_dfs_channels
4827 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304828 {
4829 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4830 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
4831 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4832 WIPHY_VENDOR_CMD_NEED_NETDEV,
4833 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
4834 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05304835 {
4836 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4837 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
4838 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4839 WIPHY_VENDOR_CMD_NEED_NETDEV,
4840 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
4841 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05304842};
4843
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08004844/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05304845static const
4846struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08004847{
4848#ifdef FEATURE_WLAN_CH_AVOID
4849 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05304850 .vendor_id = QCA_NL80211_VENDOR_ID,
4851 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08004852 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05304853#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
4854#ifdef WLAN_FEATURE_LINK_LAYER_STATS
4855 {
4856 /* Index = 1*/
4857 .vendor_id = QCA_NL80211_VENDOR_ID,
4858 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
4859 },
4860 {
4861 /* Index = 2*/
4862 .vendor_id = QCA_NL80211_VENDOR_ID,
4863 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
4864 },
4865 {
4866 /* Index = 3*/
4867 .vendor_id = QCA_NL80211_VENDOR_ID,
4868 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
4869 },
4870 {
4871 /* Index = 4*/
4872 .vendor_id = QCA_NL80211_VENDOR_ID,
4873 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
4874 },
4875 {
4876 /* Index = 5*/
4877 .vendor_id = QCA_NL80211_VENDOR_ID,
4878 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
4879 },
4880 {
4881 /* Index = 6*/
4882 .vendor_id = QCA_NL80211_VENDOR_ID,
4883 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
4884 },
4885#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05304886#ifdef WLAN_FEATURE_EXTSCAN
4887 {
4888 .vendor_id = QCA_NL80211_VENDOR_ID,
4889 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
4890 },
4891 {
4892 .vendor_id = QCA_NL80211_VENDOR_ID,
4893 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
4894 },
4895 {
4896 .vendor_id = QCA_NL80211_VENDOR_ID,
4897 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
4898 },
4899 {
4900 .vendor_id = QCA_NL80211_VENDOR_ID,
4901 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
4902 },
4903 {
4904 .vendor_id = QCA_NL80211_VENDOR_ID,
4905 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
4906 },
4907 {
4908 .vendor_id = QCA_NL80211_VENDOR_ID,
4909 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
4910 },
4911 {
4912 .vendor_id = QCA_NL80211_VENDOR_ID,
4913 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
4914 },
4915 {
4916 .vendor_id = QCA_NL80211_VENDOR_ID,
4917 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
4918 },
4919 {
4920 .vendor_id = QCA_NL80211_VENDOR_ID,
4921 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
4922 },
4923 {
4924 .vendor_id = QCA_NL80211_VENDOR_ID,
4925 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
4926 },
4927 {
4928 .vendor_id = QCA_NL80211_VENDOR_ID,
4929 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE
4930 },
4931 {
4932 .vendor_id = QCA_NL80211_VENDOR_ID,
4933 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE
4934 },
4935 {
4936 .vendor_id = QCA_NL80211_VENDOR_ID,
4937 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE
4938 },
4939#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05304940/*EXT TDLS*/
4941 {
4942 .vendor_id = QCA_NL80211_VENDOR_ID,
4943 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
4944 },
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08004945};
4946
Jeff Johnson295189b2012-06-20 16:38:30 -07004947/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05304948 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304949 * This function is called by hdd_wlan_startup()
4950 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05304951 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07004952 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05304953struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07004954{
4955 struct wiphy *wiphy;
4956 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304957 /*
4958 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07004959 */
4960 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
4961
4962 if (!wiphy)
4963 {
4964 /* Print error and jump into err label and free the memory */
4965 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
4966 return NULL;
4967 }
4968
Sunil Duttc69bccb2014-05-26 21:30:20 +05304969
Jeff Johnson295189b2012-06-20 16:38:30 -07004970 return wiphy;
4971}
4972
4973/*
4974 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304975 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07004976 * private ioctl to change the band value
4977 */
4978int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
4979{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05304980 int i, j;
4981 eNVChannelEnabledType channelEnabledState;
4982
Jeff Johnsone7245742012-09-05 17:12:55 -07004983 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304984
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05304985 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07004986 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05304987
4988 if (NULL == wiphy->bands[i])
4989 {
4990 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
4991 __func__, i);
4992 continue;
4993 }
4994
4995 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
4996 {
4997 struct ieee80211_supported_band *band = wiphy->bands[i];
4998
4999 channelEnabledState = vos_nv_getChannelEnabledState(
5000 band->channels[j].hw_value);
5001
5002 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
5003 {
Abhishek Singh678227a2014-11-04 10:52:38 +05305004 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305005 continue;
5006 }
5007 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
5008 {
5009 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5010 continue;
5011 }
5012
5013 if (NV_CHANNEL_DISABLE == channelEnabledState ||
5014 NV_CHANNEL_INVALID == channelEnabledState)
5015 {
5016 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5017 }
5018 else if (NV_CHANNEL_DFS == channelEnabledState)
5019 {
5020 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5021 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
5022 }
5023 else
5024 {
5025 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
5026 |IEEE80211_CHAN_RADAR);
5027 }
5028 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005029 }
5030 return 0;
5031}
5032/*
5033 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305034 * This function is called by hdd_wlan_startup()
5035 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07005036 * This function is used to initialize and register wiphy structure.
5037 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305038int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005039 struct wiphy *wiphy,
5040 hdd_config_t *pCfg
5041 )
5042{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305043 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305044 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5045
Jeff Johnsone7245742012-09-05 17:12:55 -07005046 ENTER();
5047
Jeff Johnson295189b2012-06-20 16:38:30 -07005048 /* Now bind the underlying wlan device with wiphy */
5049 set_wiphy_dev(wiphy, dev);
5050
5051 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005052
Kiet Lam6c583332013-10-14 05:37:09 +05305053#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07005054 /* the flag for the other case would be initialzed in
5055 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07005056 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05305057#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005058
Amar Singhalfddc28c2013-09-05 13:03:40 -07005059 /* This will disable updating of NL channels from passive to
5060 * active if a beacon is received on passive channel. */
5061 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Amar Singhalf0073192013-09-20 12:34:56 -07005062
Amar Singhalfddc28c2013-09-05 13:03:40 -07005063
Amar Singhala49cbc52013-10-08 18:37:44 -07005064
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005065#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07005066 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
5067 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
5068 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07005069 | WIPHY_FLAG_OFFCHAN_TX;
Kiet Lam6c583332013-10-14 05:37:09 +05305070 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005071#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005072
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005073#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005074 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08005075#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005076 || pCfg->isFastRoamIniFeatureEnabled
5077#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005078#ifdef FEATURE_WLAN_ESE
5079 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005080#endif
5081 )
5082 {
5083 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
5084 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08005085#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005086#ifdef FEATURE_WLAN_TDLS
5087 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
5088 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
5089#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305090#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05305091 if (pCfg->configPNOScanSupport)
5092 {
5093 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
5094 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
5095 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
5096 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
5097 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305098#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005099
Amar Singhalfddc28c2013-09-05 13:03:40 -07005100#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005101 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
5102 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07005103 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005104 driver need to determine what to do with both
5105 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07005106
5107 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07005108#else
5109 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005110#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005111
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305112 wiphy->max_scan_ssids = MAX_SCAN_SSID;
5113
Madan Mohan Koyyalamudi6815b162013-07-19 17:17:46 +05305114 wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07005115
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05305116 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
5117
Jeff Johnson295189b2012-06-20 16:38:30 -07005118 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305119 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07005120 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -07005121 | BIT(NL80211_IFTYPE_P2P_CLIENT)
5122 | BIT(NL80211_IFTYPE_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07005123 | BIT(NL80211_IFTYPE_AP);
5124
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305125 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005126 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305127#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5128 if( pCfg->enableMCC )
5129 {
5130 /* Currently, supports up to two channels */
5131 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005132
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305133 if( !pCfg->allowMCCGODiffBI )
5134 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005135
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305136 }
5137 wiphy->iface_combinations = &wlan_hdd_iface_combination;
5138 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005139#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305140 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005141
Jeff Johnson295189b2012-06-20 16:38:30 -07005142 /* Before registering we need to update the ht capabilitied based
5143 * on ini values*/
5144 if( !pCfg->ShortGI20MhzEnable )
5145 {
5146 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5147 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5148 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5149 }
5150
5151 if( !pCfg->ShortGI40MhzEnable )
5152 {
5153 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
5154 }
5155
5156 if( !pCfg->nChannelBondingMode5GHz )
5157 {
5158 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5159 }
5160
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305161 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305162 if (true == hdd_is_5g_supported(pHddCtx))
5163 {
5164 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
5165 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305166
5167 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
5168 {
5169
5170 if (NULL == wiphy->bands[i])
5171 {
5172 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
5173 __func__, i);
5174 continue;
5175 }
5176
5177 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5178 {
5179 struct ieee80211_supported_band *band = wiphy->bands[i];
5180
5181 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
5182 {
5183 // Enable social channels for P2P
5184 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
5185 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5186 else
5187 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5188 continue;
5189 }
5190 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
5191 {
5192 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5193 continue;
5194 }
5195 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005196 }
5197 /*Initialise the supported cipher suite details*/
5198 wiphy->cipher_suites = hdd_cipher_suites;
5199 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
5200
5201 /*signal strength in mBm (100*dBm) */
5202 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
5203
5204#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05305205 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07005206#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005207
Sunil Duttc69bccb2014-05-26 21:30:20 +05305208 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
5209 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005210 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
5211 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
5212
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305213 EXIT();
5214 return 0;
5215}
5216
5217/* In this function we are registering wiphy. */
5218int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
5219{
5220 ENTER();
5221 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005222 if (0 > wiphy_register(wiphy))
5223 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305224 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07005225 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
5226 return -EIO;
5227 }
5228
5229 EXIT();
5230 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305231}
Jeff Johnson295189b2012-06-20 16:38:30 -07005232
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305233/* In this function we are updating channel list when,
5234 regulatory domain is FCC and country code is US.
5235 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
5236 As per FCC smart phone is not a indoor device.
5237 GO should not opeate on indoor channels */
5238void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
5239{
5240 int j;
5241 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5242 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
5243 //Default counrtycode from NV at the time of wiphy initialization.
5244 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
5245 &defaultCountryCode[0]))
5246 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005247 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305248 }
5249 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
5250 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305251 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
5252 {
5253 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
5254 return;
5255 }
5256 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
5257 {
5258 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
5259 // Mark UNII -1 band channel as passive
5260 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
5261 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
5262 }
5263 }
5264}
5265
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05305266/* This function registers for all frame which supplicant is interested in */
5267void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005268{
Jeff Johnson295189b2012-06-20 16:38:30 -07005269 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5270 /* Register for all P2P action, public action etc frames */
5271 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
5272
Jeff Johnsone7245742012-09-05 17:12:55 -07005273 ENTER();
5274
Jeff Johnson295189b2012-06-20 16:38:30 -07005275 /* Right now we are registering these frame when driver is getting
5276 initialized. Once we will move to 2.6.37 kernel, in which we have
5277 frame register ops, we will move this code as a part of that */
5278 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305279 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07005280 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
5281
5282 /* GAS Initial Response */
5283 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5284 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305285
Jeff Johnson295189b2012-06-20 16:38:30 -07005286 /* GAS Comeback Request */
5287 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5288 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
5289
5290 /* GAS Comeback Response */
5291 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5292 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
5293
5294 /* P2P Public Action */
5295 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305296 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07005297 P2P_PUBLIC_ACTION_FRAME_SIZE );
5298
5299 /* P2P Action */
5300 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5301 (v_U8_t*)P2P_ACTION_FRAME,
5302 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07005303
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05305304 /* WNM BSS Transition Request frame */
5305 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5306 (v_U8_t*)WNM_BSS_ACTION_FRAME,
5307 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07005308
5309 /* WNM-Notification */
5310 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5311 (v_U8_t*)WNM_NOTIFICATION_FRAME,
5312 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005313}
5314
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05305315void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005316{
Jeff Johnson295189b2012-06-20 16:38:30 -07005317 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5318 /* Register for all P2P action, public action etc frames */
5319 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
5320
Jeff Johnsone7245742012-09-05 17:12:55 -07005321 ENTER();
5322
Jeff Johnson295189b2012-06-20 16:38:30 -07005323 /* Right now we are registering these frame when driver is getting
5324 initialized. Once we will move to 2.6.37 kernel, in which we have
5325 frame register ops, we will move this code as a part of that */
5326 /* GAS Initial Request */
5327
5328 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5329 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
5330
5331 /* GAS Initial Response */
5332 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5333 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305334
Jeff Johnson295189b2012-06-20 16:38:30 -07005335 /* GAS Comeback Request */
5336 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5337 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
5338
5339 /* GAS Comeback Response */
5340 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5341 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
5342
5343 /* P2P Public Action */
5344 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305345 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07005346 P2P_PUBLIC_ACTION_FRAME_SIZE );
5347
5348 /* P2P Action */
5349 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5350 (v_U8_t*)P2P_ACTION_FRAME,
5351 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07005352 /* WNM-Notification */
5353 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5354 (v_U8_t*)WNM_NOTIFICATION_FRAME,
5355 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005356}
5357
5358#ifdef FEATURE_WLAN_WAPI
5359void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
5360 const u8 *mac_addr, u8 *key , int key_Len)
5361{
5362 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5363 tCsrRoamSetKey setKey;
5364 v_BOOL_t isConnected = TRUE;
5365 int status = 0;
5366 v_U32_t roamId= 0xFF;
5367 tANI_U8 *pKeyPtr = NULL;
5368 int n = 0;
5369
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305370 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
5371 __func__, hdd_device_modetoString(pAdapter->device_mode),
5372 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005373
Gopichand Nakkalae7480202013-02-11 15:24:22 +05305374 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07005375 setKey.keyId = key_index; // Store Key ID
5376 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
5377 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
5378 setKey.paeRole = 0 ; // the PAE role
5379 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
5380 {
5381 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
5382 }
5383 else
5384 {
5385 isConnected = hdd_connIsConnected(pHddStaCtx);
5386 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
5387 }
5388 setKey.keyLength = key_Len;
5389 pKeyPtr = setKey.Key;
5390 memcpy( pKeyPtr, key, key_Len);
5391
Arif Hussain6d2a3322013-11-17 19:50:10 -08005392 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07005393 __func__, key_Len);
5394 for (n = 0 ; n < key_Len; n++)
5395 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
5396 __func__,n,setKey.Key[n]);
5397
5398 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5399 if ( isConnected )
5400 {
5401 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
5402 pAdapter->sessionId, &setKey, &roamId );
5403 }
5404 if ( status != 0 )
5405 {
5406 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5407 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5408 __LINE__, status );
5409 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5410 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05305411 /* Need to clear any trace of key value in the memory.
5412 * Thus zero out the memory even though it is local
5413 * variable.
5414 */
5415 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07005416}
5417#endif /* FEATURE_WLAN_WAPI*/
5418
5419#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305420int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005421 beacon_data_t **ppBeacon,
5422 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005423#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305424int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005425 beacon_data_t **ppBeacon,
5426 struct cfg80211_beacon_data *params,
5427 int dtim_period)
5428#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305429{
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 int size;
5431 beacon_data_t *beacon = NULL;
5432 beacon_data_t *old = NULL;
5433 int head_len,tail_len;
5434
Jeff Johnsone7245742012-09-05 17:12:55 -07005435 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07005436 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305437 {
5438 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5439 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005440 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305441 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005442
5443 old = pAdapter->sessionCtx.ap.beacon;
5444
5445 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305446 {
5447 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5448 FL("session(%d) old and new heads points to NULL"),
5449 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005450 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305451 }
5452
5453 if (params->tail && !params->tail_len)
5454 {
5455 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5456 FL("tail_len is zero but tail is not NULL"));
5457 return -EINVAL;
5458 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005459
Jeff Johnson295189b2012-06-20 16:38:30 -07005460#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
5461 /* Kernel 3.0 is not updating dtim_period for set beacon */
5462 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305463 {
5464 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5465 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005466 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305467 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005468#endif
5469
5470 if(params->head)
5471 head_len = params->head_len;
5472 else
5473 head_len = old->head_len;
5474
5475 if(params->tail || !old)
5476 tail_len = params->tail_len;
5477 else
5478 tail_len = old->tail_len;
5479
5480 size = sizeof(beacon_data_t) + head_len + tail_len;
5481
5482 beacon = kzalloc(size, GFP_KERNEL);
5483
5484 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305485 {
5486 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5487 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005488 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305489 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005490
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005491#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 if(params->dtim_period || !old )
5493 beacon->dtim_period = params->dtim_period;
5494 else
5495 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005496#else
5497 if(dtim_period || !old )
5498 beacon->dtim_period = dtim_period;
5499 else
5500 beacon->dtim_period = old->dtim_period;
5501#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305502
Jeff Johnson295189b2012-06-20 16:38:30 -07005503 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
5504 beacon->tail = beacon->head + head_len;
5505 beacon->head_len = head_len;
5506 beacon->tail_len = tail_len;
5507
5508 if(params->head) {
5509 memcpy (beacon->head,params->head,beacon->head_len);
5510 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305511 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07005512 if(old)
5513 memcpy (beacon->head,old->head,beacon->head_len);
5514 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305515
Jeff Johnson295189b2012-06-20 16:38:30 -07005516 if(params->tail) {
5517 memcpy (beacon->tail,params->tail,beacon->tail_len);
5518 }
5519 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305520 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07005521 memcpy (beacon->tail,old->tail,beacon->tail_len);
5522 }
5523
5524 *ppBeacon = beacon;
5525
5526 kfree(old);
5527
5528 return 0;
5529
5530}
Jeff Johnson295189b2012-06-20 16:38:30 -07005531
5532v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
5533{
5534 int left = length;
5535 v_U8_t *ptr = pIes;
5536 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305537
Jeff Johnson295189b2012-06-20 16:38:30 -07005538 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305539 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005540 elem_id = ptr[0];
5541 elem_len = ptr[1];
5542 left -= 2;
5543 if(elem_len > left)
5544 {
5545 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07005546 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005547 eid,elem_len,left);
5548 return NULL;
5549 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305550 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07005551 {
5552 return ptr;
5553 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305554
Jeff Johnson295189b2012-06-20 16:38:30 -07005555 left -= elem_len;
5556 ptr += (elem_len + 2);
5557 }
5558 return NULL;
5559}
5560
Jeff Johnson295189b2012-06-20 16:38:30 -07005561/* Check if rate is 11g rate or not */
5562static int wlan_hdd_rate_is_11g(u8 rate)
5563{
Sanjay Devnani28322e22013-06-21 16:13:40 -07005564 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005565 u8 i;
5566 for (i = 0; i < 8; i++)
5567 {
5568 if(rate == gRateArray[i])
5569 return TRUE;
5570 }
5571 return FALSE;
5572}
5573
5574/* Check for 11g rate and set proper 11g only mode */
5575static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
5576 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
5577{
5578 u8 i, num_rates = pIe[0];
5579
5580 pIe += 1;
5581 for ( i = 0; i < num_rates; i++)
5582 {
5583 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
5584 {
5585 /* If rate set have 11g rate than change the mode to 11G */
5586 *pSapHw_mode = eSAP_DOT11_MODE_11g;
5587 if (pIe[i] & BASIC_RATE_MASK)
5588 {
5589 /* If we have 11g rate as basic rate, it means mode
5590 is 11g only mode.
5591 */
5592 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
5593 *pCheckRatesfor11g = FALSE;
5594 }
5595 }
5596 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
5597 {
5598 *require_ht = TRUE;
5599 }
5600 }
5601 return;
5602}
5603
5604static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
5605{
5606 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
5607 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
5608 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
5609 u8 checkRatesfor11g = TRUE;
5610 u8 require_ht = FALSE;
5611 u8 *pIe=NULL;
5612
5613 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
5614
5615 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
5616 pBeacon->head_len, WLAN_EID_SUPP_RATES);
5617 if (pIe != NULL)
5618 {
5619 pIe += 1;
5620 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
5621 &pConfig->SapHw_mode);
5622 }
5623
5624 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
5625 WLAN_EID_EXT_SUPP_RATES);
5626 if (pIe != NULL)
5627 {
5628
5629 pIe += 1;
5630 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
5631 &pConfig->SapHw_mode);
5632 }
5633
5634 if( pConfig->channel > 14 )
5635 {
5636 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
5637 }
5638
5639 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
5640 WLAN_EID_HT_CAPABILITY);
5641
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305642 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07005643 {
5644 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
5645 if(require_ht)
5646 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
5647 }
5648}
5649
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305650static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
5651 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
5652{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07005653 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305654 v_U8_t *pIe = NULL;
5655 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
5656
5657 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
5658 pBeacon->tail, pBeacon->tail_len);
5659
5660 if (pIe)
5661 {
5662 ielen = pIe[1] + 2;
5663 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
5664 {
5665 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
5666 }
5667 else
5668 {
5669 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
5670 return -EINVAL;
5671 }
5672 *total_ielen += ielen;
5673 }
5674 return 0;
5675}
5676
Arif Hussaine7f3ea52013-09-12 21:56:36 -07005677static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
5678 v_U8_t *genie, v_U8_t *total_ielen)
5679{
5680 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
5681 int left = pBeacon->tail_len;
5682 v_U8_t *ptr = pBeacon->tail;
5683 v_U8_t elem_id, elem_len;
5684 v_U16_t ielen = 0;
5685
5686 if ( NULL == ptr || 0 == left )
5687 return;
5688
5689 while (left >= 2)
5690 {
5691 elem_id = ptr[0];
5692 elem_len = ptr[1];
5693 left -= 2;
5694 if (elem_len > left)
5695 {
5696 hddLog( VOS_TRACE_LEVEL_ERROR,
5697 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
5698 elem_id, elem_len, left);
5699 return;
5700 }
5701 if (IE_EID_VENDOR == elem_id)
5702 {
5703 /* skipping the VSIE's which we don't want to include or
5704 * it will be included by existing code
5705 */
5706 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
5707#ifdef WLAN_FEATURE_WFD
5708 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
5709#endif
5710 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
5711 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
5712 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
5713 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
5714 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
5715 {
5716 ielen = ptr[1] + 2;
5717 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
5718 {
5719 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
5720 *total_ielen += ielen;
5721 }
5722 else
5723 {
5724 hddLog( VOS_TRACE_LEVEL_ERROR,
5725 "IE Length is too big "
5726 "IEs eid=%d elem_len=%d total_ie_lent=%d",
5727 elem_id, elem_len, *total_ielen);
5728 }
5729 }
5730 }
5731
5732 left -= elem_len;
5733 ptr += (elem_len + 2);
5734 }
5735 return;
5736}
5737
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005738#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07005739static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
5740 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005741#else
5742static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
5743 struct cfg80211_beacon_data *params)
5744#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005745{
5746 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305747 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005748 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07005749 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005750
5751 genie = vos_mem_malloc(MAX_GENIE_LEN);
5752
5753 if(genie == NULL) {
5754
5755 return -ENOMEM;
5756 }
5757
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305758 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
5759 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005760 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305761 hddLog(LOGE,
5762 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305763 ret = -EINVAL;
5764 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005765 }
5766
5767#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305768 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
5769 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
5770 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305771 hddLog(LOGE,
5772 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305773 ret = -EINVAL;
5774 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005775 }
5776#endif
5777
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305778 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
5779 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005780 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305781 hddLog(LOGE,
5782 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305783 ret = -EINVAL;
5784 goto done;
5785 }
5786
5787 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
5788 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07005789 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005790 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005791
5792 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5793 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
5794 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
5795 {
5796 hddLog(LOGE,
5797 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005798 ret = -EINVAL;
5799 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005800 }
5801
5802 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5803 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
5804 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
5805 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
5806 ==eHAL_STATUS_FAILURE)
5807 {
5808 hddLog(LOGE,
5809 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005810 ret = -EINVAL;
5811 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005812 }
5813
5814 // Added for ProResp IE
5815 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
5816 {
5817 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
5818 u8 probe_rsp_ie_len[3] = {0};
5819 u8 counter = 0;
5820 /* Check Probe Resp Length if it is greater then 255 then Store
5821 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
5822 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
5823 Store More then 255 bytes into One Variable.
5824 */
5825 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
5826 {
5827 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
5828 {
5829 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
5830 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
5831 }
5832 else
5833 {
5834 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
5835 rem_probe_resp_ie_len = 0;
5836 }
5837 }
5838
5839 rem_probe_resp_ie_len = 0;
5840
5841 if (probe_rsp_ie_len[0] > 0)
5842 {
5843 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5844 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
5845 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
5846 probe_rsp_ie_len[0], NULL,
5847 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5848 {
5849 hddLog(LOGE,
5850 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005851 ret = -EINVAL;
5852 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005853 }
5854 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
5855 }
5856
5857 if (probe_rsp_ie_len[1] > 0)
5858 {
5859 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5860 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
5861 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
5862 probe_rsp_ie_len[1], NULL,
5863 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5864 {
5865 hddLog(LOGE,
5866 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005867 ret = -EINVAL;
5868 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005869 }
5870 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
5871 }
5872
5873 if (probe_rsp_ie_len[2] > 0)
5874 {
5875 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5876 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
5877 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
5878 probe_rsp_ie_len[2], NULL,
5879 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5880 {
5881 hddLog(LOGE,
5882 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005883 ret = -EINVAL;
5884 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005885 }
5886 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
5887 }
5888
5889 if (probe_rsp_ie_len[1] == 0 )
5890 {
5891 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5892 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
5893 eANI_BOOLEAN_FALSE) )
5894 {
5895 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005896 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005897 }
5898 }
5899
5900 if (probe_rsp_ie_len[2] == 0 )
5901 {
5902 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5903 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
5904 eANI_BOOLEAN_FALSE) )
5905 {
5906 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005907 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005908 }
5909 }
5910
5911 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5912 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
5913 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
5914 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
5915 == eHAL_STATUS_FAILURE)
5916 {
5917 hddLog(LOGE,
5918 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005919 ret = -EINVAL;
5920 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005921 }
5922 }
5923 else
5924 {
5925 // Reset WNI_CFG_PROBE_RSP Flags
5926 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
5927
5928 hddLog(VOS_TRACE_LEVEL_INFO,
5929 "%s: No Probe Response IE received in set beacon",
5930 __func__);
5931 }
5932
5933 // Added for AssocResp IE
5934 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
5935 {
5936 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5937 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
5938 params->assocresp_ies_len, NULL,
5939 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5940 {
5941 hddLog(LOGE,
5942 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005943 ret = -EINVAL;
5944 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005945 }
5946
5947 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5948 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
5949 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
5950 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
5951 == eHAL_STATUS_FAILURE)
5952 {
5953 hddLog(LOGE,
5954 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005955 ret = -EINVAL;
5956 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005957 }
5958 }
5959 else
5960 {
5961 hddLog(VOS_TRACE_LEVEL_INFO,
5962 "%s: No Assoc Response IE received in set beacon",
5963 __func__);
5964
5965 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5966 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
5967 eANI_BOOLEAN_FALSE) )
5968 {
5969 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005970 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005971 }
5972 }
5973
Jeff Johnsone7245742012-09-05 17:12:55 -07005974done:
Jeff Johnson295189b2012-06-20 16:38:30 -07005975 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305976 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07005977}
Jeff Johnson295189b2012-06-20 16:38:30 -07005978
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305979/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 * FUNCTION: wlan_hdd_validate_operation_channel
5981 * called by wlan_hdd_cfg80211_start_bss() and
5982 * wlan_hdd_cfg80211_set_channel()
5983 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305984 * channel list.
5985 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07005986VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07005987{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305988
Jeff Johnson295189b2012-06-20 16:38:30 -07005989 v_U32_t num_ch = 0;
5990 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
5991 u32 indx = 0;
5992 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05305993 v_U8_t fValidChannel = FALSE, count = 0;
5994 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305995
Jeff Johnson295189b2012-06-20 16:38:30 -07005996 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
5997
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05305998 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07005999 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306000 /* Validate the channel */
6001 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006002 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306003 if ( channel == rfChannels[count].channelNum )
6004 {
6005 fValidChannel = TRUE;
6006 break;
6007 }
6008 }
6009 if (fValidChannel != TRUE)
6010 {
6011 hddLog(VOS_TRACE_LEVEL_ERROR,
6012 "%s: Invalid Channel [%d]", __func__, channel);
6013 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006014 }
6015 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306016 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006017 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306018 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6019 valid_ch, &num_ch))
6020 {
6021 hddLog(VOS_TRACE_LEVEL_ERROR,
6022 "%s: failed to get valid channel list", __func__);
6023 return VOS_STATUS_E_FAILURE;
6024 }
6025 for (indx = 0; indx < num_ch; indx++)
6026 {
6027 if (channel == valid_ch[indx])
6028 {
6029 break;
6030 }
6031 }
6032
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306033 if (indx >= num_ch)
6034 {
6035 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6036 {
6037 eCsrBand band;
6038 unsigned int freq;
6039
6040 sme_GetFreqBand(hHal, &band);
6041
6042 if (eCSR_BAND_5G == band)
6043 {
6044#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
6045 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
6046 {
6047 freq = ieee80211_channel_to_frequency(channel,
6048 IEEE80211_BAND_2GHZ);
6049 }
6050 else
6051 {
6052 freq = ieee80211_channel_to_frequency(channel,
6053 IEEE80211_BAND_5GHZ);
6054 }
6055#else
6056 freq = ieee80211_channel_to_frequency(channel);
6057#endif
6058 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
6059 return VOS_STATUS_SUCCESS;
6060 }
6061 }
6062
6063 hddLog(VOS_TRACE_LEVEL_ERROR,
6064 "%s: Invalid Channel [%d]", __func__, channel);
6065 return VOS_STATUS_E_FAILURE;
6066 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006067 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306068
Jeff Johnson295189b2012-06-20 16:38:30 -07006069 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306070
Jeff Johnson295189b2012-06-20 16:38:30 -07006071}
6072
Viral Modi3a32cc52013-02-08 11:14:52 -08006073/**
6074 * FUNCTION: wlan_hdd_cfg80211_set_channel
6075 * This function is used to set the channel number
6076 */
6077static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
6078 struct ieee80211_channel *chan,
6079 enum nl80211_channel_type channel_type
6080 )
6081{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306082 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08006083 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07006084 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08006085 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306086 hdd_context_t *pHddCtx;
6087 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006088
6089 ENTER();
6090
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306091
Viral Modi3a32cc52013-02-08 11:14:52 -08006092 if( NULL == dev )
6093 {
6094 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006095 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006096 return -ENODEV;
6097 }
6098 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306099
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306100 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6101 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
6102 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08006103 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306104 "%s: device_mode = %s (%d) freq = %d", __func__,
6105 hdd_device_modetoString(pAdapter->device_mode),
6106 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306107
6108 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6109 status = wlan_hdd_validate_context(pHddCtx);
6110
6111 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08006112 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306113 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6114 "%s: HDD context is not valid", __func__);
6115 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006116 }
6117
6118 /*
6119 * Do freq to chan conversion
6120 * TODO: for 11a
6121 */
6122
6123 channel = ieee80211_frequency_to_channel(freq);
6124
6125 /* Check freq range */
6126 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
6127 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
6128 {
6129 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006130 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08006131 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
6132 WNI_CFG_CURRENT_CHANNEL_STAMAX);
6133 return -EINVAL;
6134 }
6135
6136 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6137
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05306138 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
6139 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08006140 {
6141 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
6142 {
6143 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006144 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08006145 return -EINVAL;
6146 }
6147 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6148 "%s: set channel to [%d] for device mode =%d",
6149 __func__, channel,pAdapter->device_mode);
6150 }
6151 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08006152 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08006153 )
6154 {
6155 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6156 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
6157 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6158
6159 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
6160 {
6161 /* Link is up then return cant set channel*/
6162 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006163 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006164 return -EINVAL;
6165 }
6166
6167 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
6168 pHddStaCtx->conn_info.operationChannel = channel;
6169 pRoamProfile->ChannelInfo.ChannelList =
6170 &pHddStaCtx->conn_info.operationChannel;
6171 }
6172 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08006173 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08006174 )
6175 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306176 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6177 {
6178 if(VOS_STATUS_SUCCESS !=
6179 wlan_hdd_validate_operation_channel(pAdapter,channel))
6180 {
6181 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006182 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306183 return -EINVAL;
6184 }
6185 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
6186 }
6187 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08006188 {
6189 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
6190
6191 /* If auto channel selection is configured as enable/ 1 then ignore
6192 channel set by supplicant
6193 */
6194 if ( cfg_param->apAutoChannelSelection )
6195 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306196 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
6197 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08006198 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306199 "%s: set channel to auto channel (0) for device mode =%s (%d)",
6200 __func__, hdd_device_modetoString(pAdapter->device_mode),
6201 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08006202 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306203 else
6204 {
6205 if(VOS_STATUS_SUCCESS !=
6206 wlan_hdd_validate_operation_channel(pAdapter,channel))
6207 {
6208 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006209 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306210 return -EINVAL;
6211 }
6212 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
6213 }
Viral Modi3a32cc52013-02-08 11:14:52 -08006214 }
6215 }
6216 else
6217 {
6218 hddLog(VOS_TRACE_LEVEL_FATAL,
6219 "%s: Invalid device mode failed to set valid channel", __func__);
6220 return -EINVAL;
6221 }
6222 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306223 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006224}
6225
Jeff Johnson295189b2012-06-20 16:38:30 -07006226#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
6227static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6228 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006229#else
6230static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6231 struct cfg80211_beacon_data *params,
6232 const u8 *ssid, size_t ssid_len,
6233 enum nl80211_hidden_ssid hidden_ssid)
6234#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006235{
6236 tsap_Config_t *pConfig;
6237 beacon_data_t *pBeacon = NULL;
6238 struct ieee80211_mgmt *pMgmt_frame;
6239 v_U8_t *pIe=NULL;
6240 v_U16_t capab_info;
6241 eCsrAuthType RSNAuthType;
6242 eCsrEncryptionType RSNEncryptType;
6243 eCsrEncryptionType mcRSNEncryptType;
6244 int status = VOS_STATUS_SUCCESS;
6245 tpWLAN_SAPEventCB pSapEventCallback;
6246 hdd_hostapd_state_t *pHostapdState;
6247 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
6248 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306249 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006250 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306251 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006252 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08006253 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05306254 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07006255 v_BOOL_t MFPCapable = VOS_FALSE;
6256 v_BOOL_t MFPRequired = VOS_FALSE;
Abhishek Singhf0ac1752014-03-05 17:47:09 +05306257 eHddDot11Mode sapDot11Mode =
6258 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07006259
6260 ENTER();
6261
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306262 iniConfig = pHddCtx->cfg_ini;
6263
Jeff Johnson295189b2012-06-20 16:38:30 -07006264 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
6265
6266 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6267
6268 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6269
6270 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
6271
6272 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
6273
6274 //channel is already set in the set_channel Call back
6275 //pConfig->channel = pCommitConfig->channel;
6276
6277 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306278 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07006279 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
6280
6281 pConfig->dtim_period = pBeacon->dtim_period;
6282
Arif Hussain6d2a3322013-11-17 19:50:10 -08006283 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07006284 pConfig->dtim_period);
6285
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08006286 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07006287 {
6288 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006289 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05306290 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
6291 {
6292 tANI_BOOLEAN restartNeeded;
6293 pConfig->ieee80211d = 1;
6294 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
6295 sme_setRegInfo(hHal, pConfig->countryCode);
6296 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
6297 }
6298 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07006299 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07006300 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006301 pConfig->ieee80211d = 1;
6302 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
6303 sme_setRegInfo(hHal, pConfig->countryCode);
6304 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07006305 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07006306 else
6307 {
6308 pConfig->ieee80211d = 0;
6309 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306310 /*
6311 * If auto channel is configured i.e. channel is 0,
6312 * so skip channel validation.
6313 */
6314 if( AUTO_CHANNEL_SELECT != pConfig->channel )
6315 {
6316 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
6317 {
6318 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006319 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306320 return -EINVAL;
6321 }
6322 }
6323 else
6324 {
6325 if(1 != pHddCtx->is_dynamic_channel_range_set)
6326 {
6327 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
6328 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
6329 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
6330 }
6331 pHddCtx->is_dynamic_channel_range_set = 0;
6332 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006333 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07006334 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006335 {
6336 pConfig->ieee80211d = 0;
6337 }
6338 pConfig->authType = eSAP_AUTO_SWITCH;
6339
6340 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306341
6342 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07006343 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
6344
6345 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
6346
6347 /*Set wps station to configured*/
6348 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
6349
6350 if(pIe)
6351 {
6352 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
6353 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006354 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07006355 return -EINVAL;
6356 }
6357 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
6358 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07006359 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07006360 /* Check 15 bit of WPS IE as it contain information for wps state
6361 * WPS state
6362 */
6363 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
6364 {
6365 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
6366 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
6367 {
6368 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
6369 }
6370 }
6371 }
6372 else
6373 {
6374 pConfig->wps_state = SAP_WPS_DISABLED;
6375 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306376 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07006377
c_hpothufe599e92014-06-16 11:38:55 +05306378 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
6379 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
6380 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
6381 eCSR_ENCRYPT_TYPE_NONE;
6382
Jeff Johnson295189b2012-06-20 16:38:30 -07006383 pConfig->RSNWPAReqIELength = 0;
6384 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306385 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006386 WLAN_EID_RSN);
6387 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306388 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006389 pConfig->RSNWPAReqIELength = pIe[1] + 2;
6390 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
6391 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306392 /* The actual processing may eventually be more extensive than
6393 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07006394 * by the app.
6395 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306396 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07006397 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
6398 &RSNEncryptType,
6399 &mcRSNEncryptType,
6400 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08006401 &MFPCapable,
6402 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07006403 pConfig->pRSNWPAReqIE[1]+2,
6404 pConfig->pRSNWPAReqIE );
6405
6406 if( VOS_STATUS_SUCCESS == status )
6407 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306408 /* Now copy over all the security attributes you have
6409 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07006410 * */
6411 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
6412 pConfig->mcRSNEncryptType = mcRSNEncryptType;
6413 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
6414 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05306415 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08006416 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006417 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
6418 }
6419 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306420
Jeff Johnson295189b2012-06-20 16:38:30 -07006421 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
6422 pBeacon->tail, pBeacon->tail_len);
6423
6424 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
6425 {
6426 if (pConfig->pRSNWPAReqIE)
6427 {
6428 /*Mixed mode WPA/WPA2*/
6429 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
6430 pConfig->RSNWPAReqIELength += pIe[1] + 2;
6431 }
6432 else
6433 {
6434 pConfig->RSNWPAReqIELength = pIe[1] + 2;
6435 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
6436 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306437 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07006438 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
6439 &RSNEncryptType,
6440 &mcRSNEncryptType,
6441 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08006442 &MFPCapable,
6443 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07006444 pConfig->pRSNWPAReqIE[1]+2,
6445 pConfig->pRSNWPAReqIE );
6446
6447 if( VOS_STATUS_SUCCESS == status )
6448 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306449 /* Now copy over all the security attributes you have
6450 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07006451 * */
6452 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
6453 pConfig->mcRSNEncryptType = mcRSNEncryptType;
6454 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
6455 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05306456 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08006457 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006458 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
6459 }
6460 }
6461 }
6462
Jeff Johnson4416a782013-03-25 14:17:50 -07006463 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
6464 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
6465 return -EINVAL;
6466 }
6467
Jeff Johnson295189b2012-06-20 16:38:30 -07006468 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
6469
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006470#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006471 if (params->ssid != NULL)
6472 {
6473 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
6474 pConfig->SSIDinfo.ssid.length = params->ssid_len;
6475 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
6476 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
6477 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006478#else
6479 if (ssid != NULL)
6480 {
6481 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
6482 pConfig->SSIDinfo.ssid.length = ssid_len;
6483 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
6484 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
6485 }
6486#endif
6487
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306488 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07006489 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306490
Jeff Johnson295189b2012-06-20 16:38:30 -07006491 /* default value */
6492 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
6493 pConfig->num_accept_mac = 0;
6494 pConfig->num_deny_mac = 0;
6495
6496 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
6497 pBeacon->tail, pBeacon->tail_len);
6498
6499 /* pIe for black list is following form:
6500 type : 1 byte
6501 length : 1 byte
6502 OUI : 4 bytes
6503 acl type : 1 byte
6504 no of mac addr in black list: 1 byte
6505 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306506 */
6507 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006508 {
6509 pConfig->SapMacaddr_acl = pIe[6];
6510 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08006511 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006512 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05306513 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
6514 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006515 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
6516 for (i = 0; i < pConfig->num_deny_mac; i++)
6517 {
6518 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
6519 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306520 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006521 }
6522 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
6523 pBeacon->tail, pBeacon->tail_len);
6524
6525 /* pIe for white list is following form:
6526 type : 1 byte
6527 length : 1 byte
6528 OUI : 4 bytes
6529 acl type : 1 byte
6530 no of mac addr in white list: 1 byte
6531 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306532 */
6533 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006534 {
6535 pConfig->SapMacaddr_acl = pIe[6];
6536 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08006537 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006538 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05306539 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
6540 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006541 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
6542 for (i = 0; i < pConfig->num_accept_mac; i++)
6543 {
6544 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
6545 acl_entry++;
6546 }
6547 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05306548
Jeff Johnson295189b2012-06-20 16:38:30 -07006549 wlan_hdd_set_sapHwmode(pHostapdAdapter);
6550
Jeff Johnsone7245742012-09-05 17:12:55 -07006551#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08006552 /* Overwrite the hostapd setting for HW mode only for 11ac.
Kiet Lam0f320422013-11-21 19:29:17 +05306553 * This is valid only if mode is set to 11n in hostapd, either AUTO or
6554 * 11ac in .ini and 11ac is supported by both host and firmware.
6555 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
6556 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08006557 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
6558 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Abhishek Singhf0ac1752014-03-05 17:47:09 +05306559 (( sapDot11Mode == eHDD_DOT11_MODE_AUTO ) ||
6560 ( sapDot11Mode == eHDD_DOT11_MODE_11ac ) ||
6561 ( sapDot11Mode == eHDD_DOT11_MODE_11ac_ONLY ) ) &&
6562 (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
6563 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07006564 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05306565 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07006566 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05306567 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07006568
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306569 /* If ACS disable and selected channel <= 14
6570 * OR
6571 * ACS enabled and ACS operating band is choosen as 2.4
6572 * AND
6573 * VHT in 2.4G Disabled
6574 * THEN
6575 * Fallback to 11N mode
6576 */
6577 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
6578 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05306579 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306580 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07006581 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05306582 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
6583 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07006584 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
6585 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006586 }
6587#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306588
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07006589 if ( AUTO_CHANNEL_SELECT != pConfig->channel )
6590 {
6591 sme_SelectCBMode(hHal,
6592 sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode),
6593 pConfig->channel);
6594 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006595 // ht_capab is not what the name conveys,this is used for protection bitmap
6596 pConfig->ht_capab =
6597 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
6598
6599 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
6600 {
6601 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
6602 return -EINVAL;
6603 }
6604
6605 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306606 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07006607 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
6608 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306609 pConfig->obssProtEnabled =
6610 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07006611
Chet Lanctot8cecea22014-02-11 19:09:36 -08006612#ifdef WLAN_FEATURE_11W
6613 pConfig->mfpCapable = MFPCapable;
6614 pConfig->mfpRequired = MFPRequired;
6615 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
6616 pConfig->mfpCapable, pConfig->mfpRequired);
6617#endif
6618
Arif Hussain6d2a3322013-11-17 19:50:10 -08006619 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07006620 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08006621 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
6622 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
6623 (int)pConfig->channel);
6624 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
6625 pConfig->SapHw_mode, pConfig->privacy,
6626 pConfig->authType);
6627 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
6628 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
6629 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
6630 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07006631
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306632 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07006633 {
6634 //Bss already started. just return.
6635 //TODO Probably it should update some beacon params.
6636 hddLog( LOGE, "Bss Already started...Ignore the request");
6637 EXIT();
6638 return 0;
6639 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306640
Agarwal Ashish51325b52014-06-16 16:50:49 +05306641 if (vos_max_concurrent_connections_reached()) {
6642 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
6643 return -EINVAL;
6644 }
6645
Jeff Johnson295189b2012-06-20 16:38:30 -07006646 pConfig->persona = pHostapdAdapter->device_mode;
6647
Peng Xu2446a892014-09-05 17:21:18 +05306648 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
6649 if ( NULL != psmeConfig)
6650 {
6651 sme_GetConfigParam(hHal, psmeConfig);
6652 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
6653 vos_mem_free(psmeConfig);
6654 }
Peng Xuafc34e32014-09-25 13:23:55 +05306655 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05306656
Jeff Johnson295189b2012-06-20 16:38:30 -07006657 pSapEventCallback = hdd_hostapd_SAPEventCB;
6658 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
6659 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
6660 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006661 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006662 return -EINVAL;
6663 }
6664
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306665 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07006666 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
6667
6668 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306669
Jeff Johnson295189b2012-06-20 16:38:30 -07006670 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306671 {
6672 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006673 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07006674 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07006675 VOS_ASSERT(0);
6676 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306677
Jeff Johnson295189b2012-06-20 16:38:30 -07006678 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05306679 /* Initialize WMM configuation */
6680 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05306681 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006682
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07006683#ifdef WLAN_FEATURE_P2P_DEBUG
6684 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
6685 {
6686 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
6687 {
6688 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
6689 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08006690 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07006691 }
6692 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
6693 {
6694 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
6695 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08006696 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07006697 }
6698 }
6699#endif
6700
Jeff Johnson295189b2012-06-20 16:38:30 -07006701 pHostapdState->bCommit = TRUE;
6702 EXIT();
6703
6704 return 0;
6705}
6706
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006707#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306708static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
6709 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07006710 struct beacon_parameters *params)
6711{
6712 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306713 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306714 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006715
6716 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306717
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306718 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6719 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
6720 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306721 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
6722 hdd_device_modetoString(pAdapter->device_mode),
6723 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006724
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306725 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6726 status = wlan_hdd_validate_context(pHddCtx);
6727
6728 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006729 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306730 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6731 "%s: HDD context is not valid", __func__);
6732 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006733 }
6734
Agarwal Ashish51325b52014-06-16 16:50:49 +05306735 if (vos_max_concurrent_connections_reached()) {
6736 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
6737 return -EINVAL;
6738 }
6739
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306740 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07006741 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07006742 )
6743 {
6744 beacon_data_t *old,*new;
6745
6746 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306747
Jeff Johnson295189b2012-06-20 16:38:30 -07006748 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306749 {
6750 hddLog(VOS_TRACE_LEVEL_WARN,
6751 FL("already beacon info added to session(%d)"),
6752 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006753 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306754 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006755
6756 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
6757
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306758 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07006759 {
6760 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006761 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006762 return -EINVAL;
6763 }
6764
6765 pAdapter->sessionCtx.ap.beacon = new;
6766
6767 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
6768 }
6769
6770 EXIT();
6771 return status;
6772}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306773
6774static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006775 struct net_device *dev,
6776 struct beacon_parameters *params)
6777{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306778 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306779 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6780 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306781 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006782
6783 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306784 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6785 TRACE_CODE_HDD_CFG80211_SET_BEACON,
6786 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
6787 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
6788 __func__, hdd_device_modetoString(pAdapter->device_mode),
6789 pAdapter->device_mode);
6790
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306791 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6792 status = wlan_hdd_validate_context(pHddCtx);
6793
6794 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006795 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306796 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6797 "%s: HDD context is not valid", __func__);
6798 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006799 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306800
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306801 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07006802 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306803 )
Jeff Johnson295189b2012-06-20 16:38:30 -07006804 {
6805 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306806
Jeff Johnson295189b2012-06-20 16:38:30 -07006807 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306808
Jeff Johnson295189b2012-06-20 16:38:30 -07006809 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306810 {
6811 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6812 FL("session(%d) old and new heads points to NULL"),
6813 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006814 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306815 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006816
6817 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
6818
6819 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306820 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006821 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006822 return -EINVAL;
6823 }
6824
6825 pAdapter->sessionCtx.ap.beacon = new;
6826
6827 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
6828 }
6829
6830 EXIT();
6831 return status;
6832}
6833
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006834#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
6835
6836#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006837static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
6838 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006839#else
6840static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
6841 struct net_device *dev)
6842#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006843{
6844 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07006845 hdd_context_t *pHddCtx = NULL;
6846 hdd_scaninfo_t *pScanInfo = NULL;
6847 hdd_adapter_t *staAdapter = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306848 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306849 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006850
6851 ENTER();
6852
6853 if (NULL == pAdapter)
6854 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306855 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006856 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006857 return -ENODEV;
6858 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006859
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306860 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6861 TRACE_CODE_HDD_CFG80211_STOP_AP,
6862 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306863 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6864 status = wlan_hdd_validate_context(pHddCtx);
6865
6866 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006867 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306868 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6869 "%s: HDD context is not valid", __func__);
6870 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07006871 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006872
6873 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
6874 if (NULL == staAdapter)
6875 {
6876 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
6877 if (NULL == staAdapter)
6878 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07006879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
6880 "%s: HDD adapter context for STA/P2P-CLI is Null",
6881 __func__);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006882 }
6883 }
6884
6885 pScanInfo = &pHddCtx->scan_info;
6886
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306887 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
6888 __func__, hdd_device_modetoString(pAdapter->device_mode),
6889 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006890
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306891 ret = wlan_hdd_scan_abort(pAdapter);
6892
Girish Gowli4bf7a632014-06-12 13:42:11 +05306893 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07006894 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306895 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6896 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306897
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306898 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07006899 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306900 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6901 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08006902
Jeff Johnsone7245742012-09-05 17:12:55 -07006903 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306904 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07006905 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306906 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07006907 }
6908
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05306909 /* Delete all associated STAs before stopping AP/P2P GO */
6910 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05306911 hdd_hostapd_stop(dev);
6912
Jeff Johnson295189b2012-06-20 16:38:30 -07006913 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07006914 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07006915 )
6916 {
6917 beacon_data_t *old;
6918
6919 old = pAdapter->sessionCtx.ap.beacon;
6920
6921 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306922 {
6923 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6924 FL("session(%d) beacon data points to NULL"),
6925 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006926 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306927 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006928
Jeff Johnson295189b2012-06-20 16:38:30 -07006929 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006930
6931 mutex_lock(&pHddCtx->sap_lock);
6932 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
6933 {
Jeff Johnson4416a782013-03-25 14:17:50 -07006934 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006935 {
6936 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
6937
6938 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
6939
6940 if (!VOS_IS_STATUS_SUCCESS(status))
6941 {
6942 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006943 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006944 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306945 }
6946 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006947 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05306948 /* BSS stopped, clear the active sessions for this device mode */
6949 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006950 }
6951 mutex_unlock(&pHddCtx->sap_lock);
6952
6953 if(status != VOS_STATUS_SUCCESS)
6954 {
6955 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006956 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006957 return -EINVAL;
6958 }
6959
Jeff Johnson4416a782013-03-25 14:17:50 -07006960 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07006961 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
6962 ==eHAL_STATUS_FAILURE)
6963 {
6964 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006965 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006966 }
6967
Jeff Johnson4416a782013-03-25 14:17:50 -07006968 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07006969 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
6970 eANI_BOOLEAN_FALSE) )
6971 {
6972 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006973 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006974 }
6975
6976 // Reset WNI_CFG_PROBE_RSP Flags
6977 wlan_hdd_reset_prob_rspies(pAdapter);
6978
6979 pAdapter->sessionCtx.ap.beacon = NULL;
6980 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07006981#ifdef WLAN_FEATURE_P2P_DEBUG
6982 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
6983 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
6984 {
6985 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
6986 "GO got removed");
6987 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
6988 }
6989#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006990 }
6991 EXIT();
6992 return status;
6993}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006994
6995#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
6996
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306997static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
6998 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006999 struct cfg80211_ap_settings *params)
7000{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307001 hdd_adapter_t *pAdapter;
7002 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307003 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007004
7005 ENTER();
7006
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307007 if (NULL == dev)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007008 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307009 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307010 "%s: Device is Null", __func__);
7011 return -ENODEV;
7012 }
7013
7014 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7015 if (NULL == pAdapter)
7016 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307017 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307018 "%s: HDD adapter is Null", __func__);
7019 return -ENODEV;
7020 }
7021
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307022 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7023 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
7024 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307025 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
7026 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307027 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307028 "%s: HDD adapter magic is invalid", __func__);
7029 return -ENODEV;
7030 }
7031
7032 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307033 status = wlan_hdd_validate_context(pHddCtx);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307034
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307035 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307036 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307037 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7038 "%s: HDD context is not valid", __func__);
7039 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307040 }
7041
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307042 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
7043 __func__, hdd_device_modetoString(pAdapter->device_mode),
7044 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307045
7046 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007047 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007048 )
7049 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307050 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007051
7052 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307053
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007054 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307055 {
7056 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7057 FL("already beacon info added to session(%d)"),
7058 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007059 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307060 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007061
7062 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, &params->beacon, params->dtim_period);
7063
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307064 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007065 {
7066 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307067 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007068 return -EINVAL;
7069 }
7070 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08007071#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07007072 wlan_hdd_cfg80211_set_channel(wiphy, dev,
7073#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
7074 params->channel, params->channel_type);
7075#else
7076 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
7077#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08007078#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007079 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
7080 params->ssid_len, params->hidden_ssid);
7081 }
7082
7083 EXIT();
7084 return status;
7085}
7086
7087
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307088static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007089 struct net_device *dev,
7090 struct cfg80211_beacon_data *params)
7091{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307092 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307093 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307094 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007095
7096 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307097
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307098 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7099 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
7100 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007101 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007102 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307103
7104 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7105 status = wlan_hdd_validate_context(pHddCtx);
7106
7107 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007108 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307109 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7110 "%s: HDD context is not valid", __func__);
7111 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007112 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007113
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307114 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007115 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307116 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007117 {
7118 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307119
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007120 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307121
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007122 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307123 {
7124 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7125 FL("session(%d) beacon data points to NULL"),
7126 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007127 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307128 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007129
7130 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
7131
7132 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307133 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007134 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007135 return -EINVAL;
7136 }
7137
7138 pAdapter->sessionCtx.ap.beacon = new;
7139
7140 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
7141 }
7142
7143 EXIT();
7144 return status;
7145}
7146
7147#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
7148
Jeff Johnson295189b2012-06-20 16:38:30 -07007149
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05307150static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007151 struct net_device *dev,
7152 struct bss_parameters *params)
7153{
7154 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7155
7156 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307157
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307158 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7159 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
7160 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307161 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7162 __func__, hdd_device_modetoString(pAdapter->device_mode),
7163 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007164
7165 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007166 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307167 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007168 {
7169 /* ap_isolate == -1 means that in change bss, upper layer doesn't
7170 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307171 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07007172 {
7173 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307174 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007175 }
7176
7177 EXIT();
7178 return 0;
7179}
7180
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05307181static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
7182 struct net_device *dev,
7183 struct bss_parameters *params)
7184{
7185 int ret;
7186
7187 vos_ssr_protect(__func__);
7188 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
7189 vos_ssr_unprotect(__func__);
7190
7191 return ret;
7192}
Kiet Lam10841362013-11-01 11:36:50 +05307193/* FUNCTION: wlan_hdd_change_country_code_cd
7194* to wait for contry code completion
7195*/
7196void* wlan_hdd_change_country_code_cb(void *pAdapter)
7197{
7198 hdd_adapter_t *call_back_pAdapter = pAdapter;
7199 complete(&call_back_pAdapter->change_country_code);
7200 return NULL;
7201}
7202
Jeff Johnson295189b2012-06-20 16:38:30 -07007203/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05307204 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07007205 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
7206 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05307207int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007208 struct net_device *ndev,
7209 enum nl80211_iftype type,
7210 u32 *flags,
7211 struct vif_params *params
7212 )
7213{
7214 struct wireless_dev *wdev;
7215 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08007216 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07007217 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007218 tCsrRoamProfile *pRoamProfile = NULL;
7219 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307220 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007221 eMib_dot11DesiredBssType connectedBssType;
7222 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307223 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007224
7225 ENTER();
7226
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307227 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08007228 {
7229 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7230 "%s: Adapter context is null", __func__);
7231 return VOS_STATUS_E_FAILURE;
7232 }
7233
7234 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7235 if (!pHddCtx)
7236 {
7237 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7238 "%s: HDD context is null", __func__);
7239 return VOS_STATUS_E_FAILURE;
7240 }
7241
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307242 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7243 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
7244 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307245 status = wlan_hdd_validate_context(pHddCtx);
7246
7247 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007248 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307249 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7250 "%s: HDD context is not valid", __func__);
7251 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007252 }
7253
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307254 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7255 __func__, hdd_device_modetoString(pAdapter->device_mode),
7256 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007257
Agarwal Ashish51325b52014-06-16 16:50:49 +05307258 if (vos_max_concurrent_connections_reached()) {
7259 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7260 return -EINVAL;
7261 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307262 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07007263 wdev = ndev->ieee80211_ptr;
7264
7265#ifdef WLAN_BTAMP_FEATURE
7266 if((NL80211_IFTYPE_P2P_CLIENT == type)||
7267 (NL80211_IFTYPE_ADHOC == type)||
7268 (NL80211_IFTYPE_AP == type)||
7269 (NL80211_IFTYPE_P2P_GO == type))
7270 {
7271 pHddCtx->isAmpAllowed = VOS_FALSE;
7272 // stop AMP traffic
7273 status = WLANBAP_StopAmp();
7274 if(VOS_STATUS_SUCCESS != status )
7275 {
7276 pHddCtx->isAmpAllowed = VOS_TRUE;
7277 hddLog(VOS_TRACE_LEVEL_FATAL,
7278 "%s: Failed to stop AMP", __func__);
7279 return -EINVAL;
7280 }
7281 }
7282#endif //WLAN_BTAMP_FEATURE
7283 /* Reset the current device mode bit mask*/
7284 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
7285
7286 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07007287 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07007288 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07007289 )
7290 {
7291 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08007292 if (!pWextState)
7293 {
7294 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7295 "%s: pWextState is null", __func__);
7296 return VOS_STATUS_E_FAILURE;
7297 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007298 pRoamProfile = &pWextState->roamProfile;
7299 LastBSSType = pRoamProfile->BSSType;
7300
7301 switch (type)
7302 {
7303 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07007304 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07007305 hddLog(VOS_TRACE_LEVEL_INFO,
7306 "%s: setting interface Type to INFRASTRUCTURE", __func__);
7307 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07007308#ifdef WLAN_FEATURE_11AC
7309 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
7310 {
7311 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
7312 }
7313#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307314 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07007315 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007316 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08007317 //Check for sub-string p2p to confirm its a p2p interface
7318 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307319 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08007320 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
7321 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
7322 }
7323 else
7324 {
7325 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07007326 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08007327 }
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05307328#ifdef FEATURE_WLAN_TDLS
7329 /* The open adapter for the p2p shall skip initializations in
7330 * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for
7331 * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke
7332 * tdls_init when the change_iface sets the device mode to
7333 * WLAN_HDD_P2P_CLIENT.
7334 */
7335
7336 if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
7337 {
Agarwal Ashish4b87f922014-06-18 03:03:21 +05307338 if (0 != wlan_hdd_sta_tdls_init (pAdapter))
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05307339 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307340 hddLog(VOS_TRACE_LEVEL_ERROR,
7341 "%s: tdls initialization failed", __func__);
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05307342 return -EINVAL;
7343 }
7344 }
7345#endif
7346
Jeff Johnson295189b2012-06-20 16:38:30 -07007347 break;
7348 case NL80211_IFTYPE_ADHOC:
7349 hddLog(VOS_TRACE_LEVEL_INFO,
7350 "%s: setting interface Type to ADHOC", __func__);
7351 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
7352 pRoamProfile->phyMode =
7353 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07007354 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007355 wdev->iftype = type;
7356 break;
7357
7358 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07007359 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07007360 {
7361 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
7362 "%s: setting interface Type to %s", __func__,
7363 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
7364
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08007365 //Cancel any remain on channel for GO mode
7366 if (NL80211_IFTYPE_P2P_GO == type)
7367 {
7368 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
7369 }
Mohit Khanna0f232092012-09-11 14:46:08 -07007370 if (NL80211_IFTYPE_AP == type)
7371 {
7372 /* As Loading WLAN Driver one interface being created for p2p device
7373 * address. This will take one HW STA and the max number of clients
7374 * that can connect to softAP will be reduced by one. so while changing
7375 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
7376 * interface as it is not required in SoftAP mode.
7377 */
7378
7379 // Get P2P Adapter
7380 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
7381
7382 if (pP2pAdapter)
7383 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307384 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -07007385 hdd_deinit_adapter(pHddCtx, pP2pAdapter);
7386 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
7387 }
7388 }
Swaroop Goltia2e32212014-04-09 23:37:33 +05307389 //Disable IMPS & BMPS for SAP/GO
7390 if(VOS_STATUS_E_FAILURE ==
7391 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
7392 {
7393 //Fail to Exit BMPS
7394 VOS_ASSERT(0);
7395 }
Deepthi Gowri500fc472014-08-11 19:53:10 +05307396
7397 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
7398
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307399#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07007400
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307401 /* A Mutex Lock is introduced while changing the mode to
7402 * protect the concurrent access for the Adapters by TDLS
7403 * module.
7404 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05307405 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307406#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007407 //De-init the adapter.
Jeff Johnson295189b2012-06-20 16:38:30 -07007408 hdd_deinit_adapter( pHddCtx, pAdapter );
7409 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07007410 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
7411 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307412#ifdef FEATURE_WLAN_TDLS
7413 mutex_unlock(&pHddCtx->tdls_lock);
7414#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07007415 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
7416 (pConfig->apRandomBssidEnabled))
7417 {
7418 /* To meet Android requirements create a randomized
7419 MAC address of the form 02:1A:11:Fx:xx:xx */
7420 get_random_bytes(&ndev->dev_addr[3], 3);
7421 ndev->dev_addr[0] = 0x02;
7422 ndev->dev_addr[1] = 0x1A;
7423 ndev->dev_addr[2] = 0x11;
7424 ndev->dev_addr[3] |= 0xF0;
7425 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
7426 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08007427 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
7428 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07007429 }
7430
Jeff Johnson295189b2012-06-20 16:38:30 -07007431 hdd_set_ap_ops( pAdapter->dev );
7432
Kiet Lam10841362013-11-01 11:36:50 +05307433 /* This is for only SAP mode where users can
7434 * control country through ini.
7435 * P2P GO follows station country code
7436 * acquired during the STA scanning. */
7437 if((NL80211_IFTYPE_AP == type) &&
7438 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
7439 {
7440 int status = 0;
7441 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
7442 "%s: setting country code from INI ", __func__);
7443 init_completion(&pAdapter->change_country_code);
7444 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
7445 (void *)(tSmeChangeCountryCallback)
7446 wlan_hdd_change_country_code_cb,
7447 pConfig->apCntryCode, pAdapter,
7448 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05307449 eSIR_FALSE,
7450 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05307451 if (eHAL_STATUS_SUCCESS == status)
7452 {
7453 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307454 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05307455 &pAdapter->change_country_code,
7456 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307457 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05307458 {
7459 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307460 FL("SME Timed out while setting country code %ld"),
7461 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08007462
7463 if (pHddCtx->isLogpInProgress)
7464 {
7465 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7466 "%s: LOGP in Progress. Ignore!!!", __func__);
7467 return -EAGAIN;
7468 }
Kiet Lam10841362013-11-01 11:36:50 +05307469 }
7470 }
7471 else
7472 {
7473 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007474 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05307475 return -EINVAL;
7476 }
7477 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007478 status = hdd_init_ap_mode(pAdapter);
7479 if(status != VOS_STATUS_SUCCESS)
7480 {
7481 hddLog(VOS_TRACE_LEVEL_FATAL,
7482 "%s: Error initializing the ap mode", __func__);
7483 return -EINVAL;
7484 }
7485 hdd_set_conparam(1);
7486
Jeff Johnson295189b2012-06-20 16:38:30 -07007487 /*interface type changed update in wiphy structure*/
7488 if(wdev)
7489 {
7490 wdev->iftype = type;
7491 pHddCtx->change_iface = type;
7492 }
7493 else
7494 {
7495 hddLog(VOS_TRACE_LEVEL_ERROR,
7496 "%s: ERROR !!!! Wireless dev is NULL", __func__);
7497 return -EINVAL;
7498 }
7499 goto done;
7500 }
7501
7502 default:
7503 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
7504 __func__);
7505 return -EOPNOTSUPP;
7506 }
7507 }
7508 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007509 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007510 )
7511 {
7512 switch(type)
7513 {
7514 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07007515 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07007516 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +05307517
7518 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307519#ifdef FEATURE_WLAN_TDLS
7520
7521 /* A Mutex Lock is introduced while changing the mode to
7522 * protect the concurrent access for the Adapters by TDLS
7523 * module.
7524 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05307525 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307526#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07007527 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07007528 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08007529 //Check for sub-string p2p to confirm its a p2p interface
7530 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08007531 {
7532 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
7533 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
7534 }
7535 else
7536 {
7537 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07007538 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08007539 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007540 hdd_set_conparam(0);
7541 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07007542 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
7543 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307544#ifdef FEATURE_WLAN_TDLS
7545 mutex_unlock(&pHddCtx->tdls_lock);
7546#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05307547 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07007548 if( VOS_STATUS_SUCCESS != status )
7549 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07007550 /* In case of JB, for P2P-GO, only change interface will be called,
7551 * This is the right place to enable back bmps_imps()
7552 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05307553 if (pHddCtx->hdd_wlan_suspended)
7554 {
7555 hdd_set_pwrparams(pHddCtx);
7556 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007557 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007558 goto done;
7559 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07007560 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07007561 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07007562 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
7563 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07007564 goto done;
7565 default:
7566 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
7567 __func__);
7568 return -EOPNOTSUPP;
7569
7570 }
7571
7572 }
7573 else
7574 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307575 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
7576 __func__, hdd_device_modetoString(pAdapter->device_mode),
7577 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007578 return -EOPNOTSUPP;
7579 }
7580
7581
7582 if(pRoamProfile)
7583 {
7584 if ( LastBSSType != pRoamProfile->BSSType )
7585 {
7586 /*interface type changed update in wiphy structure*/
7587 wdev->iftype = type;
7588
7589 /*the BSS mode changed, We need to issue disconnect
7590 if connected or in IBSS disconnect state*/
7591 if ( hdd_connGetConnectedBssType(
7592 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
7593 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
7594 {
7595 /*need to issue a disconnect to CSR.*/
7596 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7597 if( eHAL_STATUS_SUCCESS ==
7598 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
7599 pAdapter->sessionId,
7600 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
7601 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307602 ret = wait_for_completion_interruptible_timeout(
7603 &pAdapter->disconnect_comp_var,
7604 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7605 if (ret <= 0)
7606 {
7607 hddLog(VOS_TRACE_LEVEL_ERROR,
7608 FL("wait on disconnect_comp_var failed %ld"), ret);
7609 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007610 }
7611 }
7612 }
7613 }
7614
7615done:
7616 /*set bitmask based on updated value*/
7617 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07007618
7619 /* Only STA mode support TM now
7620 * all other mode, TM feature should be disabled */
7621 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
7622 (~VOS_STA & pHddCtx->concurrency_mode) )
7623 {
7624 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
7625 }
7626
Jeff Johnson295189b2012-06-20 16:38:30 -07007627#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307628 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05307629 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07007630 {
7631 //we are ok to do AMP
7632 pHddCtx->isAmpAllowed = VOS_TRUE;
7633 }
7634#endif //WLAN_BTAMP_FEATURE
7635 EXIT();
7636 return 0;
7637}
7638
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05307639/*
7640 * FUNCTION: wlan_hdd_cfg80211_change_iface
7641 * wrapper function to protect the actual implementation from SSR.
7642 */
7643int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
7644 struct net_device *ndev,
7645 enum nl80211_iftype type,
7646 u32 *flags,
7647 struct vif_params *params
7648 )
7649{
7650 int ret;
7651
7652 vos_ssr_protect(__func__);
7653 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
7654 vos_ssr_unprotect(__func__);
7655
7656 return ret;
7657}
7658
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007659#ifdef FEATURE_WLAN_TDLS
7660static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
7661 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
7662{
7663 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7664 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7665 VOS_STATUS status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007666 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307667 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05307668 tANI_U16 numCurrTdlsPeers;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007669
7670 ENTER();
7671
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05307672 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007673 {
7674 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7675 "Invalid arguments");
7676 return -EINVAL;
7677 }
Hoonki Lee27511902013-03-14 18:19:06 -07007678
7679 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
7680 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
7681 {
7682 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7683 "%s: TDLS mode is disabled OR not enabled in FW."
7684 MAC_ADDRESS_STR " Request declined.",
7685 __func__, MAC_ADDR_ARRAY(mac));
7686 return -ENOTSUPP;
7687 }
7688
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007689 if (pHddCtx->isLogpInProgress)
7690 {
7691 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7692 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +05307693 wlan_hdd_tdls_set_link_status(pAdapter,
7694 mac,
7695 eTDLS_LINK_IDLE,
7696 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007697 return -EBUSY;
7698 }
7699
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05307700 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007701
7702 if ( NULL == pTdlsPeer ) {
7703 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7704 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
7705 __func__, MAC_ADDR_ARRAY(mac), update);
7706 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007707 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007708
7709 /* in add station, we accept existing valid staId if there is */
7710 if ((0 == update) &&
7711 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
7712 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007713 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007714 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007715 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007716 " link_status %d. staId %d. add station ignored.",
7717 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
7718 return 0;
7719 }
7720 /* in change station, we accept only when staId is valid */
7721 if ((1 == update) &&
7722 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
7723 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
7724 {
7725 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7726 "%s: " MAC_ADDRESS_STR
7727 " link status %d. staId %d. change station %s.",
7728 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
7729 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
7730 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007731 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007732
7733 /* when others are on-going, we want to change link_status to idle */
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307734 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007735 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007736 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7737 "%s: " MAC_ADDRESS_STR
7738 " TDLS setup is ongoing. Request declined.",
7739 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07007740 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007741 }
7742
7743 /* first to check if we reached to maximum supported TDLS peer.
7744 TODO: for now, return -EPERM looks working fine,
7745 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05307746 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
7747 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007748 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007749 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7750 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05307751 " TDLS Max peer already connected. Request declined."
7752 " Num of peers (%d), Max allowed (%d).",
7753 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
7754 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007755 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007756 }
7757 else
7758 {
7759 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307760 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007761 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007762 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007763 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7764 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
7765 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007766 return -EPERM;
7767 }
7768 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007769 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +05307770 wlan_hdd_tdls_set_link_status(pAdapter,
7771 mac,
7772 eTDLS_LINK_CONNECTING,
7773 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007774
Jeff Johnsond75fe012013-04-06 10:53:06 -07007775 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05307776 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007777 {
7778 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7779 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07007780 if(StaParams->htcap_present)
7781 {
7782 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7783 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
7784 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7785 "ht_capa->extended_capabilities: %0x",
7786 StaParams->HTCap.extendedHtCapInfo);
7787 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007788 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7789 "params->capability: %0x",StaParams->capability);
7790 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007791 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07007792 if(StaParams->vhtcap_present)
7793 {
7794 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7795 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
7796 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
7797 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
7798 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007799 {
7800 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007801 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007802 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
7803 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7804 "[%d]: %x ", i, StaParams->supported_rates[i]);
7805 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07007806 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05307807 else if ((1 == update) && (NULL == StaParams))
7808 {
7809 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7810 "%s : update is true, but staParams is NULL. Error!", __func__);
7811 return -EPERM;
7812 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007813
7814 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
7815
7816 if (!update)
7817 {
7818 status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
7819 pAdapter->sessionId, mac);
7820 }
7821 else
7822 {
7823 status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
7824 pAdapter->sessionId, mac, StaParams);
7825 }
7826
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307827 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007828 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
7829
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307830 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007831 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307833 "%s: timeout waiting for tdls add station indication %ld",
7834 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007835 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007836 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307837
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007838 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
7839 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007841 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007842 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007843 }
7844
7845 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07007846
7847error:
Atul Mittal115287b2014-07-08 13:26:33 +05307848 wlan_hdd_tdls_set_link_status(pAdapter,
7849 mac,
7850 eTDLS_LINK_IDLE,
7851 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007852 return -EPERM;
7853
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007854}
7855#endif
7856
Jeff Johnson295189b2012-06-20 16:38:30 -07007857static int wlan_hdd_change_station(struct wiphy *wiphy,
7858 struct net_device *dev,
7859 u8 *mac,
7860 struct station_parameters *params)
7861{
7862 VOS_STATUS status = VOS_STATUS_SUCCESS;
7863 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkala29149562013-05-10 21:43:41 +05307864 hdd_context_t *pHddCtx;
7865 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007866 v_MACADDR_t STAMacAddress;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07007867#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007868 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007869 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05307870 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07007871#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07007872 ENTER();
7873
Gopichand Nakkala29149562013-05-10 21:43:41 +05307874 if ((NULL == pAdapter))
7875 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307876 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05307877 "invalid adapter ");
7878 return -EINVAL;
7879 }
7880
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307881 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7882 TRACE_CODE_HDD_CHANGE_STATION,
7883 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05307884 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7885 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7886
7887 if ((NULL == pHddCtx) || (NULL == pHddStaCtx))
7888 {
7889 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7890 "invalid HDD state or HDD station context");
7891 return -EINVAL;
7892 }
7893
7894 if (pHddCtx->isLogpInProgress)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007895 {
7896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7897 "%s:LOGP in Progress. Ignore!!!", __func__);
7898 return -EAGAIN;
7899 }
7900
Jeff Johnson295189b2012-06-20 16:38:30 -07007901 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
7902
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007903 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
7904 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07007905 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007906 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07007907 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307908 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07007909 WLANTL_STA_AUTHENTICATED);
7910
Gopichand Nakkala29149562013-05-10 21:43:41 +05307911 if (status != VOS_STATUS_SUCCESS)
7912 {
7913 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7914 "%s: Not able to change TL state to AUTHENTICATED", __func__);
7915 return -EINVAL;
7916 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007917 }
7918 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07007919 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
7920 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05307921#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007922 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
7923 StaParams.capability = params->capability;
7924 StaParams.uapsd_queues = params->uapsd_queues;
7925 StaParams.max_sp = params->max_sp;
7926
Naresh Jayaram3180aa42014-02-12 21:47:26 +05307927 /* Convert (first channel , number of channels) tuple to
7928 * the total list of channels. This goes with the assumption
7929 * that if the first channel is < 14, then the next channels
7930 * are an incremental of 1 else an incremental of 4 till the number
7931 * of channels.
7932 */
7933 if (0 != params->supported_channels_len) {
7934 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
7935 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
7936 {
7937 int wifi_chan_index;
7938 StaParams.supported_channels[j] = params->supported_channels[i];
7939 wifi_chan_index =
7940 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
7941 no_of_channels = params->supported_channels[i+1];
7942 for(k=1; k <= no_of_channels; k++)
7943 {
7944 StaParams.supported_channels[j+1] =
7945 StaParams.supported_channels[j] + wifi_chan_index;
7946 j+=1;
7947 }
7948 }
7949 StaParams.supported_channels_len = j;
7950 }
7951 vos_mem_copy(StaParams.supported_oper_classes,
7952 params->supported_oper_classes,
7953 params->supported_oper_classes_len);
7954 StaParams.supported_oper_classes_len =
7955 params->supported_oper_classes_len;
7956
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007957 if (0 != params->ext_capab_len)
7958 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
7959 sizeof(StaParams.extn_capability));
7960
7961 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07007962 {
7963 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007964 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07007965 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007966
7967 StaParams.supported_rates_len = params->supported_rates_len;
7968
7969 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
7970 * The supported_rates array , for all the structures propogating till Add Sta
7971 * to the firmware has to be modified , if the supplicant (ieee80211) is
7972 * modified to send more rates.
7973 */
7974
7975 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
7976 */
7977 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
7978 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
7979
7980 if (0 != StaParams.supported_rates_len) {
7981 int i = 0;
7982 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
7983 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007984 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007985 "Supported Rates with Length %d", StaParams.supported_rates_len);
7986 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007987 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007988 "[%d]: %0x", i, StaParams.supported_rates[i]);
7989 }
7990
7991 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07007992 {
7993 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007994 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07007995 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007996
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007997 if (0 != params->ext_capab_len ) {
7998 /*Define A Macro : TODO Sunil*/
7999 if ((1<<4) & StaParams.extn_capability[3]) {
8000 isBufSta = 1;
8001 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308002 /* TDLS Channel Switching Support */
8003 if ((1<<6) & StaParams.extn_capability[3]) {
8004 isOffChannelSupported = 1;
8005 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008006 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308007 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
8008 &StaParams, isBufSta,
8009 isOffChannelSupported);
8010
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308011 if (VOS_STATUS_SUCCESS != status) {
8012 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8013 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
8014 return -EINVAL;
8015 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008016 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
8017
8018 if (VOS_STATUS_SUCCESS != status) {
8019 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8020 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
8021 return -EINVAL;
8022 }
8023 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008024#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05308025 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008026 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008027 return status;
8028}
8029
8030/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308031 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -07008032 * This function is used to initialize the key information
8033 */
8034#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308035static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008036 struct net_device *ndev,
8037 u8 key_index, bool pairwise,
8038 const u8 *mac_addr,
8039 struct key_params *params
8040 )
8041#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308042static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008043 struct net_device *ndev,
8044 u8 key_index, const u8 *mac_addr,
8045 struct key_params *params
8046 )
8047#endif
8048{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008049 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07008050 tCsrRoamSetKey setKey;
8051 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308052 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008053 v_U32_t roamId= 0xFF;
8054 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008055 hdd_hostapd_state_t *pHostapdState;
8056 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008057 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308058 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008059
8060 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308061
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308062 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8063 TRACE_CODE_HDD_CFG80211_ADD_KEY,
8064 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308065 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8066 status = wlan_hdd_validate_context(pHddCtx);
8067
8068 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008069 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308070 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8071 "%s: HDD context is not valid", __func__);
8072 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008073 }
8074
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308075 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8076 __func__, hdd_device_modetoString(pAdapter->device_mode),
8077 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008078
8079 if (CSR_MAX_NUM_KEY <= key_index)
8080 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008081 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008082 key_index);
8083
8084 return -EINVAL;
8085 }
8086
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008087 if (CSR_MAX_KEY_LEN < params->key_len)
8088 {
8089 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
8090 params->key_len);
8091
8092 return -EINVAL;
8093 }
8094
8095 hddLog(VOS_TRACE_LEVEL_INFO,
8096 "%s: called with key index = %d & key length %d",
8097 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07008098
8099 /*extract key idx, key len and key*/
8100 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8101 setKey.keyId = key_index;
8102 setKey.keyLength = params->key_len;
8103 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
8104
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008105 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07008106 {
8107 case WLAN_CIPHER_SUITE_WEP40:
8108 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
8109 break;
8110
8111 case WLAN_CIPHER_SUITE_WEP104:
8112 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
8113 break;
8114
8115 case WLAN_CIPHER_SUITE_TKIP:
8116 {
8117 u8 *pKey = &setKey.Key[0];
8118 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
8119
8120 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
8121
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008122 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07008123
8124 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008125 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07008126 |--------------|----------|----------|
8127 <---16bytes---><--8bytes--><--8bytes-->
8128
8129 */
8130 /*Sme expects the 32 bytes key to be in the below order
8131
8132 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008133 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07008134 |--------------|----------|----------|
8135 <---16bytes---><--8bytes--><--8bytes-->
8136 */
8137 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008138 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07008139
8140 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008141 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07008142
8143 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008144 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07008145
8146
8147 break;
8148 }
8149
8150 case WLAN_CIPHER_SUITE_CCMP:
8151 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
8152 break;
8153
8154#ifdef FEATURE_WLAN_WAPI
8155 case WLAN_CIPHER_SUITE_SMS4:
8156 {
8157 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8158 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
8159 params->key, params->key_len);
8160 return 0;
8161 }
8162#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07008163
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008164#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008165 case WLAN_CIPHER_SUITE_KRK:
8166 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
8167 break;
8168#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07008169
8170#ifdef WLAN_FEATURE_11W
8171 case WLAN_CIPHER_SUITE_AES_CMAC:
8172 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07008173 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07008174#endif
8175
Jeff Johnson295189b2012-06-20 16:38:30 -07008176 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008177 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07008178 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308179 status = -EOPNOTSUPP;
8180 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07008181 }
8182
8183 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
8184 __func__, setKey.encType);
8185
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008186 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07008187#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8188 (!pairwise)
8189#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008190 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07008191#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008192 )
8193 {
8194 /* set group key*/
8195 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8196 "%s- %d: setting Broadcast key",
8197 __func__, __LINE__);
8198 setKey.keyDirection = eSIR_RX_ONLY;
8199 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
8200 }
8201 else
8202 {
8203 /* set pairwise key*/
8204 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8205 "%s- %d: setting pairwise key",
8206 __func__, __LINE__);
8207 setKey.keyDirection = eSIR_TX_RX;
8208 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
8209 }
8210 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
8211 {
8212 setKey.keyDirection = eSIR_TX_RX;
8213 /*Set the group key*/
8214 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
8215 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008216
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008217 if ( 0 != status )
8218 {
8219 hddLog(VOS_TRACE_LEVEL_ERROR,
8220 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308221 status = -EINVAL;
8222 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008223 }
8224 /*Save the keys here and call sme_RoamSetKey for setting
8225 the PTK after peer joins the IBSS network*/
8226 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
8227 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308228 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008229 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05308230 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
8231 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
8232 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008233 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008234 if( pHostapdState->bssState == BSS_START )
8235 {
c_hpothu7c55da62014-01-23 18:34:02 +05308236 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8237 vos_status = wlan_hdd_check_ula_done(pAdapter);
8238
8239 if ( vos_status != VOS_STATUS_SUCCESS )
8240 {
8241 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8242 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
8243 __LINE__, vos_status );
8244
8245 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
8246
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308247 status = -EINVAL;
8248 goto end;
c_hpothu7c55da62014-01-23 18:34:02 +05308249 }
8250
Jeff Johnson295189b2012-06-20 16:38:30 -07008251 status = WLANSAP_SetKeySta( pVosContext, &setKey);
8252
8253 if ( status != eHAL_STATUS_SUCCESS )
8254 {
8255 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8256 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
8257 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308258 status = -EINVAL;
8259 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07008260 }
8261 }
8262
8263 /* Saving WEP keys */
8264 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
8265 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
8266 {
8267 //Save the wep key in ap context. Issue setkey after the BSS is started.
8268 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
8269 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
8270 }
8271 else
8272 {
8273 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008274 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008275 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
8276 }
8277 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008278 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
8279 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008280 {
8281 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8282 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8283
Gopichand Nakkala3d295922013-05-07 16:19:14 +05308284#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8285 if (!pairwise)
8286#else
8287 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
8288#endif
8289 {
8290 /* set group key*/
8291 if (pHddStaCtx->roam_info.deferKeyComplete)
8292 {
8293 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8294 "%s- %d: Perform Set key Complete",
8295 __func__, __LINE__);
8296 hdd_PerformRoamSetKeyComplete(pAdapter);
8297 }
8298 }
8299
Jeff Johnson295189b2012-06-20 16:38:30 -07008300 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
8301
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08008302 pWextState->roamProfile.Keys.defaultIndex = key_index;
8303
8304
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008305 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07008306 params->key, params->key_len);
8307
Gopichand Nakkala3d295922013-05-07 16:19:14 +05308308
Jeff Johnson295189b2012-06-20 16:38:30 -07008309 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
8310
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308311 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07008312 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308313 __func__, setKey.peerMac[0], setKey.peerMac[1],
8314 setKey.peerMac[2], setKey.peerMac[3],
8315 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07008316 setKey.keyDirection);
8317
8318 vos_status = wlan_hdd_check_ula_done(pAdapter);
8319
8320 if ( vos_status != VOS_STATUS_SUCCESS )
8321 {
8322 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8323 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
8324 __LINE__, vos_status );
8325
8326 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
8327
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308328 status = -EINVAL;
8329 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07008330
8331 }
8332
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008333#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05308334 /* The supplicant may attempt to set the PTK once pre-authentication
8335 is done. Save the key in the UMAC and include it in the ADD BSS
8336 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008337 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05308338 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008339 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05308340 hddLog(VOS_TRACE_LEVEL_INFO_MED,
8341 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308342 status = 0;
8343 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +05308344 }
8345 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
8346 {
8347 hddLog(VOS_TRACE_LEVEL_ERROR,
8348 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308349 status = -EINVAL;
8350 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008351 }
8352#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07008353
8354 /* issue set key request to SME*/
8355 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
8356 pAdapter->sessionId, &setKey, &roamId );
8357
8358 if ( 0 != status )
8359 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308360 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07008361 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
8362 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308363 status = -EINVAL;
8364 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07008365 }
8366
8367
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308368 /* in case of IBSS as there was no information available about WEP keys during
8369 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07008370 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308371 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
8372 !( ( IW_AUTH_KEY_MGMT_802_1X
8373 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07008374 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
8375 )
8376 &&
8377 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
8378 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
8379 )
8380 )
8381 {
8382 setKey.keyDirection = eSIR_RX_ONLY;
8383 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
8384
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308385 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07008386 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308387 __func__, setKey.peerMac[0], setKey.peerMac[1],
8388 setKey.peerMac[2], setKey.peerMac[3],
8389 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07008390 setKey.keyDirection);
8391
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308392 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07008393 pAdapter->sessionId, &setKey, &roamId );
8394
8395 if ( 0 != status )
8396 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308397 hddLog(VOS_TRACE_LEVEL_ERROR,
8398 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008399 __func__, status);
8400 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308401 status = -EINVAL;
8402 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07008403 }
8404 }
8405 }
8406
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308407end:
8408 /* Need to clear any trace of key value in the memory.
8409 * Thus zero out the memory even though it is local
8410 * variable.
8411 */
8412 vos_mem_zero(&setKey, sizeof(setKey));
8413
8414 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008415}
8416
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308417#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8418static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
8419 struct net_device *ndev,
8420 u8 key_index, bool pairwise,
8421 const u8 *mac_addr,
8422 struct key_params *params
8423 )
8424#else
8425static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
8426 struct net_device *ndev,
8427 u8 key_index, const u8 *mac_addr,
8428 struct key_params *params
8429 )
8430#endif
8431{
8432 int ret;
8433 vos_ssr_protect(__func__);
8434#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8435 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
8436 mac_addr, params);
8437#else
8438 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
8439 params);
8440#endif
8441 vos_ssr_unprotect(__func__);
8442
8443 return ret;
8444}
8445
Jeff Johnson295189b2012-06-20 16:38:30 -07008446/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308447 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -07008448 * This function is used to get the key information
8449 */
8450#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308451static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308452 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008453 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308454 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07008455 const u8 *mac_addr, void *cookie,
8456 void (*callback)(void *cookie, struct key_params*)
8457 )
8458#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308459static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308460 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008461 struct net_device *ndev,
8462 u8 key_index, const u8 *mac_addr, void *cookie,
8463 void (*callback)(void *cookie, struct key_params*)
8464 )
8465#endif
8466{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308467 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308468 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8469 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008470 struct key_params params;
8471
8472 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308473
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308474 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8475 __func__, hdd_device_modetoString(pAdapter->device_mode),
8476 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308477
Jeff Johnson295189b2012-06-20 16:38:30 -07008478 memset(&params, 0, sizeof(params));
8479
8480 if (CSR_MAX_NUM_KEY <= key_index)
8481 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308482 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07008483 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308484 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008485
8486 switch(pRoamProfile->EncryptionType.encryptionType[0])
8487 {
8488 case eCSR_ENCRYPT_TYPE_NONE:
8489 params.cipher = IW_AUTH_CIPHER_NONE;
8490 break;
8491
8492 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
8493 case eCSR_ENCRYPT_TYPE_WEP40:
8494 params.cipher = WLAN_CIPHER_SUITE_WEP40;
8495 break;
8496
8497 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
8498 case eCSR_ENCRYPT_TYPE_WEP104:
8499 params.cipher = WLAN_CIPHER_SUITE_WEP104;
8500 break;
8501
8502 case eCSR_ENCRYPT_TYPE_TKIP:
8503 params.cipher = WLAN_CIPHER_SUITE_TKIP;
8504 break;
8505
8506 case eCSR_ENCRYPT_TYPE_AES:
8507 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
8508 break;
8509
8510 default:
8511 params.cipher = IW_AUTH_CIPHER_NONE;
8512 break;
8513 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308514
c_hpothuaaf19692014-05-17 17:01:48 +05308515 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8516 TRACE_CODE_HDD_CFG80211_GET_KEY,
8517 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308518
Jeff Johnson295189b2012-06-20 16:38:30 -07008519 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
8520 params.seq_len = 0;
8521 params.seq = NULL;
8522 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
8523 callback(cookie, &params);
8524 return 0;
8525}
8526
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308527#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8528static int wlan_hdd_cfg80211_get_key(
8529 struct wiphy *wiphy,
8530 struct net_device *ndev,
8531 u8 key_index, bool pairwise,
8532 const u8 *mac_addr, void *cookie,
8533 void (*callback)(void *cookie, struct key_params*)
8534 )
8535#else
8536static int wlan_hdd_cfg80211_get_key(
8537 struct wiphy *wiphy,
8538 struct net_device *ndev,
8539 u8 key_index, const u8 *mac_addr, void *cookie,
8540 void (*callback)(void *cookie, struct key_params*)
8541 )
8542#endif
8543{
8544 int ret;
8545
8546 vos_ssr_protect(__func__);
8547#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8548 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
8549 mac_addr, cookie, callback);
8550#else
8551 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
8552 callback);
8553#endif
8554 vos_ssr_unprotect(__func__);
8555
8556 return ret;
8557}
8558
Jeff Johnson295189b2012-06-20 16:38:30 -07008559/*
8560 * FUNCTION: wlan_hdd_cfg80211_del_key
8561 * This function is used to delete the key information
8562 */
8563#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308564static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008565 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308566 u8 key_index,
8567 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07008568 const u8 *mac_addr
8569 )
8570#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308571static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008572 struct net_device *ndev,
8573 u8 key_index,
8574 const u8 *mac_addr
8575 )
8576#endif
8577{
8578 int status = 0;
8579
8580 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308581 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07008582 //it is observed that this is invalidating peer
8583 //key index whenever re-key is done. This is affecting data link.
8584 //It should be ok to ignore del_key.
8585#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308586 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
8587 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008588 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
8589 tCsrRoamSetKey setKey;
8590 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308591
Jeff Johnson295189b2012-06-20 16:38:30 -07008592 ENTER();
8593
8594 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
8595 __func__,pAdapter->device_mode);
8596
8597 if (CSR_MAX_NUM_KEY <= key_index)
8598 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308599 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008600 key_index);
8601
8602 return -EINVAL;
8603 }
8604
8605 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8606 setKey.keyId = key_index;
8607
8608 if (mac_addr)
8609 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
8610 else
8611 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
8612
8613 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
8614
8615 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008616 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308617 )
8618 {
8619
8620 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07008621 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
8622 if( pHostapdState->bssState == BSS_START)
8623 {
8624 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308625
Jeff Johnson295189b2012-06-20 16:38:30 -07008626 if ( status != eHAL_STATUS_SUCCESS )
8627 {
8628 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8629 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
8630 __LINE__, status );
8631 }
8632 }
8633 }
8634 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308635 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07008636 )
8637 {
8638 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8639
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308640 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
8641
8642 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07008643 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308644 __func__, setKey.peerMac[0], setKey.peerMac[1],
8645 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07008646 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308647 if(pAdapter->sessionCtx.station.conn_info.connState ==
8648 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07008649 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308650 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07008651 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308652
Jeff Johnson295189b2012-06-20 16:38:30 -07008653 if ( 0 != status )
8654 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308655 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07008656 "%s: sme_RoamSetKey failure, returned %d",
8657 __func__, status);
8658 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
8659 return -EINVAL;
8660 }
8661 }
8662 }
8663#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008664 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008665 return status;
8666}
8667
8668/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308669 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -07008670 * This function is used to set the default tx key index
8671 */
8672#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308673static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008674 struct net_device *ndev,
8675 u8 key_index,
8676 bool unicast, bool multicast)
8677#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308678static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008679 struct net_device *ndev,
8680 u8 key_index)
8681#endif
8682{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308683 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308684 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308685 hdd_wext_state_t *pWextState;
8686 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308687 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008688
8689 ENTER();
8690
Gopichand Nakkala29149562013-05-10 21:43:41 +05308691 if ((NULL == pAdapter))
8692 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308693 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05308694 "invalid adapter");
8695 return -EINVAL;
8696 }
8697
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308698 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8699 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
8700 pAdapter->sessionId, key_index));
8701
Gopichand Nakkala29149562013-05-10 21:43:41 +05308702 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8703 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8704
8705 if ((NULL == pWextState) || (NULL == pHddStaCtx))
8706 {
8707 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8708 "invalid Wext state or HDD context");
8709 return -EINVAL;
8710 }
8711
Arif Hussain6d2a3322013-11-17 19:50:10 -08008712 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008713 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308714
Jeff Johnson295189b2012-06-20 16:38:30 -07008715 if (CSR_MAX_NUM_KEY <= key_index)
8716 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308717 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008718 key_index);
8719
8720 return -EINVAL;
8721 }
8722
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308723 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8724 status = wlan_hdd_validate_context(pHddCtx);
8725
8726 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008727 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308728 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8729 "%s: HDD context is not valid", __func__);
8730 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008731 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308732
Jeff Johnson295189b2012-06-20 16:38:30 -07008733 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07008734 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308735 )
Jeff Johnson295189b2012-06-20 16:38:30 -07008736 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05308737 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08008738 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308739 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08008740 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008741 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308742 {
8743 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07008744 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308745
Jeff Johnson295189b2012-06-20 16:38:30 -07008746 tCsrRoamSetKey setKey;
8747 v_U32_t roamId= 0xFF;
8748 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308749
8750 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008751 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308752
Jeff Johnson295189b2012-06-20 16:38:30 -07008753 Keys->defaultIndex = (u8)key_index;
8754 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8755 setKey.keyId = key_index;
8756 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308757
8758 vos_mem_copy(&setKey.Key[0],
8759 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07008760 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308761
Gopichand Nakkala29149562013-05-10 21:43:41 +05308762 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308763
8764 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07008765 &pHddStaCtx->conn_info.bssId[0],
8766 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308767
Gopichand Nakkala29149562013-05-10 21:43:41 +05308768 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
8769 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
8770 eCSR_ENCRYPT_TYPE_WEP104)
8771 {
8772 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
8773 even though ap is configured for WEP-40 encryption. In this canse the key length
8774 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
8775 type(104) and switching encryption type to 40*/
8776 pWextState->roamProfile.EncryptionType.encryptionType[0] =
8777 eCSR_ENCRYPT_TYPE_WEP40;
8778 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
8779 eCSR_ENCRYPT_TYPE_WEP40;
8780 }
8781
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308782 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07008783 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308784
Jeff Johnson295189b2012-06-20 16:38:30 -07008785 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308786 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07008787 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308788
Jeff Johnson295189b2012-06-20 16:38:30 -07008789 if ( 0 != status )
8790 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308791 hddLog(VOS_TRACE_LEVEL_ERROR,
8792 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008793 status);
8794 return -EINVAL;
8795 }
8796 }
8797 }
8798
8799 /* In SoftAp mode setting key direction for default mode */
8800 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
8801 {
8802 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
8803 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
8804 (eCSR_ENCRYPT_TYPE_AES !=
8805 pWextState->roamProfile.EncryptionType.encryptionType[0])
8806 )
8807 {
8808 /* Saving key direction for default key index to TX default */
8809 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
8810 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
8811 }
8812 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308813
Jeff Johnson295189b2012-06-20 16:38:30 -07008814 return status;
8815}
8816
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308817#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8818static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
8819 struct net_device *ndev,
8820 u8 key_index,
8821 bool unicast, bool multicast)
8822#else
8823static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
8824 struct net_device *ndev,
8825 u8 key_index)
8826#endif
8827{
8828 int ret;
8829 vos_ssr_protect(__func__);
8830#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8831 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
8832 multicast);
8833#else
8834 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
8835#endif
8836 vos_ssr_unprotect(__func__);
8837
8838 return ret;
8839}
8840
Jeff Johnson295189b2012-06-20 16:38:30 -07008841/*
8842 * FUNCTION: wlan_hdd_cfg80211_inform_bss
8843 * This function is used to inform the BSS details to nl80211 interface.
8844 */
8845static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
8846 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
8847{
8848 struct net_device *dev = pAdapter->dev;
8849 struct wireless_dev *wdev = dev->ieee80211_ptr;
8850 struct wiphy *wiphy = wdev->wiphy;
8851 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
8852 int chan_no;
8853 int ie_length;
8854 const char *ie;
8855 unsigned int freq;
8856 struct ieee80211_channel *chan;
8857 int rssi = 0;
8858 struct cfg80211_bss *bss = NULL;
8859
8860 ENTER();
8861
8862 if( NULL == pBssDesc )
8863 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008864 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008865 return bss;
8866 }
8867
8868 chan_no = pBssDesc->channelId;
8869 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
8870 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
8871
8872 if( NULL == ie )
8873 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008874 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008875 return bss;
8876 }
8877
8878#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
8879 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
8880 {
8881 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
8882 }
8883 else
8884 {
8885 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
8886 }
8887#else
8888 freq = ieee80211_channel_to_frequency(chan_no);
8889#endif
8890
8891 chan = __ieee80211_get_channel(wiphy, freq);
8892
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +05308893 if (!chan) {
8894 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
8895 return NULL;
8896 }
8897
Abhishek Singhaee43942014-06-16 18:55:47 +05308898 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -07008899
Abhishek Singhaee43942014-06-16 18:55:47 +05308900 return cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308901 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07008902 pBssDesc->capabilityInfo,
8903 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +05308904 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008905}
8906
8907
8908
8909/*
8910 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
8911 * This function is used to inform the BSS details to nl80211 interface.
8912 */
8913struct cfg80211_bss*
8914wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
8915 tSirBssDescription *bss_desc
8916 )
8917{
8918 /*
8919 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
8920 already exists in bss data base of cfg80211 for that particular BSS ID.
8921 Using cfg80211_inform_bss_frame to update the bss entry instead of
8922 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
8923 now there is no possibility to get the mgmt(probe response) frame from PE,
8924 converting bss_desc to ieee80211_mgmt(probe response) and passing to
8925 cfg80211_inform_bss_frame.
8926 */
8927 struct net_device *dev = pAdapter->dev;
8928 struct wireless_dev *wdev = dev->ieee80211_ptr;
8929 struct wiphy *wiphy = wdev->wiphy;
8930 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08008931#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
8932 qcom_ie_age *qie_age = NULL;
8933 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
8934#else
Jeff Johnson295189b2012-06-20 16:38:30 -07008935 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08008936#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008937 const char *ie =
8938 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
8939 unsigned int freq;
8940 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05308941 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008942 struct cfg80211_bss *bss_status = NULL;
8943 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
8944 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07008945 hdd_context_t *pHddCtx;
8946 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07008947#ifdef WLAN_OPEN_SOURCE
8948 struct timespec ts;
8949#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008950
Wilson Yangf80a0542013-10-07 13:02:37 -07008951 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8952 status = wlan_hdd_validate_context(pHddCtx);
8953
8954 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +05308955 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -07008956 {
8957 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8958 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
8959 return NULL;
8960 }
8961
8962
8963 if (0 != status)
8964 {
8965 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8966 "%s: HDD context is not valid", __func__);
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07008967 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07008968 }
8969
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05308970 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -07008971 if (!mgmt)
8972 {
8973 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8974 "%s: memory allocation failed ", __func__);
8975 return NULL;
8976 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07008977
Jeff Johnson295189b2012-06-20 16:38:30 -07008978 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07008979
8980#ifdef WLAN_OPEN_SOURCE
8981 /* Android does not want the timestamp from the frame.
8982 Instead it wants a monotonic increasing value */
8983 get_monotonic_boottime(&ts);
8984 mgmt->u.probe_resp.timestamp =
8985 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
8986#else
8987 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07008988 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
8989 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07008990
8991#endif
8992
Jeff Johnson295189b2012-06-20 16:38:30 -07008993 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
8994 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08008995
8996#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
8997 /* GPS Requirement: need age ie per entry. Using vendor specific. */
8998 /* Assuming this is the last IE, copy at the end */
8999 ie_length -=sizeof(qcom_ie_age);
9000 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
9001 qie_age->element_id = QCOM_VENDOR_IE_ID;
9002 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
9003 qie_age->oui_1 = QCOM_OUI1;
9004 qie_age->oui_2 = QCOM_OUI2;
9005 qie_age->oui_3 = QCOM_OUI3;
9006 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
9007 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
9008#endif
9009
Jeff Johnson295189b2012-06-20 16:38:30 -07009010 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05309011 if (bss_desc->fProbeRsp)
9012 {
9013 mgmt->frame_control |=
9014 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
9015 }
9016 else
9017 {
9018 mgmt->frame_control |=
9019 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
9020 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009021
9022#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309023 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009024 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
9025 {
9026 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
9027 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309028 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009029 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
9030
9031 {
9032 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
9033 }
9034 else
9035 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309036 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
9037 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -07009038 kfree(mgmt);
9039 return NULL;
9040 }
9041#else
9042 freq = ieee80211_channel_to_frequency(chan_no);
9043#endif
9044 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08009045 /*when the band is changed on the fly using the GUI, three things are done
9046 * 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)
9047 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
9048 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
9049 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
9050 * and discards the channels correponding to previous band and calls back with zero bss results.
9051 * 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
9052 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
9053 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
9054 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
9055 * So drop the bss and continue to next bss.
9056 */
9057 if(chan == NULL)
9058 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309059 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07009060 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08009061 return NULL;
9062 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009063 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309064 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07009065 * */
9066 if (( eConnectionState_Associated ==
9067 pAdapter->sessionCtx.station.conn_info.connState ) &&
9068 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
9069 pAdapter->sessionCtx.station.conn_info.bssId,
9070 WNI_CFG_BSSID_LEN)))
9071 {
9072 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
9073 rssi = (pAdapter->rssi * 100);
9074 }
9075 else
9076 {
9077 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
9078 }
9079
Nirav Shah20ac06f2013-12-12 18:14:06 +05309080 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
9081 "RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
9082 chan->center_freq, (int)(rssi/100));
9083
Jeff Johnson295189b2012-06-20 16:38:30 -07009084 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
9085 frame_len, rssi, GFP_KERNEL);
9086 kfree(mgmt);
9087 return bss_status;
9088}
9089
9090/*
9091 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
9092 * This function is used to update the BSS data base of CFG8011
9093 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309094struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07009095 tCsrRoamInfo *pRoamInfo
9096 )
9097{
9098 tCsrRoamConnectedProfile roamProfile;
9099 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9100 struct cfg80211_bss *bss = NULL;
9101
9102 ENTER();
9103
9104 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
9105 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
9106
9107 if (NULL != roamProfile.pBssDesc)
9108 {
Girish Gowlif4b68022014-08-28 23:18:57 +05309109 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
9110 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009111
9112 if (NULL == bss)
9113 {
9114 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
9115 __func__);
9116 }
9117
9118 sme_RoamFreeConnectProfile(hHal, &roamProfile);
9119 }
9120 else
9121 {
9122 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
9123 __func__);
9124 }
9125 return bss;
9126}
9127
9128/*
9129 * FUNCTION: wlan_hdd_cfg80211_update_bss
9130 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309131static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
9132 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07009133 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309134{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309135 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009136 tCsrScanResultInfo *pScanResult;
9137 eHalStatus status = 0;
9138 tScanResultHandle pResult;
9139 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07009140 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009141
9142 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309143
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309144 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9145 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
9146 NO_SESSION, pAdapter->sessionId));
9147
Wilson Yangf80a0542013-10-07 13:02:37 -07009148 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9149
9150 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -07009151 {
Wilson Yangf80a0542013-10-07 13:02:37 -07009152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9153 "%s:LOGP in Progress. Ignore!!!",__func__);
9154 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07009155 }
9156
Wilson Yangf80a0542013-10-07 13:02:37 -07009157
9158 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +05309159 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -07009160 {
9161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9162 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
9163 return VOS_STATUS_E_PERM;
9164 }
9165
9166
Jeff Johnson295189b2012-06-20 16:38:30 -07009167 /*
9168 * start getting scan results and populate cgf80211 BSS database
9169 */
9170 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
9171
9172 /* no scan results */
9173 if (NULL == pResult)
9174 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309175 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
9176 __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07009177 return status;
9178 }
9179
9180 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
9181
9182 while (pScanResult)
9183 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309184 /*
9185 * cfg80211_inform_bss() is not updating ie field of bss entry, if
9186 * entry already exists in bss data base of cfg80211 for that
9187 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
9188 * bss entry instead of cfg80211_inform_bss, But this call expects
9189 * mgmt packet as input. As of now there is no possibility to get
9190 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07009191 * ieee80211_mgmt(probe response) and passing to c
9192 * fg80211_inform_bss_frame.
9193 * */
9194
9195 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
9196 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309197
Jeff Johnson295189b2012-06-20 16:38:30 -07009198
9199 if (NULL == bss_status)
9200 {
9201 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009202 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009203 }
9204 else
9205 {
Yue Maf49ba872013-08-19 12:04:25 -07009206 cfg80211_put_bss(
9207#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9208 wiphy,
9209#endif
9210 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07009211 }
9212
9213 pScanResult = sme_ScanResultGetNext(hHal, pResult);
9214 }
9215
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309216 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07009217
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309218 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009219}
9220
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009221void
9222hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
9223{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309224 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -08009225 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009226} /****** end hddPrintMacAddr() ******/
9227
9228void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07009229hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009230{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309231 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009232 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07009233 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
9234 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
9235 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009236} /****** end hddPrintPmkId() ******/
9237
9238//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
9239//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
9240
9241//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
9242//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
9243
9244#define dump_bssid(bssid) \
9245 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07009246 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
9247 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009248 }
9249
9250#define dump_pmkid(pMac, pmkid) \
9251 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07009252 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
9253 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009254 }
9255
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07009256#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009257/*
9258 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
9259 * This function is used to notify the supplicant of a new PMKSA candidate.
9260 */
9261int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309262 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009263 int index, bool preauth )
9264{
Jeff Johnsone7245742012-09-05 17:12:55 -07009265#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009266 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07009267 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009268
9269 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07009270 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009271
9272 if( NULL == pRoamInfo )
9273 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009274 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009275 return -EINVAL;
9276 }
9277
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07009278 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
9279 {
9280 dump_bssid(pRoamInfo->bssid);
9281 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009282 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07009283 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009284#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309285 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009286}
9287#endif //FEATURE_WLAN_LFR
9288
Yue Maef608272013-04-08 23:09:17 -07009289#ifdef FEATURE_WLAN_LFR_METRICS
9290/*
9291 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
9292 * 802.11r/LFR metrics reporting function to report preauth initiation
9293 *
9294 */
9295#define MAX_LFR_METRICS_EVENT_LENGTH 100
9296VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
9297 tCsrRoamInfo *pRoamInfo)
9298{
9299 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
9300 union iwreq_data wrqu;
9301
9302 ENTER();
9303
9304 if (NULL == pAdapter)
9305 {
9306 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
9307 return VOS_STATUS_E_FAILURE;
9308 }
9309
9310 /* create the event */
9311 memset(&wrqu, 0, sizeof(wrqu));
9312 memset(metrics_notification, 0, sizeof(metrics_notification));
9313
9314 wrqu.data.pointer = metrics_notification;
9315 wrqu.data.length = scnprintf(metrics_notification,
9316 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
9317 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
9318
9319 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
9320
9321 EXIT();
9322
9323 return VOS_STATUS_SUCCESS;
9324}
9325
9326/*
9327 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
9328 * 802.11r/LFR metrics reporting function to report preauth completion
9329 * or failure
9330 */
9331VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
9332 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
9333{
9334 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
9335 union iwreq_data wrqu;
9336
9337 ENTER();
9338
9339 if (NULL == pAdapter)
9340 {
9341 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
9342 return VOS_STATUS_E_FAILURE;
9343 }
9344
9345 /* create the event */
9346 memset(&wrqu, 0, sizeof(wrqu));
9347 memset(metrics_notification, 0, sizeof(metrics_notification));
9348
9349 scnprintf(metrics_notification, sizeof(metrics_notification),
9350 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
9351 MAC_ADDR_ARRAY(pRoamInfo->bssid));
9352
9353 if (1 == preauth_status)
9354 strncat(metrics_notification, " TRUE", 5);
9355 else
9356 strncat(metrics_notification, " FALSE", 6);
9357
9358 wrqu.data.pointer = metrics_notification;
9359 wrqu.data.length = strlen(metrics_notification);
9360
9361 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
9362
9363 EXIT();
9364
9365 return VOS_STATUS_SUCCESS;
9366}
9367
9368/*
9369 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
9370 * 802.11r/LFR metrics reporting function to report handover initiation
9371 *
9372 */
9373VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
9374 tCsrRoamInfo *pRoamInfo)
9375{
9376 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
9377 union iwreq_data wrqu;
9378
9379 ENTER();
9380
9381 if (NULL == pAdapter)
9382 {
9383 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
9384 return VOS_STATUS_E_FAILURE;
9385 }
9386
9387 /* create the event */
9388 memset(&wrqu, 0, sizeof(wrqu));
9389 memset(metrics_notification, 0, sizeof(metrics_notification));
9390
9391 wrqu.data.pointer = metrics_notification;
9392 wrqu.data.length = scnprintf(metrics_notification,
9393 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
9394 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
9395
9396 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
9397
9398 EXIT();
9399
9400 return VOS_STATUS_SUCCESS;
9401}
9402#endif
9403
Jeff Johnson295189b2012-06-20 16:38:30 -07009404/*
9405 * FUNCTION: hdd_cfg80211_scan_done_callback
9406 * scanning callback function, called after finishing scan
9407 *
9408 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309409static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -07009410 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
9411{
9412 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309413 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009414 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009415 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9416 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07009417 struct cfg80211_scan_request *req = NULL;
9418 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05309419 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309420 long waitRet = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009421
9422 ENTER();
9423
9424 hddLog(VOS_TRACE_LEVEL_INFO,
9425 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -08009426 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009427 __func__, halHandle, pContext, (int) scanId, (int) status);
9428
Kiet Lamac06e2c2013-10-23 16:25:07 +05309429 pScanInfo->mScanPendingCounter = 0;
9430
Jeff Johnson295189b2012-06-20 16:38:30 -07009431 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309432 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -07009433 &pScanInfo->scan_req_completion_event,
9434 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309435 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07009436 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309437 hddLog(VOS_TRACE_LEVEL_ERROR,
9438 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -07009439 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07009440 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07009441 }
9442
Yue Maef608272013-04-08 23:09:17 -07009443 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07009444 {
9445 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07009446 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07009447 }
9448
9449 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309450 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -07009451 {
9452 hddLog(VOS_TRACE_LEVEL_INFO,
9453 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -08009454 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -07009455 (int) scanId);
9456 }
9457
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309458 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009459 pAdapter);
9460
9461 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309462 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009463
9464
9465 /* If any client wait scan result through WEXT
9466 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009467 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07009468 {
9469 /* The other scan request waiting for current scan finish
9470 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009471 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07009472 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009473 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07009474 }
9475 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009476 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07009477 {
9478 struct net_device *dev = pAdapter->dev;
9479 union iwreq_data wrqu;
9480 int we_event;
9481 char *msg;
9482
9483 memset(&wrqu, '\0', sizeof(wrqu));
9484 we_event = SIOCGIWSCAN;
9485 msg = NULL;
9486 wireless_send_event(dev, we_event, &wrqu, msg);
9487 }
9488 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009489 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009490
9491 /* Get the Scan Req */
9492 req = pAdapter->request;
9493
9494 if (!req)
9495 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009496 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07009497 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07009498 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07009499 }
9500
Jeff Johnson295189b2012-06-20 16:38:30 -07009501 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07009502 /* Scan is no longer pending */
9503 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009504
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -07009505 /*
9506 * cfg80211_scan_done informing NL80211 about completion
9507 * of scanning
9508 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05309509 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
9510 {
9511 aborted = true;
9512 }
9513 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08009514 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07009515
Siddharth Bhal76972212014-10-15 16:22:51 +05309516 if (pHddCtx->spoofMacAddr.isEnabled || pHddCtx->spoofMacAddr.isReqDeferred) {
9517 /* Generate new random mac addr for next scan */
9518 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
9519 hdd_processSpoofMacAddrRequest(pHddCtx);
9520 }
9521
Jeff Johnsone7245742012-09-05 17:12:55 -07009522allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07009523 /* release the wake lock at the end of the scan*/
9524 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07009525
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07009526 /* Acquire wakelock to handle the case where APP's tries to suspend
9527 * immediatly after the driver gets connect request(i.e after scan)
9528 * from supplicant, this result in app's is suspending and not able
9529 * to process the connect request to AP */
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05309530 hdd_prevent_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07009531
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07009532#ifdef FEATURE_WLAN_TDLS
c_hpothu3c8f8e82014-06-02 18:01:50 +05309533 if (!(eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode))
9534 {
9535 wlan_hdd_tdls_scan_done_callback(pAdapter);
9536 }
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07009537#endif
9538
Jeff Johnson295189b2012-06-20 16:38:30 -07009539 EXIT();
9540 return 0;
9541}
9542
9543/*
Rashmi Ramannab1429032014-04-26 14:59:09 +05309544 * FUNCTION: hdd_isConnectionInProgress
9545 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009546 *
9547 */
Ganesh Kondabattiniaeb7b772014-08-11 20:00:36 +05309548v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx, v_BOOL_t isRoC )
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009549{
9550 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
9551 hdd_station_ctx_t *pHddStaCtx = NULL;
9552 hdd_adapter_t *pAdapter = NULL;
9553 VOS_STATUS status = 0;
9554 v_U8_t staId = 0;
9555 v_U8_t *staMac = NULL;
9556
c_hpothu9b781ba2013-12-30 20:57:45 +05309557 if (TRUE == pHddCtx->btCoexModeSet)
9558 {
9559 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +05309560 FL("BTCoex Mode operation in progress"));
9561 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +05309562 }
9563
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009564 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
9565
9566 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
9567 {
9568 pAdapter = pAdapterNode->pAdapter;
9569
9570 if( pAdapter )
9571 {
9572 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309573 "%s: Adapter with device mode %s (%d) exists",
9574 __func__, hdd_device_modetoString(pAdapter->device_mode),
9575 pAdapter->device_mode);
Ganesh Kondabattiniaeb7b772014-08-11 20:00:36 +05309576 if ((((!isRoC) && (WLAN_HDD_INFRA_STATION == pAdapter->device_mode)) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +05309577 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
9578 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
9579 (eConnectionState_Connecting ==
9580 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
9581 {
9582 hddLog(VOS_TRACE_LEVEL_ERROR,
9583 "%s: %p(%d) Connection is in progress", __func__,
9584 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
9585 return VOS_TRUE;
9586 }
Ganesh Kondabattiniaeb7b772014-08-11 20:00:36 +05309587 if (((!isRoC) && (WLAN_HDD_INFRA_STATION == pAdapter->device_mode)) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309588 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
9589 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009590 {
9591 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9592 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309593 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009594 {
9595 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
9596 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08009597 "%s: client " MAC_ADDRESS_STR
9598 " is in the middle of WPS/EAPOL exchange.", __func__,
9599 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +05309600 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009601 }
9602 }
9603 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
9604 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
9605 {
9606 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
9607 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309608 if ((pAdapter->aStaInfo[staId].isUsed) &&
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009609 (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState))
9610 {
9611 staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
9612
9613 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08009614 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
9615 "middle of WPS/EAPOL exchange.", __func__,
9616 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +05309617 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009618 }
9619 }
9620 }
9621 }
9622 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
9623 pAdapterNode = pNext;
9624 }
Rashmi Ramannab1429032014-04-26 14:59:09 +05309625 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309626}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009627
9628/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05309629 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -07009630 * this scan respond to scan trigger and update cfg80211 scan database
9631 * later, scan dump command can be used to recieve scan results
9632 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05309633int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009634#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
9635 struct net_device *dev,
9636#endif
9637 struct cfg80211_scan_request *request)
9638{
Siddharth Bhal0c162d02014-05-06 19:50:42 +05309639 hdd_adapter_t *pAdapter = NULL;
9640 hdd_context_t *pHddCtx = NULL;
9641 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309642 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009643 tCsrScanRequest scanRequest;
9644 tANI_U8 *channelList = NULL, i;
9645 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309646 int status;
9647 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009648 v_U8_t* pP2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009649
Siddharth Bhal0c162d02014-05-06 19:50:42 +05309650#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
9651 struct net_device *dev = NULL;
9652 if (NULL == request)
9653 {
9654 hddLog(VOS_TRACE_LEVEL_ERROR,
9655 "%s: scan req param null", __func__);
9656 return -EINVAL;
9657 }
9658 dev = request->wdev->netdev;
9659#endif
9660
9661 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
9662 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
9663 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9664
Jeff Johnson295189b2012-06-20 16:38:30 -07009665 ENTER();
9666
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309667
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309668 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9669 __func__, hdd_device_modetoString(pAdapter->device_mode),
9670 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309671
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309672 status = wlan_hdd_validate_context(pHddCtx);
9673
9674 if (0 != status)
9675 {
9676 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9677 "%s: HDD context is not valid", __func__);
9678 return status;
9679 }
9680
Siddharth Bhal0c162d02014-05-06 19:50:42 +05309681 if (NULL == pwextBuf)
9682 {
9683 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
9684 __func__);
9685 return -EIO;
9686 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309687 cfg_param = pHddCtx->cfg_ini;
9688 pScanInfo = &pHddCtx->scan_info;
9689
Jeff Johnson295189b2012-06-20 16:38:30 -07009690#ifdef WLAN_BTAMP_FEATURE
9691 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009692 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -07009693 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08009694 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009695 "%s: No scanning when AMP is on", __func__);
9696 return -EOPNOTSUPP;
9697 }
9698#endif
9699 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009700 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009701 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009702 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309703 "%s: Not scanning on device_mode = %s (%d)",
9704 __func__, hdd_device_modetoString(pAdapter->device_mode),
9705 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009706 return -EOPNOTSUPP;
9707 }
9708
9709 if (TRUE == pScanInfo->mScanPending)
9710 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05309711 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
9712 {
9713 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
9714 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009715 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07009716 }
9717
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309718 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -07009719 //Channel and action frame is pending
9720 //Otherwise Cancel Remain On Channel and allow Scan
9721 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009722 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -07009723 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05309724 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009725 return -EBUSY;
9726 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009727#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07009728 /* if tdls disagree scan right now, return immediately.
9729 tdls will schedule the scan when scan is allowed. (return SUCCESS)
9730 or will reject the scan if any TDLS is in progress. (return -EBUSY)
9731 */
9732 status = wlan_hdd_tdls_scan_callback (pAdapter,
9733 wiphy,
9734#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
9735 dev,
Gopichand Nakkalac3c42b92013-03-20 19:42:34 -07009736#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07009737 request);
9738 if(status <= 0)
9739 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309740 if(!status)
9741 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
9742 "scan rejected %d", __func__, status);
9743 else
9744 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
9745 __func__, status);
9746
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07009747 return status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009748 }
9749#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07009750
Jeff Johnson295189b2012-06-20 16:38:30 -07009751 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
9752 {
9753 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -08009754 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009755 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309756 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009757 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
9758 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309759 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009760 "%s: MAX TM Level Scan not allowed", __func__);
9761 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309762 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07009763 }
9764 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
9765
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009766 /* Check if scan is allowed at this point of time.
9767 */
Ganesh Kondabattiniaeb7b772014-08-11 20:00:36 +05309768 if (hdd_isConnectionInProgress(pHddCtx, VOS_FALSE))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009769 {
9770 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
9771 return -EBUSY;
9772 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309773
Jeff Johnson295189b2012-06-20 16:38:30 -07009774 vos_mem_zero( &scanRequest, sizeof(scanRequest));
9775
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309776 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
9777 (int)request->n_ssids);
9778
9779 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
9780 * Becasue of this, driver is assuming that this is not wildcard scan and so
9781 * is not aging out the scan results.
9782 */
9783 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07009784 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309785 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009786 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309787
9788 if ((request->ssids) && (0 < request->n_ssids))
9789 {
9790 tCsrSSIDInfo *SsidInfo;
9791 int j;
9792 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
9793 /* Allocate num_ssid tCsrSSIDInfo structure */
9794 SsidInfo = scanRequest.SSIDs.SSIDList =
9795 ( tCsrSSIDInfo *)vos_mem_malloc(
9796 request->n_ssids*sizeof(tCsrSSIDInfo));
9797
9798 if(NULL == scanRequest.SSIDs.SSIDList)
9799 {
9800 hddLog(VOS_TRACE_LEVEL_ERROR,
9801 "%s: memory alloc failed SSIDInfo buffer", __func__);
9802 return -ENOMEM;
9803 }
9804
9805 /* copy all the ssid's and their length */
9806 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
9807 {
9808 /* get the ssid length */
9809 SsidInfo->SSID.length = request->ssids[j].ssid_len;
9810 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
9811 SsidInfo->SSID.length);
9812 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
9813 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
9814 j, SsidInfo->SSID.ssId);
9815 }
9816 /* set the scan type to active */
9817 scanRequest.scanType = eSIR_ACTIVE_SCAN;
9818 }
9819 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07009820 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +05309821 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9822 TRACE_CODE_HDD_CFG80211_SCAN,
9823 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07009824 /* set the scan type to active */
9825 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07009826 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309827 else
9828 {
9829 /*Set the scan type to default type, in this case it is ACTIVE*/
9830 scanRequest.scanType = pScanInfo->scan_mode;
9831 }
9832 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
9833 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07009834
9835 /* set BSSType to default type */
9836 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
9837
9838 /*TODO: scan the requested channels only*/
9839
9840 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309841 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -07009842 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309843 hddLog(VOS_TRACE_LEVEL_WARN,
9844 "No of Scan Channels exceeded limit: %d", request->n_channels);
9845 request->n_channels = MAX_CHANNEL;
9846 }
9847
9848 hddLog(VOS_TRACE_LEVEL_INFO,
9849 "No of Scan Channels: %d", request->n_channels);
9850
9851
9852 if( request->n_channels )
9853 {
9854 char chList [(request->n_channels*5)+1];
9855 int len;
9856 channelList = vos_mem_malloc( request->n_channels );
9857 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +05309858 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309859 hddLog(VOS_TRACE_LEVEL_ERROR,
9860 "%s: memory alloc failed channelList", __func__);
9861 status = -ENOMEM;
9862 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +05309863 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309864
9865 for( i = 0, len = 0; i < request->n_channels ; i++ )
9866 {
9867 channelList[i] = request->channels[i]->hw_value;
9868 len += snprintf(chList+len, 5, "%d ", channelList[i]);
9869 }
9870
Nirav Shah20ac06f2013-12-12 18:14:06 +05309871 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309872 "Channel-List: %s ", chList);
9873 }
c_hpothu53512302014-04-15 18:49:53 +05309874
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309875 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
9876 scanRequest.ChannelInfo.ChannelList = channelList;
9877
9878 /* set requestType to full scan */
9879 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
9880
9881 /* Flush the scan results(only p2p beacons) for STA scan and P2P
9882 * search (Flush on both full scan and social scan but not on single
9883 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
9884 */
9885
9886 /* Supplicant does single channel scan after 8-way handshake
9887 * and in that case driver shoudnt flush scan results. If
9888 * driver flushes the scan results here and unfortunately if
9889 * the AP doesnt respond to our probe req then association
9890 * fails which is not desired
9891 */
9892
9893 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
9894 {
9895 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
9896 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
9897 pAdapter->sessionId );
9898 }
9899
9900 if( request->ie_len )
9901 {
9902 /* save this for future association (join requires this) */
9903 /*TODO: Array needs to be converted to dynamic allocation,
9904 * as multiple ie.s can be sent in cfg80211_scan_request structure
9905 * CR 597966
9906 */
9907 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
9908 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
9909 pScanInfo->scanAddIE.length = request->ie_len;
9910
9911 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
9912 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
9913 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07009914 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309915 if ( request->ie_len <= SIR_MAC_MAX_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -07009916 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309917 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
9918 memcpy( pwextBuf->roamProfile.addIEScan,
9919 request->ie, request->ie_len);
9920 }
9921 else
9922 {
9923 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
9924 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07009925 }
9926
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309927 }
9928 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
9929 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
9930
9931 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
9932 request->ie_len);
9933 if (pP2pIe != NULL)
9934 {
9935#ifdef WLAN_FEATURE_P2P_DEBUG
9936 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
9937 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
9938 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +05309939 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309940 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
9941 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
9942 "Go nego completed to Connection is started");
9943 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
9944 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +05309945 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309946 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
9947 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07009948 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309949 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
9950 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
9951 "Disconnected state to Connection is started");
9952 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
9953 "for 4way Handshake");
9954 }
9955#endif
9956
9957 /* no_cck will be set during p2p find to disable 11b rates */
9958 if(TRUE == request->no_cck)
9959 {
9960 hddLog(VOS_TRACE_LEVEL_INFO,
9961 "%s: This is a P2P Search", __func__);
9962 scanRequest.p2pSearch = 1;
9963
9964 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +05309965 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309966 /* set requestType to P2P Discovery */
9967 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
9968 }
9969
9970 /*
9971 Skip Dfs Channel in case of P2P Search
9972 if it is set in ini file
9973 */
9974 if(cfg_param->skipDfsChnlInP2pSearch)
9975 {
9976 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +05309977 }
9978 else
9979 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309980 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05309981 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009982
Agarwal Ashish4f616132013-12-30 23:32:50 +05309983 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009984 }
9985 }
9986
9987 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
9988
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07009989 /* acquire the wakelock to avoid the apps suspend during the scan. To
9990 * address the following issues.
9991 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
9992 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
9993 * for long time, this result in apps running at full power for long time.
9994 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
9995 * be stuck in full power because of resume BMPS
9996 */
9997 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07009998
Nirav Shah20ac06f2013-12-12 18:14:06 +05309999 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
10000 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010001 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
10002 scanRequest.requestType, scanRequest.scanType,
10003 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053010004 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
10005
Siddharth Bhal76972212014-10-15 16:22:51 +053010006 if (pHddCtx->spoofMacAddr.isEnabled)
10007 {
10008 hddLog(VOS_TRACE_LEVEL_INFO,
10009 "%s: MAC Spoofing enabled for current scan", __func__);
10010 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
10011 * to fill TxBds for probe request during current scan
10012 */
10013 WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
10014 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
10015 }
10016
Jeff Johnsone7245742012-09-05 17:12:55 -070010017 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070010018 pAdapter->sessionId, &scanRequest, &scanId,
10019 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070010020
Jeff Johnson295189b2012-06-20 16:38:30 -070010021 if (eHAL_STATUS_SUCCESS != status)
10022 {
10023 hddLog(VOS_TRACE_LEVEL_ERROR,
10024 "%s: sme_ScanRequest returned error %d", __func__, status);
10025 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070010026 if(eHAL_STATUS_RESOURCES == status)
10027 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010028 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
10029 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070010030 status = -EBUSY;
10031 } else {
10032 status = -EIO;
10033 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010034 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -070010035 goto free_mem;
10036 }
10037
10038 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010039 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010040 pAdapter->request = request;
10041 pScanInfo->scanId = scanId;
10042
10043 complete(&pScanInfo->scan_req_completion_event);
10044
10045free_mem:
10046 if( scanRequest.SSIDs.SSIDList )
10047 {
10048 vos_mem_free(scanRequest.SSIDs.SSIDList);
10049 }
10050
10051 if( channelList )
10052 vos_mem_free( channelList );
10053
10054 EXIT();
10055
10056 return status;
10057}
10058
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010059int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
10060#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10061 struct net_device *dev,
10062#endif
10063 struct cfg80211_scan_request *request)
10064{
10065 int ret;
10066
10067 vos_ssr_protect(__func__);
10068 ret = __wlan_hdd_cfg80211_scan(wiphy,
10069#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10070 dev,
10071#endif
10072 request);
10073 vos_ssr_unprotect(__func__);
10074
10075 return ret;
10076}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010077
10078void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
10079{
10080 v_U8_t iniDot11Mode =
10081 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
10082 eHddDot11Mode hddDot11Mode = iniDot11Mode;
10083
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053010084 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
10085 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010086 switch ( iniDot11Mode )
10087 {
10088 case eHDD_DOT11_MODE_AUTO:
10089 case eHDD_DOT11_MODE_11ac:
10090 case eHDD_DOT11_MODE_11ac_ONLY:
10091#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053010092 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
10093 sme_IsFeatureSupportedByFW(DOT11AC) )
10094 hddDot11Mode = eHDD_DOT11_MODE_11ac;
10095 else
10096 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010097#else
10098 hddDot11Mode = eHDD_DOT11_MODE_11n;
10099#endif
10100 break;
10101 case eHDD_DOT11_MODE_11n:
10102 case eHDD_DOT11_MODE_11n_ONLY:
10103 hddDot11Mode = eHDD_DOT11_MODE_11n;
10104 break;
10105 default:
10106 hddDot11Mode = iniDot11Mode;
10107 break;
10108 }
10109 /* This call decides required channel bonding mode */
10110 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
10111 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
10112 operationChannel);
10113}
10114
Jeff Johnson295189b2012-06-20 16:38:30 -070010115/*
10116 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010117 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070010118 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010119int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -070010120 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070010121{
10122 int status = 0;
10123 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080010124 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010125 v_U32_t roamId;
10126 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070010127 eCsrAuthType RSNAuthType;
10128
10129 ENTER();
10130
10131 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080010132 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10133
10134 status = wlan_hdd_validate_context(pHddCtx);
10135 if (status)
10136 {
10137 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10138 "%s: HDD context is not valid!", __func__);
10139 return status;
10140 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010141
Jeff Johnson295189b2012-06-20 16:38:30 -070010142 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
10143 {
10144 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
10145 return -EINVAL;
10146 }
10147
10148 pRoamProfile = &pWextState->roamProfile;
10149
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010150 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070010151 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010152 hdd_station_ctx_t *pHddStaCtx;
10153 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010154
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010155 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070010156 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
10157 {
10158 /*QoS not enabled in cfg file*/
10159 pRoamProfile->uapsd_mask = 0;
10160 }
10161 else
10162 {
10163 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010164 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070010165 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
10166 }
10167
10168 pRoamProfile->SSIDs.numOfSSIDs = 1;
10169 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
10170 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010171 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070010172 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
10173 ssid, ssid_len);
10174
10175 if (bssid)
10176 {
10177 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
10178 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
10179 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010180 /* Save BSSID in seperate variable as well, as RoamProfile
10181 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070010182 case of join failure we should send valid BSSID to supplicant
10183 */
10184 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
10185 WNI_CFG_BSSID_LEN);
10186 }
Dhanashri Atre51981c62013-06-13 11:47:57 -070010187 else
10188 {
10189 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
10190 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010191
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053010192 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
10193 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070010194 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
10195 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010196 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010197 /*set gen ie*/
10198 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
10199 /*set auth*/
10200 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
10201 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010202#ifdef FEATURE_WLAN_WAPI
10203 if (pAdapter->wapi_info.nWapiMode)
10204 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010205 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010206 switch (pAdapter->wapi_info.wapiAuthMode)
10207 {
10208 case WAPI_AUTH_MODE_PSK:
10209 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010210 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070010211 pAdapter->wapi_info.wapiAuthMode);
10212 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
10213 break;
10214 }
10215 case WAPI_AUTH_MODE_CERT:
10216 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010217 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070010218 pAdapter->wapi_info.wapiAuthMode);
10219 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
10220 break;
10221 }
10222 } // End of switch
10223 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
10224 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
10225 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010226 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010227 pRoamProfile->AuthType.numEntries = 1;
10228 pRoamProfile->EncryptionType.numEntries = 1;
10229 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
10230 pRoamProfile->mcEncryptionType.numEntries = 1;
10231 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
10232 }
10233 }
10234#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010235#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053010236 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010237 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
10238 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
10239 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053010240 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
10241 sizeof (tSirGtkOffloadParams));
10242 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010243 }
10244#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010245 pRoamProfile->csrPersona = pAdapter->device_mode;
10246
Jeff Johnson32d95a32012-09-10 13:15:23 -070010247 if( operatingChannel )
10248 {
10249 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
10250 pRoamProfile->ChannelInfo.numOfChannels = 1;
10251 }
Chet Lanctot186b5732013-03-18 10:26:30 -070010252 else
10253 {
10254 pRoamProfile->ChannelInfo.ChannelList = NULL;
10255 pRoamProfile->ChannelInfo.numOfChannels = 0;
10256 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010257 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
10258 {
10259 hdd_select_cbmode(pAdapter,operatingChannel);
10260 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053010261
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080010262 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
10263 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010264 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080010265 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080010266 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
10267 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053010268 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
10269 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053010270 {
10271 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10272 "%s: Set HDD connState to eConnectionState_Connecting",
10273 __func__);
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080010274 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
10275 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053010276 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010277 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070010278 pAdapter->sessionId, pRoamProfile, &roamId);
10279
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053010280 if ((eHAL_STATUS_SUCCESS != status) &&
10281 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
10282 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053010283
10284 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080010285 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
10286 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
10287 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053010288 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080010289 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053010290 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080010291
10292 pRoamProfile->ChannelInfo.ChannelList = NULL;
10293 pRoamProfile->ChannelInfo.numOfChannels = 0;
10294
Jeff Johnson295189b2012-06-20 16:38:30 -070010295 }
10296 else
10297 {
10298 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
10299 return -EINVAL;
10300 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080010301 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010302 return status;
10303}
10304
10305/*
10306 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
10307 * This function is used to set the authentication type (OPEN/SHARED).
10308 *
10309 */
10310static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
10311 enum nl80211_auth_type auth_type)
10312{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010313 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010314 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10315
10316 ENTER();
10317
10318 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010319 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070010320 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010321 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053010322 hddLog(VOS_TRACE_LEVEL_INFO,
10323 "%s: set authentication type to AUTOSWITCH", __func__);
10324 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
10325 break;
10326
10327 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070010328#ifdef WLAN_FEATURE_VOWIFI_11R
10329 case NL80211_AUTHTYPE_FT:
10330#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010331 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070010332 "%s: set authentication type to OPEN", __func__);
10333 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
10334 break;
10335
10336 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010337 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070010338 "%s: set authentication type to SHARED", __func__);
10339 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
10340 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010341#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010342 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010343 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070010344 "%s: set authentication type to CCKM WPA", __func__);
10345 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
10346 break;
10347#endif
10348
10349
10350 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010351 hddLog(VOS_TRACE_LEVEL_ERROR,
10352 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070010353 auth_type);
10354 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
10355 return -EINVAL;
10356 }
10357
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010358 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070010359 pHddStaCtx->conn_info.authType;
10360 return 0;
10361}
10362
10363/*
10364 * FUNCTION: wlan_hdd_set_akm_suite
10365 * This function is used to set the key mgmt type(PSK/8021x).
10366 *
10367 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010368static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070010369 u32 key_mgmt
10370 )
10371{
10372 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10373 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053010374 /* Should be in ieee802_11_defs.h */
10375#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
10376#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070010377 /*set key mgmt type*/
10378 switch(key_mgmt)
10379 {
10380 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053010381 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053010382#ifdef WLAN_FEATURE_VOWIFI_11R
10383 case WLAN_AKM_SUITE_FT_PSK:
10384#endif
10385 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070010386 __func__);
10387 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
10388 break;
10389
10390 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053010391 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053010392#ifdef WLAN_FEATURE_VOWIFI_11R
10393 case WLAN_AKM_SUITE_FT_8021X:
10394#endif
10395 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070010396 __func__);
10397 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
10398 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010399#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010400#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
10401#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
10402 case WLAN_AKM_SUITE_CCKM:
10403 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
10404 __func__);
10405 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
10406 break;
10407#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070010408#ifndef WLAN_AKM_SUITE_OSEN
10409#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
10410 case WLAN_AKM_SUITE_OSEN:
10411 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
10412 __func__);
10413 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
10414 break;
10415#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010416
10417 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010418 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010419 __func__, key_mgmt);
10420 return -EINVAL;
10421
10422 }
10423 return 0;
10424}
10425
10426/*
10427 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010428 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070010429 * (NONE/WEP40/WEP104/TKIP/CCMP).
10430 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010431static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
10432 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070010433 bool ucast
10434 )
10435{
10436 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010437 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010438 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10439
10440 ENTER();
10441
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010442 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070010443 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010444 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070010445 __func__, cipher);
10446 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
10447 }
10448 else
10449 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010450
Jeff Johnson295189b2012-06-20 16:38:30 -070010451 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010452 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070010453 {
10454 case IW_AUTH_CIPHER_NONE:
10455 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
10456 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010457
Jeff Johnson295189b2012-06-20 16:38:30 -070010458 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053010459 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070010460 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010461
Jeff Johnson295189b2012-06-20 16:38:30 -070010462 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053010463 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070010464 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010465
Jeff Johnson295189b2012-06-20 16:38:30 -070010466 case WLAN_CIPHER_SUITE_TKIP:
10467 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
10468 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010469
Jeff Johnson295189b2012-06-20 16:38:30 -070010470 case WLAN_CIPHER_SUITE_CCMP:
10471 encryptionType = eCSR_ENCRYPT_TYPE_AES;
10472 break;
10473#ifdef FEATURE_WLAN_WAPI
10474 case WLAN_CIPHER_SUITE_SMS4:
10475 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
10476 break;
10477#endif
10478
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010479#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010480 case WLAN_CIPHER_SUITE_KRK:
10481 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
10482 break;
10483#endif
10484 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010485 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010486 __func__, cipher);
10487 return -EOPNOTSUPP;
10488 }
10489 }
10490
10491 if (ucast)
10492 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010493 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010494 __func__, encryptionType);
10495 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
10496 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010497 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070010498 encryptionType;
10499 }
10500 else
10501 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010502 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010503 __func__, encryptionType);
10504 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
10505 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
10506 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
10507 }
10508
10509 return 0;
10510}
10511
10512
10513/*
10514 * FUNCTION: wlan_hdd_cfg80211_set_ie
10515 * This function is used to parse WPA/RSN IE's.
10516 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010517int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
10518 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -070010519 size_t ie_len
10520 )
10521{
10522 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10523 u8 *genie = ie;
10524 v_U16_t remLen = ie_len;
10525#ifdef FEATURE_WLAN_WAPI
10526 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
10527 u16 *tmp;
10528 v_U16_t akmsuiteCount;
10529 int *akmlist;
10530#endif
10531 ENTER();
10532
10533 /* clear previous assocAddIE */
10534 pWextState->assocAddIE.length = 0;
10535 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070010536 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010537
10538 while (remLen >= 2)
10539 {
10540 v_U16_t eLen = 0;
10541 v_U8_t elementId;
10542 elementId = *genie++;
10543 eLen = *genie++;
10544 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010545
Arif Hussain6d2a3322013-11-17 19:50:10 -080010546 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070010547 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010548
10549 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070010550 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010551 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010552 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 -070010553 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010554 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010555 "%s: Invalid WPA IE", __func__);
10556 return -EINVAL;
10557 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010558 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070010559 {
10560 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010561 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070010562 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010563
Jeff Johnson295189b2012-06-20 16:38:30 -070010564 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
10565 {
Jeff Johnson902c9832012-12-10 14:28:09 -080010566 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
10567 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070010568 VOS_ASSERT(0);
10569 return -ENOMEM;
10570 }
10571 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
10572 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
10573 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010574
Jeff Johnson295189b2012-06-20 16:38:30 -070010575 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
10576 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
10577 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
10578 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010579 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
10580 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010581 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
10582 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
10583 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
10584 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
10585 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
10586 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010587 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053010588 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070010589 {
10590 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010591 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070010592 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010593
Jeff Johnson295189b2012-06-20 16:38:30 -070010594 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
10595 {
Jeff Johnson902c9832012-12-10 14:28:09 -080010596 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
10597 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070010598 VOS_ASSERT(0);
10599 return -ENOMEM;
10600 }
10601 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
10602 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
10603 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010604
Jeff Johnson295189b2012-06-20 16:38:30 -070010605 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
10606 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
10607 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010608#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010609 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
10610 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070010611 /*Consider WFD IE, only for P2P Client */
10612 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
10613 {
10614 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010615 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070010616 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010617
Jeff Johnson295189b2012-06-20 16:38:30 -070010618 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
10619 {
Jeff Johnson902c9832012-12-10 14:28:09 -080010620 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
10621 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070010622 VOS_ASSERT(0);
10623 return -ENOMEM;
10624 }
10625 // WFD IE is saved to Additional IE ; it should be accumulated to handle
10626 // WPS IE + P2P IE + WFD IE
10627 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
10628 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010629
Jeff Johnson295189b2012-06-20 16:38:30 -070010630 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
10631 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
10632 }
10633#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010634 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010635 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070010636 HS20_OUI_TYPE_SIZE)) )
10637 {
10638 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010639 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070010640 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010641
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070010642 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
10643 {
Jeff Johnson902c9832012-12-10 14:28:09 -080010644 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
10645 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070010646 VOS_ASSERT(0);
10647 return -ENOMEM;
10648 }
10649 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
10650 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010651
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070010652 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
10653 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
10654 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070010655 /* Appending OSEN Information Element in Assiciation Request */
10656 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
10657 OSEN_OUI_TYPE_SIZE)) )
10658 {
10659 v_U16_t curAddIELen = pWextState->assocAddIE.length;
10660 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
10661 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010662
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070010663 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
10664 {
10665 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
10666 "Need bigger buffer space");
10667 VOS_ASSERT(0);
10668 return -ENOMEM;
10669 }
10670 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
10671 pWextState->assocAddIE.length += eLen + 2;
10672
10673 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
10674 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
10675 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
10676 }
10677
10678 break;
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070010679 if (WLAN_HDD_IBSS == pAdapter->device_mode) {
10680
10681 /* populating as ADDIE in beacon frames */
10682 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
10683 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
10684 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
10685 {
10686 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
10687 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
10688 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
10689 {
10690 hddLog(LOGE,
10691 "Coldn't pass "
10692 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
10693 }
10694 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
10695 else
10696 hddLog(LOGE,
10697 "Could not pass on "
10698 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
10699
10700 /* IBSS mode doesn't contain params->proberesp_ies still
10701 beaconIE's need to be populated in probe response frames */
10702 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
10703 {
10704 u16 rem_probe_resp_ie_len = eLen + 2;
10705 u8 probe_rsp_ie_len[3] = {0};
10706 u8 counter = 0;
10707
10708 /* Check Probe Resp Length if it is greater then 255 then
10709 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
10710 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
10711 not able Store More then 255 bytes into One Variable */
10712
10713 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
10714 {
10715 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
10716 {
10717 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
10718 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
10719 }
10720 else
10721 {
10722 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
10723 rem_probe_resp_ie_len = 0;
10724 }
10725 }
10726
10727 rem_probe_resp_ie_len = 0;
10728
10729 if (probe_rsp_ie_len[0] > 0)
10730 {
10731 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
10732 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
10733 (tANI_U8*)(genie - 2),
10734 probe_rsp_ie_len[0], NULL,
10735 eANI_BOOLEAN_FALSE)
10736 == eHAL_STATUS_FAILURE)
10737 {
10738 hddLog(LOGE,
10739 "Could not pass"
10740 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
10741 }
10742 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
10743 }
10744
10745 if (probe_rsp_ie_len[1] > 0)
10746 {
10747 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
10748 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
10749 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
10750 probe_rsp_ie_len[1], NULL,
10751 eANI_BOOLEAN_FALSE)
10752 == eHAL_STATUS_FAILURE)
10753 {
10754 hddLog(LOGE,
10755 "Could not pass"
10756 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
10757 }
10758 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
10759 }
10760
10761 if (probe_rsp_ie_len[2] > 0)
10762 {
10763 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
10764 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
10765 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
10766 probe_rsp_ie_len[2], NULL,
10767 eANI_BOOLEAN_FALSE)
10768 == eHAL_STATUS_FAILURE)
10769 {
10770 hddLog(LOGE,
10771 "Could not pass"
10772 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
10773 }
10774 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
10775 }
10776
10777 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
10778 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
10779 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
10780 {
10781 hddLog(LOGE,
10782 "Could not pass"
10783 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
10784 }
10785 }
10786 else
10787 {
10788 // Reset WNI_CFG_PROBE_RSP Flags
10789 wlan_hdd_reset_prob_rspies(pAdapter);
10790
10791 hddLog(VOS_TRACE_LEVEL_INFO,
10792 "%s: No Probe Response IE received in set beacon",
10793 __func__);
10794 }
10795 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070010796 break;
10797 case DOT11F_EID_RSN:
10798 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
10799 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
10800 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
10801 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
10802 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
10803 break;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010804 /* Appending Extended Capabilities with Interworking bit set in Assoc Req */
10805 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010806 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010807 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010808 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010809 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010810
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010811 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
10812 {
Jeff Johnson902c9832012-12-10 14:28:09 -080010813 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
10814 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010815 VOS_ASSERT(0);
10816 return -ENOMEM;
10817 }
10818 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
10819 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010820
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010821 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
10822 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
10823 break;
10824 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010825#ifdef FEATURE_WLAN_WAPI
10826 case WLAN_EID_WAPI:
10827 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070010828 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070010829 pAdapter->wapi_info.nWapiMode);
10830 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010831 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070010832 akmsuiteCount = WPA_GET_LE16(tmp);
10833 tmp = tmp + 1;
10834 akmlist = (int *)(tmp);
10835 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
10836 {
10837 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
10838 }
10839 else
10840 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010841 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070010842 VOS_ASSERT(0);
10843 return -EINVAL;
10844 }
10845
10846 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
10847 {
10848 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010849 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010850 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010851 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010852 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010853 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010854 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010855 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010856 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
10857 }
10858 break;
10859#endif
10860 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010861 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010862 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010863 /* when Unknown IE is received we should break and continue
10864 * to the next IE in the buffer instead we were returning
10865 * so changing this to break */
10866 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010867 }
10868 genie += eLen;
10869 remLen -= eLen;
10870 }
10871 EXIT();
10872 return 0;
10873}
10874
10875/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053010876 * FUNCTION: hdd_isWPAIEPresent
10877 * Parse the received IE to find the WPA IE
10878 *
10879 */
10880static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
10881{
10882 v_U8_t eLen = 0;
10883 v_U16_t remLen = ie_len;
10884 v_U8_t elementId = 0;
10885
10886 while (remLen >= 2)
10887 {
10888 elementId = *ie++;
10889 eLen = *ie++;
10890 remLen -= 2;
10891 if (eLen > remLen)
10892 {
10893 hddLog(VOS_TRACE_LEVEL_ERROR,
10894 "%s: IE length is wrong %d", __func__, eLen);
10895 return FALSE;
10896 }
10897 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
10898 {
10899 /* OUI - 0x00 0X50 0XF2
10900 WPA Information Element - 0x01
10901 WPA version - 0x01*/
10902 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
10903 return TRUE;
10904 }
10905 ie += eLen;
10906 remLen -= eLen;
10907 }
10908 return FALSE;
10909}
10910
10911/*
Jeff Johnson295189b2012-06-20 16:38:30 -070010912 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010913 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070010914 * parameters during connect operation.
10915 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010916int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070010917 struct cfg80211_connect_params *req
10918 )
10919{
10920 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010921 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010922 ENTER();
10923
10924 /*set wpa version*/
10925 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
10926
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010927 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070010928 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053010929 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070010930 {
10931 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
10932 }
10933 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
10934 {
10935 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
10936 }
10937 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010938
10939 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070010940 pWextState->wpaVersion);
10941
10942 /*set authentication type*/
10943 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
10944
10945 if (0 > status)
10946 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010947 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010948 "%s: failed to set authentication type ", __func__);
10949 return status;
10950 }
10951
10952 /*set key mgmt type*/
10953 if (req->crypto.n_akm_suites)
10954 {
10955 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
10956 if (0 > status)
10957 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010958 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070010959 __func__);
10960 return status;
10961 }
10962 }
10963
10964 /*set pairwise cipher type*/
10965 if (req->crypto.n_ciphers_pairwise)
10966 {
10967 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
10968 req->crypto.ciphers_pairwise[0], true);
10969 if (0 > status)
10970 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010971 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010972 "%s: failed to set unicast cipher type", __func__);
10973 return status;
10974 }
10975 }
10976 else
10977 {
10978 /*Reset previous cipher suite to none*/
10979 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
10980 if (0 > status)
10981 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010982 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010983 "%s: failed to set unicast cipher type", __func__);
10984 return status;
10985 }
10986 }
10987
10988 /*set group cipher type*/
10989 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
10990 false);
10991
10992 if (0 > status)
10993 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010994 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070010995 __func__);
10996 return status;
10997 }
10998
Chet Lanctot186b5732013-03-18 10:26:30 -070010999#ifdef WLAN_FEATURE_11W
11000 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
11001#endif
11002
Jeff Johnson295189b2012-06-20 16:38:30 -070011003 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
11004 if (req->ie_len)
11005 {
11006 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
11007 if ( 0 > status)
11008 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011009 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070011010 __func__);
11011 return status;
11012 }
11013 }
11014
11015 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011016 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070011017 {
11018 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
11019 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
11020 )
11021 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011022 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070011023 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
11024 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011025 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070011026 __func__);
11027 return -EOPNOTSUPP;
11028 }
11029 else
11030 {
11031 u8 key_len = req->key_len;
11032 u8 key_idx = req->key_idx;
11033
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011034 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070011035 && (CSR_MAX_NUM_KEY > key_idx)
11036 )
11037 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011038 hddLog(VOS_TRACE_LEVEL_INFO,
11039 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011040 __func__, key_idx, key_len);
11041 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011042 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070011043 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011044 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011045 (u8)key_len;
11046 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
11047 }
11048 }
11049 }
11050 }
11051
11052 return status;
11053}
11054
11055/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053011056 * FUNCTION: wlan_hdd_try_disconnect
11057 * This function is used to disconnect from previous
11058 * connection
11059 */
11060static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
11061{
11062 long ret = 0;
11063 hdd_station_ctx_t *pHddStaCtx;
11064 eMib_dot11DesiredBssType connectedBssType;
11065
11066 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11067
11068 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
11069
11070 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
11071 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
11072 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
11073 {
11074 /* Issue disconnect to CSR */
11075 INIT_COMPLETION(pAdapter->disconnect_comp_var);
11076 if( eHAL_STATUS_SUCCESS ==
11077 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
11078 pAdapter->sessionId,
11079 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
11080 {
11081 ret = wait_for_completion_interruptible_timeout(
11082 &pAdapter->disconnect_comp_var,
11083 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
11084 if (0 >= ret)
11085 {
11086 hddLog(LOGE, FL("Failed to receive disconnect event"));
11087 return -EALREADY;
11088 }
11089 }
11090 }
11091 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
11092 {
11093 ret = wait_for_completion_interruptible_timeout(
11094 &pAdapter->disconnect_comp_var,
11095 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
11096 if (0 >= ret)
11097 {
11098 hddLog(LOGE, FL("Failed to receive disconnect event"));
11099 return -EALREADY;
11100 }
11101 }
11102
11103 return 0;
11104}
11105
11106/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053011107 * FUNCTION: __wlan_hdd_cfg80211_connect
11108 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070011109 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011110static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011111 struct net_device *ndev,
11112 struct cfg80211_connect_params *req
11113 )
11114{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011115 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011116 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070011117 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053011118 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011119
11120 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011121
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011122 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11123 TRACE_CODE_HDD_CFG80211_CONNECT,
11124 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011125 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011126 "%s: device_mode = %s (%d)", __func__,
11127 hdd_device_modetoString(pAdapter->device_mode),
11128 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011129
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011130 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080011131 if (!pHddCtx)
11132 {
11133 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11134 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053011135 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080011136 }
11137
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011138 status = wlan_hdd_validate_context(pHddCtx);
11139
11140 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070011141 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011142 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11143 "%s: HDD context is not valid", __func__);
11144 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011145 }
11146
Agarwal Ashish51325b52014-06-16 16:50:49 +053011147 if (vos_max_concurrent_connections_reached()) {
11148 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
11149 return -ECONNREFUSED;
11150 }
11151
Jeff Johnson295189b2012-06-20 16:38:30 -070011152#ifdef WLAN_BTAMP_FEATURE
11153 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011154 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070011155 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011156 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011157 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080011158 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011159 }
11160#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053011161
11162 //If Device Mode is Station Concurrent Sessions Exit BMps
11163 //P2P Mode will be taken care in Open/close adapter
11164 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053011165 (vos_concurrent_open_sessions_running())) {
11166 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
11167 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053011168 }
11169
11170 /*Try disconnecting if already in connected state*/
11171 status = wlan_hdd_try_disconnect(pAdapter);
11172 if ( 0 > status)
11173 {
11174 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
11175 " connection"));
11176 return -EALREADY;
11177 }
11178
Jeff Johnson295189b2012-06-20 16:38:30 -070011179 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011180 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070011181
11182 if ( 0 > status)
11183 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011184 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070011185 __func__);
11186 return status;
11187 }
Mohit Khanna765234a2012-09-11 15:08:35 -070011188 if ( req->channel )
11189 {
11190 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
11191 req->ssid_len, req->bssid,
11192 req->channel->hw_value);
11193 }
11194 else
11195 {
11196 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011197 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -070011198 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011199
11200 if (0 > status)
11201 {
11202 //ReEnable BMPS if disabled
11203 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
11204 (NULL != pHddCtx))
11205 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053011206 if (pHddCtx->hdd_wlan_suspended)
11207 {
11208 hdd_set_pwrparams(pHddCtx);
11209 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011210 //ReEnable Bmps and Imps back
11211 hdd_enable_bmps_imps(pHddCtx);
11212 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053011213 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011214 return status;
11215 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011216 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011217 EXIT();
11218 return status;
11219}
11220
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011221static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
11222 struct net_device *ndev,
11223 struct cfg80211_connect_params *req)
11224{
11225 int ret;
11226 vos_ssr_protect(__func__);
11227 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
11228 vos_ssr_unprotect(__func__);
11229
11230 return ret;
11231}
Jeff Johnson295189b2012-06-20 16:38:30 -070011232
11233/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011234 * FUNCTION: wlan_hdd_disconnect
11235 * This function is used to issue a disconnect request to SME
11236 */
11237int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
11238{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011239 int status;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011240 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011241 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011242 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011243
11244 status = wlan_hdd_validate_context(pHddCtx);
11245
11246 if (0 != status)
11247 {
11248 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11249 "%s: HDD context is not valid", __func__);
11250 return status;
11251 }
11252
11253 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053011254
Agarwal Ashish47d18112014-08-04 19:55:07 +053011255 /* Need to apply spin lock before decreasing active sessions
11256 * as there can be chance for double decrement if context switch
11257 * Calls hdd_DisConnectHandler.
11258 */
11259
11260 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053011261 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
11262 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053011263 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
11264 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053011265 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
11266 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053011267
Abhishek Singhf4669da2014-05-26 15:07:49 +053011268 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053011269 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
11270
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011271 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011272
Mihir Shete182a0b22014-08-18 16:08:48 +053011273 /*
11274 * stop tx queues before deleting STA/BSS context from the firmware.
11275 * tx has to be disabled because the firmware can get busy dropping
11276 * the tx frames after BSS/STA has been deleted and will not send
11277 * back a response resulting in WDI timeout
11278 */
11279 netif_tx_disable(pAdapter->dev);
11280 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011281
Mihir Shete182a0b22014-08-18 16:08:48 +053011282 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011283 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
11284 pAdapter->sessionId, reason);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011285 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
11286 {
11287 hddLog(VOS_TRACE_LEVEL_INFO,
11288 FL("status = %d, already disconnected"),
11289 (int)status );
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011290
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011291 }
11292 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011293 {
11294 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011295 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011296 __func__, (int)status );
11297 return -EINVAL;
11298 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011299 ret = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011300 &pAdapter->disconnect_comp_var,
11301 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011302 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status ))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011303 {
11304 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053011305 "%s: Failed to disconnect, timed out", __func__);
11306 return -ETIMEDOUT;
11307 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011308 else if (ret == -ERESTARTSYS)
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053011309 {
11310 hddLog(VOS_TRACE_LEVEL_ERROR,
11311 "%s: Failed to disconnect, wait interrupted", __func__);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011312 return ret;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011313 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011314 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11315 FL("Set HDD connState to eConnectionState_NotConnected"));
11316 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
11317
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053011318 return 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011319}
11320
11321
11322/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011323 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070011324 * This function is used to issue a disconnect request to SME
11325 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011326static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011327 struct net_device *dev,
11328 u16 reason
11329 )
11330{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011331 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011332 tCsrRoamProfile *pRoamProfile =
11333 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011334 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011335 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11336 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053011337#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080011338 tANI_U8 staIdx;
11339#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011340
Jeff Johnson295189b2012-06-20 16:38:30 -070011341 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011342
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011343 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11344 TRACE_CODE_HDD_CFG80211_DISCONNECT,
11345 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011346 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
11347 __func__, hdd_device_modetoString(pAdapter->device_mode),
11348 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011349
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011350 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
11351 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070011352
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011353 status = wlan_hdd_validate_context(pHddCtx);
11354
11355 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070011356 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011357 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11358 "%s: HDD context is not valid", __func__);
11359 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011360 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011361
Jeff Johnson295189b2012-06-20 16:38:30 -070011362 if (NULL != pRoamProfile)
11363 {
11364 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053011365 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
11366 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070011367 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011368 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070011369 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053011370 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070011371 switch(reason)
11372 {
11373 case WLAN_REASON_MIC_FAILURE:
11374 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
11375 break;
11376
11377 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
11378 case WLAN_REASON_DISASSOC_AP_BUSY:
11379 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
11380 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
11381 break;
11382
11383 case WLAN_REASON_PREV_AUTH_NOT_VALID:
11384 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053011385 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070011386 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
11387 break;
11388
Jeff Johnson295189b2012-06-20 16:38:30 -070011389 default:
11390 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
11391 break;
11392 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053011393 pScanInfo = &pHddCtx->scan_info;
11394 if (pScanInfo->mScanPending)
11395 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053011396 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053011397 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053011398 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053011399 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053011400 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011401
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080011402#ifdef FEATURE_WLAN_TDLS
11403 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080011404 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080011405 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080011406 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
11407 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080011408 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080011409 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080011410 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080011411 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011412 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080011413 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011414 MAC_ADDR_ARRAY(mac));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080011415 sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala4327a152013-03-04 23:22:42 -080011416 pAdapter->sessionId,
11417 mac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080011418 }
11419 }
11420#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011421 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011422 status = wlan_hdd_disconnect(pAdapter, reasonCode);
11423 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070011424 {
11425 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011426 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011427 __func__, (int)status );
11428 return -EINVAL;
11429 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011430 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053011431 else
11432 {
11433 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
11434 "called while in %d state", __func__,
11435 pHddStaCtx->conn_info.connState);
11436 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011437 }
11438 else
11439 {
11440 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
11441 }
11442
11443 return status;
11444}
11445
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011446static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
11447 struct net_device *dev,
11448 u16 reason
11449 )
11450{
11451 int ret;
11452 vos_ssr_protect(__func__);
11453 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
11454 vos_ssr_unprotect(__func__);
11455
11456 return ret;
11457}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011458
Jeff Johnson295189b2012-06-20 16:38:30 -070011459/*
11460 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011461 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070011462 * settings in IBSS mode.
11463 */
11464static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011465 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011466 struct cfg80211_ibss_params *params
11467 )
11468{
11469 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011470 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011471 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11472 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011473
Jeff Johnson295189b2012-06-20 16:38:30 -070011474 ENTER();
11475
11476 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070011477 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070011478
11479 if (params->ie_len && ( NULL != params->ie) )
11480 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070011481 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
11482 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070011483 {
11484 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
11485 encryptionType = eCSR_ENCRYPT_TYPE_AES;
11486 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070011487 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070011488 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011489 tDot11fIEWPA dot11WPAIE;
11490 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070011491 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011492
Wilson Yang00256342013-10-10 23:13:38 -070011493 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070011494 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
11495 params->ie_len, DOT11F_EID_WPA);
11496 if ( NULL != ie )
11497 {
11498 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
11499 // Unpack the WPA IE
11500 //Skip past the EID byte and length byte - and four byte WiFi OUI
11501 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
11502 &ie[2+4],
11503 ie[1] - 4,
11504 &dot11WPAIE);
11505 /*Extract the multicast cipher, the encType for unicast
11506 cipher for wpa-none is none*/
11507 encryptionType =
11508 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
11509 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011510 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070011511
Jeff Johnson295189b2012-06-20 16:38:30 -070011512 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
11513
11514 if (0 > status)
11515 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011516 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070011517 __func__);
11518 return status;
11519 }
11520 }
11521
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011522 pWextState->roamProfile.AuthType.authType[0] =
11523 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070011524 eCSR_AUTH_TYPE_OPEN_SYSTEM;
11525
11526 if (params->privacy)
11527 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011528 /* Security enabled IBSS, At this time there is no information available
11529 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070011530 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011531 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070011532 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011533 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070011534 *enable privacy bit in beacons */
11535
11536 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
11537 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011538 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
11539 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011540 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
11541 pWextState->roamProfile.EncryptionType.numEntries = 1;
11542 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070011543 return status;
11544}
11545
11546/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011547 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011548 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070011549 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011550static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011551 struct net_device *dev,
11552 struct cfg80211_ibss_params *params
11553 )
11554{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011555 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070011556 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11557 tCsrRoamProfile *pRoamProfile;
11558 int status;
krunal sonie9002db2013-11-25 14:24:17 -080011559 bool alloc_bssid = VOS_FALSE;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011560 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11561 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011562
11563 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011564
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011565 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11566 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
11567 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011568 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011569 "%s: device_mode = %s (%d)", __func__,
11570 hdd_device_modetoString(pAdapter->device_mode),
11571 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011572
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011573 status = wlan_hdd_validate_context(pHddCtx);
11574
11575 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070011576 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011577 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11578 "%s: HDD context is not valid", __func__);
11579 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011580 }
11581
11582 if (NULL == pWextState)
11583 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011584 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070011585 __func__);
11586 return -EIO;
11587 }
11588
Agarwal Ashish51325b52014-06-16 16:50:49 +053011589 if (vos_max_concurrent_connections_reached()) {
11590 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
11591 return -ECONNREFUSED;
11592 }
11593
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053011594 /*Try disconnecting if already in connected state*/
11595 status = wlan_hdd_try_disconnect(pAdapter);
11596 if ( 0 > status)
11597 {
11598 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
11599 " IBSS connection"));
11600 return -EALREADY;
11601 }
11602
Jeff Johnson295189b2012-06-20 16:38:30 -070011603 pRoamProfile = &pWextState->roamProfile;
11604
11605 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
11606 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011607 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011608 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011609 return -EINVAL;
11610 }
11611
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070011612 /* BSSID is provided by upper layers hence no need to AUTO generate */
11613 if (NULL != params->bssid) {
11614 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
11615 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
11616 hddLog (VOS_TRACE_LEVEL_ERROR,
11617 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
11618 return -EIO;
11619 }
11620 }
krunal sonie9002db2013-11-25 14:24:17 -080011621 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
11622 {
11623 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
11624 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
11625 {
11626 hddLog (VOS_TRACE_LEVEL_ERROR,
11627 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
11628 return -EIO;
11629 }
11630 params->bssid = vos_mem_malloc(sizeof(VOS_MAC_ADDR_SIZE));
11631 if (!params->bssid)
11632 {
11633 hddLog (VOS_TRACE_LEVEL_ERROR,
11634 "%s:Failed memory allocation", __func__);
11635 return -EIO;
11636 }
11637 vos_mem_copy((v_U8_t *)params->bssid,
11638 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
11639 VOS_MAC_ADDR_SIZE);
11640 alloc_bssid = VOS_TRUE;
11641 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070011642
Jeff Johnson295189b2012-06-20 16:38:30 -070011643 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070011644 if (NULL !=
11645#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
11646 params->chandef.chan)
11647#else
11648 params->channel)
11649#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011650 {
11651 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011652 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
11653 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
11654 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11655 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011656
11657 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011658 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070011659 ieee80211_frequency_to_channel(
11660#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
11661 params->chandef.chan->center_freq);
11662#else
11663 params->channel->center_freq);
11664#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011665
11666 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
11667 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070011668 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011669 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
11670 __func__);
11671 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070011672 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011673
11674 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070011675 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011676 if (channelNum == validChan[indx])
11677 {
11678 break;
11679 }
11680 }
11681 if (indx >= numChans)
11682 {
11683 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011684 __func__, channelNum);
11685 return -EINVAL;
11686 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011687 /* Set the Operational Channel */
11688 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
11689 channelNum);
11690 pRoamProfile->ChannelInfo.numOfChannels = 1;
11691 pHddStaCtx->conn_info.operationChannel = channelNum;
11692 pRoamProfile->ChannelInfo.ChannelList =
11693 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070011694 }
11695
11696 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011697 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070011698 if (status < 0)
11699 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011700 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070011701 __func__);
11702 return status;
11703 }
11704
11705 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011706 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011707 params->ssid_len, params->bssid,
11708 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070011709
11710 if (0 > status)
11711 {
11712 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
11713 return status;
11714 }
11715
krunal sonie9002db2013-11-25 14:24:17 -080011716 if (NULL != params->bssid &&
11717 pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 &&
11718 alloc_bssid == VOS_TRUE)
11719 {
11720 vos_mem_free(params->bssid);
11721 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011722 return 0;
11723}
11724
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011725static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
11726 struct net_device *dev,
11727 struct cfg80211_ibss_params *params
11728 )
11729{
11730 int ret = 0;
11731
11732 vos_ssr_protect(__func__);
11733 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
11734 vos_ssr_unprotect(__func__);
11735
11736 return ret;
11737}
11738
Jeff Johnson295189b2012-06-20 16:38:30 -070011739/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011740 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011741 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070011742 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011743static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011744 struct net_device *dev
11745 )
11746{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011747 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011748 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11749 tCsrRoamProfile *pRoamProfile;
11750 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011751 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011752
11753 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011754
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011755 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11756 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
11757 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011758 status = wlan_hdd_validate_context(pHddCtx);
11759
11760 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011761 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011762 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11763 "%s: HDD context is not valid", __func__);
11764 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011765 }
11766
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011767 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
11768 hdd_device_modetoString(pAdapter->device_mode),
11769 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011770 if (NULL == pWextState)
11771 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011772 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070011773 __func__);
11774 return -EIO;
11775 }
11776
11777 pRoamProfile = &pWextState->roamProfile;
11778
11779 /* Issue disconnect only if interface type is set to IBSS */
11780 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
11781 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011782 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070011783 __func__);
11784 return -EINVAL;
11785 }
11786
11787 /* Issue Disconnect request */
11788 INIT_COMPLETION(pAdapter->disconnect_comp_var);
11789 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
11790 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
11791
11792 return 0;
11793}
11794
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011795static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
11796 struct net_device *dev
11797 )
11798{
11799 int ret = 0;
11800
11801 vos_ssr_protect(__func__);
11802 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
11803 vos_ssr_unprotect(__func__);
11804
11805 return ret;
11806}
11807
Jeff Johnson295189b2012-06-20 16:38:30 -070011808/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053011809 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070011810 * This function is used to set the phy parameters
11811 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
11812 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053011813static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011814 u32 changed)
11815{
11816 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
11817 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011818 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011819
11820 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011821 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11822 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
11823 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011824 status = wlan_hdd_validate_context(pHddCtx);
11825
11826 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011827 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011828 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11829 "%s: HDD context is not valid", __func__);
11830 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011831 }
11832
Jeff Johnson295189b2012-06-20 16:38:30 -070011833 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
11834 {
11835 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
11836 WNI_CFG_RTS_THRESHOLD_STAMAX :
11837 wiphy->rts_threshold;
11838
11839 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011840 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070011841 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011842 hddLog(VOS_TRACE_LEVEL_ERROR,
11843 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011844 __func__, rts_threshold);
11845 return -EINVAL;
11846 }
11847
11848 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
11849 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011850 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011851 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011852 hddLog(VOS_TRACE_LEVEL_ERROR,
11853 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011854 __func__, rts_threshold);
11855 return -EIO;
11856 }
11857
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011858 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011859 rts_threshold);
11860 }
11861
11862 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
11863 {
11864 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
11865 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
11866 wiphy->frag_threshold;
11867
11868 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011869 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011870 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011871 hddLog(VOS_TRACE_LEVEL_ERROR,
11872 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011873 frag_threshold);
11874 return -EINVAL;
11875 }
11876
11877 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
11878 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011879 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011880 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011881 hddLog(VOS_TRACE_LEVEL_ERROR,
11882 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011883 __func__, frag_threshold);
11884 return -EIO;
11885 }
11886
11887 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
11888 frag_threshold);
11889 }
11890
11891 if ((changed & WIPHY_PARAM_RETRY_SHORT)
11892 || (changed & WIPHY_PARAM_RETRY_LONG))
11893 {
11894 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
11895 wiphy->retry_short :
11896 wiphy->retry_long;
11897
11898 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
11899 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
11900 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011901 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011902 __func__, retry_value);
11903 return -EINVAL;
11904 }
11905
11906 if (changed & WIPHY_PARAM_RETRY_SHORT)
11907 {
11908 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
11909 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011910 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011911 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011912 hddLog(VOS_TRACE_LEVEL_ERROR,
11913 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011914 __func__, retry_value);
11915 return -EIO;
11916 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011917 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011918 __func__, retry_value);
11919 }
11920 else if (changed & WIPHY_PARAM_RETRY_SHORT)
11921 {
11922 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
11923 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011924 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011925 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011926 hddLog(VOS_TRACE_LEVEL_ERROR,
11927 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011928 __func__, retry_value);
11929 return -EIO;
11930 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011931 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011932 __func__, retry_value);
11933 }
11934 }
11935
11936 return 0;
11937}
11938
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053011939static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
11940 u32 changed)
11941{
11942 int ret;
11943
11944 vos_ssr_protect(__func__);
11945 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
11946 vos_ssr_unprotect(__func__);
11947
11948 return ret;
11949}
11950
Jeff Johnson295189b2012-06-20 16:38:30 -070011951/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053011952 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070011953 * This function is used to set the txpower
11954 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053011955static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070011956#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
11957 struct wireless_dev *wdev,
11958#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011959#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011960 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070011961#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011962 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070011963#endif
11964 int dbm)
11965{
11966 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011967 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011968 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
11969 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011970 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011971
11972 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011973 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11974 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
11975 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011976 status = wlan_hdd_validate_context(pHddCtx);
11977
11978 if (0 != status)
11979 {
11980 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11981 "%s: HDD context is not valid", __func__);
11982 return status;
11983 }
11984
11985 hHal = pHddCtx->hHal;
11986
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011987 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
11988 dbm, ccmCfgSetCallback,
11989 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011990 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011991 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011992 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
11993 return -EIO;
11994 }
11995
11996 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
11997 dbm);
11998
11999 switch(type)
12000 {
12001 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
12002 /* Fall through */
12003 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
12004 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
12005 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012006 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
12007 __func__);
12008 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070012009 }
12010 break;
12011 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012012 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070012013 __func__);
12014 return -EOPNOTSUPP;
12015 break;
12016 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012017 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
12018 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070012019 return -EIO;
12020 }
12021
12022 return 0;
12023}
12024
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012025static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
12026#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12027 struct wireless_dev *wdev,
12028#endif
12029#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
12030 enum tx_power_setting type,
12031#else
12032 enum nl80211_tx_power_setting type,
12033#endif
12034 int dbm)
12035{
12036 int ret;
12037 vos_ssr_protect(__func__);
12038 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
12039#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12040 wdev,
12041#endif
12042#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
12043 type,
12044#else
12045 type,
12046#endif
12047 dbm);
12048 vos_ssr_unprotect(__func__);
12049
12050 return ret;
12051}
12052
Jeff Johnson295189b2012-06-20 16:38:30 -070012053/*
12054 * FUNCTION: wlan_hdd_cfg80211_get_txpower
12055 * This function is used to read the txpower
12056 */
Yue Maf49ba872013-08-19 12:04:25 -070012057static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
12058#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12059 struct wireless_dev *wdev,
12060#endif
12061 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070012062{
12063
12064 hdd_adapter_t *pAdapter;
12065 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012066 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012067
Jeff Johnsone7245742012-09-05 17:12:55 -070012068 ENTER();
12069
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012070 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070012071
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012072 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012073 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012074 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12075 "%s: HDD context is not valid", __func__);
12076 *dbm = 0;
12077 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012078 }
12079
Jeff Johnson295189b2012-06-20 16:38:30 -070012080 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
12081 if (NULL == pAdapter)
12082 {
12083 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
12084 return -ENOENT;
12085 }
12086
12087 wlan_hdd_get_classAstats(pAdapter);
12088 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
12089
Jeff Johnsone7245742012-09-05 17:12:55 -070012090 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012091 return 0;
12092}
12093
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012094static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070012095 u8* mac, struct station_info *sinfo)
12096{
12097 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
12098 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12099 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053012100 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070012101
12102 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
12103 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070012104
12105 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
12106 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
12107 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
12108 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
12109 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
12110 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
12111 tANI_U16 maxRate = 0;
12112 tANI_U16 myRate;
12113 tANI_U16 currentRate = 0;
12114 tANI_U8 maxSpeedMCS = 0;
12115 tANI_U8 maxMCSIdx = 0;
12116 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053012117 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070012118 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012119 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012120
Leo Chang6f8870f2013-03-26 18:11:36 -070012121#ifdef WLAN_FEATURE_11AC
12122 tANI_U32 vht_mcs_map;
12123 eDataRate11ACMaxMcs vhtMaxMcs;
12124#endif /* WLAN_FEATURE_11AC */
12125
Jeff Johnsone7245742012-09-05 17:12:55 -070012126 ENTER();
12127
Jeff Johnson295189b2012-06-20 16:38:30 -070012128 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
12129 (0 == ssidlen))
12130 {
12131 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
12132 " Invalid ssidlen, %d", __func__, ssidlen);
12133 /*To keep GUI happy*/
12134 return 0;
12135 }
12136
Mukul Sharma811205f2014-07-09 21:07:30 +053012137 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
12138 {
12139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12140 "%s: Roaming in progress, so unable to proceed this request", __func__);
12141 return 0;
12142 }
12143
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012144 status = wlan_hdd_validate_context(pHddCtx);
12145
12146 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012147 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012148 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12149 "%s: HDD context is not valid", __func__);
12150 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012151 }
12152
Jeff Johnson295189b2012-06-20 16:38:30 -070012153
Kiet Lam3b17fc82013-09-27 05:24:08 +053012154 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
12155 sinfo->filled |= STATION_INFO_SIGNAL;
12156
c_hpothu09f19542014-05-30 21:53:31 +053012157 wlan_hdd_get_station_stats(pAdapter);
12158 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
12159
12160 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053012161 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
12162 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053012163 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053012164 {
12165 rate_flags = pAdapter->maxRateFlags;
12166 }
c_hpothu44ff4e02014-05-08 00:13:57 +053012167
Jeff Johnson295189b2012-06-20 16:38:30 -070012168 //convert to the UI units of 100kbps
12169 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
12170
12171#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070012172 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 -070012173 sinfo->signal,
12174 pCfg->reportMaxLinkSpeed,
12175 myRate,
12176 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070012177 (int) pCfg->linkSpeedRssiMid,
12178 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070012179 (int) rate_flags,
12180 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070012181#endif //LINKSPEED_DEBUG_ENABLED
12182
12183 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
12184 {
12185 // we do not want to necessarily report the current speed
12186 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
12187 {
12188 // report the max possible speed
12189 rssidx = 0;
12190 }
12191 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
12192 {
12193 // report the max possible speed with RSSI scaling
12194 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
12195 {
12196 // report the max possible speed
12197 rssidx = 0;
12198 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070012199 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070012200 {
12201 // report middle speed
12202 rssidx = 1;
12203 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070012204 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
12205 {
12206 // report middle speed
12207 rssidx = 2;
12208 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012209 else
12210 {
12211 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070012212 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070012213 }
12214 }
12215 else
12216 {
12217 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
12218 hddLog(VOS_TRACE_LEVEL_ERROR,
12219 "%s: Invalid value for reportMaxLinkSpeed: %u",
12220 __func__, pCfg->reportMaxLinkSpeed);
12221 rssidx = 0;
12222 }
12223
12224 maxRate = 0;
12225
12226 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053012227 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
12228 OperationalRates, &ORLeng))
12229 {
12230 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
12231 /*To keep GUI happy*/
12232 return 0;
12233 }
12234
Jeff Johnson295189b2012-06-20 16:38:30 -070012235 for (i = 0; i < ORLeng; i++)
12236 {
Jeff Johnsone7245742012-09-05 17:12:55 -070012237 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070012238 {
12239 /* Validate Rate Set */
12240 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
12241 {
12242 currentRate = supported_data_rate[j].supported_rate[rssidx];
12243 break;
12244 }
12245 }
12246 /* Update MAX rate */
12247 maxRate = (currentRate > maxRate)?currentRate:maxRate;
12248 }
12249
12250 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053012251 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
12252 ExtendedRates, &ERLeng))
12253 {
12254 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
12255 /*To keep GUI happy*/
12256 return 0;
12257 }
12258
Jeff Johnson295189b2012-06-20 16:38:30 -070012259 for (i = 0; i < ERLeng; i++)
12260 {
Jeff Johnsone7245742012-09-05 17:12:55 -070012261 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070012262 {
12263 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
12264 {
12265 currentRate = supported_data_rate[j].supported_rate[rssidx];
12266 break;
12267 }
12268 }
12269 /* Update MAX rate */
12270 maxRate = (currentRate > maxRate)?currentRate:maxRate;
12271 }
c_hpothu79aab322014-07-14 21:11:01 +053012272
Kiet Lamb69f8dc2013-11-15 15:34:27 +053012273 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053012274 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053012275 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053012276 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070012277 {
c_hpothu79aab322014-07-14 21:11:01 +053012278 if (rate_flags & eHAL_TX_RATE_VHT80)
12279 mode = 2;
12280 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
12281 mode = 1;
12282 else
12283 mode = 0;
12284
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053012285 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
12286 MCSRates, &MCSLeng))
12287 {
12288 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
12289 /*To keep GUI happy*/
12290 return 0;
12291 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012292 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070012293#ifdef WLAN_FEATURE_11AC
12294 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012295 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070012296 {
Leo Chang6f8870f2013-03-26 18:11:36 -070012297 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012298 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070012299 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070012300 {
Leo Chang6f8870f2013-03-26 18:11:36 -070012301 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070012302 }
Leo Chang6f8870f2013-03-26 18:11:36 -070012303 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070012304 {
Leo Chang6f8870f2013-03-26 18:11:36 -070012305 maxMCSIdx = 7;
12306 }
12307 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
12308 {
12309 maxMCSIdx = 8;
12310 }
12311 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
12312 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012313 //VHT20 is supporting 0~8
12314 if (rate_flags & eHAL_TX_RATE_VHT20)
12315 maxMCSIdx = 8;
12316 else
12317 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070012318 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012319
c_hpothu79aab322014-07-14 21:11:01 +053012320 if (0 != rssidx)/*check for scaled */
12321 {
12322 //get middle rate MCS index if rssi=1/2
12323 for (i=0; i <= maxMCSIdx; i++)
12324 {
12325 if (sinfo->signal <= rssiMcsTbl[mode][i])
12326 {
12327 maxMCSIdx = i;
12328 break;
12329 }
12330 }
12331 }
12332
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012333 if (rate_flags & eHAL_TX_RATE_VHT80)
12334 {
12335 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
12336 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
12337 }
12338 else if (rate_flags & eHAL_TX_RATE_VHT40)
12339 {
12340 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
12341 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
12342 }
12343 else if (rate_flags & eHAL_TX_RATE_VHT20)
12344 {
12345 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
12346 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
12347 }
12348
Leo Chang6f8870f2013-03-26 18:11:36 -070012349 maxSpeedMCS = 1;
12350 if (currentRate > maxRate)
12351 {
12352 maxRate = currentRate;
12353 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012354
Leo Chang6f8870f2013-03-26 18:11:36 -070012355 }
12356 else
12357#endif /* WLAN_FEATURE_11AC */
12358 {
12359 if (rate_flags & eHAL_TX_RATE_HT40)
12360 {
12361 rateFlag |= 1;
12362 }
12363 if (rate_flags & eHAL_TX_RATE_SGI)
12364 {
12365 rateFlag |= 2;
12366 }
12367
Girish Gowli01abcee2014-07-31 20:18:55 +053012368 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053012369 if (rssidx == 1 || rssidx == 2)
12370 {
12371 //get middle rate MCS index if rssi=1/2
12372 for (i=0; i <= 7; i++)
12373 {
12374 if (sinfo->signal <= rssiMcsTbl[mode][i])
12375 {
12376 temp = i+1;
12377 break;
12378 }
12379 }
12380 }
c_hpothu79aab322014-07-14 21:11:01 +053012381
12382 for (i = 0; i < MCSLeng; i++)
12383 {
Leo Chang6f8870f2013-03-26 18:11:36 -070012384 for (j = 0; j < temp; j++)
12385 {
12386 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
12387 {
12388 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
12389 break;
12390 }
12391 }
12392 if ((j < temp) && (currentRate > maxRate))
12393 {
12394 maxRate = currentRate;
12395 maxSpeedMCS = 1;
12396 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
12397 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012398 }
12399 }
12400 }
12401
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012402 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
12403 {
12404 maxRate = myRate;
12405 maxSpeedMCS = 1;
12406 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
12407 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012408 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053012409 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070012410 {
12411 maxRate = myRate;
12412 if (rate_flags & eHAL_TX_RATE_LEGACY)
12413 {
12414 maxSpeedMCS = 0;
12415 }
12416 else
12417 {
12418 maxSpeedMCS = 1;
12419 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
12420 }
12421 }
12422
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012423 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070012424 {
12425 sinfo->txrate.legacy = maxRate;
12426#ifdef LINKSPEED_DEBUG_ENABLED
12427 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
12428#endif //LINKSPEED_DEBUG_ENABLED
12429 }
12430 else
12431 {
12432 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070012433#ifdef WLAN_FEATURE_11AC
12434 sinfo->txrate.nss = 1;
12435 if (rate_flags & eHAL_TX_RATE_VHT80)
12436 {
12437 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012438 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070012439 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012440 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070012441 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012442 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
12443 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
12444 }
12445 else if (rate_flags & eHAL_TX_RATE_VHT20)
12446 {
12447 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
12448 }
12449#endif /* WLAN_FEATURE_11AC */
12450 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
12451 {
12452 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
12453 if (rate_flags & eHAL_TX_RATE_HT40)
12454 {
12455 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
12456 }
Leo Chang6f8870f2013-03-26 18:11:36 -070012457 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012458 if (rate_flags & eHAL_TX_RATE_SGI)
12459 {
12460 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
12461 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012462
Jeff Johnson295189b2012-06-20 16:38:30 -070012463#ifdef LINKSPEED_DEBUG_ENABLED
12464 pr_info("Reporting MCS rate %d flags %x\n",
12465 sinfo->txrate.mcs,
12466 sinfo->txrate.flags );
12467#endif //LINKSPEED_DEBUG_ENABLED
12468 }
12469 }
12470 else
12471 {
12472 // report current rate instead of max rate
12473
12474 if (rate_flags & eHAL_TX_RATE_LEGACY)
12475 {
12476 //provide to the UI in units of 100kbps
12477 sinfo->txrate.legacy = myRate;
12478#ifdef LINKSPEED_DEBUG_ENABLED
12479 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
12480#endif //LINKSPEED_DEBUG_ENABLED
12481 }
12482 else
12483 {
12484 //must be MCS
12485 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070012486#ifdef WLAN_FEATURE_11AC
12487 sinfo->txrate.nss = 1;
12488 if (rate_flags & eHAL_TX_RATE_VHT80)
12489 {
12490 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
12491 }
12492 else
12493#endif /* WLAN_FEATURE_11AC */
12494 {
12495 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
12496 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012497 if (rate_flags & eHAL_TX_RATE_SGI)
12498 {
12499 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
12500 }
12501 if (rate_flags & eHAL_TX_RATE_HT40)
12502 {
12503 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
12504 }
Leo Chang6f8870f2013-03-26 18:11:36 -070012505#ifdef WLAN_FEATURE_11AC
12506 else if (rate_flags & eHAL_TX_RATE_VHT80)
12507 {
12508 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
12509 }
12510#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070012511#ifdef LINKSPEED_DEBUG_ENABLED
12512 pr_info("Reporting actual MCS rate %d flags %x\n",
12513 sinfo->txrate.mcs,
12514 sinfo->txrate.flags );
12515#endif //LINKSPEED_DEBUG_ENABLED
12516 }
12517 }
12518 sinfo->filled |= STATION_INFO_TX_BITRATE;
12519
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070012520 sinfo->tx_packets =
12521 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
12522 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
12523 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
12524 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
12525
12526 sinfo->tx_retries =
12527 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
12528 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
12529 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
12530 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
12531
12532 sinfo->tx_failed =
12533 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
12534 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
12535 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
12536 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
12537
12538 sinfo->filled |=
12539 STATION_INFO_TX_PACKETS |
12540 STATION_INFO_TX_RETRIES |
12541 STATION_INFO_TX_FAILED;
12542
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012543 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12544 TRACE_CODE_HDD_CFG80211_GET_STA,
12545 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070012546 EXIT();
12547 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012548}
12549
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012550static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
12551 u8* mac, struct station_info *sinfo)
12552{
12553 int ret;
12554
12555 vos_ssr_protect(__func__);
12556 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
12557 vos_ssr_unprotect(__func__);
12558
12559 return ret;
12560}
12561
12562static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070012563 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070012564{
12565 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053012566 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012567 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012568 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012569
Jeff Johnsone7245742012-09-05 17:12:55 -070012570 ENTER();
12571
Jeff Johnson295189b2012-06-20 16:38:30 -070012572 if (NULL == pAdapter)
12573 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012574 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012575 return -ENODEV;
12576 }
12577
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012578 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12579 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
12580 pAdapter->sessionId, timeout));
12581
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053012582 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012583 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053012584
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012585 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012586 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012587 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12588 "%s: HDD context is not valid", __func__);
12589 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012590 }
12591
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053012592 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
12593 (TRUE == pHddCtx->hdd_wlan_suspended) &&
12594 (pHddCtx->cfg_ini->fhostArpOffload) &&
12595 (eConnectionState_Associated ==
12596 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
12597 {
Amar Singhald53568e2013-09-26 11:03:45 -070012598
12599 hddLog(VOS_TRACE_LEVEL_INFO,
12600 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053012601 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053012602 if (!VOS_IS_STATUS_SUCCESS(vos_status))
12603 {
12604 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012605 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053012606 __func__, vos_status);
12607 }
12608 }
12609
Jeff Johnson295189b2012-06-20 16:38:30 -070012610 /**The get power cmd from the supplicant gets updated by the nl only
12611 *on successful execution of the function call
12612 *we are oppositely mapped w.r.t mode in the driver
12613 **/
12614 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
12615
Jeff Johnsone7245742012-09-05 17:12:55 -070012616 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012617 if (VOS_STATUS_E_FAILURE == vos_status)
12618 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012619 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12620 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012621 return -EINVAL;
12622 }
12623 return 0;
12624}
12625
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012626static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
12627 struct net_device *dev, bool mode, int timeout)
12628{
12629 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070012630
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012631 vos_ssr_protect(__func__);
12632 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
12633 vos_ssr_unprotect(__func__);
12634
12635 return ret;
12636}
Jeff Johnson295189b2012-06-20 16:38:30 -070012637#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12638static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
12639 struct net_device *netdev,
12640 u8 key_index)
12641{
Jeff Johnsone7245742012-09-05 17:12:55 -070012642 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070012643 return 0;
12644}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012645#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070012646
12647#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
12648static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
12649 struct net_device *dev,
12650 struct ieee80211_txq_params *params)
12651{
Jeff Johnsone7245742012-09-05 17:12:55 -070012652 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070012653 return 0;
12654}
12655#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12656static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
12657 struct ieee80211_txq_params *params)
12658{
Jeff Johnsone7245742012-09-05 17:12:55 -070012659 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070012660 return 0;
12661}
12662#endif //LINUX_VERSION_CODE
12663
Naresh Jayaram69e3f282014-10-14 12:29:12 +053012664static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012665 struct net_device *dev,
12666 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070012667{
12668 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012669 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012670 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012671 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012672 v_U8_t staId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012673
Jeff Johnsone7245742012-09-05 17:12:55 -070012674 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012675
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012676 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070012677 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012678 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012679 return -EINVAL;
12680 }
12681
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012682 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12683 TRACE_CODE_HDD_CFG80211_DEL_STA,
12684 pAdapter->sessionId, pAdapter->device_mode));
12685
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012686 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12687 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070012688
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012689 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012690 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012691 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12692 "%s: HDD context is not valid", __func__);
12693 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012694 }
12695
Jeff Johnson295189b2012-06-20 16:38:30 -070012696 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070012697 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070012698 )
12699 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012700 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070012701 {
12702 v_U16_t i;
12703 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
12704 {
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070012705 if ((pAdapter->aStaInfo[i].isUsed) &&
12706 (!pAdapter->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070012707 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012708 vos_mem_copy(pDelStaParams->peerMacAddr,
12709 pAdapter->aStaInfo[i].macAddrSTA.bytes,
12710 ETHER_ADDR_LEN);
12711
Jeff Johnson295189b2012-06-20 16:38:30 -070012712 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080012713 "%s: Delete STA with MAC::"
12714 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012715 __func__,
12716 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
12717 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070012718 if (VOS_IS_STATUS_SUCCESS(vos_status))
12719 pAdapter->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012720 }
12721 }
12722 }
12723 else
12724 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012725
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012726 vos_status = hdd_softap_GetStaId(pAdapter,
12727 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012728 if (!VOS_IS_STATUS_SUCCESS(vos_status))
12729 {
12730 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080012731 "%s: Skip this DEL STA as this is not used::"
12732 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012733 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012734 return -ENOENT;
12735 }
12736
12737 if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE)
12738 {
12739 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080012740 "%s: Skip this DEL STA as deauth is in progress::"
12741 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012742 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012743 return -ENOENT;
12744 }
12745
12746 pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE;
12747
Jeff Johnson295189b2012-06-20 16:38:30 -070012748 hddLog(VOS_TRACE_LEVEL_INFO,
12749 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080012750 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012751 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012752 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012753
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012754 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012755 if (!VOS_IS_STATUS_SUCCESS(vos_status))
12756 {
12757 pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE;
12758 hddLog(VOS_TRACE_LEVEL_INFO,
12759 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080012760 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012761 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012762 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012763 return -ENOENT;
12764 }
12765
Jeff Johnson295189b2012-06-20 16:38:30 -070012766 }
12767 }
12768
12769 EXIT();
12770
12771 return 0;
12772}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053012773
12774#ifdef CFG80211_DEL_STA_V2
12775static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
12776 struct net_device *dev,
12777 struct station_del_parameters *param)
12778#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012779static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
12780 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053012781#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012782{
12783 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012784 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070012785
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012786 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012787
Naresh Jayaram69e3f282014-10-14 12:29:12 +053012788#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012789 if (NULL == param) {
12790 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
12791 return -EINVAL;
12792 }
12793
12794 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
12795 param->subtype, &delStaParams);
12796
Naresh Jayaram69e3f282014-10-14 12:29:12 +053012797#else
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012798 WLANSAP_PopulateDelStaParams(mac, eCsrForcedDeauthSta,
12799 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053012800#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053012801 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
12802
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012803 vos_ssr_unprotect(__func__);
12804
12805 return ret;
12806}
12807
12808static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012809 struct net_device *dev, u8 *mac, struct station_parameters *params)
12810{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012811 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalab977a972013-02-18 19:15:09 -080012812 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012813#ifdef FEATURE_WLAN_TDLS
12814 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012815 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012816
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012817 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12818 TRACE_CODE_HDD_CFG80211_ADD_STA,
12819 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012820 mask = params->sta_flags_mask;
12821
12822 set = params->sta_flags_set;
12823
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012824#ifdef WLAN_FEATURE_TDLS_DEBUG
12825 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12826 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
12827 __func__, mask, set, MAC_ADDR_ARRAY(mac));
12828#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012829
12830 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
12831 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012832 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012833 }
12834 }
12835#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -080012836 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012837}
12838
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012839static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
12840 struct net_device *dev, u8 *mac, struct station_parameters *params)
12841{
12842 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012843
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012844 vos_ssr_protect(__func__);
12845 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
12846 vos_ssr_unprotect(__func__);
12847
12848 return ret;
12849}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012850#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070012851
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053012852static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070012853 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012854{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012855 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12856 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012857 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012858 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012859 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012860 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070012861
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012862 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012863 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012864 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012865 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012866 return -EINVAL;
12867 }
12868
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012869 if (!pmksa) {
12870 hddLog(LOGE, FL("pmksa is NULL"));
12871 return -EINVAL;
12872 }
12873
12874 if (!pmksa->bssid || !pmksa->pmkid) {
12875 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
12876 pmksa->bssid, pmksa->pmkid);
12877 return -EINVAL;
12878 }
12879
12880 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
12881 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
12882
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012883 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12884 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012885
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012886 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012887 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012888 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12889 "%s: HDD context is not valid", __func__);
12890 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012891 }
12892
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012893 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012894 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
12895
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012896 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
12897 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012898
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012899 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012900 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012901 &pmk_id, 1, FALSE);
12902
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012903 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12904 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
12905 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012906
12907 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012908}
12909
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053012910static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
12911 struct cfg80211_pmksa *pmksa)
12912{
12913 int ret;
12914
12915 vos_ssr_protect(__func__);
12916 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
12917 vos_ssr_unprotect(__func__);
12918
12919 return ret;
12920}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012921
Wilson Yang6507c4e2013-10-01 20:11:19 -070012922
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053012923static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070012924 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012925{
Wilson Yang6507c4e2013-10-01 20:11:19 -070012926 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12927 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070012928 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080012929 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070012930
Wilson Yang6507c4e2013-10-01 20:11:19 -070012931 /* Validate pAdapter */
12932 if (NULL == pAdapter)
12933 {
12934 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
12935 return -EINVAL;
12936 }
12937
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012938 if (!pmksa) {
12939 hddLog(LOGE, FL("pmksa is NULL"));
12940 return -EINVAL;
12941 }
12942
12943 if (!pmksa->bssid) {
12944 hddLog(LOGE, FL("pmksa->bssid is NULL"));
12945 return -EINVAL;
12946 }
12947
Kiet Lam98c46a12014-10-31 15:34:57 -070012948 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
12949 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
12950
Wilson Yang6507c4e2013-10-01 20:11:19 -070012951 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12952 status = wlan_hdd_validate_context(pHddCtx);
12953
12954 if (0 != status)
12955 {
12956 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12957 "%s: HDD context is not valid", __func__);
12958 return status;
12959 }
12960
12961 /*Retrieve halHandle*/
12962 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
12963
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012964 /* Delete the PMKID CSR cache */
12965 if (eHAL_STATUS_SUCCESS !=
12966 sme_RoamDelPMKIDfromCache(halHandle,
12967 pAdapter->sessionId, pmksa->bssid, FALSE)) {
12968 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
12969 MAC_ADDR_ARRAY(pmksa->bssid));
12970 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070012971 }
12972
Wilson Yangef657d32014-01-15 19:19:23 -080012973 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012974}
12975
Wilson Yang6507c4e2013-10-01 20:11:19 -070012976
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053012977static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
12978 struct cfg80211_pmksa *pmksa)
12979{
12980 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070012981
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053012982 vos_ssr_protect(__func__);
12983 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
12984 vos_ssr_unprotect(__func__);
12985
12986 return ret;
12987
12988}
12989
12990static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012991{
Wilson Yang6507c4e2013-10-01 20:11:19 -070012992 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12993 tHalHandle halHandle;
12994 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080012995 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070012996
12997 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__);
12998
12999 /* Validate pAdapter */
13000 if (NULL == pAdapter)
13001 {
13002 hddLog(VOS_TRACE_LEVEL_ERROR,
13003 "%s: Invalid Adapter" ,__func__);
13004 return -EINVAL;
13005 }
13006
13007 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13008 status = wlan_hdd_validate_context(pHddCtx);
13009
13010 if (0 != status)
13011 {
13012 hddLog(VOS_TRACE_LEVEL_ERROR,
13013 "%s: HDD context is not valid", __func__);
13014 return status;
13015 }
13016
13017 /*Retrieve halHandle*/
13018 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
13019
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013020 /* Flush the PMKID cache in CSR */
13021 if (eHAL_STATUS_SUCCESS !=
13022 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
13023 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
13024 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013025 }
13026
Wilson Yangef657d32014-01-15 19:19:23 -080013027 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013028}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013029
13030static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
13031{
13032 int ret;
13033
13034 vos_ssr_protect(__func__);
13035 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
13036 vos_ssr_unprotect(__func__);
13037
13038 return ret;
13039}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013040#endif
13041
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013042#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013043static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
13044 struct net_device *dev,
13045 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013046{
13047 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13048 hdd_station_ctx_t *pHddStaCtx;
13049
13050 if (NULL == pAdapter)
13051 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013052 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013053 return -ENODEV;
13054 }
13055
13056 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13057
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013058 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13059 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
13060 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013061 // Added for debug on reception of Re-assoc Req.
13062 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
13063 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013064 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013065 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080013066 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013067 }
13068
13069#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080013070 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013071 ftie->ie_len);
13072#endif
13073
13074 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053013075 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
13076 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013077 ftie->ie_len);
13078 return 0;
13079}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013080
13081static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
13082 struct net_device *dev,
13083 struct cfg80211_update_ft_ies_params *ftie)
13084{
13085 int ret;
13086
13087 vos_ssr_protect(__func__);
13088 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
13089 vos_ssr_unprotect(__func__);
13090
13091 return ret;
13092}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013093#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013094
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013095#ifdef FEATURE_WLAN_SCAN_PNO
13096
13097void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
13098 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
13099{
13100 int ret;
13101 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
13102 hdd_context_t *pHddCtx;
13103
Nirav Shah80830bf2013-12-31 16:35:12 +053013104 ENTER();
13105
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013106 if (NULL == pAdapter)
13107 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053013108 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013109 "%s: HDD adapter is Null", __func__);
13110 return ;
13111 }
13112
13113 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13114 if (NULL == pHddCtx)
13115 {
13116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13117 "%s: HDD context is Null!!!", __func__);
13118 return ;
13119 }
13120
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013121 spin_lock(&pHddCtx->schedScan_lock);
13122 if (TRUE == pHddCtx->isWiphySuspended)
13123 {
13124 pHddCtx->isSchedScanUpdatePending = TRUE;
13125 spin_unlock(&pHddCtx->schedScan_lock);
13126 hddLog(VOS_TRACE_LEVEL_INFO,
13127 "%s: Update cfg80211 scan database after it resume", __func__);
13128 return ;
13129 }
13130 spin_unlock(&pHddCtx->schedScan_lock);
13131
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013132 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
13133
13134 if (0 > ret)
13135 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
13136
13137 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013138 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13139 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013140}
13141
13142/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013143 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053013144 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013145 */
13146static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
13147{
13148 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
13149 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053013150 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013151 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13152 int status = 0;
13153 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
13154
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053013155 /* The current firmware design does not allow PNO during any
13156 * active sessions. Hence, determine the active sessions
13157 * and return a failure.
13158 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013159 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
13160 {
13161 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053013162 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013163
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053013164 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
13165 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
13166 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
13167 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
13168 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
13169 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013170 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053013171 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013172 }
13173 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
13174 pAdapterNode = pNext;
13175 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053013176 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013177}
13178
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013179void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
13180{
13181 hdd_adapter_t *pAdapter = callbackContext;
13182 hdd_context_t *pHddCtx;
13183
13184 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
13185 {
13186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13187 FL("Invalid adapter or adapter has invalid magic"));
13188 return;
13189 }
13190
13191 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13192 if (0 != wlan_hdd_validate_context(pHddCtx))
13193 {
13194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13195 FL("HDD context is not valid"));
13196 return;
13197 }
13198
c_hpothub53c45d2014-08-18 16:53:14 +053013199 if (VOS_STATUS_SUCCESS != status)
13200 {
13201 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013202 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053013203 pHddCtx->isPnoEnable = FALSE;
13204 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013205
13206 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
13207 complete(&pAdapter->pno_comp_var);
13208}
13209
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013210/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053013211 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
13212 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013213 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053013214static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013215 struct net_device *dev, struct cfg80211_sched_scan_request *request)
13216{
13217 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13218 tpSirPNOScanReq pPnoRequest = NULL;
13219 hdd_context_t *pHddCtx;
13220 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053013221 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053013222 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
13223 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013224 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
13225 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013226 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013227
13228 if (NULL == pAdapter)
13229 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013231 "%s: HDD adapter is Null", __func__);
13232 return -ENODEV;
13233 }
13234
13235 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013236 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013237
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013238 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013239 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053013240 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13241 "%s: HDD context is not valid", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013242 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013243 }
13244
13245 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
13246 if (NULL == hHal)
13247 {
13248 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13249 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013250 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013251 }
Sushant Kaushik2fe89932014-09-03 10:58:09 +053013252 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053013253 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053013254 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053013255 {
13256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13257 "%s: aborting the existing scan is unsuccessfull", __func__);
13258 return -EBUSY;
13259 }
13260
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053013261 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013262 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053013263 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053013264 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013265 return -EBUSY;
13266 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013267
c_hpothu37f21312014-04-09 21:49:54 +053013268 if (TRUE == pHddCtx->isPnoEnable)
13269 {
13270 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
13271 FL("already PNO is enabled"));
13272 return -EBUSY;
13273 }
c_hpothu225aa7c2014-10-22 17:45:13 +053013274
13275 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
13276 {
13277 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13278 "%s: abort ROC failed ", __func__);
13279 return -EBUSY;
13280 }
13281
c_hpothu37f21312014-04-09 21:49:54 +053013282 pHddCtx->isPnoEnable = TRUE;
13283
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013284 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
13285 if (NULL == pPnoRequest)
13286 {
13287 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
13288 "%s: vos_mem_malloc failed", __func__);
c_hpothu37f21312014-04-09 21:49:54 +053013289 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013290 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013291 }
13292
Madan Mohan Koyyalamudic3f04352013-09-26 19:21:48 +053013293 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013294 pPnoRequest->enable = 1; /*Enable PNO */
13295 pPnoRequest->ucNetworksCount = request->n_match_sets;
13296
13297 if (( !pPnoRequest->ucNetworksCount ) ||
13298 ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
13299 {
13300 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053013301 "%s: Network input is not correct %d Max Network supported is %d",
13302 __func__, pPnoRequest->ucNetworksCount,
13303 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013304 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013305 goto error;
13306 }
13307
13308 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
13309 {
13310 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053013311 "%s: Incorrect number of channels %d",
13312 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013313 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013314 goto error;
13315 }
13316
13317 /* Framework provides one set of channels(all)
13318 * common for all saved profile */
13319 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
13320 channels_allowed, &num_channels_allowed))
13321 {
13322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13323 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013324 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013325 goto error;
13326 }
13327 /* Checking each channel against allowed channel list */
13328 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053013329 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013330 {
Nirav Shah80830bf2013-12-31 16:35:12 +053013331 char chList [(request->n_channels*5)+1];
13332 int len;
13333 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013334 {
Nirav Shah80830bf2013-12-31 16:35:12 +053013335 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013336 {
Nirav Shah80830bf2013-12-31 16:35:12 +053013337 if (request->channels[i]->hw_value == channels_allowed[indx])
13338 {
13339 valid_ch[num_ch++] = request->channels[i]->hw_value;
13340 len += snprintf(chList+len, 5, "%d ",
13341 request->channels[i]->hw_value);
13342 break ;
13343 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013344 }
13345 }
Nirav Shah80830bf2013-12-31 16:35:12 +053013346 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
13347 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013348
13349 /* Filling per profile params */
13350 for (i = 0; i < pPnoRequest->ucNetworksCount; i++)
13351 {
13352 pPnoRequest->aNetworks[i].ssId.length =
13353 request->match_sets[i].ssid.ssid_len;
13354
13355 if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) ||
13356 ( pPnoRequest->aNetworks[i].ssId.length > 32 ) )
13357 {
13358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053013359 "%s: SSID Len %d is not correct for network %d",
13360 __func__, pPnoRequest->aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013361 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013362 goto error;
13363 }
13364
13365 memcpy(pPnoRequest->aNetworks[i].ssId.ssId,
13366 request->match_sets[i].ssid.ssid,
13367 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053013368 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13369 "%s: SSID of network %d is %s ", __func__,
13370 i, pPnoRequest->aNetworks[i].ssId.ssId);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013371 pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
13372 pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/
13373 pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
13374
13375 /*Copying list of valid channel into request */
13376 memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch);
13377 pPnoRequest->aNetworks[i].ucChannelCount = num_ch;
13378
13379 pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value
13380 }
13381
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053013382 for (i = 0; i < request->n_ssids; i++)
13383 {
13384 j = 0;
13385 while (j < pPnoRequest->ucNetworksCount)
13386 {
13387 if ((pPnoRequest->aNetworks[j].ssId.length ==
13388 request->ssids[i].ssid_len) &&
13389 (0 == memcmp(pPnoRequest->aNetworks[j].ssId.ssId,
13390 request->ssids[i].ssid,
13391 pPnoRequest->aNetworks[j].ssId.length)))
13392 {
13393 pPnoRequest->aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
13394 break;
13395 }
13396 j++;
13397 }
13398 }
13399 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13400 "Number of hidden networks being Configured = %d",
13401 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053013402 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080013403 "request->ie_len = %zu", request->ie_len);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053013404 if ((0 < request->ie_len) && (NULL != request->ie))
13405 {
13406 pPnoRequest->us24GProbeTemplateLen = request->ie_len;
13407 memcpy(&pPnoRequest->p24GProbeTemplate, request->ie,
13408 pPnoRequest->us24GProbeTemplateLen);
13409
13410 pPnoRequest->us5GProbeTemplateLen = request->ie_len;
13411 memcpy(&pPnoRequest->p5GProbeTemplate, request->ie,
13412 pPnoRequest->us5GProbeTemplateLen);
13413 }
13414
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053013415 /* Driver gets only one time interval which is hardcoded in
13416 * supplicant for 10000ms. Taking power consumption into account 6 timers
13417 * will be used, Timervalue is increased exponentially i.e 10,20,40,
13418 * 80,160,320 secs. And number of scan cycle for each timer
13419 * is configurable through INI param gPNOScanTimerRepeatValue.
13420 * If it is set to 0 only one timer will be used and PNO scan cycle
13421 * will be repeated after each interval specified by supplicant
13422 * till PNO is disabled.
13423 */
13424 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
13425 pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
13426 else
13427 pPnoRequest->scanTimers.ucScanTimersCount =
13428 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
13429
13430 tempInterval = (request->interval)/1000;
13431 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13432 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
13433 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
13434 for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++)
13435 {
13436 pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat =
13437 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
13438 pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval;
13439 tempInterval *= 2;
13440 }
13441 //Repeat last timer until pno disabled.
13442 pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
13443
Madan Mohan Koyyalamudid206c7b2013-09-26 22:54:51 +053013444 pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013445
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013446 INIT_COMPLETION(pAdapter->pno_comp_var);
13447 pPnoRequest->statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
13448 pPnoRequest->callbackContext = pAdapter;
13449 pAdapter->pno_req_status = 0;
13450
Nirav Shah80830bf2013-12-31 16:35:12 +053013451 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13452 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
13453 pAdapter->sessionId, pPnoRequest->enable, pPnoRequest->modePNO,
13454 pPnoRequest->scanTimers.ucScanTimersCount);
13455
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013456 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
13457 pPnoRequest, pAdapter->sessionId,
13458 hdd_cfg80211_sched_scan_done_callback, pAdapter);
13459 if (eHAL_STATUS_SUCCESS != status)
13460 {
13461 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053013462 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013463 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013464 goto error;
13465 }
13466
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013467 ret = wait_for_completion_timeout(
13468 &pAdapter->pno_comp_var,
13469 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
13470 if (0 >= ret)
13471 {
13472 // Did not receive the response for PNO enable in time.
13473 // Assuming the PNO enable was success.
13474 // Returning error from here, because we timeout, results
13475 // in side effect of Wifi (Wifi Setting) not to work.
13476 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13477 FL("Timed out waiting for PNO to be Enabled"));
13478 ret = 0;
13479 goto error;
13480 }
13481
c_hpothu3c986b22014-07-09 14:45:09 +053013482 vos_mem_free(pPnoRequest);
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013483 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053013484 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013485
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013486error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013487 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13488 FL("PNO scanRequest offloaded ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013489 vos_mem_free(pPnoRequest);
c_hpothu37f21312014-04-09 21:49:54 +053013490 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013491 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013492}
13493
13494/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053013495 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
13496 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013497 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053013498static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
13499 struct net_device *dev, struct cfg80211_sched_scan_request *request)
13500{
13501 int ret;
13502
13503 vos_ssr_protect(__func__);
13504 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
13505 vos_ssr_unprotect(__func__);
13506
13507 return ret;
13508}
13509
13510/*
13511 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
13512 * Function to disable PNO
13513 */
13514static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013515 struct net_device *dev)
13516{
13517 eHalStatus status = eHAL_STATUS_FAILURE;
13518 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13519 hdd_context_t *pHddCtx;
13520 tHalHandle hHal;
13521 tpSirPNOScanReq pPnoRequest = NULL;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013522 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013523
13524 ENTER();
13525
13526 if (NULL == pAdapter)
13527 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013528 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013529 "%s: HDD adapter is Null", __func__);
13530 return -ENODEV;
13531 }
13532
13533 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013534
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013535 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013536 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053013537 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013538 "%s: HDD context is Null", __func__);
13539 return -ENODEV;
13540 }
13541
13542 /* The return 0 is intentional when isLogpInProgress and
13543 * isLoadUnloadInProgress. We did observe a crash due to a return of
13544 * failure in sched_scan_stop , especially for a case where the unload
13545 * of the happens at the same time. The function __cfg80211_stop_sched_scan
13546 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
13547 * success. If it returns a failure , then its next invocation due to the
13548 * clean up of the second interface will have the dev pointer corresponding
13549 * to the first one leading to a crash.
13550 */
13551 if (pHddCtx->isLogpInProgress)
13552 {
13553 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13554 "%s: LOGP in Progress. Ignore!!!", __func__);
13555 return ret;
13556 }
13557
Mihir Shete18156292014-03-11 15:38:30 +053013558 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013559 {
13560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13561 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
13562 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013563 }
13564
13565 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
13566 if (NULL == hHal)
13567 {
13568 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13569 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013570 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013571 }
13572
13573 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
13574 if (NULL == pPnoRequest)
13575 {
13576 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
13577 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013578 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013579 }
13580
13581 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
13582 pPnoRequest->enable = 0; /* Disable PNO */
13583 pPnoRequest->ucNetworksCount = 0;
13584
13585 status = sme_SetPreferredNetworkList(hHal, pPnoRequest,
13586 pAdapter->sessionId,
13587 NULL, pAdapter);
13588 if (eHAL_STATUS_SUCCESS != status)
13589 {
13590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13591 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013592 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013593 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013594 }
c_hpothu37f21312014-04-09 21:49:54 +053013595 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013596
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013597error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013598 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013599 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013600 vos_mem_free(pPnoRequest);
13601
13602 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013603 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013604}
13605
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053013606/*
13607 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
13608 * NL interface to disable PNO
13609 */
13610static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
13611 struct net_device *dev)
13612{
13613 int ret;
13614
13615 vos_ssr_protect(__func__);
13616 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
13617 vos_ssr_unprotect(__func__);
13618
13619 return ret;
13620}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013621#endif /*FEATURE_WLAN_SCAN_PNO*/
13622
13623
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013624#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053013625#if TDLS_MGMT_VERSION2
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013626static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
13627 u8 *peer, u8 action_code, u8 dialog_token,
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053013628 u16 status_code, u32 peer_capability, const u8 *buf, size_t len)
13629#else
13630static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
13631 u8 *peer, u8 action_code, u8 dialog_token,
13632 u16 status_code, const u8 *buf, size_t len)
13633#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013634{
13635
13636 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13637 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013638 u8 peerMac[6];
13639 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070013640 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080013641 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070013642 long rc;
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053013643#if !(TDLS_MGMT_VERSION2)
13644 u32 peer_capability = 0;
13645#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053013646 tANI_U16 numCurrTdlsPeers;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013647
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013648 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13649 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
13650 pAdapter->sessionId, action_code));
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013651 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013652 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013653 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013654 "Invalid arguments");
13655 return -EINVAL;
13656 }
13657
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080013658 if (pHddCtx->isLogpInProgress)
13659 {
13660 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13661 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053013662 wlan_hdd_tdls_set_link_status(pAdapter,
13663 peer,
13664 eTDLS_LINK_IDLE,
13665 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080013666 return -EBUSY;
13667 }
13668
Hoonki Lee27511902013-03-14 18:19:06 -070013669 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013670 {
Hoonki Lee27511902013-03-14 18:19:06 -070013671 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
13672 "%s: TDLS mode is disabled OR not enabled in FW."
13673 MAC_ADDRESS_STR " action %d declined.",
13674 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013675 return -ENOTSUPP;
13676 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080013677
Hoonki Lee27511902013-03-14 18:19:06 -070013678 /* other than teardown frame, other mgmt frames are not sent if disabled */
13679 if (SIR_MAC_TDLS_TEARDOWN != action_code)
13680 {
13681 /* if tdls_mode is disabled to respond to peer's request */
13682 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
13683 {
13684 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
13685 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070013686 " TDLS mode is disabled. action %d declined.",
13687 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070013688
13689 return -ENOTSUPP;
13690 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053013691
13692 if (vos_max_concurrent_connections_reached())
13693 {
13694 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
13695 return -EINVAL;
13696 }
Hoonki Lee27511902013-03-14 18:19:06 -070013697 }
13698
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013699 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
13700 {
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053013701 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013702 {
13703 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013704 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070013705 " TDLS setup is ongoing. action %d declined.",
13706 __func__, MAC_ADDR_ARRAY(peer), action_code);
13707 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013708 }
13709 }
13710
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013711 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
13712 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080013713 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053013714 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
13715 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080013716 {
13717 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
13718 we return error code at 'add_station()'. Hence we have this
13719 check again in addtion to add_station().
13720 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013721 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080013722 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013723 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13724 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053013725 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
13726 __func__, MAC_ADDR_ARRAY(peer), action_code,
13727 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053013728 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080013729 }
13730 else
13731 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013732 /* maximum reached. tweak to send error code to peer and return
13733 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080013734 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013735 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13736 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053013737 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
13738 __func__, MAC_ADDR_ARRAY(peer), status_code,
13739 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070013740 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013741 /* fall through to send setup resp with failure status
13742 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080013743 }
13744 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013745 else
13746 {
13747 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053013748 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013749 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013750 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013751 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070013752 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
13753 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013754 return -EPERM;
13755 }
13756 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080013757 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013758 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013759
Hoonki Lee1090c6a2013-01-16 17:40:54 -080013760#ifdef WLAN_FEATURE_TDLS_DEBUG
13761 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053013762 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013763 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
13764 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -080013765#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013766
Hoonki Leea34dd892013-02-05 22:56:02 -080013767 /*Except teardown responder will not be used so just make 0*/
13768 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013769 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080013770 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070013771
13772 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053013773 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070013774
13775 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
13776 responder = pTdlsPeer->is_responder;
13777 else
Hoonki Leea34dd892013-02-05 22:56:02 -080013778 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070013779 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053013780 "%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 -070013781 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
13782 dialog_token, status_code, len);
13783 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080013784 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013785 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013786
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053013787 /* For explicit trigger of DIS_REQ come out of BMPS for
13788 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070013789 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053013790 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
13791 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070013792 {
13793 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
13794 {
13795 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053013796 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Hoonki Lee14621352013-04-16 17:51:19 -070013797 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
13798 }
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053013799 if (SIR_MAC_TDLS_DIS_REQ != action_code)
13800 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
Hoonki Lee14621352013-04-16 17:51:19 -070013801 }
13802
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013803 /* make sure doesn't call send_mgmt() while it is pending */
13804 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
13805 {
13806 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080013807 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013808 __func__, MAC_ADDR_ARRAY(peer), action_code);
13809 return -EBUSY;
13810 }
13811
13812 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013813 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
13814
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013815 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +053013816 peerMac, action_code, dialog_token, status_code, peer_capability, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013817
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013818 if (VOS_STATUS_SUCCESS != status)
13819 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013820 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13821 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013822 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -070013823 wlan_hdd_tdls_check_bmps(pAdapter);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053013824 return -EINVAL;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013825 }
13826
Hoonki Leed37cbb32013-04-20 00:31:14 -070013827 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
13828 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
13829
13830 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013831 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070013832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070013833 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070013834 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013835 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080013836
13837 if (pHddCtx->isLogpInProgress)
13838 {
13839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13840 "%s: LOGP in Progress. Ignore!!!", __func__);
13841 return -EAGAIN;
13842 }
13843
Hoonki Leed37cbb32013-04-20 00:31:14 -070013844 wlan_hdd_tdls_check_bmps(pAdapter);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053013845 return -EINVAL;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013846 }
13847
Gopichand Nakkala05922802013-03-14 12:23:19 -070013848 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070013849 {
13850 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -070013851 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070013852 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013853
Hoonki Leea34dd892013-02-05 22:56:02 -080013854 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
13855 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080013856 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -080013857 }
13858 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
13859 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080013860 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -080013861 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013862
13863 return 0;
13864}
13865
Atul Mittal115287b2014-07-08 13:26:33 +053013866
13867int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
13868 u8 *peer,
13869 cfg80211_exttdls_callback callback)
13870{
13871
13872 hddTdlsPeer_t *pTdlsPeer;
13873 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13874 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13875 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
13876 __func__, MAC_ADDR_ARRAY(peer));
13877
13878 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
13879 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
13880
13881 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13882 " %s TDLS External control and Implicit Trigger not enabled ",
13883 __func__);
13884 return -ENOTSUPP;
13885 }
13886
13887 /* To cater the requirement of establishing the TDLS link
13888 * irrespective of the data traffic , get an entry of TDLS peer.
13889 */
13890 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
13891 if (pTdlsPeer == NULL) {
13892 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13893 "%s: peer " MAC_ADDRESS_STR " not existing",
13894 __func__, MAC_ADDR_ARRAY(peer));
13895 return -EINVAL;
13896 }
13897
13898 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
13899
13900 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13901 " %s TDLS Add Force Peer Failed",
13902 __func__);
13903 return -EINVAL;
13904 }
13905 /*EXT TDLS*/
13906
13907 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
13908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13909 " %s TDLS set callback Failed",
13910 __func__);
13911 return -EINVAL;
13912 }
13913
13914 return(0);
13915
13916}
13917
13918int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter, u8 *peer)
13919{
13920
13921 hddTdlsPeer_t *pTdlsPeer;
13922 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13923 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13924 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
13925 __func__, MAC_ADDR_ARRAY(peer));
13926
13927 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
13928 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
13929
13930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13931 " %s TDLS External control and Implicit Trigger not enabled ",
13932 __func__);
13933 return -ENOTSUPP;
13934 }
13935
13936
13937 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
13938
13939 if ( NULL == pTdlsPeer ) {
13940 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
13941 " peer not exsting",
13942 __func__, MAC_ADDR_ARRAY(peer));
13943 return -EINVAL;
13944 }
13945 else {
13946 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
13947 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
13948 }
13949
13950 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) )
13951 return -EINVAL;
13952
13953 /*EXT TDLS*/
13954
13955 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
13956
13957 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13958 " %s TDLS set callback Failed",
13959 __func__);
13960 return -EINVAL;
13961 }
13962 return(0);
13963
13964}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013965static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013966 u8 *peer, enum nl80211_tdls_operation oper)
13967{
13968 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13969 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013970 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013971 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013972
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013973 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13974 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
13975 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013976 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013977 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013978 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070013979 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013980 return -EINVAL;
13981 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080013982
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013983 status = wlan_hdd_validate_context(pHddCtx);
13984
13985 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080013986 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013987 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13988 "%s: HDD context is not valid", __func__);
13989 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080013990 }
13991
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013992
13993 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080013994 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013995 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080013996 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070013997 "TDLS Disabled in INI OR not enabled in FW. "
13998 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013999 return -ENOTSUPP;
14000 }
14001
14002 switch (oper) {
14003 case NL80211_TDLS_ENABLE_LINK:
14004 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014005 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014006 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053014007 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014008
Sunil Dutt41de4e22013-11-14 18:09:02 +053014009 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
14010
14011 if ( NULL == pTdlsPeer ) {
14012 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
14013 " (oper %d) not exsting. ignored",
14014 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
14015 return -EINVAL;
14016 }
14017
14018 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14019 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
14020 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
14021 "NL80211_TDLS_ENABLE_LINK");
14022
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070014023 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
14024 {
14025 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
14026 MAC_ADDRESS_STR " failed",
14027 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
14028 return -EINVAL;
14029 }
14030
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014031 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014032 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053014033 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053014034
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053014035 if (0 != wlan_hdd_tdls_get_link_establish_params(
14036 pAdapter, peer,&tdlsLinkEstablishParams)) {
14037 return -EINVAL;
14038 }
14039 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053014040
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053014041 sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter),
14042 pAdapter->sessionId, peer, &tdlsLinkEstablishParams);
14043 /* Send TDLS peer UAPSD capabilities to the firmware and
14044 * register with the TL on after the response for this operation
14045 * is received .
14046 */
14047 ret = wait_for_completion_interruptible_timeout(
14048 &pAdapter->tdls_link_establish_req_comp,
14049 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
14050 if (ret <= 0)
14051 {
14052 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14053 "%s: Link Establish Request Faled Status %ld",
14054 __func__, ret);
14055 return -EINVAL;
14056 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053014057 }
Atul Mittal115287b2014-07-08 13:26:33 +053014058 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
14059 eTDLS_LINK_CONNECTED,
14060 eTDLS_LINK_SUCCESS);
Gopichand Nakkala471708b2013-06-04 20:03:01 +053014061 /* Mark TDLS client Authenticated .*/
14062 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
14063 pTdlsPeer->staId,
14064 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070014065 if (VOS_STATUS_SUCCESS == status)
14066 {
Hoonki Lee14621352013-04-16 17:51:19 -070014067 if (pTdlsPeer->is_responder == 0)
14068 {
14069 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
14070
14071 wlan_hdd_tdls_timer_restart(pAdapter,
14072 &pTdlsPeer->initiatorWaitTimeoutTimer,
14073 WAIT_TIME_TDLS_INITIATOR);
14074 /* suspend initiator TX until it receives direct packet from the
14075 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
14076 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
14077 &staId, NULL);
14078 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070014079 wlan_hdd_tdls_increment_peer_count(pAdapter);
14080 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014081 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053014082
14083 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053014084 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
14085 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053014086 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053014087 int ac;
14088 uint8 ucAc[4] = { WLANTL_AC_VO,
14089 WLANTL_AC_VI,
14090 WLANTL_AC_BK,
14091 WLANTL_AC_BE };
14092 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
14093 for(ac=0; ac < 4; ac++)
14094 {
14095 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
14096 pTdlsPeer->staId, ucAc[ac],
14097 tlTid[ac], tlTid[ac], 0, 0,
14098 WLANTL_BI_DIR );
14099 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053014100 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014101 }
14102
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014103 }
14104 break;
14105 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080014106 {
Sunil Dutt41de4e22013-11-14 18:09:02 +053014107 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
14108
14109 if ( NULL == pTdlsPeer ) {
14110 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
14111 " (oper %d) not exsting. ignored",
14112 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
14113 return -EINVAL;
14114 }
14115
14116 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14117 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
14118 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
14119 "NL80211_TDLS_DISABLE_LINK");
14120
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014121 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080014122 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070014123 long status;
14124
Atul Mittal271a7652014-09-12 13:18:22 +053014125
14126 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
14127 eTDLS_LINK_TEARING,
14128 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
14129 eTDLS_LINK_UNSPECIFIED:
14130 eTDLS_LINK_DROPPED_BY_REMOTE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070014131 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
14132
Lee Hoonkic1262f22013-01-24 21:59:00 -080014133 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
14134 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070014135
14136 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
14137 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Atul Mittal271a7652014-09-12 13:18:22 +053014138 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053014139 eTDLS_LINK_IDLE,
14140 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070014141 if (status <= 0)
14142 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070014143 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14144 "%s: Del station failed status %ld",
14145 __func__, status);
14146 return -EPERM;
14147 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080014148 }
14149 else
14150 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014151 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14152 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080014153 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080014154 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014155 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014156 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053014157 {
Atul Mittal115287b2014-07-08 13:26:33 +053014158 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053014159
Atul Mittal115287b2014-07-08 13:26:33 +053014160 if (0 != status)
14161 {
14162 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14163 "%s: Error in TDLS Teardown", __func__);
14164 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053014165 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053014166 break;
14167 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014168 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053014169 {
Atul Mittal115287b2014-07-08 13:26:33 +053014170 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
14171 peer,
14172 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053014173
Atul Mittal115287b2014-07-08 13:26:33 +053014174 if (0 != status)
14175 {
14176 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14177 "%s: Error in TDLS Setup", __func__);
14178 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053014179 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053014180 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053014181 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014182 case NL80211_TDLS_DISCOVERY_REQ:
14183 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014184 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
14185 "%s: We don't support in-driver setup/teardown/discovery "
14186 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014187 return -ENOTSUPP;
14188 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14190 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014191 return -ENOTSUPP;
14192 }
14193 return 0;
14194}
Chilam NG571c65a2013-01-19 12:27:36 +053014195
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014196static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
14197 u8 *peer, enum nl80211_tdls_operation oper)
14198{
14199 int ret;
14200
14201 vos_ssr_protect(__func__);
14202 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
14203 vos_ssr_unprotect(__func__);
14204
14205 return ret;
14206}
14207
Chilam NG571c65a2013-01-19 12:27:36 +053014208int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
14209 struct net_device *dev, u8 *peer)
14210{
Arif Hussaina7c8e412013-11-20 11:06:42 -080014211 hddLog(VOS_TRACE_LEVEL_INFO,
14212 "tdls send discover req: "MAC_ADDRESS_STR,
14213 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053014214
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014215#if TDLS_MGMT_VERSION2
14216 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
14217 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
14218#else
Chilam NG571c65a2013-01-19 12:27:36 +053014219 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
14220 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014221#endif
Chilam NG571c65a2013-01-19 12:27:36 +053014222}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014223#endif
14224
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014225#ifdef WLAN_FEATURE_GTK_OFFLOAD
14226/*
14227 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
14228 * Callback rountine called upon receiving response for
14229 * get offload info
14230 */
14231void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
14232 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
14233{
14234
14235 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014236 tANI_U8 tempReplayCounter[8];
14237 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014238
14239 ENTER();
14240
14241 if (NULL == pAdapter)
14242 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053014243 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014244 "%s: HDD adapter is Null", __func__);
14245 return ;
14246 }
14247
14248 if (NULL == pGtkOffloadGetInfoRsp)
14249 {
14250 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14251 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
14252 return ;
14253 }
14254
14255 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
14256 {
14257 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14258 "%s: wlan Failed to get replay counter value",
14259 __func__);
14260 return ;
14261 }
14262
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014263 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14264 /* Update replay counter */
14265 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
14266 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
14267
14268 {
14269 /* changing from little to big endian since supplicant
14270 * works on big endian format
14271 */
14272 int i;
14273 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
14274
14275 for (i = 0; i < 8; i++)
14276 {
14277 tempReplayCounter[7-i] = (tANI_U8)p[i];
14278 }
14279 }
14280
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014281 /* Update replay counter to NL */
14282 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014283 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014284}
14285
14286/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014287 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014288 * This function is used to offload GTK rekeying job to the firmware.
14289 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014290int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014291 struct cfg80211_gtk_rekey_data *data)
14292{
14293 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14294 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
14295 hdd_station_ctx_t *pHddStaCtx;
14296 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014297 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014298 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014299 eHalStatus status = eHAL_STATUS_FAILURE;
14300
14301 ENTER();
14302
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014303
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014304 if (NULL == pAdapter)
14305 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014306 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014307 "%s: HDD adapter is Null", __func__);
14308 return -ENODEV;
14309 }
14310
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014311 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14312 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
14313 pAdapter->sessionId, pAdapter->device_mode));
14314
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014315 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014316
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014317 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014318 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014319 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14320 "%s: HDD context is not valid", __func__);
14321 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014322 }
14323
14324 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14325 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14326 if (NULL == hHal)
14327 {
14328 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14329 "%s: HAL context is Null!!!", __func__);
14330 return -EAGAIN;
14331 }
14332
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014333 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
14334 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
14335 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
14336 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014337 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014338 {
14339 /* changing from big to little endian since driver
14340 * works on little endian format
14341 */
14342 tANI_U8 *p =
14343 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
14344 int i;
14345
14346 for (i = 0; i < 8; i++)
14347 {
14348 p[7-i] = data->replay_ctr[i];
14349 }
14350 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014351
14352 if (TRUE == pHddCtx->hdd_wlan_suspended)
14353 {
14354 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014355 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
14356 sizeof (tSirGtkOffloadParams));
14357 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014358 pAdapter->sessionId);
14359
14360 if (eHAL_STATUS_SUCCESS != status)
14361 {
14362 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14363 "%s: sme_SetGTKOffload failed, returned %d",
14364 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053014365
14366 /* Need to clear any trace of key value in the memory.
14367 * Thus zero out the memory even though it is local
14368 * variable.
14369 */
14370 vos_mem_zero(&hddGtkOffloadReqParams,
14371 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014372 return status;
14373 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014374 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14375 "%s: sme_SetGTKOffload successfull", __func__);
14376 }
14377 else
14378 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014379 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14380 "%s: wlan not suspended GTKOffload request is stored",
14381 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014382 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014383
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053014384 /* Need to clear any trace of key value in the memory.
14385 * Thus zero out the memory even though it is local
14386 * variable.
14387 */
14388 vos_mem_zero(&hddGtkOffloadReqParams,
14389 sizeof(hddGtkOffloadReqParams));
14390
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014391 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014392}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014393
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014394int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
14395 struct cfg80211_gtk_rekey_data *data)
14396{
14397 int ret;
14398
14399 vos_ssr_protect(__func__);
14400 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
14401 vos_ssr_unprotect(__func__);
14402
14403 return ret;
14404}
14405#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014406/*
14407 * FUNCTION: wlan_hdd_cfg80211_set_mac_acl
14408 * This function is used to set access control policy
14409 */
14410static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
14411 struct net_device *dev, const struct cfg80211_acl_data *params)
14412{
14413 int i;
14414 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14415 hdd_hostapd_state_t *pHostapdState;
14416 tsap_Config_t *pConfig;
14417 v_CONTEXT_t pVosContext = NULL;
14418 hdd_context_t *pHddCtx;
14419 int status;
14420
14421 ENTER();
14422
14423 if (NULL == pAdapter)
14424 {
14425 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14426 "%s: HDD adapter is Null", __func__);
14427 return -ENODEV;
14428 }
14429
14430 if (NULL == params)
14431 {
14432 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14433 "%s: params is Null", __func__);
14434 return -EINVAL;
14435 }
14436
14437 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14438 status = wlan_hdd_validate_context(pHddCtx);
14439
14440 if (0 != status)
14441 {
14442 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14443 "%s: HDD context is not valid", __func__);
14444 return status;
14445 }
14446
14447 pVosContext = pHddCtx->pvosContext;
14448 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
14449
14450 if (NULL == pHostapdState)
14451 {
14452 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14453 "%s: pHostapdState is Null", __func__);
14454 return -EINVAL;
14455 }
14456
14457 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
14458 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
14459
14460 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
14461 {
14462 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
14463
14464 /* default value */
14465 pConfig->num_accept_mac = 0;
14466 pConfig->num_deny_mac = 0;
14467
14468 /**
14469 * access control policy
14470 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
14471 * listed in hostapd.deny file.
14472 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
14473 * listed in hostapd.accept file.
14474 */
14475 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
14476 {
14477 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
14478 }
14479 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
14480 {
14481 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
14482 }
14483 else
14484 {
14485 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14486 "%s:Acl Policy : %d is not supported",
14487 __func__, params->acl_policy);
14488 return -ENOTSUPP;
14489 }
14490
14491 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
14492 {
14493 pConfig->num_accept_mac = params->n_acl_entries;
14494 for (i = 0; i < params->n_acl_entries; i++)
14495 {
14496 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14497 "** Add ACL MAC entry %i in WhiletList :"
14498 MAC_ADDRESS_STR, i,
14499 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
14500
14501 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
14502 sizeof(qcmacaddr));
14503 }
14504 }
14505 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
14506 {
14507 pConfig->num_deny_mac = params->n_acl_entries;
14508 for (i = 0; i < params->n_acl_entries; i++)
14509 {
14510 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14511 "** Add ACL MAC entry %i in BlackList :"
14512 MAC_ADDRESS_STR, i,
14513 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
14514
14515 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
14516 sizeof(qcmacaddr));
14517 }
14518 }
14519
14520 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
14521 {
14522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14523 "%s: SAP Set Mac Acl fail", __func__);
14524 return -EINVAL;
14525 }
14526 }
14527 else
14528 {
14529 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053014530 "%s: Invalid device_mode = %s (%d)",
14531 __func__, hdd_device_modetoString(pAdapter->device_mode),
14532 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014533 return -EINVAL;
14534 }
14535
14536 return 0;
14537}
14538
Leo Chang9056f462013-08-01 19:21:11 -070014539#ifdef WLAN_NL80211_TESTMODE
14540#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070014541void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070014542(
14543 void *pAdapter,
14544 void *indCont
14545)
14546{
Leo Changd9df8aa2013-09-26 13:32:26 -070014547 tSirLPHBInd *lphbInd;
14548 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053014549 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070014550
14551 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070014552 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070014553
c_hpothu73f35e62014-04-18 13:40:08 +053014554 if (pAdapter == NULL)
14555 {
14556 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14557 "%s: pAdapter is NULL\n",__func__);
14558 return;
14559 }
14560
Leo Chang9056f462013-08-01 19:21:11 -070014561 if (NULL == indCont)
14562 {
14563 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070014564 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070014565 return;
14566 }
14567
c_hpothu73f35e62014-04-18 13:40:08 +053014568 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070014569 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070014570 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053014571 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070014572 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070014573 GFP_ATOMIC);
14574 if (!skb)
14575 {
14576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14577 "LPHB timeout, NL buffer alloc fail");
14578 return;
14579 }
14580
Leo Changac3ba772013-10-07 09:47:04 -070014581 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070014582 {
14583 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14584 "WLAN_HDD_TM_ATTR_CMD put fail");
14585 goto nla_put_failure;
14586 }
Leo Changac3ba772013-10-07 09:47:04 -070014587 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070014588 {
14589 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14590 "WLAN_HDD_TM_ATTR_TYPE put fail");
14591 goto nla_put_failure;
14592 }
Leo Changac3ba772013-10-07 09:47:04 -070014593 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070014594 sizeof(tSirLPHBInd), lphbInd))
14595 {
14596 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14597 "WLAN_HDD_TM_ATTR_DATA put fail");
14598 goto nla_put_failure;
14599 }
Leo Chang9056f462013-08-01 19:21:11 -070014600 cfg80211_testmode_event(skb, GFP_ATOMIC);
14601 return;
14602
14603nla_put_failure:
14604 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14605 "NLA Put fail");
14606 kfree_skb(skb);
14607
14608 return;
14609}
14610#endif /* FEATURE_WLAN_LPHB */
14611
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014612static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070014613{
14614 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
14615 int err = 0;
14616#ifdef FEATURE_WLAN_LPHB
14617 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070014618 eHalStatus smeStatus;
Leo Chang9056f462013-08-01 19:21:11 -070014619#endif /* FEATURE_WLAN_LPHB */
14620
14621 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
14622 if (err)
14623 {
14624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14625 "%s Testmode INV ATTR", __func__);
14626 return err;
14627 }
14628
14629 if (!tb[WLAN_HDD_TM_ATTR_CMD])
14630 {
14631 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14632 "%s Testmode INV CMD", __func__);
14633 return -EINVAL;
14634 }
14635
14636 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
14637 {
14638#ifdef FEATURE_WLAN_LPHB
14639 /* Low Power Heartbeat configuration request */
14640 case WLAN_HDD_TM_CMD_WLAN_HB:
14641 {
14642 int buf_len;
14643 void *buf;
14644 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080014645 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070014646
14647 if (!tb[WLAN_HDD_TM_ATTR_DATA])
14648 {
14649 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14650 "%s Testmode INV DATA", __func__);
14651 return -EINVAL;
14652 }
14653
14654 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
14655 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080014656
14657 hb_params_temp =(tSirLPHBReq *)buf;
14658 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
14659 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
14660 return -EINVAL;
14661
Leo Chang9056f462013-08-01 19:21:11 -070014662 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
14663 if (NULL == hb_params)
14664 {
14665 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14666 "%s Request Buffer Alloc Fail", __func__);
14667 return -EINVAL;
14668 }
14669
14670 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070014671 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
14672 hb_params,
14673 wlan_hdd_cfg80211_lphb_ind_handler);
14674 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070014675 {
Leo Changd9df8aa2013-09-26 13:32:26 -070014676 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14677 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070014678 vos_mem_free(hb_params);
14679 }
Leo Chang9056f462013-08-01 19:21:11 -070014680 return 0;
14681 }
14682#endif /* FEATURE_WLAN_LPHB */
14683 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014684 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14685 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070014686 return -EOPNOTSUPP;
14687 }
14688
14689 return err;
14690}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014691
14692static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
14693{
14694 int ret;
14695
14696 vos_ssr_protect(__func__);
14697 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
14698 vos_ssr_unprotect(__func__);
14699
14700 return ret;
14701}
Leo Chang9056f462013-08-01 19:21:11 -070014702#endif /* CONFIG_NL80211_TESTMODE */
14703
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014704static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014705 struct net_device *dev,
14706 int idx, struct survey_info *survey)
14707{
14708 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14709 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053014710 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014711 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053014712 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014713 v_S7_t snr,rssi;
14714 int status, i, j, filled = 0;
14715
14716 ENTER();
14717
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014718 if (NULL == pAdapter)
14719 {
14720 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14721 "%s: HDD adapter is Null", __func__);
14722 return -ENODEV;
14723 }
14724
14725 if (NULL == wiphy)
14726 {
14727 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14728 "%s: wiphy is Null", __func__);
14729 return -ENODEV;
14730 }
14731
14732 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14733 status = wlan_hdd_validate_context(pHddCtx);
14734
14735 if (0 != status)
14736 {
14737 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14738 "%s: HDD context is not valid", __func__);
14739 return status;
14740 }
14741
Mihir Sheted9072e02013-08-21 17:02:29 +053014742 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14743
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014744 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053014745 0 != pAdapter->survey_idx ||
14746 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014747 {
14748 /* The survey dump ops when implemented completely is expected to
14749 * return a survey of all channels and the ops is called by the
14750 * kernel with incremental values of the argument 'idx' till it
14751 * returns -ENONET. But we can only support the survey for the
14752 * operating channel for now. survey_idx is used to track
14753 * that the ops is called only once and then return -ENONET for
14754 * the next iteration
14755 */
14756 pAdapter->survey_idx = 0;
14757 return -ENONET;
14758 }
14759
14760 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14761
14762 wlan_hdd_get_snr(pAdapter, &snr);
14763 wlan_hdd_get_rssi(pAdapter, &rssi);
14764
14765 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
14766 hdd_wlan_get_freq(channel, &freq);
14767
14768
14769 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
14770 {
14771 if (NULL == wiphy->bands[i])
14772 {
14773 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
14774 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
14775 continue;
14776 }
14777
14778 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
14779 {
14780 struct ieee80211_supported_band *band = wiphy->bands[i];
14781
14782 if (band->channels[j].center_freq == (v_U16_t)freq)
14783 {
14784 survey->channel = &band->channels[j];
14785 /* The Rx BDs contain SNR values in dB for the received frames
14786 * while the supplicant expects noise. So we calculate and
14787 * return the value of noise (dBm)
14788 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
14789 */
14790 survey->noise = rssi - snr;
14791 survey->filled = SURVEY_INFO_NOISE_DBM;
14792 filled = 1;
14793 }
14794 }
14795 }
14796
14797 if (filled)
14798 pAdapter->survey_idx = 1;
14799 else
14800 {
14801 pAdapter->survey_idx = 0;
14802 return -ENONET;
14803 }
14804
14805 return 0;
14806}
14807
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014808static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
14809 struct net_device *dev,
14810 int idx, struct survey_info *survey)
14811{
14812 int ret;
14813
14814 vos_ssr_protect(__func__);
14815 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
14816 vos_ssr_unprotect(__func__);
14817
14818 return ret;
14819}
14820
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014821/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053014822 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014823 * this is called when cfg80211 driver resume
14824 * driver updates latest sched_scan scan result(if any) to cfg80211 database
14825 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053014826int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014827{
14828 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
14829 hdd_adapter_t *pAdapter;
14830 hdd_adapter_list_node_t *pAdapterNode, *pNext;
14831 VOS_STATUS status = VOS_STATUS_SUCCESS;
14832
14833 ENTER();
14834
14835 if ( NULL == pHddCtx )
14836 {
14837 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14838 "%s: HddCtx validation failed", __func__);
14839 return 0;
14840 }
14841
14842 if (pHddCtx->isLogpInProgress)
14843 {
14844 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14845 "%s: LOGP in Progress. Ignore!!!", __func__);
14846 return 0;
14847 }
14848
Mihir Shete18156292014-03-11 15:38:30 +053014849 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014850 {
14851 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14852 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14853 return 0;
14854 }
14855
14856 spin_lock(&pHddCtx->schedScan_lock);
14857 pHddCtx->isWiphySuspended = FALSE;
14858 if (TRUE != pHddCtx->isSchedScanUpdatePending)
14859 {
14860 spin_unlock(&pHddCtx->schedScan_lock);
14861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14862 "%s: Return resume is not due to PNO indication", __func__);
14863 return 0;
14864 }
14865 // Reset flag to avoid updatating cfg80211 data old results again
14866 pHddCtx->isSchedScanUpdatePending = FALSE;
14867 spin_unlock(&pHddCtx->schedScan_lock);
14868
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053014869
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014870 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
14871
14872 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
14873 {
14874 pAdapter = pAdapterNode->pAdapter;
14875 if ( (NULL != pAdapter) &&
14876 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
14877 {
14878 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053014879 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014880 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
14881 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053014882 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014883 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053014884 {
14885 /* Acquire wakelock to handle the case where APP's tries to
14886 * suspend immediately after updating the scan results. Whis
14887 * results in app's is in suspended state and not able to
14888 * process the connect request to AP
14889 */
14890 hdd_prevent_suspend_timeout(2000);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014891 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053014892 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014893
14894 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14895 "%s : cfg80211 scan result database updated", __func__);
14896
14897 return 0;
14898
14899 }
14900 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
14901 pAdapterNode = pNext;
14902 }
14903
14904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14905 "%s: Failed to find Adapter", __func__);
14906 return 0;
14907}
14908
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053014909int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
14910{
14911 int ret;
14912
14913 vos_ssr_protect(__func__);
14914 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
14915 vos_ssr_unprotect(__func__);
14916
14917 return ret;
14918}
14919
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014920/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053014921 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014922 * this is called when cfg80211 driver suspends
14923 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053014924int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014925 struct cfg80211_wowlan *wow)
14926{
14927 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
14928
14929 ENTER();
14930 if (NULL == pHddCtx)
14931 {
14932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14933 "%s: HddCtx validation failed", __func__);
14934 return 0;
14935 }
14936
14937 pHddCtx->isWiphySuspended = TRUE;
14938
14939 EXIT();
14940
14941 return 0;
14942}
14943
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053014944int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
14945 struct cfg80211_wowlan *wow)
14946{
14947 int ret;
14948
14949 vos_ssr_protect(__func__);
14950 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
14951 vos_ssr_unprotect(__func__);
14952
14953 return ret;
14954}
Jeff Johnson295189b2012-06-20 16:38:30 -070014955/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014956static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070014957{
14958 .add_virtual_intf = wlan_hdd_add_virtual_intf,
14959 .del_virtual_intf = wlan_hdd_del_virtual_intf,
14960 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
14961 .change_station = wlan_hdd_change_station,
14962#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
14963 .add_beacon = wlan_hdd_cfg80211_add_beacon,
14964 .del_beacon = wlan_hdd_cfg80211_del_beacon,
14965 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014966#else
14967 .start_ap = wlan_hdd_cfg80211_start_ap,
14968 .change_beacon = wlan_hdd_cfg80211_change_beacon,
14969 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070014970#endif
14971 .change_bss = wlan_hdd_cfg80211_change_bss,
14972 .add_key = wlan_hdd_cfg80211_add_key,
14973 .get_key = wlan_hdd_cfg80211_get_key,
14974 .del_key = wlan_hdd_cfg80211_del_key,
14975 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080014976#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070014977 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080014978#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014979 .scan = wlan_hdd_cfg80211_scan,
14980 .connect = wlan_hdd_cfg80211_connect,
14981 .disconnect = wlan_hdd_cfg80211_disconnect,
14982 .join_ibss = wlan_hdd_cfg80211_join_ibss,
14983 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
14984 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
14985 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
14986 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070014987 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
14988 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053014989 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070014990#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
14991 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
14992 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
14993 .set_txq_params = wlan_hdd_set_txq_params,
14994#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014995 .get_station = wlan_hdd_cfg80211_get_station,
14996 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
14997 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014998 .add_station = wlan_hdd_cfg80211_add_station,
14999#ifdef FEATURE_WLAN_LFR
15000 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
15001 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
15002 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
15003#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070015004#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
15005 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
15006#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015007#ifdef FEATURE_WLAN_TDLS
15008 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
15009 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
15010#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015011#ifdef WLAN_FEATURE_GTK_OFFLOAD
15012 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
15013#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015014#ifdef FEATURE_WLAN_SCAN_PNO
15015 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
15016 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
15017#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053015018 .resume = wlan_hdd_cfg80211_resume_wlan,
15019 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015020 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070015021#ifdef WLAN_NL80211_TESTMODE
15022 .testmode_cmd = wlan_hdd_cfg80211_testmode,
15023#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015024 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070015025};
15026