blob: 68c3dfb9d11cbd1bbc0152034aacd2296dacd492 [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
146
Sunil Duttc69bccb2014-05-26 21:30:20 +0530147#ifdef WLAN_FEATURE_LINK_LAYER_STATS
148/*
149 * Used to allocate the size of 4096 for the link layer stats.
150 * The size of 4096 is considered assuming that all data per
151 * respective event fit with in the limit.Please take a call
152 * on the limit based on the data requirements on link layer
153 * statistics.
154 */
155#define LL_STATS_EVENT_BUF_SIZE 4096
156#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +0530157#ifdef WLAN_FEATURE_EXTSCAN
158/*
159 * Used to allocate the size of 4096 for the EXTScan NL data.
160 * The size of 4096 is considered assuming that all data per
161 * respective event fit with in the limit.Please take a call
162 * on the limit based on the data requirements.
163 */
164
165#define EXTSCAN_EVENT_BUF_SIZE 4096
166#define EXTSCAN_MAX_CACHED_RESULTS_PER_IND 32
167#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +0530168
Atul Mittal115287b2014-07-08 13:26:33 +0530169/*EXT TDLS*/
170/*
171 * Used to allocate the size of 4096 for the TDLS.
172 * The size of 4096 is considered assuming that all data per
173 * respective event fit with in the limit.Please take a call
174 * on the limit based on the data requirements on link layer
175 * statistics.
176 */
177#define EXTTDLS_EVENT_BUF_SIZE 4096
178
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530179static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700180{
181 WLAN_CIPHER_SUITE_WEP40,
182 WLAN_CIPHER_SUITE_WEP104,
183 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800184#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700185#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
186 WLAN_CIPHER_SUITE_KRK,
187 WLAN_CIPHER_SUITE_CCMP,
188#else
189 WLAN_CIPHER_SUITE_CCMP,
190#endif
191#ifdef FEATURE_WLAN_WAPI
192 WLAN_CIPHER_SUITE_SMS4,
193#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700194#ifdef WLAN_FEATURE_11W
195 WLAN_CIPHER_SUITE_AES_CMAC,
196#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700197};
198
199static inline int is_broadcast_ether_addr(const u8 *addr)
200{
201 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
202 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
203}
204
205static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530206{
Jeff Johnson295189b2012-06-20 16:38:30 -0700207 HDD2GHZCHAN(2412, 1, 0) ,
208 HDD2GHZCHAN(2417, 2, 0) ,
209 HDD2GHZCHAN(2422, 3, 0) ,
210 HDD2GHZCHAN(2427, 4, 0) ,
211 HDD2GHZCHAN(2432, 5, 0) ,
212 HDD2GHZCHAN(2437, 6, 0) ,
213 HDD2GHZCHAN(2442, 7, 0) ,
214 HDD2GHZCHAN(2447, 8, 0) ,
215 HDD2GHZCHAN(2452, 9, 0) ,
216 HDD2GHZCHAN(2457, 10, 0) ,
217 HDD2GHZCHAN(2462, 11, 0) ,
218 HDD2GHZCHAN(2467, 12, 0) ,
219 HDD2GHZCHAN(2472, 13, 0) ,
220 HDD2GHZCHAN(2484, 14, 0) ,
221};
222
Jeff Johnson295189b2012-06-20 16:38:30 -0700223static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
224{
225 HDD2GHZCHAN(2412, 1, 0) ,
226 HDD2GHZCHAN(2437, 6, 0) ,
227 HDD2GHZCHAN(2462, 11, 0) ,
228};
Jeff Johnson295189b2012-06-20 16:38:30 -0700229
230static struct ieee80211_channel hdd_channels_5_GHZ[] =
231{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700232 HDD5GHZCHAN(4920, 240, 0) ,
233 HDD5GHZCHAN(4940, 244, 0) ,
234 HDD5GHZCHAN(4960, 248, 0) ,
235 HDD5GHZCHAN(4980, 252, 0) ,
236 HDD5GHZCHAN(5040, 208, 0) ,
237 HDD5GHZCHAN(5060, 212, 0) ,
238 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700239 HDD5GHZCHAN(5180, 36, 0) ,
240 HDD5GHZCHAN(5200, 40, 0) ,
241 HDD5GHZCHAN(5220, 44, 0) ,
242 HDD5GHZCHAN(5240, 48, 0) ,
243 HDD5GHZCHAN(5260, 52, 0) ,
244 HDD5GHZCHAN(5280, 56, 0) ,
245 HDD5GHZCHAN(5300, 60, 0) ,
246 HDD5GHZCHAN(5320, 64, 0) ,
247 HDD5GHZCHAN(5500,100, 0) ,
248 HDD5GHZCHAN(5520,104, 0) ,
249 HDD5GHZCHAN(5540,108, 0) ,
250 HDD5GHZCHAN(5560,112, 0) ,
251 HDD5GHZCHAN(5580,116, 0) ,
252 HDD5GHZCHAN(5600,120, 0) ,
253 HDD5GHZCHAN(5620,124, 0) ,
254 HDD5GHZCHAN(5640,128, 0) ,
255 HDD5GHZCHAN(5660,132, 0) ,
256 HDD5GHZCHAN(5680,136, 0) ,
257 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800258#ifdef FEATURE_WLAN_CH144
259 HDD5GHZCHAN(5720,144, 0) ,
260#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700261 HDD5GHZCHAN(5745,149, 0) ,
262 HDD5GHZCHAN(5765,153, 0) ,
263 HDD5GHZCHAN(5785,157, 0) ,
264 HDD5GHZCHAN(5805,161, 0) ,
265 HDD5GHZCHAN(5825,165, 0) ,
266};
267
268static struct ieee80211_rate g_mode_rates[] =
269{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530270 HDD_G_MODE_RATETAB(10, 0x1, 0),
271 HDD_G_MODE_RATETAB(20, 0x2, 0),
272 HDD_G_MODE_RATETAB(55, 0x4, 0),
273 HDD_G_MODE_RATETAB(110, 0x8, 0),
274 HDD_G_MODE_RATETAB(60, 0x10, 0),
275 HDD_G_MODE_RATETAB(90, 0x20, 0),
276 HDD_G_MODE_RATETAB(120, 0x40, 0),
277 HDD_G_MODE_RATETAB(180, 0x80, 0),
278 HDD_G_MODE_RATETAB(240, 0x100, 0),
279 HDD_G_MODE_RATETAB(360, 0x200, 0),
280 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700281 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530282};
Jeff Johnson295189b2012-06-20 16:38:30 -0700283
284static struct ieee80211_rate a_mode_rates[] =
285{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530286 HDD_G_MODE_RATETAB(60, 0x10, 0),
287 HDD_G_MODE_RATETAB(90, 0x20, 0),
288 HDD_G_MODE_RATETAB(120, 0x40, 0),
289 HDD_G_MODE_RATETAB(180, 0x80, 0),
290 HDD_G_MODE_RATETAB(240, 0x100, 0),
291 HDD_G_MODE_RATETAB(360, 0x200, 0),
292 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700293 HDD_G_MODE_RATETAB(540, 0x800, 0),
294};
295
296static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
297{
298 .channels = hdd_channels_2_4_GHZ,
299 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
300 .band = IEEE80211_BAND_2GHZ,
301 .bitrates = g_mode_rates,
302 .n_bitrates = g_mode_rates_size,
303 .ht_cap.ht_supported = 1,
304 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
305 | IEEE80211_HT_CAP_GRN_FLD
306 | IEEE80211_HT_CAP_DSSSCCK40
307 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
308 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
309 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
310 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
311 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
312 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
313};
314
Jeff Johnson295189b2012-06-20 16:38:30 -0700315static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
316{
317 .channels = hdd_social_channels_2_4_GHZ,
318 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
319 .band = IEEE80211_BAND_2GHZ,
320 .bitrates = g_mode_rates,
321 .n_bitrates = g_mode_rates_size,
322 .ht_cap.ht_supported = 1,
323 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
324 | IEEE80211_HT_CAP_GRN_FLD
325 | IEEE80211_HT_CAP_DSSSCCK40
326 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
327 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
328 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
329 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
330 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
331 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
332};
Jeff Johnson295189b2012-06-20 16:38:30 -0700333
334static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
335{
336 .channels = hdd_channels_5_GHZ,
337 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
338 .band = IEEE80211_BAND_5GHZ,
339 .bitrates = a_mode_rates,
340 .n_bitrates = a_mode_rates_size,
341 .ht_cap.ht_supported = 1,
342 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
343 | IEEE80211_HT_CAP_GRN_FLD
344 | IEEE80211_HT_CAP_DSSSCCK40
345 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
346 | IEEE80211_HT_CAP_SGI_40
347 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
348 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
349 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
350 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
351 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
352 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
353};
354
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530355/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700356 TX/RX direction for each kind of interface */
357static const struct ieee80211_txrx_stypes
358wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
359 [NL80211_IFTYPE_STATION] = {
360 .tx = 0xffff,
361 .rx = BIT(SIR_MAC_MGMT_ACTION) |
362 BIT(SIR_MAC_MGMT_PROBE_REQ),
363 },
364 [NL80211_IFTYPE_AP] = {
365 .tx = 0xffff,
366 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
367 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
368 BIT(SIR_MAC_MGMT_PROBE_REQ) |
369 BIT(SIR_MAC_MGMT_DISASSOC) |
370 BIT(SIR_MAC_MGMT_AUTH) |
371 BIT(SIR_MAC_MGMT_DEAUTH) |
372 BIT(SIR_MAC_MGMT_ACTION),
373 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700374 [NL80211_IFTYPE_ADHOC] = {
375 .tx = 0xffff,
376 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
377 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
378 BIT(SIR_MAC_MGMT_PROBE_REQ) |
379 BIT(SIR_MAC_MGMT_DISASSOC) |
380 BIT(SIR_MAC_MGMT_AUTH) |
381 BIT(SIR_MAC_MGMT_DEAUTH) |
382 BIT(SIR_MAC_MGMT_ACTION),
383 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700384 [NL80211_IFTYPE_P2P_CLIENT] = {
385 .tx = 0xffff,
386 .rx = BIT(SIR_MAC_MGMT_ACTION) |
387 BIT(SIR_MAC_MGMT_PROBE_REQ),
388 },
389 [NL80211_IFTYPE_P2P_GO] = {
390 /* This is also same as for SoftAP */
391 .tx = 0xffff,
392 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
393 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
394 BIT(SIR_MAC_MGMT_PROBE_REQ) |
395 BIT(SIR_MAC_MGMT_DISASSOC) |
396 BIT(SIR_MAC_MGMT_AUTH) |
397 BIT(SIR_MAC_MGMT_DEAUTH) |
398 BIT(SIR_MAC_MGMT_ACTION),
399 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700400};
401
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800402#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800403static const struct ieee80211_iface_limit
404wlan_hdd_iface_limit[] = {
405 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800406 /* max = 3 ; Our driver create two interfaces during driver init
407 * wlan0 and p2p0 interfaces. p2p0 is considered as station
408 * interface until a group is formed. In JB architecture, once the
409 * group is formed, interface type of p2p0 is changed to P2P GO or
410 * Client.
411 * When supplicant remove the group, it first issue a set interface
412 * cmd to change the mode back to Station. In JB this works fine as
413 * we advertize two station type interface during driver init.
414 * Some vendors create separate interface for P2P GO/Client,
415 * after group formation(Third one). But while group remove
416 * supplicant first tries to change the mode(3rd interface) to STATION
417 * But as we advertized only two sta type interfaces nl80211 was
418 * returning error for the third one which was leading to failure in
419 * delete interface. Ideally while removing the group, supplicant
420 * should not try to change the 3rd interface mode to Station type.
421 * Till we get a fix in wpa_supplicant, we advertize max STA
422 * interface type to 3
423 */
424 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800425 .types = BIT(NL80211_IFTYPE_STATION),
426 },
427 {
428 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700429 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800430 },
431 {
432 .max = 1,
433 .types = BIT(NL80211_IFTYPE_P2P_GO) |
434 BIT(NL80211_IFTYPE_P2P_CLIENT),
435 },
436};
437
438/* By default, only single channel concurrency is allowed */
439static struct ieee80211_iface_combination
440wlan_hdd_iface_combination = {
441 .limits = wlan_hdd_iface_limit,
442 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800443 /*
444 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
445 * and p2p0 interfaces during driver init
446 * Some vendors create separate interface for P2P operations.
447 * wlan0: STA interface
448 * p2p0: P2P Device interface, action frames goes
449 * through this interface.
450 * p2p-xx: P2P interface, After GO negotiation this interface is
451 * created for p2p operations(GO/CLIENT interface).
452 */
453 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800454 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
455 .beacon_int_infra_match = false,
456};
457#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800458
Jeff Johnson295189b2012-06-20 16:38:30 -0700459static struct cfg80211_ops wlan_hdd_cfg80211_ops;
460
461/* Data rate 100KBPS based on IE Index */
462struct index_data_rate_type
463{
464 v_U8_t beacon_rate_index;
465 v_U16_t supported_rate[4];
466};
467
468/* 11B, 11G Rate table include Basic rate and Extended rate
469 The IDX field is the rate index
470 The HI field is the rate when RSSI is strong or being ignored
471 (in this case we report actual rate)
472 The MID field is the rate when RSSI is moderate
473 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
474 The LO field is the rate when RSSI is low
475 (in this case we don't report rates, actual current rate used)
476 */
477static const struct
478{
479 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700480 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700481} supported_data_rate[] =
482{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700483/* IDX HI HM LM LO (RSSI-based index */
484 {2, { 10, 10, 10, 0}},
485 {4, { 20, 20, 10, 0}},
486 {11, { 55, 20, 10, 0}},
487 {12, { 60, 55, 20, 0}},
488 {18, { 90, 55, 20, 0}},
489 {22, {110, 55, 20, 0}},
490 {24, {120, 90, 60, 0}},
491 {36, {180, 120, 60, 0}},
492 {44, {220, 180, 60, 0}},
493 {48, {240, 180, 90, 0}},
494 {66, {330, 180, 90, 0}},
495 {72, {360, 240, 90, 0}},
496 {96, {480, 240, 120, 0}},
497 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700498};
499
500/* MCS Based rate table */
501static struct index_data_rate_type supported_mcs_rate[] =
502{
503/* MCS L20 L40 S20 S40 */
504 {0, {65, 135, 72, 150}},
505 {1, {130, 270, 144, 300}},
506 {2, {195, 405, 217, 450}},
507 {3, {260, 540, 289, 600}},
508 {4, {390, 810, 433, 900}},
509 {5, {520, 1080, 578, 1200}},
510 {6, {585, 1215, 650, 1350}},
511 {7, {650, 1350, 722, 1500}}
512};
513
Leo Chang6f8870f2013-03-26 18:11:36 -0700514#ifdef WLAN_FEATURE_11AC
515
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530516#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700517
518struct index_vht_data_rate_type
519{
520 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530521 v_U16_t supported_VHT80_rate[2];
522 v_U16_t supported_VHT40_rate[2];
523 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700524};
525
526typedef enum
527{
528 DATA_RATE_11AC_MAX_MCS_7,
529 DATA_RATE_11AC_MAX_MCS_8,
530 DATA_RATE_11AC_MAX_MCS_9,
531 DATA_RATE_11AC_MAX_MCS_NA
532} eDataRate11ACMaxMcs;
533
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +0530534/* SSID broadcast type */
535typedef enum eSSIDBcastType
536{
537 eBCAST_UNKNOWN = 0,
538 eBCAST_NORMAL = 1,
539 eBCAST_HIDDEN = 2,
540} tSSIDBcastType;
541
Leo Chang6f8870f2013-03-26 18:11:36 -0700542/* MCS Based VHT rate table */
543static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
544{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530545/* MCS L80 S80 L40 S40 L20 S40*/
546 {0, {293, 325}, {135, 150}, {65, 72}},
547 {1, {585, 650}, {270, 300}, {130, 144}},
548 {2, {878, 975}, {405, 450}, {195, 217}},
549 {3, {1170, 1300}, {540, 600}, {260, 289}},
550 {4, {1755, 1950}, {810, 900}, {390, 433}},
551 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
552 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
553 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
554 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
555 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700556};
557#endif /* WLAN_FEATURE_11AC */
558
c_hpothu79aab322014-07-14 21:11:01 +0530559/*array index points to MCS and array value points respective rssi*/
560static int rssiMcsTbl[][10] =
561{
562/*MCS 0 1 2 3 4 5 6 7 8 9*/
563 {-82, -79, -77, -74, -70, -66, -65, -64, -59, -57}, //20
564 {-79, -76, -74, -71, -67, -63, -62, -61, -56, -54}, //40
565 {-76, -73, -71, -68, -64, -60, -59, -58, -53, -51} //80
566};
567
Jeff Johnson295189b2012-06-20 16:38:30 -0700568extern struct net_device_ops net_ops_struct;
Dasari Srinivas7875a302014-09-26 17:50:57 +0530569#ifdef FEATURE_WLAN_SCAN_PNO
570static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter);
571#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700572
Leo Chang9056f462013-08-01 19:21:11 -0700573#ifdef WLAN_NL80211_TESTMODE
574enum wlan_hdd_tm_attr
575{
576 WLAN_HDD_TM_ATTR_INVALID = 0,
577 WLAN_HDD_TM_ATTR_CMD = 1,
578 WLAN_HDD_TM_ATTR_DATA = 2,
579 WLAN_HDD_TM_ATTR_TYPE = 3,
580 /* keep last */
581 WLAN_HDD_TM_ATTR_AFTER_LAST,
582 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
583};
584
585enum wlan_hdd_tm_cmd
586{
587 WLAN_HDD_TM_CMD_WLAN_HB = 1,
588};
589
590#define WLAN_HDD_TM_DATA_MAX_LEN 5000
591
592static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
593{
594 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
595 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
596 .len = WLAN_HDD_TM_DATA_MAX_LEN },
597};
598#endif /* WLAN_NL80211_TESTMODE */
599
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800600#ifdef FEATURE_WLAN_CH_AVOID
601/*
602 * FUNCTION: wlan_hdd_send_avoid_freq_event
603 * This is called when wlan driver needs to send vendor specific
604 * avoid frequency range event to userspace
605 */
606int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
607 tHddAvoidFreqList *pAvoidFreqList)
608{
609 struct sk_buff *vendor_event;
610
611 ENTER();
612
613 if (!pHddCtx)
614 {
615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
616 "%s: HDD context is null", __func__);
617 return -1;
618 }
619
620 if (!pAvoidFreqList)
621 {
622 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
623 "%s: pAvoidFreqList is null", __func__);
624 return -1;
625 }
626
627 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
628 sizeof(tHddAvoidFreqList),
Sunil Duttc69bccb2014-05-26 21:30:20 +0530629 QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800630 GFP_KERNEL);
631 if (!vendor_event)
632 {
633 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
634 "%s: cfg80211_vendor_event_alloc failed", __func__);
635 return -1;
636 }
637
638 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
639 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
640
641 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
642
643 EXIT();
644 return 0;
645}
646#endif /* FEATURE_WLAN_CH_AVOID */
647
Sunil Duttc69bccb2014-05-26 21:30:20 +0530648#ifdef WLAN_FEATURE_LINK_LAYER_STATS
649
650static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
651 struct sk_buff *vendor_event)
652{
653 if (nla_put_u8(vendor_event,
654 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
655 stats->rate.preamble) ||
656 nla_put_u8(vendor_event,
657 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
658 stats->rate.nss) ||
659 nla_put_u8(vendor_event,
660 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
661 stats->rate.bw) ||
662 nla_put_u8(vendor_event,
663 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
664 stats->rate.rateMcsIdx) ||
665 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
666 stats->rate.bitrate ) ||
667 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
668 stats->txMpdu ) ||
669 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
670 stats->rxMpdu ) ||
671 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
672 stats->mpduLost ) ||
673 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
674 stats->retries) ||
675 nla_put_u32(vendor_event,
676 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
677 stats->retriesShort ) ||
678 nla_put_u32(vendor_event,
679 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
680 stats->retriesLong))
681 {
682 hddLog(VOS_TRACE_LEVEL_ERROR,
683 FL("QCA_WLAN_VENDOR_ATTR put fail"));
684 return FALSE;
685 }
686 return TRUE;
687}
688
689static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
690 struct sk_buff *vendor_event)
691{
692 u32 i = 0;
693 struct nlattr *rateInfo;
694 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
695 stats->type) ||
696 nla_put(vendor_event,
697 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
698 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
699 nla_put_u32(vendor_event,
700 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
701 stats->capabilities) ||
702 nla_put_u32(vendor_event,
703 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
704 stats->numRate))
705 {
706 hddLog(VOS_TRACE_LEVEL_ERROR,
707 FL("QCA_WLAN_VENDOR_ATTR put fail"));
708 goto error;
709 }
710
711 rateInfo = nla_nest_start(vendor_event,
712 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
713 for (i = 0; i < stats->numRate; i++)
714 {
715 struct nlattr *rates;
716 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
717 stats->rateStats +
718 (i * sizeof(tSirWifiRateStat)));
719 rates = nla_nest_start(vendor_event, i);
720
721 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
722 {
723 hddLog(VOS_TRACE_LEVEL_ERROR,
724 FL("QCA_WLAN_VENDOR_ATTR put fail"));
725 return FALSE;
726 }
727 nla_nest_end(vendor_event, rates);
728 }
729 nla_nest_end(vendor_event, rateInfo);
730
731 return TRUE;
732error:
733 return FALSE;
734}
735
736static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
737 struct sk_buff *vendor_event)
738{
739 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
740 stats->ac ) ||
741 nla_put_u32(vendor_event,
742 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
743 stats->txMpdu ) ||
744 nla_put_u32(vendor_event,
745 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
746 stats->rxMpdu ) ||
747 nla_put_u32(vendor_event,
748 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
749 stats->txMcast ) ||
750 nla_put_u32(vendor_event,
751 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
752 stats->rxMcast ) ||
753 nla_put_u32(vendor_event,
754 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
755 stats->rxAmpdu ) ||
756 nla_put_u32(vendor_event,
757 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
758 stats->txAmpdu ) ||
759 nla_put_u32(vendor_event,
760 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
761 stats->mpduLost )||
762 nla_put_u32(vendor_event,
763 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
764 stats->retries ) ||
765 nla_put_u32(vendor_event,
766 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
767 stats->retriesShort ) ||
768 nla_put_u32(vendor_event,
769 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
770 stats->retriesLong ) ||
771 nla_put_u32(vendor_event,
772 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
773 stats->contentionTimeMin ) ||
774 nla_put_u32(vendor_event,
775 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
776 stats->contentionTimeMax ) ||
777 nla_put_u32(vendor_event,
778 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
779 stats->contentionTimeAvg ) ||
780 nla_put_u32(vendor_event,
781 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
782 stats->contentionNumSamples ))
783 {
784 hddLog(VOS_TRACE_LEVEL_ERROR,
785 FL("QCA_WLAN_VENDOR_ATTR put fail") );
786 return FALSE;
787 }
788 return TRUE;
789}
790
791static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
792 struct sk_buff *vendor_event)
793{
Dino Myclec8f3f332014-07-21 16:48:27 +0530794 if (nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530795 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
796 nla_put(vendor_event,
797 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
798 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
799 nla_put_u32(vendor_event,
800 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
801 stats->state ) ||
802 nla_put_u32(vendor_event,
803 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
804 stats->roaming ) ||
805 nla_put_u32(vendor_event,
806 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
807 stats->capabilities ) ||
808 nla_put(vendor_event,
809 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
810 strlen(stats->ssid), stats->ssid) ||
811 nla_put(vendor_event,
812 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
813 WNI_CFG_BSSID_LEN, stats->bssid) ||
814 nla_put(vendor_event,
815 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
816 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
817 nla_put(vendor_event,
818 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
819 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
820 )
821 {
822 hddLog(VOS_TRACE_LEVEL_ERROR,
823 FL("QCA_WLAN_VENDOR_ATTR put fail") );
824 return FALSE;
825 }
826 return TRUE;
827}
828
Dino Mycle3b9536d2014-07-09 22:05:24 +0530829static v_BOOL_t put_wifi_iface_stats(hdd_adapter_t *pAdapter,
830 tpSirWifiIfaceStat pWifiIfaceStat,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530831 struct sk_buff *vendor_event)
832{
833 int i = 0;
834 struct nlattr *wmmInfo;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530835 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
836 WLANTL_InterfaceStatsType *pWifiIfaceStatTL = NULL;
837
Sunil Duttc69bccb2014-05-26 21:30:20 +0530838 if (FALSE == put_wifi_interface_info(
839 &pWifiIfaceStat->info,
840 vendor_event))
841 {
842 hddLog(VOS_TRACE_LEVEL_ERROR,
843 FL("QCA_WLAN_VENDOR_ATTR put fail") );
844 return FALSE;
845
846 }
Dino Mycle3b9536d2014-07-09 22:05:24 +0530847 pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *)
848 vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType));
849 if (NULL == pWifiIfaceStatTL)
850 {
851 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
852 return FALSE;
853 }
854
855
856 if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED)
857 {
858 if (VOS_STATUS_SUCCESS ==
859 WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
860 pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL))
861 {
862 /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are
863 * obtained from TL structure
864 */
865
866 pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx +
867 pWifiIfaceStatTL->mgmtRx;
868 pWifiIfaceStat->mgmtActionRx = pWifiIfaceStatTL->mgmtActionRx;
869 pWifiIfaceStat->mgmtActionTx = pWifiIfaceStatTL->mgmtActionTx;
870 pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData;
871
872 vos_mem_copy(
873 (void *) &pWifiIfaceStat->AccessclassStats[WIFI_AC_VO],
874 (void *) &pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO],
875 sizeof(WLANTL_AccessCategoryStatsType));
876
877 vos_mem_copy(
878 (void *) &pWifiIfaceStat->AccessclassStats[WIFI_AC_VI],
879 (void *) &pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI],
880 sizeof(WLANTL_AccessCategoryStatsType));
881
882 vos_mem_copy(
883 (void *) &pWifiIfaceStat->AccessclassStats[WIFI_AC_BE],
884 (void *) &pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE],
885 sizeof(WLANTL_AccessCategoryStatsType));
886
887 vos_mem_copy(
888 (void *) &pWifiIfaceStat->AccessclassStats[WIFI_AC_BK],
889 (void *) &pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK],
890 sizeof(WLANTL_AccessCategoryStatsType));
891 }
892 else
893 {
894 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL"));
895 }
896
897 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMpdu =
898 pAdapter->hdd_stats.hddTxRxStats.txFetchedAC[WLANTL_AC_VO];
899 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMpdu =
900 pAdapter->hdd_stats.hddTxRxStats.txFetchedAC[WLANTL_AC_VI];
901 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMpdu =
902 pAdapter->hdd_stats.hddTxRxStats.txFetchedAC[WLANTL_AC_BE];
903 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMpdu =
904 pAdapter->hdd_stats.hddTxRxStats.txFetchedAC[WLANTL_AC_BK];
905
906 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast =
907 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO];
908 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast =
909 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI];
910 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast =
911 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE];
912 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast =
913 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK];
914 }
915 else
916 {
917 hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated"));
918 }
919
920
Sunil Duttc69bccb2014-05-26 21:30:20 +0530921
922 if (nla_put_u32(vendor_event,
923 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
924 pWifiIfaceStat->beaconRx) ||
925 nla_put_u32(vendor_event,
926 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
927 pWifiIfaceStat->mgmtRx) ||
928 nla_put_u32(vendor_event,
929 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
930 pWifiIfaceStat->mgmtActionRx) ||
931 nla_put_u32(vendor_event,
932 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
933 pWifiIfaceStat->mgmtActionTx) ||
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_MGMT,
936 pWifiIfaceStat->rssiMgmt) ||
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_DATA,
939 pWifiIfaceStat->rssiData) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +0530940 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530941 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
942 pWifiIfaceStat->rssiAck))
943 {
944 hddLog(VOS_TRACE_LEVEL_ERROR,
945 FL("QCA_WLAN_VENDOR_ATTR put fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +0530946 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +0530947 return FALSE;
948 }
949
950 wmmInfo = nla_nest_start(vendor_event,
951 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
952 for (i = 0; i < WIFI_AC_MAX; i++)
953 {
954 struct nlattr *wmmStats;
955 wmmStats = nla_nest_start(vendor_event, i);
956 if (FALSE == put_wifi_wmm_ac_stat(
957 &pWifiIfaceStat->AccessclassStats[i],
958 vendor_event))
959 {
960 hddLog(VOS_TRACE_LEVEL_ERROR,
961 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +0530962 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +0530963 return FALSE;
964 }
965
966 nla_nest_end(vendor_event, wmmStats);
967 }
968 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +0530969 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +0530970 return TRUE;
971}
972
973static tSirWifiInterfaceMode
974 hdd_map_device_to_ll_iface_mode ( int deviceMode )
975{
976 switch (deviceMode)
977 {
978 case WLAN_HDD_INFRA_STATION:
979 return WIFI_INTERFACE_STA;
980 case WLAN_HDD_SOFTAP:
981 return WIFI_INTERFACE_SOFTAP;
982 case WLAN_HDD_P2P_CLIENT:
983 return WIFI_INTERFACE_P2P_CLIENT;
984 case WLAN_HDD_P2P_GO:
985 return WIFI_INTERFACE_P2P_GO;
986 case WLAN_HDD_IBSS:
987 return WIFI_INTERFACE_IBSS;
988 default:
Dino Myclec8f3f332014-07-21 16:48:27 +0530989 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530990 }
991}
992
993static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
994 tpSirWifiInterfaceInfo pInfo)
995{
996 v_U8_t *staMac = NULL;
997 hdd_station_ctx_t *pHddStaCtx;
998 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
999 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1000
1001 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
1002
1003 vos_mem_copy(pInfo->macAddr,
1004 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1005
1006 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1007 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
1008 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
1009 {
1010 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1011 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
1012 {
1013 pInfo->state = WIFI_DISCONNECTED;
1014 }
1015 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
1016 {
1017 hddLog(VOS_TRACE_LEVEL_ERROR,
1018 "%s: Session ID %d, Connection is in progress", __func__,
1019 pAdapter->sessionId);
1020 pInfo->state = WIFI_ASSOCIATING;
1021 }
1022 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1023 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
1024 {
1025 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
1026 hddLog(VOS_TRACE_LEVEL_ERROR,
1027 "%s: client " MAC_ADDRESS_STR
1028 " is in the middle of WPS/EAPOL exchange.", __func__,
1029 MAC_ADDR_ARRAY(staMac));
1030 pInfo->state = WIFI_AUTHENTICATING;
1031 }
1032 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1033 {
1034 pInfo->state = WIFI_ASSOCIATED;
1035 vos_mem_copy(pInfo->bssid,
1036 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
1037 vos_mem_copy(pInfo->ssid,
1038 pHddStaCtx->conn_info.SSID.SSID.ssId,
1039 pHddStaCtx->conn_info.SSID.SSID.length);
1040 //NULL Terminate the string.
1041 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
1042 }
1043 }
1044 vos_mem_copy(pInfo->countryStr,
1045 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1046
1047 vos_mem_copy(pInfo->apCountryStr,
1048 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1049
1050 return TRUE;
1051}
1052
1053/*
1054 * hdd_link_layer_process_peer_stats () - This function is called after
1055 * receiving Link Layer Peer statistics from FW.This function converts
1056 * the firmware data to the NL data and sends the same to the kernel/upper
1057 * layers.
1058 */
1059static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
1060 v_VOID_t *pData)
1061{
1062 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1063 tpSirWifiRateStat pWifiRateStat;
1064 tpSirWifiPeerStat pWifiPeerStat;
1065 tpSirWifiPeerInfo pWifiPeerInfo;
1066 struct nlattr *peerInfo;
1067 struct sk_buff *vendor_event;
1068 int status, i;
1069
1070 status = wlan_hdd_validate_context(pHddCtx);
1071 if (0 != status)
1072 {
1073 hddLog(VOS_TRACE_LEVEL_ERROR,
1074 FL("HDD context is not valid") );
1075 return;
1076 }
1077
1078 pWifiPeerStat = (tpSirWifiPeerStat) pData;
1079
1080 hddLog(VOS_TRACE_LEVEL_INFO,
1081 "LL_STATS_PEER_ALL : numPeers %u",
1082 pWifiPeerStat->numPeers);
1083 {
1084 for (i = 0; i < pWifiPeerStat->numPeers; i++)
1085 {
1086 pWifiPeerInfo = (tpSirWifiPeerInfo)
1087 ((uint8 *)pWifiPeerStat->peerInfo +
1088 ( i * sizeof(tSirWifiPeerInfo)));
1089
1090 hddLog(VOS_TRACE_LEVEL_INFO,
1091 " %d) LL_STATS Channel Stats "
1092 " Peer Type %u "
1093 " peerMacAddress %pM "
1094 " capabilities 0x%x "
1095 " numRate %u ",
1096 i,
1097 pWifiPeerInfo->type,
1098 pWifiPeerInfo->peerMacAddress,
1099 pWifiPeerInfo->capabilities,
1100 pWifiPeerInfo->numRate);
1101 {
1102 int j;
1103 for (j = 0; j < pWifiPeerInfo->numRate; j++)
1104 {
1105 pWifiRateStat = (tpSirWifiRateStat)
1106 ((tANI_U8 *) pWifiPeerInfo->rateStats +
1107 ( j * sizeof(tSirWifiRateStat)));
1108
1109 hddLog(VOS_TRACE_LEVEL_INFO,
1110 " peer Rate Stats "
1111 " preamble %u "
1112 " nss %u "
1113 " bw %u "
1114 " rateMcsIdx %u "
1115 " reserved %u "
1116 " bitrate %u "
1117 " txMpdu %u "
1118 " rxMpdu %u "
1119 " mpduLost %u "
1120 " retries %u "
1121 " retriesShort %u "
1122 " retriesLong %u",
1123 pWifiRateStat->rate.preamble,
1124 pWifiRateStat->rate.nss,
1125 pWifiRateStat->rate.bw,
1126 pWifiRateStat->rate.rateMcsIdx,
1127 pWifiRateStat->rate.reserved,
1128 pWifiRateStat->rate.bitrate,
1129 pWifiRateStat->txMpdu,
1130 pWifiRateStat->rxMpdu,
1131 pWifiRateStat->mpduLost,
1132 pWifiRateStat->retries,
1133 pWifiRateStat->retriesShort,
1134 pWifiRateStat->retriesLong);
1135 }
1136 }
1137 }
1138 }
1139
1140 /*
1141 * Allocate a size of 4096 for the peer stats comprising
1142 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1143 * sizeof (tSirWifiRateStat).Each field is put with an
1144 * NL attribute.The size of 4096 is considered assuming
1145 * that number of rates shall not exceed beyond 50 with
1146 * the sizeof (tSirWifiRateStat) being 32.
1147 */
1148 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1149 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1150 QCA_NL80211_VENDOR_SUBCMD_LL_PEER_INFO_STATS_INDEX,
1151 GFP_KERNEL);
1152 if (!vendor_event)
1153 {
1154 hddLog(VOS_TRACE_LEVEL_ERROR,
1155 "%s: cfg80211_vendor_event_alloc failed",
1156 __func__);
1157 return;
1158 }
1159 if (nla_put_u32(vendor_event,
1160 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1161 pWifiPeerStat->numPeers))
1162 {
1163 hddLog(VOS_TRACE_LEVEL_ERROR,
1164 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1165 kfree_skb(vendor_event);
1166 return;
1167 }
1168
1169 peerInfo = nla_nest_start(vendor_event,
1170 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
1171
1172 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1173 pWifiPeerStat->peerInfo);
1174
1175 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1176 {
1177 struct nlattr *peers = nla_nest_start(vendor_event, i);
1178 int numRate = pWifiPeerInfo->numRate;
1179
1180 if (FALSE == put_wifi_peer_info(
1181 pWifiPeerInfo, vendor_event))
1182 {
1183 hddLog(VOS_TRACE_LEVEL_ERROR,
1184 "%s: put_wifi_peer_info put fail", __func__);
1185 kfree_skb(vendor_event);
1186 return;
1187 }
1188
1189 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1190 pWifiPeerStat->peerInfo +
1191 (i * sizeof(tSirWifiPeerInfo)) +
1192 (numRate * sizeof (tSirWifiRateStat)));
1193 nla_nest_end(vendor_event, peers);
1194 }
1195 nla_nest_end(vendor_event, peerInfo);
1196 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
1197}
1198
1199/*
1200 * hdd_link_layer_process_iface_stats () - This function is called after
1201 * receiving Link Layer Interface statistics from FW.This function converts
1202 * the firmware data to the NL data and sends the same to the kernel/upper
1203 * layers.
1204 */
1205static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1206 v_VOID_t *pData)
1207{
1208 tpSirWifiIfaceStat pWifiIfaceStat;
1209 struct sk_buff *vendor_event;
1210 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1211 int status;
1212
1213 status = wlan_hdd_validate_context(pHddCtx);
1214 if (0 != status)
1215 {
1216 hddLog(VOS_TRACE_LEVEL_ERROR,
1217 FL("HDD context is not valid") );
1218 return;
1219 }
1220 /*
1221 * Allocate a size of 4096 for the interface stats comprising
1222 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1223 * assuming that all these fit with in the limit.Please take
1224 * a call on the limit based on the data requirements on
1225 * interface statistics.
1226 */
1227 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1228 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1229 QCA_NL80211_VENDOR_SUBCMD_LL_IFACE_STATS_INDEX,
1230 GFP_KERNEL);
1231 if (!vendor_event)
1232 {
1233 hddLog(VOS_TRACE_LEVEL_ERROR,
1234 FL("cfg80211_vendor_event_alloc failed") );
1235 return;
1236 }
1237
1238 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1239
Dino Mycle3b9536d2014-07-09 22:05:24 +05301240
1241 if (FALSE == hdd_get_interface_info( pAdapter,
1242 &pWifiIfaceStat->info))
1243 {
1244 hddLog(VOS_TRACE_LEVEL_ERROR,
1245 FL("hdd_get_interface_info get fail") );
1246 kfree_skb(vendor_event);
1247 return;
1248 }
1249
1250 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
1251 vendor_event))
1252 {
1253 hddLog(VOS_TRACE_LEVEL_ERROR,
1254 FL("put_wifi_iface_stats fail") );
1255 kfree_skb(vendor_event);
1256 return;
1257 }
1258
Sunil Duttc69bccb2014-05-26 21:30:20 +05301259 hddLog(VOS_TRACE_LEVEL_INFO,
1260 "WMI_LINK_STATS_IFACE Data");
1261
1262 hddLog(VOS_TRACE_LEVEL_INFO,
1263 "LL_STATS_IFACE: "
1264 " Mode %u "
1265 " MAC %pM "
1266 " State %u "
1267 " Roaming %u "
1268 " capabilities 0x%x "
1269 " SSID %s "
1270 " BSSID %pM",
1271 pWifiIfaceStat->info.mode,
1272 pWifiIfaceStat->info.macAddr,
1273 pWifiIfaceStat->info.state,
1274 pWifiIfaceStat->info.roaming,
1275 pWifiIfaceStat->info.capabilities,
1276 pWifiIfaceStat->info.ssid,
1277 pWifiIfaceStat->info.bssid);
1278
1279 hddLog(VOS_TRACE_LEVEL_INFO,
1280 " AP country str: %c%c%c",
1281 pWifiIfaceStat->info.apCountryStr[0],
1282 pWifiIfaceStat->info.apCountryStr[1],
1283 pWifiIfaceStat->info.apCountryStr[2]);
1284
1285
1286 hddLog(VOS_TRACE_LEVEL_INFO,
1287 " Country Str Association: %c%c%c",
1288 pWifiIfaceStat->info.countryStr[0],
1289 pWifiIfaceStat->info.countryStr[1],
1290 pWifiIfaceStat->info.countryStr[2]);
1291
1292 hddLog(VOS_TRACE_LEVEL_INFO,
1293 " beaconRx %u "
1294 " mgmtRx %u "
1295 " mgmtActionRx %u "
1296 " mgmtActionTx %u "
Dino Mycle3b9536d2014-07-09 22:05:24 +05301297 " rssiMgmt %d "
1298 " rssiData %d "
1299 " rssiAck %d",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301300 pWifiIfaceStat->beaconRx,
1301 pWifiIfaceStat->mgmtRx,
1302 pWifiIfaceStat->mgmtActionRx,
1303 pWifiIfaceStat->mgmtActionTx,
1304 pWifiIfaceStat->rssiMgmt,
1305 pWifiIfaceStat->rssiData,
1306 pWifiIfaceStat->rssiAck );
1307
1308
1309 {
1310 int i;
1311 for (i = 0 ; i < WIFI_AC_MAX; i ++)
1312 {
1313 hddLog(VOS_TRACE_LEVEL_INFO,
1314
1315 " %d) LL_STATS IFACE: "
1316 " ac: %u txMpdu: %u "
1317 " rxMpdu: %u txMcast: %u "
1318 " rxMcast: %u rxAmpdu: %u "
1319 " txAmpdu: %u mpduLost: %u "
1320 " retries: %u retriesShort: %u "
1321 " retriesLong: %u contentionTimeMin: %u "
1322 " contentionTimeMax: %u contentionTimeAvg: %u "
1323 " contentionNumSamples: %u",
1324 i,
1325 pWifiIfaceStat->AccessclassStats[i].ac,
1326 pWifiIfaceStat->AccessclassStats[i].txMpdu,
1327 pWifiIfaceStat->AccessclassStats[i].rxMpdu,
1328 pWifiIfaceStat->AccessclassStats[i].txMcast,
1329 pWifiIfaceStat->AccessclassStats[i].rxMcast,
1330 pWifiIfaceStat->AccessclassStats[i].rxAmpdu,
1331 pWifiIfaceStat->AccessclassStats[i].txAmpdu,
1332 pWifiIfaceStat->AccessclassStats[i].mpduLost,
1333 pWifiIfaceStat->AccessclassStats[i].retries,
1334 pWifiIfaceStat->
1335 AccessclassStats[i].retriesShort,
1336 pWifiIfaceStat->AccessclassStats[i].retriesLong,
1337 pWifiIfaceStat->
1338 AccessclassStats[i].contentionTimeMin,
1339 pWifiIfaceStat->
1340 AccessclassStats[i].contentionTimeMax,
1341 pWifiIfaceStat->
1342 AccessclassStats[i].contentionTimeAvg,
1343 pWifiIfaceStat->
1344 AccessclassStats[i].contentionNumSamples);
1345
1346 }
1347 }
1348
Sunil Duttc69bccb2014-05-26 21:30:20 +05301349 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
1350}
1351
1352/*
1353 * hdd_link_layer_process_radio_stats () - This function is called after
1354 * receiving Link Layer Radio statistics from FW.This function converts
1355 * the firmware data to the NL data and sends the same to the kernel/upper
1356 * layers.
1357 */
1358static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1359 v_VOID_t *pData)
1360{
1361 int status, i;
1362 tpSirWifiRadioStat pWifiRadioStat;
1363 tpSirWifiChannelStats pWifiChannelStats;
1364 struct sk_buff *vendor_event;
1365 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1366 struct nlattr *chList;
1367
1368 status = wlan_hdd_validate_context(pHddCtx);
1369 if (0 != status)
1370 {
1371 hddLog(VOS_TRACE_LEVEL_ERROR,
1372 FL("HDD context is not valid") );
1373 return;
1374 }
1375 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1376
1377 hddLog(VOS_TRACE_LEVEL_INFO,
1378 "LL_STATS_RADIO"
1379 " radio is %d onTime is %u "
1380 " txTime is %u rxTime is %u "
1381 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05301382 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05301383 " onTimePnoScan is %u onTimeHs20 is %u "
1384 " numChannels is %u",
1385 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1386 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1387 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301388 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301389 pWifiRadioStat->onTimeRoamScan,
1390 pWifiRadioStat->onTimePnoScan,
1391 pWifiRadioStat->onTimeHs20,
1392 pWifiRadioStat->numChannels);
1393 /*
1394 * Allocate a size of 4096 for the Radio stats comprising
1395 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1396 * (tSirWifiChannelStats).Each channel data is put with an
1397 * NL attribute.The size of 4096 is considered assuming that
1398 * number of channels shall not exceed beyond 60 with the
1399 * sizeof (tSirWifiChannelStats) being 24 bytes.
1400 */
1401
1402 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1403 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN ,
1404 QCA_NL80211_VENDOR_SUBCMD_LL_RADIO_STATS_INDEX,
1405 GFP_KERNEL);
1406
1407 if (!vendor_event)
1408 {
1409 hddLog(VOS_TRACE_LEVEL_ERROR,
1410 FL("cfg80211_vendor_event_alloc failed") );
1411 return;
1412 }
1413
1414 if (nla_put_u32(vendor_event,
1415 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1416 pWifiRadioStat->radio) ||
1417 nla_put_u32(vendor_event,
1418 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1419 pWifiRadioStat->onTime) ||
1420 nla_put_u32(vendor_event,
1421 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1422 pWifiRadioStat->txTime) ||
1423 nla_put_u32(vendor_event,
1424 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1425 pWifiRadioStat->rxTime) ||
1426 nla_put_u32(vendor_event,
1427 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1428 pWifiRadioStat->onTimeScan) ||
1429 nla_put_u32(vendor_event,
1430 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1431 pWifiRadioStat->onTimeNbd) ||
1432 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301433 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
1434 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05301435 nla_put_u32(vendor_event,
1436 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1437 pWifiRadioStat->onTimeRoamScan) ||
1438 nla_put_u32(vendor_event,
1439 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1440 pWifiRadioStat->onTimePnoScan) ||
1441 nla_put_u32(vendor_event,
1442 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1443 pWifiRadioStat->onTimeHs20) ||
1444 nla_put_u32(vendor_event,
1445 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1446 pWifiRadioStat->numChannels))
1447 {
1448 hddLog(VOS_TRACE_LEVEL_ERROR,
1449 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1450 kfree_skb(vendor_event);
1451 return ;
1452 }
1453
1454 chList = nla_nest_start(vendor_event,
1455 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
1456 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1457 {
1458 struct nlattr *chInfo;
1459
1460 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1461 pWifiRadioStat->channels +
1462 (i * sizeof(tSirWifiChannelStats)));
1463
1464 hddLog(VOS_TRACE_LEVEL_INFO,
1465 " %d) Channel Info"
1466 " width is %u "
1467 " CenterFreq %u "
1468 " CenterFreq0 %u "
1469 " CenterFreq1 %u "
1470 " onTime %u "
1471 " ccaBusyTime %u",
1472 i,
1473 pWifiChannelStats->channel.width,
1474 pWifiChannelStats->channel.centerFreq,
1475 pWifiChannelStats->channel.centerFreq0,
1476 pWifiChannelStats->channel.centerFreq1,
1477 pWifiChannelStats->onTime,
1478 pWifiChannelStats->ccaBusyTime);
1479
1480
1481 chInfo = nla_nest_start(vendor_event, i);
1482
1483 if (nla_put_u32(vendor_event,
1484 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1485 pWifiChannelStats->channel.width) ||
1486 nla_put_u32(vendor_event,
1487 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1488 pWifiChannelStats->channel.centerFreq) ||
1489 nla_put_u32(vendor_event,
1490 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1491 pWifiChannelStats->channel.centerFreq0) ||
1492 nla_put_u32(vendor_event,
1493 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1494 pWifiChannelStats->channel.centerFreq1) ||
1495 nla_put_u32(vendor_event,
1496 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1497 pWifiChannelStats->onTime) ||
1498 nla_put_u32(vendor_event,
1499 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1500 pWifiChannelStats->ccaBusyTime))
1501 {
1502 hddLog(VOS_TRACE_LEVEL_ERROR,
1503 FL("cfg80211_vendor_event_alloc failed") );
1504 kfree_skb(vendor_event);
1505 return ;
1506 }
1507 nla_nest_end(vendor_event, chInfo);
1508 }
1509 nla_nest_end(vendor_event, chList);
1510
1511 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
1512 return;
1513}
1514
1515/*
1516 * hdd_link_layer_stats_ind_callback () - This function is called after
1517 * receiving Link Layer indications from FW.This callback converts the firmware
1518 * data to the NL data and send the same to the kernel/upper layers.
1519 */
1520static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1521 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05301522 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301523{
Dino Mycled3d50022014-07-07 12:58:25 +05301524 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
1525 hdd_adapter_t *pAdapter = NULL;
1526 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301527 int status;
1528
1529 status = wlan_hdd_validate_context(pHddCtx);
1530
1531 if (0 != status)
1532 {
1533 hddLog(VOS_TRACE_LEVEL_ERROR,
1534 FL("HDD context is not valid"));
1535 return;
1536 }
1537
Dino Mycled3d50022014-07-07 12:58:25 +05301538
1539
1540 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
1541 if (NULL == pAdapter)
1542 {
1543 hddLog(VOS_TRACE_LEVEL_ERROR,
1544 FL(" MAC address %pM does not exist with host"),
1545 macAddr);
1546 return;
1547 }
1548
Sunil Duttc69bccb2014-05-26 21:30:20 +05301549 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301550 "%s: Interface: %s LLStats indType: %d", __func__,
1551 pAdapter->dev->name, indType);
1552
Sunil Duttc69bccb2014-05-26 21:30:20 +05301553 switch (indType)
1554 {
1555 case SIR_HAL_LL_STATS_RESULTS_RSP:
1556 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301557 hddLog(VOS_TRACE_LEVEL_INFO,
1558 FL("RESPONSE SIR_HAL_LL_STATS_RESULTS_RSP") );
1559 hddLog(VOS_TRACE_LEVEL_INFO,
1560 "LL_STATS RESULTS RESPONSE paramID = 0x%x",
1561 linkLayerStatsResults->paramId);
1562 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301563 "LL_STATS RESULTS RESPONSE ifaceId = %u MAC: %pM",
1564 linkLayerStatsResults->ifaceId, macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301565 hddLog(VOS_TRACE_LEVEL_INFO,
1566 "LL_STATS RESULTS RESPONSE respId = %u",
1567 linkLayerStatsResults->respId);
1568 hddLog(VOS_TRACE_LEVEL_INFO,
1569 "LL_STATS RESULTS RESPONSE moreResultToFollow = %u",
1570 linkLayerStatsResults->moreResultToFollow);
1571 hddLog(VOS_TRACE_LEVEL_INFO,
1572 "LL_STATS RESULTS RESPONSE result = %p",
1573 linkLayerStatsResults->result);
1574 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1575 {
1576 hdd_link_layer_process_radio_stats(pAdapter,
1577 (v_VOID_t *)linkLayerStatsResults->result);
1578 }
1579 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1580 {
1581 hdd_link_layer_process_iface_stats(pAdapter,
1582 (v_VOID_t *)linkLayerStatsResults->result);
1583 }
1584 else if ( linkLayerStatsResults->paramId &
1585 WMI_LINK_STATS_ALL_PEER )
1586 {
1587 hdd_link_layer_process_peer_stats(pAdapter,
1588 (v_VOID_t *)linkLayerStatsResults->result);
1589 } /* WMI_LINK_STATS_ALL_PEER */
1590 else
1591 {
1592 hddLog(VOS_TRACE_LEVEL_ERROR,
1593 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1594 }
1595
1596 break;
1597 }
1598 default:
1599 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1600 break;
1601 }
1602 return;
1603}
1604
1605const struct
1606nla_policy
1607qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1608{
1609 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1610 { .type = NLA_U32 },
1611 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1612 { .type = NLA_U32 },
1613};
1614
1615static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1616 struct wireless_dev *wdev,
1617 void *data,
1618 int data_len)
1619{
1620 int status;
1621 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301622 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301623 struct net_device *dev = wdev->netdev;
1624 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1625 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1626
1627 status = wlan_hdd_validate_context(pHddCtx);
1628 if (0 != status)
1629 {
1630 hddLog(VOS_TRACE_LEVEL_ERROR,
1631 FL("HDD context is not valid"));
1632 return -EINVAL;
1633 }
1634
1635 if (NULL == pAdapter)
1636 {
1637 hddLog(VOS_TRACE_LEVEL_ERROR,
1638 FL("HDD adapter is Null"));
1639 return -ENODEV;
1640 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301641 /* check the LLStats Capability */
1642 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1643 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1644 {
1645 hddLog(VOS_TRACE_LEVEL_ERROR,
1646 FL("Link Layer Statistics not supported by Firmware"));
1647 return -EINVAL;
1648 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301649
1650 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1651 (struct nlattr *)data,
1652 data_len, qca_wlan_vendor_ll_set_policy))
1653 {
1654 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1655 return -EINVAL;
1656 }
1657 if (!tb_vendor
1658 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1659 {
1660 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1661 return -EINVAL;
1662 }
1663 if (!tb_vendor[
1664 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1665 {
1666 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1667 return -EINVAL;
1668 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301669 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301670 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301671
Dino Mycledf0a5d92014-07-04 09:41:55 +05301672 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301673 nla_get_u32(
1674 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1675
Dino Mycledf0a5d92014-07-04 09:41:55 +05301676 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301677 nla_get_u32(
1678 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1679
Dino Mycled3d50022014-07-07 12:58:25 +05301680 vos_mem_copy(linkLayerStatsSetReq.macAddr,
1681 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301682
1683
1684 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301685 "LL_STATS_SET reqId = %d", linkLayerStatsSetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301686 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301687 "LL_STATS_SET MAC = %pM", linkLayerStatsSetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301688 hddLog(VOS_TRACE_LEVEL_INFO,
1689 "LL_STATS_SET mpduSizeThreshold = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301690 linkLayerStatsSetReq.mpduSizeThreshold);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301691 hddLog(VOS_TRACE_LEVEL_INFO,
1692 "LL_STATS_SET aggressive Statistics Gathering = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301693 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301694
1695 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1696 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05301697 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301698 {
1699 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1700 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301701 return -EINVAL;
1702
1703 }
1704 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301705 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301706 {
1707 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1708 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301709 return -EINVAL;
1710 }
1711
1712 pAdapter->isLinkLayerStatsSet = 1;
1713
1714 return 0;
1715}
1716
1717const struct
1718nla_policy
1719qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1720{
1721 /* Unsigned 32bit value provided by the caller issuing the GET stats
1722 * command. When reporting
1723 * the stats results, the driver uses the same value to indicate
1724 * which GET request the results
1725 * correspond to.
1726 */
1727 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1728
1729 /* Unsigned 32bit value . bit mask to identify what statistics are
1730 requested for retrieval */
1731 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1732};
1733
1734static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1735 struct wireless_dev *wdev,
1736 void *data,
1737 int data_len)
1738{
1739 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1740 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301741 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301742 struct net_device *dev = wdev->netdev;
1743 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1744 int status;
1745
1746 status = wlan_hdd_validate_context(pHddCtx);
1747 if (0 != status)
1748 {
1749 hddLog(VOS_TRACE_LEVEL_ERROR,
1750 FL("HDD context is not valid"));
1751 return -EINVAL ;
1752 }
1753
1754 if (NULL == pAdapter)
1755 {
1756 hddLog(VOS_TRACE_LEVEL_FATAL,
1757 "%s: HDD adapter is Null", __func__);
1758 return -ENODEV;
1759 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301760 /* check the LLStats Capability */
1761 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1762 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1763 {
1764 hddLog(VOS_TRACE_LEVEL_ERROR,
1765 FL("Link Layer Statistics not supported by Firmware"));
1766 return -EINVAL;
1767 }
1768
Sunil Duttc69bccb2014-05-26 21:30:20 +05301769
1770 if (!pAdapter->isLinkLayerStatsSet)
1771 {
1772 hddLog(VOS_TRACE_LEVEL_FATAL,
1773 "%s: isLinkLayerStatsSet : %d",
1774 __func__, pAdapter->isLinkLayerStatsSet);
1775 return -EINVAL;
1776 }
1777
1778 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
1779 (struct nlattr *)data,
1780 data_len, qca_wlan_vendor_ll_get_policy))
1781 {
1782 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1783 return -EINVAL;
1784 }
1785
1786 if (!tb_vendor
1787 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
1788 {
1789 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
1790 return -EINVAL;
1791 }
1792
1793 if (!tb_vendor
1794 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
1795 {
1796 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
1797 return -EINVAL;
1798 }
1799
Sunil Duttc69bccb2014-05-26 21:30:20 +05301800
Dino Mycledf0a5d92014-07-04 09:41:55 +05301801 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301802 nla_get_u32( tb_vendor[
1803 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05301804 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301805 nla_get_u32( tb_vendor[
1806 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
1807
Dino Mycled3d50022014-07-07 12:58:25 +05301808 vos_mem_copy(linkLayerStatsGetReq.macAddr,
1809 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301810
1811 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301812 "LL_STATS_GET reqId = %d", linkLayerStatsGetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301813 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301814 "LL_STATS_GET MAC = %pM", linkLayerStatsGetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301815 hddLog(VOS_TRACE_LEVEL_INFO,
1816 "LL_STATS_GET paramIdMask = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301817 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301818
1819 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301820 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301821 {
1822 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1823 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301824 return -EINVAL;
1825 }
1826 return 0;
1827}
1828
1829const struct
1830nla_policy
1831qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
1832{
1833 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
1834 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
1835 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
1836 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
1837};
1838
1839static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
1840 struct wireless_dev *wdev,
1841 void *data,
1842 int data_len)
1843{
1844 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1845 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301846 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301847 struct net_device *dev = wdev->netdev;
1848 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1849 u32 statsClearReqMask;
1850 u8 stopReq;
1851 int status;
1852
1853 status = wlan_hdd_validate_context(pHddCtx);
1854 if (0 != status)
1855 {
1856 hddLog(VOS_TRACE_LEVEL_ERROR,
1857 FL("HDD context is not valid"));
1858 return -EINVAL;
1859 }
1860
1861 if (NULL == pAdapter)
1862 {
1863 hddLog(VOS_TRACE_LEVEL_FATAL,
1864 "%s: HDD adapter is Null", __func__);
1865 return -ENODEV;
1866 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301867 /* check the LLStats Capability */
1868 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1869 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1870 {
1871 hddLog(VOS_TRACE_LEVEL_ERROR,
1872 FL("Enable LLStats Capability"));
1873 return -EINVAL;
1874 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301875
1876 if (!pAdapter->isLinkLayerStatsSet)
1877 {
1878 hddLog(VOS_TRACE_LEVEL_FATAL,
1879 "%s: isLinkLayerStatsSet : %d",
1880 __func__, pAdapter->isLinkLayerStatsSet);
1881 return -EINVAL;
1882 }
1883
1884 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
1885 (struct nlattr *)data,
1886 data_len, qca_wlan_vendor_ll_clr_policy))
1887 {
1888 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1889 return -EINVAL;
1890 }
1891
1892 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
1893
1894 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
1895 {
1896 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
1897 return -EINVAL;
1898
1899 }
1900
Sunil Duttc69bccb2014-05-26 21:30:20 +05301901
Dino Mycledf0a5d92014-07-04 09:41:55 +05301902 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301903 nla_get_u32(
1904 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
1905
Dino Mycledf0a5d92014-07-04 09:41:55 +05301906 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301907 nla_get_u8(
1908 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
1909
1910 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301911 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301912
Dino Mycled3d50022014-07-07 12:58:25 +05301913 vos_mem_copy(linkLayerStatsClearReq.macAddr,
1914 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301915
1916 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301917 "LL_STATS_CLEAR reqId = %d", linkLayerStatsClearReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301918 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301919 "LL_STATS_CLEAR MAC = %pM", linkLayerStatsClearReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301920 hddLog(VOS_TRACE_LEVEL_INFO,
1921 "LL_STATS_CLEAR statsClearReqMask = 0x%X",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301922 linkLayerStatsClearReq.statsClearReqMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301923 hddLog(VOS_TRACE_LEVEL_INFO,
1924 "LL_STATS_CLEAR stopReq = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301925 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301926
1927 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301928 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301929 {
1930 struct sk_buff *temp_skbuff;
1931 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
1932 2 * sizeof(u32) +
1933 NLMSG_HDRLEN);
1934
1935 if (temp_skbuff != NULL)
1936 {
1937
1938 if (nla_put_u32(temp_skbuff,
1939 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
1940 statsClearReqMask) ||
1941 nla_put_u32(temp_skbuff,
1942 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
1943 stopReq))
1944 {
1945 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
1946 kfree_skb(temp_skbuff);
1947 return -EINVAL;
1948 }
1949 /* If the ask is to stop the stats collection as part of clear
1950 * (stopReq = 1) , ensure that no further requests of get
1951 * go to the firmware by having isLinkLayerStatsSet set to 0.
1952 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301953 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05301954 * case the firmware is just asked to clear the statistics.
1955 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05301956 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301957 pAdapter->isLinkLayerStatsSet = 0;
1958 return cfg80211_vendor_cmd_reply(temp_skbuff);
1959 }
1960 return -ENOMEM;
1961 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301962 return -EINVAL;
1963}
1964#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
1965
Dino Mycle6fb96c12014-06-10 11:52:40 +05301966#ifdef WLAN_FEATURE_EXTSCAN
1967static const struct nla_policy
1968wlan_hdd_extscan_config_policy
1969 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
1970{
1971 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
1972 { .type = NLA_U32 },
1973 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
1974 { .type = NLA_U32 },
1975 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
1976 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
1977 { .type = NLA_U32 },
1978 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
1979 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
1980
1981 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
1982 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
1983 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
1984 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
1985 { .type = NLA_U8 },
1986 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
1987 { .type = NLA_U32 },
1988 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
1989 { .type = NLA_U32 },
1990 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
1991 { .type = NLA_U32 },
1992 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD] =
1993 { .type = NLA_U8 },
1994 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
1995 { .type = NLA_U8 },
1996 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
1997 { .type = NLA_U8 },
1998
1999 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
2000 { .type = NLA_U32 },
2001 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] =
2002 { .type = NLA_UNSPEC },
2003 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
2004 { .type = NLA_S32 },
2005 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
2006 { .type = NLA_S32 },
2007 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
2008 { .type = NLA_U32 },
2009 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
2010 { .type = NLA_U32 },
2011 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE] =
2012 { .type = NLA_U32 },
2013 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]
2014 = { .type = NLA_U32 },
2015 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING] =
2016 { .type = NLA_U32 },
2017 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP] = { .type =
2018 NLA_U32 },
2019};
2020
2021static void wlan_hdd_cfg80211_extscan_get_capabilities_ind(void *ctx, void *pMsg)
2022{
2023 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2024 struct sk_buff *skb = NULL;
2025 tpSirEXTScanCapabilitiesEvent pData =
2026 (tpSirEXTScanCapabilitiesEvent) pMsg;
2027
2028 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2029 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2030 "or pData(%p) is null"), pData);
2031 return;
2032 }
2033
2034 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2035 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2036 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES_INDEX,
2037 GFP_KERNEL);
2038
2039 if (!skb) {
2040 hddLog(VOS_TRACE_LEVEL_ERROR,
2041 FL("cfg80211_vendor_event_alloc failed"));
2042 return;
2043 }
2044
2045 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2046 hddLog(VOS_TRACE_LEVEL_INFO, "Scan cache size (%u)", pData->scanCacheSize);
2047 hddLog(VOS_TRACE_LEVEL_INFO, "Scan buckets (%u)", pData->scanBuckets);
2048 hddLog(VOS_TRACE_LEVEL_INFO, "Max AP per scan (%u)", pData->maxApPerScan);
2049 hddLog(VOS_TRACE_LEVEL_INFO, "maxRssiSampleSize (%u)",
2050 pData->maxRssiSampleSize);
2051 hddLog(VOS_TRACE_LEVEL_INFO, "maxScanReportingThreshold (%u)",
2052 pData->maxScanReportingThreshold);
2053 hddLog(VOS_TRACE_LEVEL_INFO, "maxHotlistAPs (%u)", pData->maxHotlistAPs);
2054 hddLog(VOS_TRACE_LEVEL_INFO, "maxSignificantWifiChangeAPs (%u)",
2055 pData->maxSignificantWifiChangeAPs);
2056 hddLog(VOS_TRACE_LEVEL_INFO, "maxBsidHistoryEntries (%u)",
2057 pData->maxBsidHistoryEntries);
2058
2059 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2060 pData->requestId) ||
2061 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status) ||
2062 nla_put_u32(skb,
2063 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE,
2064 pData->scanCacheSize) ||
2065 nla_put_u32(skb,
2066 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS,
2067 pData->scanBuckets) ||
2068 nla_put_u32(skb,
2069 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN,
2070 pData->maxApPerScan) ||
2071 nla_put_u32(skb,
2072 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE,
2073 pData->maxRssiSampleSize) ||
2074 nla_put_u32(skb,
2075 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD,
2076 pData->maxScanReportingThreshold) ||
2077 nla_put_u32(skb,
2078 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_APS,
2079 pData->maxHotlistAPs) ||
2080 nla_put_u32(skb,
2081 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS,
2082 pData->maxSignificantWifiChangeAPs) ||
2083 nla_put_u32(skb,
2084 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES,
2085 pData->maxBsidHistoryEntries)) {
2086 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2087 goto nla_put_failure;
2088 }
2089
2090 cfg80211_vendor_event(skb, GFP_KERNEL);
2091 return;
2092
2093nla_put_failure:
2094 kfree_skb(skb);
2095 return;
2096}
2097
2098
2099static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg)
2100{
2101 tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg;
2102 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2103 struct sk_buff *skb = NULL;
2104 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
2105
2106
2107 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2108 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2109 "or pData(%p) is null"), pData);
2110 return;
2111 }
2112
2113 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2114 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2115 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START_INDEX,
2116 GFP_KERNEL);
2117
2118 if (!skb) {
2119 hddLog(VOS_TRACE_LEVEL_ERROR,
2120 FL("cfg80211_vendor_event_alloc failed"));
2121 return;
2122 }
2123 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2124 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2125 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2126
2127 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2128 pData->requestId) ||
2129 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2130 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2131 goto nla_put_failure;
2132 }
2133
2134 /*
2135 * Store the Request ID for comparing with the requestID obtained
2136 * in other requests.HDD shall return a failure is the extscan_stop
2137 * request is issued with a different requestId as that of the
2138 * extscan_start request. Also, This requestId shall be used while
2139 * indicating the full scan results to the upper layers.
2140 * The requestId is stored with the assumption that the firmware
2141 * shall return the ext scan start request's requestId in ext scan
2142 * start response.
2143 */
2144 if (pData->status == 0)
2145 pMac->sme.extScanStartReqId = pData->requestId;
2146
2147
2148 cfg80211_vendor_event(skb, GFP_KERNEL);
2149 return;
2150
2151nla_put_failure:
2152 kfree_skb(skb);
2153 return;
2154}
2155
2156
2157static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
2158{
2159 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
2160 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2161 struct sk_buff *skb = NULL;
2162
2163 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2164 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2165 "or pData(%p) is null"), pData);
2166 return;
2167 }
2168
2169 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2170 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2171 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP_INDEX,
2172 GFP_KERNEL);
2173
2174 if (!skb) {
2175 hddLog(VOS_TRACE_LEVEL_ERROR,
2176 FL("cfg80211_vendor_event_alloc failed"));
2177 return;
2178 }
2179 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2180 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2181
2182 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2183 pData->requestId) ||
2184 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2185 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2186 goto nla_put_failure;
2187 }
2188
2189 cfg80211_vendor_event(skb, GFP_KERNEL);
2190 return;
2191
2192nla_put_failure:
2193 kfree_skb(skb);
2194 return;
2195}
2196
2197
2198static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
2199 void *pMsg)
2200{
2201 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2202 struct sk_buff *skb = NULL;
2203 tpSirEXTScanSetBssidHotListRspParams pData =
2204 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
2205
2206 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2207 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2208 "or pData(%p) is null"), pData);
2209 return;
2210 }
2211 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2212 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2213 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST_INDEX,
2214 GFP_KERNEL);
2215
2216 if (!skb) {
2217 hddLog(VOS_TRACE_LEVEL_ERROR,
2218 FL("cfg80211_vendor_event_alloc failed"));
2219 return;
2220 }
2221 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2222 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2223 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2224
2225 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2226 pData->requestId) ||
2227 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2228 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2229 goto nla_put_failure;
2230 }
2231
2232 cfg80211_vendor_event(skb, GFP_KERNEL);
2233 return;
2234
2235nla_put_failure:
2236 kfree_skb(skb);
2237 return;
2238}
2239
2240static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
2241 void *pMsg)
2242{
2243 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2244 struct sk_buff *skb = NULL;
2245 tpSirEXTScanResetBssidHotlistRspParams pData =
2246 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
2247
2248 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2249 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2250 "or pData(%p) is null"), pData);
2251 return;
2252 }
2253
2254 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2255 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2256 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST_INDEX,
2257 GFP_KERNEL);
2258
2259 if (!skb) {
2260 hddLog(VOS_TRACE_LEVEL_ERROR,
2261 FL("cfg80211_vendor_event_alloc failed"));
2262 return;
2263 }
2264 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2265 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2266
2267 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2268 pData->requestId) ||
2269 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2270 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2271 goto nla_put_failure;
2272 }
2273
2274 cfg80211_vendor_event(skb, GFP_KERNEL);
2275 return;
2276
2277nla_put_failure:
2278 kfree_skb(skb);
2279 return;
2280}
2281
2282
2283static void wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(void *ctx,
2284 void *pMsg)
2285{
2286 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2287 struct sk_buff *skb = NULL;
2288 tpSirEXTScanSetSignificantChangeRspParams pData =
2289 (tpSirEXTScanSetSignificantChangeRspParams) pMsg;
2290
2291 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2292 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2293 "or pData(%p) is null"), pData);
2294 return;
2295 }
2296
2297 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2298 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2299 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE_INDEX,
2300 GFP_KERNEL);
2301
2302 if (!skb) {
2303 hddLog(VOS_TRACE_LEVEL_ERROR,
2304 FL("cfg80211_vendor_event_alloc failed"));
2305 return;
2306 }
2307 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2308 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2309 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2310
2311 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2312 pData->requestId) ||
2313 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2314 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2315 goto nla_put_failure;
2316 }
2317
2318 cfg80211_vendor_event(skb, GFP_KERNEL);
2319 return;
2320
2321nla_put_failure:
2322 kfree_skb(skb);
2323 return;
2324}
2325
2326
2327static void wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(void *ctx,
2328 void *pMsg)
2329{
2330 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2331 struct sk_buff *skb = NULL;
2332 tpSirEXTScanResetSignificantChangeRspParams pData =
2333 (tpSirEXTScanResetSignificantChangeRspParams) pMsg;
2334
2335 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2336 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2337 "or pData(%p) is null"), pData);
2338 return;
2339 }
2340
2341 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2342 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2343 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE_INDEX,
2344 GFP_KERNEL);
2345
2346 if (!skb) {
2347 hddLog(VOS_TRACE_LEVEL_ERROR,
2348 FL("cfg80211_vendor_event_alloc failed"));
2349 return;
2350 }
2351 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2352 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2353 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2354
2355 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2356 pData->requestId) ||
2357 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2358 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2359 goto nla_put_failure;
2360 }
2361
2362 cfg80211_vendor_event(skb, GFP_KERNEL);
2363 return;
2364
2365nla_put_failure:
2366 kfree_skb(skb);
2367 return;
2368}
2369
2370static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
2371 void *pMsg)
2372{
2373 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2374 struct sk_buff *skb = NULL;
2375 tANI_U32 i = 0, j, resultsPerEvent;
2376 tANI_S32 totalResults;
2377 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2378 tpSirWifiScanResult pSirWifiScanResult;
2379
2380 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2381 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2382 "or pData(%p) is null"), pData);
2383 return;
2384 }
2385 totalResults = pData->numOfAps;
2386 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2387 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2388 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2389
2390 do{
2391 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
2392 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
2393 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
2394
2395 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2396 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2397 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS_INDEX,
2398 GFP_KERNEL);
2399
2400 if (!skb) {
2401 hddLog(VOS_TRACE_LEVEL_ERROR,
2402 FL("cfg80211_vendor_event_alloc failed"));
2403 return;
2404 }
2405
2406 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
2407
2408 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2409 pData->requestId) ||
2410 nla_put_u32(skb,
2411 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2412 resultsPerEvent)) {
2413 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2414 goto fail;
2415 }
2416 if (nla_put_u8(skb,
2417 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2418 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
2419 {
2420 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2421 goto fail;
2422 }
2423
2424 if (resultsPerEvent) {
2425 struct nlattr *aps;
2426
2427 aps = nla_nest_start(skb,
2428 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2429 if (!aps)
2430 {
2431 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2432 goto fail;
2433 }
2434
2435 for (j = 0; j < resultsPerEvent; j++, i++) {
2436 struct nlattr *ap;
2437 pSirWifiScanResult = (tpSirWifiScanResult) ((tANI_U8 *)
2438 pData->ap + ( i* sizeof(tSirWifiScanResult)));
2439
2440 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
2441 "Ssid (%s)"
2442 "Bssid: %pM "
2443 "Channel (%u)"
2444 "Rssi (%d)"
2445 "RTT (%u)"
2446 "RTT_SD (%u)",
2447 i,
2448 pSirWifiScanResult->ts,
2449 pSirWifiScanResult->ssid,
2450 pSirWifiScanResult->bssid,
2451 pSirWifiScanResult->channel,
2452 pSirWifiScanResult->rssi,
2453 pSirWifiScanResult->rtt,
2454 pSirWifiScanResult->rtt_sd);
2455
2456 ap = nla_nest_start(skb, j + 1);
2457 if (!ap)
2458 {
2459 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2460 goto fail;
2461 }
2462
2463 if (nla_put_u64(skb,
2464 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2465 pSirWifiScanResult->ts) )
2466 {
2467 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2468 goto fail;
2469 }
2470 if (nla_put(skb,
2471 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2472 sizeof(pSirWifiScanResult->ssid),
2473 pSirWifiScanResult->ssid) )
2474 {
2475 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2476 goto fail;
2477 }
2478 if (nla_put(skb,
2479 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2480 sizeof(pSirWifiScanResult->bssid),
2481 pSirWifiScanResult->bssid) )
2482 {
2483 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2484 goto fail;
2485 }
2486 if (nla_put_u32(skb,
2487 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2488 pSirWifiScanResult->channel) )
2489 {
2490 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2491 goto fail;
2492 }
Dasari Srinivas90747d72014-10-08 12:16:15 +05302493 if (nla_put_s32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302494 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2495 pSirWifiScanResult->rssi) )
2496 {
2497 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2498 goto fail;
2499 }
2500 if (nla_put_u32(skb,
2501 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2502 pSirWifiScanResult->rtt) )
2503 {
2504 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2505 goto fail;
2506 }
2507 if (nla_put_u32(skb,
2508 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2509 pSirWifiScanResult->rtt_sd))
2510 {
2511 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2512 goto fail;
2513 }
2514
2515 nla_nest_end(skb, ap);
2516 }
2517 nla_nest_end(skb, aps);
2518
2519 }
2520 cfg80211_vendor_event(skb, GFP_KERNEL);
2521 } while (totalResults > 0);
2522
2523 return;
2524fail:
2525 kfree_skb(skb);
2526 return;
2527}
2528
2529static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
2530 void *pMsg)
2531{
2532 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2533 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2534 struct sk_buff *skb = NULL;
2535 tANI_U32 i;
2536
2537 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2538 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2539 "or pData(%p) is null"), pData);
2540 return;
2541 }
2542
2543 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2544 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2545 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX,
2546 GFP_KERNEL);
2547
2548 if (!skb) {
2549 hddLog(VOS_TRACE_LEVEL_ERROR,
2550 FL("cfg80211_vendor_event_alloc failed"));
2551 return;
2552 }
2553 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2554 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2555 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2556 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2557
2558 for (i = 0; i < pData->numOfAps; i++) {
2559 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
2560 "Ssid (%s) "
2561 "Bssid (" MAC_ADDRESS_STR ") "
2562 "Channel (%u) "
2563 "Rssi (%d) "
2564 "RTT (%u) "
2565 "RTT_SD (%u) ",
2566 i,
2567 pData->ap[i].ts,
2568 pData->ap[i].ssid,
2569 MAC_ADDR_ARRAY(pData->ap[i].bssid),
2570 pData->ap[i].channel,
2571 pData->ap[i].rssi,
2572 pData->ap[i].rtt,
2573 pData->ap[i].rtt_sd);
2574 }
2575
2576 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2577 pData->requestId) ||
2578 nla_put_u32(skb,
2579 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2580 pData->numOfAps)) {
2581 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2582 goto fail;
2583 }
2584 if (pData->numOfAps) {
2585 struct nlattr *aps;
2586
2587 aps = nla_nest_start(skb,
2588 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2589 if (!aps)
2590 goto fail;
2591
2592 for (i = 0; i < pData->numOfAps; i++) {
2593 struct nlattr *ap;
2594
2595 ap = nla_nest_start(skb, i + 1);
2596 if (!ap)
2597 goto fail;
2598
2599 if (nla_put_u64(skb,
2600 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2601 pData->ap[i].ts) ||
2602 nla_put(skb,
2603 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2604 sizeof(pData->ap[i].ssid),
2605 pData->ap[i].ssid) ||
2606 nla_put(skb,
2607 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2608 sizeof(pData->ap[i].bssid),
2609 pData->ap[i].bssid) ||
2610 nla_put_u32(skb,
2611 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2612 pData->ap[i].channel) ||
2613 nla_put_s32(skb,
2614 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2615 pData->ap[i].rssi) ||
2616 nla_put_u32(skb,
2617 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2618 pData->ap[i].rtt) ||
2619 nla_put_u32(skb,
2620 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2621 pData->ap[i].rtt_sd))
2622 goto fail;
2623
2624 nla_nest_end(skb, ap);
2625 }
2626 nla_nest_end(skb, aps);
2627
2628 if (nla_put_u8(skb,
2629 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2630 pData->moreData))
2631 goto fail;
2632 }
2633
2634 cfg80211_vendor_event(skb, GFP_KERNEL);
2635 return;
2636
2637fail:
2638 kfree_skb(skb);
2639 return;
2640
2641}
2642static void wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(void *ctx,
2643 void *pMsg)
2644{
2645 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2646 struct sk_buff *skb = NULL;
2647 tANI_U32 i, j;
2648 tpSirWifiSignificantChangeEvent pData =
2649 (tpSirWifiSignificantChangeEvent) pMsg;
2650
2651 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2652 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2653 "or pData(%p) is null"), pData);
2654 return;
2655 }
2656 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2657 EXTSCAN_EVENT_BUF_SIZE,
2658 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE_INDEX,
2659 GFP_KERNEL);
2660
2661 if (!skb) {
2662 hddLog(VOS_TRACE_LEVEL_ERROR,
2663 FL("cfg80211_vendor_event_alloc failed"));
2664 return;
2665 }
2666 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2667 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2668 hddLog(VOS_TRACE_LEVEL_INFO, "total List Size %u ", pData->numSigRssiBss);
2669 hddLog(VOS_TRACE_LEVEL_INFO, " CUrrent List size (%u)",
2670 pData->numSigRssiBss);
2671 hddLog(VOS_TRACE_LEVEL_INFO, "moreData (%u)", pData->moreData);
2672
2673 for (i = 0; i < pData->numSigRssiBss; i++) {
2674 hddLog(VOS_TRACE_LEVEL_INFO , "Rssi List [%d] BSSID: (%pM) Channel %u "
2675 " num RSSI %u ",
2676 i, pData->sigRssiResult[i].bssid,
2677 pData->sigRssiResult[i].channel,
2678 pData->sigRssiResult[i].numRssi);
2679
2680 for (j = 0; j < pData->sigRssiResult[i].numRssi; j++){
2681
2682 hddLog(VOS_TRACE_LEVEL_INFO,
2683 " [%d]",
Dino Myclec8f3f332014-07-21 16:48:27 +05302684 pData->sigRssiResult[i].rssi[j]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302685
2686 }
2687 }
2688
2689
2690 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2691 pData->requestId) ||
2692 nla_put_u32(skb,
2693 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2694 pData->numSigRssiBss)) {
2695 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2696 goto fail;
2697 }
2698
2699 if (pData->numSigRssiBss) {
2700 struct nlattr *aps;
2701 aps = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2702 if (!aps)
2703 goto fail;
2704 for (i = 0; i < pData->numSigRssiBss; i++) {
2705 struct nlattr *ap;
2706
2707 ap = nla_nest_start(skb, i);
2708 if (!ap)
2709 goto fail;
2710 if (nla_put(skb,
2711 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_BSSID,
2712 sizeof(tSirMacAddr), pData->sigRssiResult[i].bssid) ||
2713 nla_put_u32(skb,
2714 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_CHANNEL,
2715 pData->sigRssiResult[i].channel) ||
2716 nla_put_u32(skb,
2717 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_NUM_RSSI,
2718 pData->sigRssiResult[i].numRssi) ||
2719 nla_put(skb,
2720 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_RSSI_LIST,
2721 sizeof(s32) * pData->sigRssiResult[i].numRssi,
2722 pData->sigRssiResult[i].rssi))
2723 goto fail;
2724 nla_nest_end(skb, ap);
2725 }
2726 nla_nest_end(skb, aps);
2727 if (nla_put_u8(skb,
2728 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2729 pData->moreData))
2730 goto fail;
2731 }
2732 cfg80211_vendor_event(skb, GFP_KERNEL);
2733 return;
2734fail:
2735 kfree_skb(skb);
2736 return;
2737}
2738
2739static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
2740 void *pMsg)
2741{
2742 struct sk_buff *skb;
2743 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2744 tpSirWifiFullScanResultEvent pData =
2745 (tpSirWifiFullScanResultEvent) (pMsg);
2746
2747 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2748 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2749 "or pData(%p) is null"), pData);
2750 return;
2751 }
2752
2753 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2754 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2755 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
2756 GFP_KERNEL);
2757
2758 if (!skb) {
2759 hddLog(VOS_TRACE_LEVEL_ERROR,
2760 FL("cfg80211_vendor_event_alloc failed"));
2761 return;
2762 }
2763
2764 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2765 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
2766 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
2767 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
2768 "Ssid (%s)"
2769 "Bssid (" MAC_ADDRESS_STR ")"
2770 "Channel (%u)"
2771 "Rssi (%d)"
2772 "RTT (%u)"
2773 "RTT_SD (%u)"),
2774 pData->ap.ts,
2775 pData->ap.ssid,
2776 MAC_ADDR_ARRAY(pData->ap.bssid),
2777 pData->ap.channel,
2778 pData->ap.rssi,
2779 pData->ap.rtt,
2780 pData->ap.rtt_sd);
2781 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
2782 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2783 pData->requestId) ||
2784 nla_put_u64(skb,
2785 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2786 pData->ap.ts) ||
2787 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2788 sizeof(pData->ap.ssid),
2789 pData->ap.ssid) ||
2790 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2791 WNI_CFG_BSSID_LEN,
2792 pData->ap.bssid) ||
2793 nla_put_u32(skb,
2794 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2795 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05302796 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302797 pData->ap.rssi) ||
2798 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2799 pData->ap.rtt) ||
2800 nla_put_u32(skb,
2801 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2802 pData->ap.rtt_sd) ||
2803 nla_put_u16(skb,
2804 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
2805 pData->ap.beaconPeriod) ||
2806 nla_put_u16(skb,
2807 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
2808 pData->ap.capability) ||
2809 nla_put_u32(skb,
2810 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
2811 pData->ieLength))
2812 {
2813 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2814 goto nla_put_failure;
2815 }
2816 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
2817 pData->ieLength,
2818 pData->ie))
2819 {
2820 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2821 goto nla_put_failure;
2822 }
2823
2824 cfg80211_vendor_event(skb, GFP_KERNEL);
2825 return;
2826
2827nla_put_failure:
2828 kfree_skb(skb);
2829 return;
2830}
2831
2832static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
2833 void *pMsg)
2834{
2835 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2836 struct sk_buff *skb = NULL;
2837 tpSirEXTScanResultsAvailableIndParams pData =
2838 (tpSirEXTScanResultsAvailableIndParams) pMsg;
2839
2840 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2841 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2842 "or pData(%p) is null"), pData);
2843 return;
2844 }
2845
2846 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2847 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2848 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
2849 GFP_KERNEL);
2850
2851 if (!skb) {
2852 hddLog(VOS_TRACE_LEVEL_ERROR,
2853 FL("cfg80211_vendor_event_alloc failed"));
2854 return;
2855 }
2856
2857 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2858 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2859 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
2860 pData->numResultsAvailable);
2861 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2862 pData->requestId) ||
2863 nla_put_u32(skb,
2864 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2865 pData->numResultsAvailable)) {
2866 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2867 goto nla_put_failure;
2868 }
2869
2870 cfg80211_vendor_event(skb, GFP_KERNEL);
2871 return;
2872
2873nla_put_failure:
2874 kfree_skb(skb);
2875 return;
2876}
2877
2878static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
2879{
2880 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2881 struct sk_buff *skb = NULL;
2882 tpSirEXTScanProgressIndParams pData =
2883 (tpSirEXTScanProgressIndParams) pMsg;
2884
2885 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2886 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2887 "or pData(%p) is null"), pData);
2888 return;
2889 }
2890
2891 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2892 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2893 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
2894 GFP_KERNEL);
2895
2896 if (!skb) {
2897 hddLog(VOS_TRACE_LEVEL_ERROR,
2898 FL("cfg80211_vendor_event_alloc failed"));
2899 return;
2900 }
2901 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2902 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
2903 pData->extScanEventType);
2904 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
2905 pData->status);
2906
2907 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
2908 pData->extScanEventType) ||
2909 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05302910 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2911 pData->requestId) ||
2912 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302913 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
2914 pData->status)) {
2915 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2916 goto nla_put_failure;
2917 }
2918
2919 cfg80211_vendor_event(skb, GFP_KERNEL);
2920 return;
2921
2922nla_put_failure:
2923 kfree_skb(skb);
2924 return;
2925}
2926
2927void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
2928 void *pMsg)
2929{
2930 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2931
2932 if (wlan_hdd_validate_context(pHddCtx)) {
Dasari Srinivasb46ed1d2014-10-08 13:03:08 +05302933 hddLog(VOS_TRACE_LEVEL_INFO, FL("HDD context is not valid"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302934 return;
2935 }
2936
2937 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
2938
2939
2940 switch(evType) {
2941 case SIR_HAL_EXTSCAN_START_RSP:
2942 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
2943 break;
2944
2945 case SIR_HAL_EXTSCAN_STOP_RSP:
2946 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
2947 break;
2948 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
2949 /* There is no need to send this response to upper layer
2950 Just log the message */
2951 hddLog(VOS_TRACE_LEVEL_INFO,
2952 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
2953 break;
2954 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
2955 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
2956 break;
2957
2958 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
2959 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
2960 break;
2961
2962 case SIR_HAL_EXTSCAN_SET_SIGNF_RSSI_CHANGE_RSP:
2963 wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(ctx, pMsg);
2964 break;
2965
2966 case SIR_HAL_EXTSCAN_RESET_SIGNF_RSSI_CHANGE_RSP:
2967 wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(ctx, pMsg);
2968 break;
2969 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
2970 wlan_hdd_cfg80211_extscan_get_capabilities_ind(ctx, pMsg);
2971 break;
2972 case SIR_HAL_EXTSCAN_PROGRESS_IND:
2973 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
2974 break;
2975 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
2976 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
2977 break;
2978 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
2979 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
2980 break;
2981 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
2982 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
2983 break;
2984 case SIR_HAL_EXTSCAN_SIGNF_WIFI_CHANGE_IND:
2985 wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(ctx, pMsg);
2986 break;
2987 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
2988 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
2989 break;
2990 default:
2991 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
2992 break;
2993 }
2994}
2995
2996static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
2997 struct wireless_dev *wdev,
2998 void *data, int dataLen)
2999{
Dino Myclee8843b32014-07-04 14:21:45 +05303000 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303001 struct net_device *dev = wdev->netdev;
3002 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3003 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3004 struct nlattr
3005 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3006 eHalStatus status;
3007
3008 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering"));
3009 status = wlan_hdd_validate_context(pHddCtx);
3010 if (0 != status)
3011 {
3012 hddLog(VOS_TRACE_LEVEL_ERROR,
3013 FL("HDD context is not valid"));
3014 return -EINVAL;
3015 }
Dino Myclee8843b32014-07-04 14:21:45 +05303016 /* check the EXTScan Capability */
3017 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3018 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3019 {
3020 hddLog(VOS_TRACE_LEVEL_ERROR,
3021 FL("EXTScan not enabled/supported by Firmware"));
3022 return -EINVAL;
3023 }
3024
Dino Mycle6fb96c12014-06-10 11:52:40 +05303025 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3026 data, dataLen,
3027 wlan_hdd_extscan_config_policy)) {
3028 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3029 return -EINVAL;
3030 }
3031
3032 /* Parse and fetch request Id */
3033 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3034 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3035 return -EINVAL;
3036 }
3037
Dino Mycle6fb96c12014-06-10 11:52:40 +05303038
Dino Myclee8843b32014-07-04 14:21:45 +05303039 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303040 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303041 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303042
Dino Myclee8843b32014-07-04 14:21:45 +05303043 reqMsg.sessionId = pAdapter->sessionId;
3044 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303045
Dino Myclee8843b32014-07-04 14:21:45 +05303046 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303047 if (!HAL_STATUS_SUCCESS(status)) {
3048 hddLog(VOS_TRACE_LEVEL_ERROR,
3049 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303050 return -EINVAL;
3051 }
3052
3053 return 0;
3054}
3055
3056
3057static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3058 struct wireless_dev *wdev,
3059 void *data, int dataLen)
3060{
Dino Myclee8843b32014-07-04 14:21:45 +05303061 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303062 struct net_device *dev = wdev->netdev;
3063 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3064 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3065 struct nlattr
3066 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3067 eHalStatus status;
3068
3069 status = wlan_hdd_validate_context(pHddCtx);
3070 if (0 != status)
3071 {
3072 hddLog(VOS_TRACE_LEVEL_ERROR,
3073 FL("HDD context is not valid"));
3074 return -EINVAL;
3075 }
Dino Myclee8843b32014-07-04 14:21:45 +05303076 /* check the EXTScan Capability */
3077 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3078 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3079 {
3080 hddLog(VOS_TRACE_LEVEL_ERROR,
3081 FL("EXTScan not enabled/supported by Firmware"));
3082 return -EINVAL;
3083 }
3084
Dino Mycle6fb96c12014-06-10 11:52:40 +05303085 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3086 data, dataLen,
3087 wlan_hdd_extscan_config_policy)) {
3088 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3089 return -EINVAL;
3090 }
3091 /* Parse and fetch request Id */
3092 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3093 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3094 return -EINVAL;
3095 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303096
Dino Myclee8843b32014-07-04 14:21:45 +05303097 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303098 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3099
Dino Myclee8843b32014-07-04 14:21:45 +05303100 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303101
Dino Myclee8843b32014-07-04 14:21:45 +05303102 reqMsg.sessionId = pAdapter->sessionId;
3103 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303104
3105 /* Parse and fetch flush parameter */
3106 if (!tb
3107 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3108 {
3109 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3110 goto failed;
3111 }
Dino Myclee8843b32014-07-04 14:21:45 +05303112 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303113 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3114
Dino Myclee8843b32014-07-04 14:21:45 +05303115 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303116
Dino Myclee8843b32014-07-04 14:21:45 +05303117 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303118 if (!HAL_STATUS_SUCCESS(status)) {
3119 hddLog(VOS_TRACE_LEVEL_ERROR,
3120 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303121 return -EINVAL;
3122 }
3123 return 0;
3124
3125failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303126 return -EINVAL;
3127}
3128
3129static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3130 struct wireless_dev *wdev,
3131 void *data, int dataLen)
3132{
3133 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3134 struct net_device *dev = wdev->netdev;
3135 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3136 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3137 struct nlattr
3138 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3139 struct nlattr
3140 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3141 struct nlattr *apTh;
3142 eHalStatus status;
3143 tANI_U8 i = 0;
3144 int rem;
3145
3146 status = wlan_hdd_validate_context(pHddCtx);
3147 if (0 != status)
3148 {
3149 hddLog(VOS_TRACE_LEVEL_ERROR,
3150 FL("HDD context is not valid"));
3151 return -EINVAL;
3152 }
Dino Myclee8843b32014-07-04 14:21:45 +05303153 /* check the EXTScan Capability */
3154 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3155 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3156 {
3157 hddLog(VOS_TRACE_LEVEL_ERROR,
3158 FL("EXTScan not enabled/supported by Firmware"));
3159 return -EINVAL;
3160 }
3161
Dino Mycle6fb96c12014-06-10 11:52:40 +05303162 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3163 data, dataLen,
3164 wlan_hdd_extscan_config_policy)) {
3165 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3166 return -EINVAL;
3167 }
3168
3169 /* Parse and fetch request Id */
3170 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3171 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3172 return -EINVAL;
3173 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303174 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3175 vos_mem_malloc(sizeof(*pReqMsg));
3176 if (!pReqMsg) {
3177 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3178 return -ENOMEM;
3179 }
3180
Dino Myclee8843b32014-07-04 14:21:45 +05303181
Dino Mycle6fb96c12014-06-10 11:52:40 +05303182 pReqMsg->requestId = nla_get_u32(
3183 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3184 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3185
3186 /* Parse and fetch number of APs */
3187 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3188 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3189 goto fail;
3190 }
3191
3192 pReqMsg->sessionId = pAdapter->sessionId;
3193 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3194
3195 pReqMsg->numAp = nla_get_u32(
3196 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
3197 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3198
3199 nla_for_each_nested(apTh,
3200 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3201 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3202 nla_data(apTh), nla_len(apTh),
3203 NULL)) {
3204 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3205 goto fail;
3206 }
3207
3208 /* Parse and fetch MAC address */
3209 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3210 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3211 goto fail;
3212 }
3213 memcpy(pReqMsg->ap[i].bssid, nla_data(
3214 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3215 sizeof(tSirMacAddr));
3216 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3217
3218 /* Parse and fetch low RSSI */
3219 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3220 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3221 goto fail;
3222 }
3223 pReqMsg->ap[i].low = nla_get_s32(
3224 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3225 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3226
3227 /* Parse and fetch high RSSI */
3228 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3229 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3230 goto fail;
3231 }
3232 pReqMsg->ap[i].high = nla_get_s32(
3233 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3234 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3235 pReqMsg->ap[i].high);
3236
3237 /* Parse and fetch channel */
3238 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3239 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3240 goto fail;
3241 }
3242 pReqMsg->ap[i].channel = nla_get_u32(
3243 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3244 hddLog(VOS_TRACE_LEVEL_INFO,
3245 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3246 i++;
3247 }
3248 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3249 if (!HAL_STATUS_SUCCESS(status)) {
3250 hddLog(VOS_TRACE_LEVEL_ERROR,
3251 FL("sme_SetBssHotlist failed(err=%d)"), status);
3252 vos_mem_free(pReqMsg);
3253 return -EINVAL;
3254 }
3255
Dino Myclee8843b32014-07-04 14:21:45 +05303256 vos_mem_free(pReqMsg);
3257
Dino Mycle6fb96c12014-06-10 11:52:40 +05303258 return 0;
3259
3260fail:
3261 vos_mem_free(pReqMsg);
3262 return -EINVAL;
3263}
3264
3265static int wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
3266 struct wireless_dev *wdev,
3267 void *data, int dataLen)
3268{
3269 tpSirEXTScanSetSignificantChangeReqParams pReqMsg = NULL;
3270 struct net_device *dev = wdev->netdev;
3271 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3272 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3273 struct nlattr
3274 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3275 struct nlattr
3276 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3277 struct nlattr *apTh;
3278 eHalStatus status;
3279 int i = 0;
3280 int rem;
3281
3282 status = wlan_hdd_validate_context(pHddCtx);
3283 if (0 != status)
3284 {
3285 hddLog(VOS_TRACE_LEVEL_ERROR,
3286 FL("HDD context is not valid"));
3287 return -EINVAL;
3288 }
Dino Myclee8843b32014-07-04 14:21:45 +05303289 /* check the EXTScan Capability */
3290 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3291 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3292 {
3293 hddLog(VOS_TRACE_LEVEL_ERROR,
3294 FL("EXTScan not enabled/supported by Firmware"));
3295 return -EINVAL;
3296 }
3297
Dino Mycle6fb96c12014-06-10 11:52:40 +05303298 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3299 data, dataLen,
3300 wlan_hdd_extscan_config_policy)) {
3301 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3302 return -EINVAL;
3303 }
3304
3305 /* Parse and fetch request Id */
3306 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3307 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3308 return -EINVAL;
3309 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303310 pReqMsg = (tpSirEXTScanSetSignificantChangeReqParams)
Dino Myclee8843b32014-07-04 14:21:45 +05303311 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303312 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05303313 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3314 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303315 }
3316
Dino Myclee8843b32014-07-04 14:21:45 +05303317
3318
Dino Mycle6fb96c12014-06-10 11:52:40 +05303319 pReqMsg->requestId = nla_get_u32(
3320 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3321 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3322
3323 /* Parse and fetch RSSI sample size */
3324 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE])
3325 {
3326 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr RSSI sample size failed"));
3327 goto fail;
3328 }
3329 pReqMsg->rssiSampleSize = nla_get_u32(
3330 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE]);
3331 hddLog(VOS_TRACE_LEVEL_INFO,
3332 FL("RSSI sample size (%u)"), pReqMsg->rssiSampleSize);
3333
3334 /* Parse and fetch lost AP sample size */
3335 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE])
3336 {
3337 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr lost AP sample size failed"));
3338 goto fail;
3339 }
3340 pReqMsg->lostApSampleSize = nla_get_u32(
3341 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]);
3342 hddLog(VOS_TRACE_LEVEL_INFO,
3343 FL("Lost AP sample size (%u)"), pReqMsg->lostApSampleSize);
3344 /* Parse and fetch minimum Breaching */
3345 if (!tb
3346 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]) {
3347 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr minBreaching failed"));
3348 goto fail;
3349 }
3350 pReqMsg->minBreaching = nla_get_u32(
3351 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]);
3352 hddLog(VOS_TRACE_LEVEL_INFO, FL(" Breaching (%d)"), pReqMsg->minBreaching);
3353
3354 /* Parse and fetch number of APs */
3355 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]) {
3356 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3357 goto fail;
3358 }
3359 pReqMsg->numAp = nla_get_u32(
3360 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]);
3361 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3362
3363 pReqMsg->sessionId = pAdapter->sessionId;
3364 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3365
3366 nla_for_each_nested(apTh,
3367 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3368 if(nla_parse(tb2,
3369 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3370 nla_data(apTh), nla_len(apTh),
3371 NULL)) {
3372 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3373 goto fail;
3374 }
3375
3376 /* Parse and fetch MAC address */
3377 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3378 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3379 goto fail;
3380 }
3381 memcpy(pReqMsg->ap[i].bssid, nla_data(
3382 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3383 sizeof(tSirMacAddr));
3384
3385 /* Parse and fetch low RSSI */
3386 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3387 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3388 goto fail;
3389 }
3390 pReqMsg->ap[i].low = nla_get_s32(
3391 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3392 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3393
3394 /* Parse and fetch high RSSI */
3395 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3396 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3397 goto fail;
3398 }
3399 pReqMsg->ap[i].high = nla_get_s32(
3400 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3401 hddLog(VOS_TRACE_LEVEL_INFO,
3402 FL("RSSI High (%d)"), pReqMsg->ap[i].high);
3403
3404 /* Parse and fetch channel */
3405 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3406 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3407 goto fail;
3408 }
3409 pReqMsg->ap[i].channel = nla_get_u32(
3410 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3411 hddLog(VOS_TRACE_LEVEL_INFO,
3412 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3413 i++;
3414 }
3415
3416 status = sme_SetSignificantChange(pHddCtx->hHal, pReqMsg);
3417 if (!HAL_STATUS_SUCCESS(status)) {
3418 hddLog(VOS_TRACE_LEVEL_ERROR,
3419 FL("sme_SetSignificantChange failed(err=%d)"), status);
3420 vos_mem_free(pReqMsg);
3421 return -EINVAL;
3422 }
Dino Myclee8843b32014-07-04 14:21:45 +05303423 vos_mem_free(pReqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303424 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Exiting"));
3425 return 0;
3426
3427fail:
3428 vos_mem_free(pReqMsg);
3429 return -EINVAL;
3430}
3431
3432static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
3433 struct wireless_dev *wdev,
3434 void *data, int dataLen)
3435{
3436 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3437 tANI_U32 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
3438 tANI_U8 numChannels = 0;
3439 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3440 tANI_U32 requestId;
3441 tWifiBand wifiBand;
3442 eHalStatus status;
3443 struct sk_buff *replySkb;
3444 tANI_U8 i;
3445
3446 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering"));
3447 status = wlan_hdd_validate_context(pHddCtx);
3448 if (0 != status)
3449 {
3450 hddLog(VOS_TRACE_LEVEL_ERROR,
3451 FL("HDD context is not valid"));
3452 return -EINVAL;
3453 }
Dino Myclee8843b32014-07-04 14:21:45 +05303454 /* check the EXTScan Capability */
3455 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3456 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3457 {
3458 hddLog(VOS_TRACE_LEVEL_ERROR,
3459 FL("EXTScan not enabled/supported by Firmware"));
3460 return -EINVAL;
3461 }
3462
Dino Mycle6fb96c12014-06-10 11:52:40 +05303463 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3464 data, dataLen,
3465 wlan_hdd_extscan_config_policy)) {
3466 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3467 return -EINVAL;
3468 }
3469
3470 /* Parse and fetch request Id */
3471 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3472 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3473 return -EINVAL;
3474 }
3475 requestId = nla_get_u32(
3476 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3477 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
3478
3479 /* Parse and fetch wifi band */
3480 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
3481 {
3482 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
3483 return -EINVAL;
3484 }
3485 wifiBand = nla_get_u32(
3486 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
3487 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
3488
3489 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
3490 wifiBand, ChannelList,
3491 &numChannels);
3492 if (eHAL_STATUS_SUCCESS != status) {
3493 hddLog(VOS_TRACE_LEVEL_ERROR,
3494 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
3495 return -EINVAL;
3496 }
3497 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of channels (%d)"), numChannels);
3498 for (i = 0; i < numChannels; i++)
3499 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %u ", ChannelList[i]);
3500
3501 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
3502 sizeof(u32) * numChannels +
3503 NLMSG_HDRLEN);
3504
3505 if (!replySkb) {
3506 hddLog(VOS_TRACE_LEVEL_ERROR,
3507 FL("valid channels: buffer alloc fail"));
3508 return -EINVAL;
3509 }
3510 if (nla_put_u32(replySkb,
3511 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
3512 numChannels) ||
3513 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
3514 sizeof(u32) * numChannels, ChannelList)) {
3515
3516 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3517 kfree_skb(replySkb);
3518 return -EINVAL;
3519 }
3520
3521 return cfg80211_vendor_cmd_reply(replySkb);
3522}
3523
3524static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
3525 struct wireless_dev *wdev,
3526 void *data, int dataLen)
3527{
Dino Myclee8843b32014-07-04 14:21:45 +05303528 tpSirEXTScanStartReqParams pReqMsg = NULL;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303529 struct net_device *dev = wdev->netdev;
3530 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3531 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3532 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3533 struct nlattr *bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3534 struct nlattr *channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3535 struct nlattr *buckets;
3536 struct nlattr *channels;
3537 int rem1;
3538 int rem2;
3539 eHalStatus status;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303540 tANI_U32 j = 0, index = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303541
3542 status = wlan_hdd_validate_context(pHddCtx);
3543 if (0 != status)
3544 {
3545 hddLog(VOS_TRACE_LEVEL_ERROR,
3546 FL("HDD context is not valid"));
3547 return -EINVAL;
3548 }
Dino Myclee8843b32014-07-04 14:21:45 +05303549 /* check the EXTScan Capability */
3550 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3551 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3552 {
3553 hddLog(VOS_TRACE_LEVEL_ERROR,
3554 FL("EXTScan not enabled/supported by Firmware"));
3555 return -EINVAL;
3556 }
3557
Dino Mycle6fb96c12014-06-10 11:52:40 +05303558 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3559 data, dataLen,
3560 wlan_hdd_extscan_config_policy)) {
3561 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3562 return -EINVAL;
3563 }
3564
3565 /* Parse and fetch request Id */
3566 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3567 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3568 return -EINVAL;
3569 }
3570
Dino Myclee8843b32014-07-04 14:21:45 +05303571 pReqMsg = (tpSirEXTScanStartReqParams)
3572 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303573 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05303574 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3575 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303576 }
3577
3578 pReqMsg->requestId = nla_get_u32(
3579 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3580 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3581
3582 pReqMsg->sessionId = pAdapter->sessionId;
3583 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3584
3585 /* Parse and fetch base period */
3586 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]) {
3587 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
3588 goto fail;
3589 }
3590 pReqMsg->basePeriod = nla_get_u32(
3591 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]);
3592 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
3593 pReqMsg->basePeriod);
3594
3595 /* Parse and fetch max AP per scan */
3596 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]) {
3597 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
3598 goto fail;
3599 }
3600 pReqMsg->maxAPperScan = nla_get_u32(
3601 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]);
3602 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
3603 pReqMsg->maxAPperScan);
3604
3605 /* Parse and fetch report threshold */
3606 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]) {
3607 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
3608 goto fail;
3609 }
3610 pReqMsg->reportThreshold = nla_get_u8(
3611 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]);
3612 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
3613 pReqMsg->reportThreshold);
3614
3615 /* Parse and fetch number of buckets */
3616 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]) {
3617 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
3618 goto fail;
3619 }
3620 pReqMsg->numBuckets = nla_get_u8(
3621 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]);
3622 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
3623 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
3624 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
3625 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
3626 }
3627 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
3628 pReqMsg->numBuckets);
3629 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
3630 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
3631 goto fail;
3632 }
3633
3634 nla_for_each_nested(buckets,
3635 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
3636 if(nla_parse(bucket,
3637 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3638 nla_data(buckets), nla_len(buckets), NULL)) { //policy
3639 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3640 goto fail;
3641 }
3642
3643 /* Parse and fetch bucket spec */
3644 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
3645 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket index failed"));
3646 goto fail;
3647 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303648
3649 pReqMsg->buckets[index].bucket = nla_get_u8(
3650 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
3651
3652 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bucket spec Index (%d)"),
3653 pReqMsg->buckets[index].bucket);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303654
3655 /* Parse and fetch wifi band */
3656 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
3657 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
3658 goto fail;
3659 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303660 pReqMsg->buckets[index].band = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303661 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
3662 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303663 pReqMsg->buckets[index].band);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303664
3665 /* Parse and fetch period */
3666 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
3667 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr period failed"));
3668 goto fail;
3669 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303670 pReqMsg->buckets[index].period = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303671 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
3672 hddLog(VOS_TRACE_LEVEL_INFO, FL("period (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303673 pReqMsg->buckets[index].period);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303674
3675 /* Parse and fetch report events */
3676 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
3677 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report events failed"));
3678 goto fail;
3679 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303680 pReqMsg->buckets[index].reportEvents = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303681 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
3682 hddLog(VOS_TRACE_LEVEL_INFO, FL("report events (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303683 pReqMsg->buckets[index].reportEvents);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303684
3685 /* Parse and fetch number of channels */
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303686 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS])
3687 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303688 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr num channels failed"));
3689 goto fail;
3690 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303691 pReqMsg->buckets[index].numChannels = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303692 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
3693 hddLog(VOS_TRACE_LEVEL_INFO, FL("num channels (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303694 pReqMsg->buckets[index].numChannels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303695
3696 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
3697 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel spec failed"));
3698 goto fail;
3699 }
3700
3701 j = 0;
3702 nla_for_each_nested(channels,
3703 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
3704 if(nla_parse(channel,
3705 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3706 nla_data(channels), nla_len(channels),
3707 NULL)) { //wlan_hdd_extscan_config_policy here
3708 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3709 goto fail;
3710 }
3711
3712 /* Parse and fetch channel */
3713 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
3714 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3715 goto fail;
3716 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303717 pReqMsg->buckets[index].channels[j].channel = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303718 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
3719 hddLog(VOS_TRACE_LEVEL_INFO, FL("channel (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303720 pReqMsg->buckets[index].channels[j].channel);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303721
3722 /* Parse and fetch dwell time */
3723 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
3724 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dwelltime failed"));
3725 goto fail;
3726 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303727 pReqMsg->buckets[index].channels[j].dwellTimeMs = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303728 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
3729 hddLog(VOS_TRACE_LEVEL_INFO, FL("Dwell time (%u ms)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303730 pReqMsg->buckets[index].channels[j].dwellTimeMs);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303731
3732 /* Parse and fetch channel spec passive */
3733 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
3734 hddLog(VOS_TRACE_LEVEL_ERROR,
3735 FL("attr channel spec passive failed"));
3736 goto fail;
3737 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303738 pReqMsg->buckets[index].channels[j].passive = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303739 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
3740 hddLog(VOS_TRACE_LEVEL_INFO, FL("Chnl spec passive (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303741 pReqMsg->buckets[index].channels[j].passive);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303742 j++;
3743 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303744 index++;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303745 }
3746 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
3747 if (!HAL_STATUS_SUCCESS(status)) {
3748 hddLog(VOS_TRACE_LEVEL_ERROR,
3749 FL("sme_EXTScanStart failed(err=%d)"), status);
3750 vos_mem_free(pReqMsg);
3751 return -EINVAL;
3752 }
3753
Dino Myclee8843b32014-07-04 14:21:45 +05303754 vos_mem_free(pReqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303755 return 0;
3756
3757fail:
3758 vos_mem_free(pReqMsg);
3759 return -EINVAL;
3760}
3761
3762static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
3763 struct wireless_dev *wdev,
3764 void *data, int dataLen)
3765{
Dino Myclee8843b32014-07-04 14:21:45 +05303766 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303767 struct net_device *dev = wdev->netdev;
3768 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3769 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3770 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3771 eHalStatus status;
3772
3773 status = wlan_hdd_validate_context(pHddCtx);
3774 if (0 != status)
3775 {
3776 hddLog(VOS_TRACE_LEVEL_ERROR,
3777 FL("HDD context is not valid"));
3778 return -EINVAL;
3779 }
Dino Myclee8843b32014-07-04 14:21:45 +05303780 /* check the EXTScan Capability */
3781 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3782 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3783 {
3784 hddLog(VOS_TRACE_LEVEL_ERROR,
3785 FL("EXTScan not enabled/supported by Firmware"));
3786 return -EINVAL;
3787 }
3788
Dino Mycle6fb96c12014-06-10 11:52:40 +05303789 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3790 data, dataLen,
3791 wlan_hdd_extscan_config_policy)) {
3792 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3793 return -EINVAL;
3794 }
3795
3796 /* Parse and fetch request Id */
3797 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3798 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3799 return -EINVAL;
3800 }
3801
Dino Myclee8843b32014-07-04 14:21:45 +05303802 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303803 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303804 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303805
Dino Myclee8843b32014-07-04 14:21:45 +05303806 reqMsg.sessionId = pAdapter->sessionId;
3807 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303808
Dino Myclee8843b32014-07-04 14:21:45 +05303809 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303810 if (!HAL_STATUS_SUCCESS(status)) {
3811 hddLog(VOS_TRACE_LEVEL_ERROR,
3812 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303813 return -EINVAL;
3814 }
3815
3816 return 0;
3817}
3818
3819static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
3820 struct wireless_dev *wdev,
3821 void *data, int dataLen)
3822{
Dino Myclee8843b32014-07-04 14:21:45 +05303823 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303824 struct net_device *dev = wdev->netdev;
3825 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3826 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3827 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3828 eHalStatus status;
3829
3830 status = wlan_hdd_validate_context(pHddCtx);
3831 if (0 != status)
3832 {
3833 hddLog(VOS_TRACE_LEVEL_ERROR,
3834 FL("HDD context is not valid"));
3835 return -EINVAL;
3836 }
Dino Myclee8843b32014-07-04 14:21:45 +05303837 /* check the EXTScan Capability */
3838 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3839 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3840 {
3841 hddLog(VOS_TRACE_LEVEL_ERROR,
3842 FL("EXTScan not enabled/supported by Firmware"));
3843 return -EINVAL;
3844 }
3845
Dino Mycle6fb96c12014-06-10 11:52:40 +05303846 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3847 data, dataLen,
3848 wlan_hdd_extscan_config_policy)) {
3849 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3850 return -EINVAL;
3851 }
3852
3853 /* Parse and fetch request Id */
3854 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3855 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3856 return -EINVAL;
3857 }
3858
Dino Myclee8843b32014-07-04 14:21:45 +05303859 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303860 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303861 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303862
Dino Myclee8843b32014-07-04 14:21:45 +05303863 reqMsg.sessionId = pAdapter->sessionId;
3864 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303865
Dino Myclee8843b32014-07-04 14:21:45 +05303866 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303867 if (!HAL_STATUS_SUCCESS(status)) {
3868 hddLog(VOS_TRACE_LEVEL_ERROR,
3869 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303870 return -EINVAL;
3871 }
3872
3873 return 0;
3874}
3875
3876static int wlan_hdd_cfg80211_extscan_reset_significant_change(
3877 struct wiphy *wiphy,
3878 struct wireless_dev *wdev,
3879 void *data, int dataLen)
3880{
Dino Myclee8843b32014-07-04 14:21:45 +05303881 tSirEXTScanResetSignificantChangeReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303882 struct net_device *dev = wdev->netdev;
3883 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3884 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3885 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3886 eHalStatus status;
3887
3888 hddLog(VOS_TRACE_LEVEL_INFO, FL(" Entering"));
3889 status = wlan_hdd_validate_context(pHddCtx);
3890 if (0 != status)
3891 {
3892 hddLog(VOS_TRACE_LEVEL_ERROR,
3893 FL("HDD context is not valid"));
3894 return -EINVAL;
3895 }
Dino Myclee8843b32014-07-04 14:21:45 +05303896 /* check the EXTScan Capability */
3897 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3898 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3899 {
3900 hddLog(VOS_TRACE_LEVEL_ERROR,
3901 FL("EXTScan not enabled/supported by Firmware"));
3902 return -EINVAL;
3903 }
3904
Dino Mycle6fb96c12014-06-10 11:52:40 +05303905 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3906 data, dataLen,
3907 wlan_hdd_extscan_config_policy)) {
3908 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3909 return -EINVAL;
3910 }
3911
3912 /* Parse and fetch request Id */
3913 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3914 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3915 return -EINVAL;
3916 }
3917
Dino Mycle6fb96c12014-06-10 11:52:40 +05303918
Dino Myclee8843b32014-07-04 14:21:45 +05303919 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303920 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303921 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303922
Dino Myclee8843b32014-07-04 14:21:45 +05303923 reqMsg.sessionId = pAdapter->sessionId;
3924 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303925
Dino Myclee8843b32014-07-04 14:21:45 +05303926 status = sme_ResetSignificantChange(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303927 if (!HAL_STATUS_SUCCESS(status)) {
3928 hddLog(VOS_TRACE_LEVEL_ERROR,
3929 FL("sme_ResetSignificantChange failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303930 return -EINVAL;
3931 }
3932
3933 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Exiting"));
3934 return 0;
3935}
3936
3937#endif /* WLAN_FEATURE_EXTSCAN */
3938
Atul Mittal115287b2014-07-08 13:26:33 +05303939/*EXT TDLS*/
3940static const struct nla_policy
3941wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
3942{
3943 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
3944 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
3945 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
3946 {.type = NLA_S32 },
3947 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
3948 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
3949
3950};
3951
3952static const struct nla_policy
3953wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
3954{
3955 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
3956
3957};
3958
3959static const struct nla_policy
3960wlan_hdd_tdls_config_state_change_policy[
3961 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
3962{
3963 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
3964 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
3965 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
3966
3967};
3968
3969static const struct nla_policy
3970wlan_hdd_tdls_config_get_status_policy[
3971 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
3972{
3973 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
3974 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
3975 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
3976
3977};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05303978
3979static const struct nla_policy
3980wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
3981{
3982 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
3983};
3984
3985static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
3986 struct wireless_dev *wdev,
3987 void *data,
3988 int data_len)
3989{
3990
3991 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3992 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
3993
3994 if (0 != wlan_hdd_validate_context(pHddCtx)){
3995 hddLog(VOS_TRACE_LEVEL_ERROR, FL("hdd Ctx invalid while spoof macAddr"));
3996 return -EINVAL;
3997 }
3998 if (FALSE == pHddCtx->cfg_ini->enableMacSpoofing) {
3999 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MAC_SPOOFED_SCAN disabled in ini"));
4000 return -ENOTSUPP;
4001 }
4002 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
4003 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MAC_SPOOFED_SCAN not supported by FW"));
4004 return -ENOTSUPP;
4005 }
4006
4007 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
4008 data, data_len, wlan_hdd_mac_config)) {
4009 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4010 return -EINVAL;
4011 }
4012
4013 /* Parse and fetch mac address */
4014 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
4015 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4016 return -EINVAL;
4017 }
4018
4019 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
4020 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4021 VOS_MAC_ADDR_LAST_3_BYTES);
4022
4023 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,nla_data(
4024 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4025 VOS_MAC_ADDR_FIRST_3_BYTES);
4026
4027 if (VOS_STATUS_SUCCESS != vos_randomize_n_bytes(
4028 (void *)(&pHddCtx->spoofMacAddr.randomMacAddr.bytes[3]),
4029 VOS_MAC_ADDR_LAST_3_BYTES)) {
4030 hddLog(LOGE, FL("Failed to generate random Mac Addr"));
4031 }
4032 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4033 pHddCtx->spoofMacAddr.randomMacAddr.bytes,
4034 VOS_MAC_ADDR_SIZE);
4035
4036 if (eHAL_STATUS_SUCCESS != sme_SpoofMacAddrReq(pHddCtx->hHal,
4037 &pHddCtx->spoofMacAddr.randomMacAddr)) {
4038 hddLog(LOGE, FL("Failed to send Spoof Mac Addr to FW"));
4039 }
4040
4041 return 0;
4042}
4043
Atul Mittal115287b2014-07-08 13:26:33 +05304044static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
4045 struct wireless_dev *wdev,
4046 void *data,
4047 int data_len)
4048{
4049 u8 peer[6] = {0};
4050 struct net_device *dev = wdev->netdev;
4051 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4052 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4053 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
4054 eHalStatus ret;
4055 tANI_S32 state;
4056 tANI_S32 reason;
4057 struct sk_buff *skb = NULL;
4058
4059 ret = wlan_hdd_validate_context(pHddCtx);
4060 if (0 != ret) {
4061
4062 return -EINVAL;
4063 }
4064 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
4065
4066 return -ENOTSUPP;
4067 }
4068 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
4069 data, data_len,
4070 wlan_hdd_tdls_config_get_status_policy)) {
4071 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4072 return -EINVAL;
4073 }
4074
4075 /* Parse and fetch mac address */
4076 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
4077 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4078 return -EINVAL;
4079 }
4080
4081 memcpy(peer, nla_data(
4082 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
4083 sizeof(peer));
4084 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4085
4086 ret = wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
4087
4088 if (0 != ret) {
4089 hddLog(VOS_TRACE_LEVEL_ERROR,
4090 FL("get status Failed"));
4091 return -EINVAL;
4092 }
4093 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
4094 2 * sizeof(s32) +
4095 NLMSG_HDRLEN);
4096
4097 if (!skb) {
4098 hddLog(VOS_TRACE_LEVEL_ERROR,
4099 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
4100 return -EINVAL;
4101 }
4102 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reason (%d) Status (%d) tdls peer" MAC_ADDRESS_STR),
4103 reason,
4104 state,
4105 MAC_ADDR_ARRAY(peer));
4106
4107 if (nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE, state) ||
4108 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON, reason)) {
4109
4110 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4111 goto nla_put_failure;
4112 }
4113
4114 return cfg80211_vendor_cmd_reply(skb);
4115
4116nla_put_failure:
4117 kfree_skb(skb);
4118 return -EINVAL;
4119}
4120
4121static int wlan_hdd_cfg80211_exttdls_callback(tANI_U8* mac,
4122 tANI_S32 state,
4123 tANI_S32 reason,
4124 void *ctx)
4125{
4126 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
4127 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4128 struct sk_buff *skb = NULL;
4129
4130 if (wlan_hdd_validate_context(pHddCtx)) {
4131 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "));
4132 return -EINVAL;
4133 }
4134
4135 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
4136
4137 return -ENOTSUPP;
4138 }
4139 skb = cfg80211_vendor_event_alloc(
4140 pHddCtx->wiphy,
4141 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
4142 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
4143 GFP_KERNEL);
4144
4145 if (!skb) {
4146 hddLog(VOS_TRACE_LEVEL_ERROR,
4147 FL("cfg80211_vendor_event_alloc failed"));
4148 return -EINVAL;
4149 }
4150 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
4151 hddLog(VOS_TRACE_LEVEL_INFO, "Reason (%d) Status (%d)", reason, state);
4152 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
4153 MAC_ADDR_ARRAY(mac));
4154
4155 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
4156 VOS_MAC_ADDR_SIZE, mac) ||
4157 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE, state) ||
4158 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON, reason)
4159 ) {
4160
4161 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4162 goto nla_put_failure;
4163 }
4164
4165 cfg80211_vendor_event(skb, GFP_KERNEL);
4166 return (0);
4167
4168nla_put_failure:
4169 kfree_skb(skb);
4170 return -EINVAL;
4171}
4172
4173static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
4174 struct wireless_dev *wdev,
4175 void *data,
4176 int data_len)
4177{
4178 u8 peer[6] = {0};
4179 struct net_device *dev = wdev->netdev;
4180 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4181 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4182 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
4183 eHalStatus status;
4184 tdls_req_params_t pReqMsg = {0};
4185
4186 status = wlan_hdd_validate_context(pHddCtx);
4187 if (0 != status) {
4188 hddLog(VOS_TRACE_LEVEL_ERROR,
4189 FL("HDD context is not valid"));
4190 return -EINVAL;
4191 }
4192 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
4193
4194 return -ENOTSUPP;
4195 }
4196 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
4197 data, data_len,
4198 wlan_hdd_tdls_config_enable_policy)) {
4199 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4200 return -EINVAL;
4201 }
4202
4203 /* Parse and fetch mac address */
4204 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
4205 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4206 return -EINVAL;
4207 }
4208
4209 memcpy(peer, nla_data(
4210 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
4211 sizeof(peer));
4212 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4213
4214 /* Parse and fetch channel */
4215 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
4216 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4217 return -EINVAL;
4218 }
4219 pReqMsg.channel = nla_get_s32(
4220 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
4221 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
4222
4223 /* Parse and fetch global operating class */
4224 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
4225 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
4226 return -EINVAL;
4227 }
4228 pReqMsg.global_operating_class = nla_get_s32(
4229 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
4230 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
4231 pReqMsg.global_operating_class);
4232
4233 /* Parse and fetch latency ms */
4234 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
4235 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
4236 return -EINVAL;
4237 }
4238 pReqMsg.max_latency_ms = nla_get_s32(
4239 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
4240 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
4241 pReqMsg.max_latency_ms);
4242
4243 /* Parse and fetch required bandwidth kbps */
4244 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
4245 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
4246 return -EINVAL;
4247 }
4248
4249 pReqMsg.min_bandwidth_kbps = nla_get_s32(
4250 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
4251 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
4252 pReqMsg.min_bandwidth_kbps);
4253
4254 return (wlan_hdd_tdls_extctrl_config_peer(pAdapter,
4255 peer,
4256 wlan_hdd_cfg80211_exttdls_callback));
4257}
4258
4259static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
4260 struct wireless_dev *wdev,
4261 void *data,
4262 int data_len)
4263{
4264 u8 peer[6] = {0};
4265 struct net_device *dev = wdev->netdev;
4266 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4267 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4268 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
4269 eHalStatus status;
4270
4271 status = wlan_hdd_validate_context(pHddCtx);
4272 if (0 != status) {
4273 hddLog(VOS_TRACE_LEVEL_ERROR,
4274 FL("HDD context is not valid"));
4275 return -EINVAL;
4276 }
4277 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
4278
4279 return -ENOTSUPP;
4280 }
4281 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
4282 data, data_len,
4283 wlan_hdd_tdls_config_disable_policy)) {
4284 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4285 return -EINVAL;
4286 }
4287 /* Parse and fetch mac address */
4288 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
4289 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4290 return -EINVAL;
4291 }
4292
4293 memcpy(peer, nla_data(
4294 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
4295 sizeof(peer));
4296 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4297
4298 return (wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer));
4299}
4300
Dasari Srinivas7875a302014-09-26 17:50:57 +05304301static int
4302wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
4303 struct wireless_dev *wdev,
4304 void *data, int data_len)
4305{
4306 struct net_device *dev = wdev->netdev;
4307 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4308 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4309 struct sk_buff *skb = NULL;
4310 tANI_U32 fset = 0;
4311
4312 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
4313 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
4314 fset |= WIFI_FEATURE_INFRA;
4315 }
4316
4317 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
4318 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
4319 fset |= WIFI_FEATURE_INFRA_5G;
4320 }
4321
4322#ifdef WLAN_FEATURE_P2P
4323 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
4324 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
4325 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
4326 fset |= WIFI_FEATURE_P2P;
4327 }
4328#endif
4329
4330 /* Soft-AP is supported currently by default */
4331 fset |= WIFI_FEATURE_SOFT_AP;
4332
4333#ifdef WLAN_FEATURE_EXTSCAN
4334 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
4335 sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) {
4336 hddLog(LOG1, FL("EXTScan is supported by firmware"));
4337 fset |= WIFI_FEATURE_EXTSCAN;
4338 }
4339#endif
4340
4341#ifdef WLAN_FEATURE_NAN
4342 if (sme_IsFeatureSupportedByFW(NAN)) {
4343 hddLog(LOG1, FL("NAN is supported by firmware"));
4344 fset |= WIFI_FEATURE_NAN;
4345 }
4346#endif
4347
4348 /* D2D RTT is not supported currently by default */
4349 if (sme_IsFeatureSupportedByFW(RTT)) {
4350 hddLog(LOG1, FL("RTT is supported by firmware"));
4351 fset |= WIFI_FEATURE_D2AP_RTT;
4352 }
4353
4354#ifdef FEATURE_WLAN_BATCH_SCAN
4355 if (fset & WIFI_FEATURE_EXTSCAN) {
4356 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
4357 fset &= ~WIFI_FEATURE_BATCH_SCAN;
4358 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
4359 hddLog(LOG1, FL("Batch scan is supported by firmware"));
4360 fset |= WIFI_FEATURE_BATCH_SCAN;
4361 }
4362#endif
4363
4364#ifdef FEATURE_WLAN_SCAN_PNO
4365 if (pHddCtx->cfg_ini->configPNOScanSupport &&
4366 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
4367 hddLog(LOG1, FL("PNO is supported by firmware"));
4368 fset |= WIFI_FEATURE_PNO;
4369 }
4370#endif
4371
4372 /* STA+STA is supported currently by default */
4373 fset |= WIFI_FEATURE_ADDITIONAL_STA;
4374
4375#ifdef FEATURE_WLAN_TDLS
4376 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
4377 sme_IsFeatureSupportedByFW(TDLS)) {
4378 hddLog(LOG1, FL("TDLS is supported by firmware"));
4379 fset |= WIFI_FEATURE_TDLS;
4380 }
4381
4382 /* TDLS_OFFCHANNEL is not supported currently by default */
4383#endif
4384
4385#ifdef WLAN_AP_STA_CONCURRENCY
4386 /* AP+STA concurrency is supported currently by default */
4387 fset |= WIFI_FEATURE_AP_STA;
4388#endif
4389
4390 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
4391 NLMSG_HDRLEN);
4392
4393 if (!skb) {
4394 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
4395 return -EINVAL;
4396 }
4397 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
4398
4399 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
4400 hddLog(LOGE, FL("nla put fail"));
4401 goto nla_put_failure;
4402 }
4403
4404 return cfg80211_vendor_cmd_reply(skb);
4405
4406nla_put_failure:
4407 kfree_skb(skb);
4408 return -EINVAL;
4409}
4410
Agarwal Ashish738843c2014-09-25 12:27:56 +05304411static const struct nla_policy
4412wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
4413 +1] =
4414{
4415 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
4416};
4417
4418static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
4419 struct wireless_dev *wdev,
4420 void *data,
4421 int data_len)
4422{
4423 struct net_device *dev = wdev->netdev;
4424 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4425 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4426 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4427 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
4428 eHalStatus status;
4429 u32 dfsFlag = 0;
4430
4431 status = wlan_hdd_validate_context(pHddCtx);
4432 if (0 != status) {
4433 hddLog(VOS_TRACE_LEVEL_ERROR,
4434 FL("HDD context is not valid"));
4435 return -EINVAL;
4436 }
4437 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
4438 data, data_len,
4439 wlan_hdd_set_no_dfs_flag_config_policy)) {
4440 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4441 return -EINVAL;
4442 }
4443
4444 /* Parse and fetch required bandwidth kbps */
4445 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
4446 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
4447 return -EINVAL;
4448 }
4449
4450 dfsFlag = nla_get_u32(
4451 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
4452 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
4453 dfsFlag);
4454
4455 pHddCtx->disable_dfs_flag = dfsFlag;
4456
4457 sme_disable_dfs_channel(hHal, dfsFlag);
4458 sme_FilterScanResults(hHal, pAdapter->sessionId);
4459 return 0;
4460}
Atul Mittal115287b2014-07-08 13:26:33 +05304461
Sunil Duttc69bccb2014-05-26 21:30:20 +05304462const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
4463{
4464#ifdef WLAN_FEATURE_LINK_LAYER_STATS
4465 {
4466 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4467 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
4468 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4469 WIPHY_VENDOR_CMD_NEED_NETDEV |
4470 WIPHY_VENDOR_CMD_NEED_RUNNING,
4471 .doit = wlan_hdd_cfg80211_ll_stats_clear
4472 },
4473
4474 {
4475 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4476 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
4477 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4478 WIPHY_VENDOR_CMD_NEED_NETDEV |
4479 WIPHY_VENDOR_CMD_NEED_RUNNING,
4480 .doit = wlan_hdd_cfg80211_ll_stats_set
4481 },
4482
4483 {
4484 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4485 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
4486 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4487 WIPHY_VENDOR_CMD_NEED_NETDEV |
4488 WIPHY_VENDOR_CMD_NEED_RUNNING,
4489 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05304490 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05304491#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05304492#ifdef WLAN_FEATURE_EXTSCAN
4493 {
4494 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4495 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
4496 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4497 WIPHY_VENDOR_CMD_NEED_NETDEV |
4498 WIPHY_VENDOR_CMD_NEED_RUNNING,
4499 .doit = wlan_hdd_cfg80211_extscan_start
4500 },
4501 {
4502 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4503 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
4504 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4505 WIPHY_VENDOR_CMD_NEED_NETDEV |
4506 WIPHY_VENDOR_CMD_NEED_RUNNING,
4507 .doit = wlan_hdd_cfg80211_extscan_stop
4508 },
4509 {
4510 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4511 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
4512 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4513 WIPHY_VENDOR_CMD_NEED_NETDEV,
4514 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
4515 },
4516 {
4517 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4518 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
4519 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4520 WIPHY_VENDOR_CMD_NEED_NETDEV |
4521 WIPHY_VENDOR_CMD_NEED_RUNNING,
4522 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
4523 },
4524 {
4525 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4526 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
4527 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4528 WIPHY_VENDOR_CMD_NEED_NETDEV |
4529 WIPHY_VENDOR_CMD_NEED_RUNNING,
4530 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
4531 },
4532 {
4533 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4534 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
4535 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4536 WIPHY_VENDOR_CMD_NEED_NETDEV |
4537 WIPHY_VENDOR_CMD_NEED_RUNNING,
4538 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
4539 },
4540 {
4541 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4542 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
4543 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4544 WIPHY_VENDOR_CMD_NEED_NETDEV |
4545 WIPHY_VENDOR_CMD_NEED_RUNNING,
4546 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
4547 },
4548 {
4549 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4550 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE,
4551 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4552 WIPHY_VENDOR_CMD_NEED_NETDEV |
4553 WIPHY_VENDOR_CMD_NEED_RUNNING,
4554 .doit = wlan_hdd_cfg80211_extscan_set_significant_change
4555 },
4556 {
4557 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4558 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE,
4559 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4560 WIPHY_VENDOR_CMD_NEED_NETDEV |
4561 WIPHY_VENDOR_CMD_NEED_RUNNING,
4562 .doit = wlan_hdd_cfg80211_extscan_reset_significant_change
4563 },
4564#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05304565/*EXT TDLS*/
4566 {
4567 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4568 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
4569 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4570 WIPHY_VENDOR_CMD_NEED_NETDEV |
4571 WIPHY_VENDOR_CMD_NEED_RUNNING,
4572 .doit = wlan_hdd_cfg80211_exttdls_enable
4573 },
4574 {
4575 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4576 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
4577 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4578 WIPHY_VENDOR_CMD_NEED_NETDEV |
4579 WIPHY_VENDOR_CMD_NEED_RUNNING,
4580 .doit = wlan_hdd_cfg80211_exttdls_disable
4581 },
4582 {
4583 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4584 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
4585 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4586 WIPHY_VENDOR_CMD_NEED_NETDEV,
4587 .doit = wlan_hdd_cfg80211_exttdls_get_status
4588 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05304589 {
4590 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4591 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
4592 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4593 WIPHY_VENDOR_CMD_NEED_NETDEV,
4594 .doit = wlan_hdd_cfg80211_get_supported_features
4595 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05304596 {
4597 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4598 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
4599 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4600 WIPHY_VENDOR_CMD_NEED_NETDEV,
4601 .doit = wlan_hdd_cfg80211_disable_dfs_channels
4602 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304603 {
4604 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4605 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
4606 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4607 WIPHY_VENDOR_CMD_NEED_NETDEV,
4608 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
4609 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05304610};
4611
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08004612/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05304613static const
4614struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08004615{
4616#ifdef FEATURE_WLAN_CH_AVOID
4617 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05304618 .vendor_id = QCA_NL80211_VENDOR_ID,
4619 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08004620 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05304621#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
4622#ifdef WLAN_FEATURE_LINK_LAYER_STATS
4623 {
4624 /* Index = 1*/
4625 .vendor_id = QCA_NL80211_VENDOR_ID,
4626 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
4627 },
4628 {
4629 /* Index = 2*/
4630 .vendor_id = QCA_NL80211_VENDOR_ID,
4631 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
4632 },
4633 {
4634 /* Index = 3*/
4635 .vendor_id = QCA_NL80211_VENDOR_ID,
4636 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
4637 },
4638 {
4639 /* Index = 4*/
4640 .vendor_id = QCA_NL80211_VENDOR_ID,
4641 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
4642 },
4643 {
4644 /* Index = 5*/
4645 .vendor_id = QCA_NL80211_VENDOR_ID,
4646 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
4647 },
4648 {
4649 /* Index = 6*/
4650 .vendor_id = QCA_NL80211_VENDOR_ID,
4651 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
4652 },
4653#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05304654#ifdef WLAN_FEATURE_EXTSCAN
4655 {
4656 .vendor_id = QCA_NL80211_VENDOR_ID,
4657 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
4658 },
4659 {
4660 .vendor_id = QCA_NL80211_VENDOR_ID,
4661 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
4662 },
4663 {
4664 .vendor_id = QCA_NL80211_VENDOR_ID,
4665 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
4666 },
4667 {
4668 .vendor_id = QCA_NL80211_VENDOR_ID,
4669 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
4670 },
4671 {
4672 .vendor_id = QCA_NL80211_VENDOR_ID,
4673 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
4674 },
4675 {
4676 .vendor_id = QCA_NL80211_VENDOR_ID,
4677 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
4678 },
4679 {
4680 .vendor_id = QCA_NL80211_VENDOR_ID,
4681 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
4682 },
4683 {
4684 .vendor_id = QCA_NL80211_VENDOR_ID,
4685 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
4686 },
4687 {
4688 .vendor_id = QCA_NL80211_VENDOR_ID,
4689 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
4690 },
4691 {
4692 .vendor_id = QCA_NL80211_VENDOR_ID,
4693 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
4694 },
4695 {
4696 .vendor_id = QCA_NL80211_VENDOR_ID,
4697 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE
4698 },
4699 {
4700 .vendor_id = QCA_NL80211_VENDOR_ID,
4701 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE
4702 },
4703 {
4704 .vendor_id = QCA_NL80211_VENDOR_ID,
4705 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE
4706 },
4707#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05304708/*EXT TDLS*/
4709 {
4710 .vendor_id = QCA_NL80211_VENDOR_ID,
4711 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
4712 },
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08004713};
4714
Jeff Johnson295189b2012-06-20 16:38:30 -07004715/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05304716 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304717 * This function is called by hdd_wlan_startup()
4718 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05304719 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07004720 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05304721struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07004722{
4723 struct wiphy *wiphy;
4724 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304725 /*
4726 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07004727 */
4728 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
4729
4730 if (!wiphy)
4731 {
4732 /* Print error and jump into err label and free the memory */
4733 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
4734 return NULL;
4735 }
4736
Sunil Duttc69bccb2014-05-26 21:30:20 +05304737
Jeff Johnson295189b2012-06-20 16:38:30 -07004738 return wiphy;
4739}
4740
4741/*
4742 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304743 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07004744 * private ioctl to change the band value
4745 */
4746int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
4747{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05304748 int i, j;
4749 eNVChannelEnabledType channelEnabledState;
4750
Jeff Johnsone7245742012-09-05 17:12:55 -07004751 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304752
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05304753 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07004754 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05304755
4756 if (NULL == wiphy->bands[i])
4757 {
4758 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
4759 __func__, i);
4760 continue;
4761 }
4762
4763 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
4764 {
4765 struct ieee80211_supported_band *band = wiphy->bands[i];
4766
4767 channelEnabledState = vos_nv_getChannelEnabledState(
4768 band->channels[j].hw_value);
4769
4770 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
4771 {
4772 // Enable Social channels for P2P
4773 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq) &&
4774 NV_CHANNEL_ENABLE == channelEnabledState)
4775 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
4776 else
4777 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
4778 continue;
4779 }
4780 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
4781 {
4782 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
4783 continue;
4784 }
4785
4786 if (NV_CHANNEL_DISABLE == channelEnabledState ||
4787 NV_CHANNEL_INVALID == channelEnabledState)
4788 {
4789 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
4790 }
4791 else if (NV_CHANNEL_DFS == channelEnabledState)
4792 {
4793 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
4794 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
4795 }
4796 else
4797 {
4798 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
4799 |IEEE80211_CHAN_RADAR);
4800 }
4801 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004802 }
4803 return 0;
4804}
4805/*
4806 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304807 * This function is called by hdd_wlan_startup()
4808 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07004809 * This function is used to initialize and register wiphy structure.
4810 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05304811int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004812 struct wiphy *wiphy,
4813 hdd_config_t *pCfg
4814 )
4815{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05304816 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05304817 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4818
Jeff Johnsone7245742012-09-05 17:12:55 -07004819 ENTER();
4820
Jeff Johnson295189b2012-06-20 16:38:30 -07004821 /* Now bind the underlying wlan device with wiphy */
4822 set_wiphy_dev(wiphy, dev);
4823
4824 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07004825
Kiet Lam6c583332013-10-14 05:37:09 +05304826#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07004827 /* the flag for the other case would be initialzed in
4828 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07004829 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05304830#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07004831
Amar Singhalfddc28c2013-09-05 13:03:40 -07004832 /* This will disable updating of NL channels from passive to
4833 * active if a beacon is received on passive channel. */
4834 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Amar Singhalf0073192013-09-20 12:34:56 -07004835
Amar Singhalfddc28c2013-09-05 13:03:40 -07004836
Amar Singhala49cbc52013-10-08 18:37:44 -07004837
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004838#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004839 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
4840 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
4841 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07004842 | WIPHY_FLAG_OFFCHAN_TX;
Kiet Lam6c583332013-10-14 05:37:09 +05304843 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004844#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07004845
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004846#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07004847 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08004848#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07004849 || pCfg->isFastRoamIniFeatureEnabled
4850#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004851#ifdef FEATURE_WLAN_ESE
4852 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07004853#endif
4854 )
4855 {
4856 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
4857 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08004858#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004859#ifdef FEATURE_WLAN_TDLS
4860 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
4861 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
4862#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05304863#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05304864 if (pCfg->configPNOScanSupport)
4865 {
4866 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
4867 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
4868 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
4869 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
4870 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05304871#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004872
Amar Singhalfddc28c2013-09-05 13:03:40 -07004873#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07004874 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
4875 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07004876 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07004877 driver need to determine what to do with both
4878 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07004879
4880 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07004881#else
4882 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07004883#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004884
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304885 wiphy->max_scan_ssids = MAX_SCAN_SSID;
4886
Madan Mohan Koyyalamudi6815b162013-07-19 17:17:46 +05304887 wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07004888
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05304889 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
4890
Jeff Johnson295189b2012-06-20 16:38:30 -07004891 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304892 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07004893 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -07004894 | BIT(NL80211_IFTYPE_P2P_CLIENT)
4895 | BIT(NL80211_IFTYPE_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07004896 | BIT(NL80211_IFTYPE_AP);
4897
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05304898 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08004899 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05304900#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
4901 if( pCfg->enableMCC )
4902 {
4903 /* Currently, supports up to two channels */
4904 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08004905
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05304906 if( !pCfg->allowMCCGODiffBI )
4907 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08004908
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05304909 }
4910 wiphy->iface_combinations = &wlan_hdd_iface_combination;
4911 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08004912#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05304913 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08004914
Jeff Johnson295189b2012-06-20 16:38:30 -07004915 /* Before registering we need to update the ht capabilitied based
4916 * on ini values*/
4917 if( !pCfg->ShortGI20MhzEnable )
4918 {
4919 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
4920 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
4921 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
4922 }
4923
4924 if( !pCfg->ShortGI40MhzEnable )
4925 {
4926 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
4927 }
4928
4929 if( !pCfg->nChannelBondingMode5GHz )
4930 {
4931 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
4932 }
4933
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05304934 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05304935 if (true == hdd_is_5g_supported(pHddCtx))
4936 {
4937 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
4938 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05304939
4940 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
4941 {
4942
4943 if (NULL == wiphy->bands[i])
4944 {
4945 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
4946 __func__, i);
4947 continue;
4948 }
4949
4950 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
4951 {
4952 struct ieee80211_supported_band *band = wiphy->bands[i];
4953
4954 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
4955 {
4956 // Enable social channels for P2P
4957 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
4958 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
4959 else
4960 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
4961 continue;
4962 }
4963 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
4964 {
4965 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
4966 continue;
4967 }
4968 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004969 }
4970 /*Initialise the supported cipher suite details*/
4971 wiphy->cipher_suites = hdd_cipher_suites;
4972 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
4973
4974 /*signal strength in mBm (100*dBm) */
4975 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
4976
4977#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05304978 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07004979#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004980
Sunil Duttc69bccb2014-05-26 21:30:20 +05304981 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
4982 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08004983 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
4984 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
4985
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05304986 EXIT();
4987 return 0;
4988}
4989
4990/* In this function we are registering wiphy. */
4991int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
4992{
4993 ENTER();
4994 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004995 if (0 > wiphy_register(wiphy))
4996 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05304997 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07004998 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
4999 return -EIO;
5000 }
5001
5002 EXIT();
5003 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305004}
Jeff Johnson295189b2012-06-20 16:38:30 -07005005
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305006/* In this function we are updating channel list when,
5007 regulatory domain is FCC and country code is US.
5008 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
5009 As per FCC smart phone is not a indoor device.
5010 GO should not opeate on indoor channels */
5011void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
5012{
5013 int j;
5014 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5015 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
5016 //Default counrtycode from NV at the time of wiphy initialization.
5017 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
5018 &defaultCountryCode[0]))
5019 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005020 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305021 }
5022 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
5023 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305024 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
5025 {
5026 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
5027 return;
5028 }
5029 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
5030 {
5031 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
5032 // Mark UNII -1 band channel as passive
5033 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
5034 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
5035 }
5036 }
5037}
5038
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05305039/* This function registers for all frame which supplicant is interested in */
5040void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005041{
Jeff Johnson295189b2012-06-20 16:38:30 -07005042 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5043 /* Register for all P2P action, public action etc frames */
5044 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
5045
Jeff Johnsone7245742012-09-05 17:12:55 -07005046 ENTER();
5047
Jeff Johnson295189b2012-06-20 16:38:30 -07005048 /* Right now we are registering these frame when driver is getting
5049 initialized. Once we will move to 2.6.37 kernel, in which we have
5050 frame register ops, we will move this code as a part of that */
5051 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305052 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07005053 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
5054
5055 /* GAS Initial Response */
5056 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5057 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305058
Jeff Johnson295189b2012-06-20 16:38:30 -07005059 /* GAS Comeback Request */
5060 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5061 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
5062
5063 /* GAS Comeback Response */
5064 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5065 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
5066
5067 /* P2P Public Action */
5068 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305069 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07005070 P2P_PUBLIC_ACTION_FRAME_SIZE );
5071
5072 /* P2P Action */
5073 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5074 (v_U8_t*)P2P_ACTION_FRAME,
5075 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07005076
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05305077 /* WNM BSS Transition Request frame */
5078 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5079 (v_U8_t*)WNM_BSS_ACTION_FRAME,
5080 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07005081
5082 /* WNM-Notification */
5083 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5084 (v_U8_t*)WNM_NOTIFICATION_FRAME,
5085 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005086}
5087
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05305088void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005089{
Jeff Johnson295189b2012-06-20 16:38:30 -07005090 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5091 /* Register for all P2P action, public action etc frames */
5092 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
5093
Jeff Johnsone7245742012-09-05 17:12:55 -07005094 ENTER();
5095
Jeff Johnson295189b2012-06-20 16:38:30 -07005096 /* Right now we are registering these frame when driver is getting
5097 initialized. Once we will move to 2.6.37 kernel, in which we have
5098 frame register ops, we will move this code as a part of that */
5099 /* GAS Initial Request */
5100
5101 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5102 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
5103
5104 /* GAS Initial Response */
5105 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5106 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305107
Jeff Johnson295189b2012-06-20 16:38:30 -07005108 /* GAS Comeback Request */
5109 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5110 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
5111
5112 /* GAS Comeback Response */
5113 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5114 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
5115
5116 /* P2P Public Action */
5117 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305118 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07005119 P2P_PUBLIC_ACTION_FRAME_SIZE );
5120
5121 /* P2P Action */
5122 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5123 (v_U8_t*)P2P_ACTION_FRAME,
5124 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07005125 /* WNM-Notification */
5126 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5127 (v_U8_t*)WNM_NOTIFICATION_FRAME,
5128 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005129}
5130
5131#ifdef FEATURE_WLAN_WAPI
5132void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
5133 const u8 *mac_addr, u8 *key , int key_Len)
5134{
5135 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5136 tCsrRoamSetKey setKey;
5137 v_BOOL_t isConnected = TRUE;
5138 int status = 0;
5139 v_U32_t roamId= 0xFF;
5140 tANI_U8 *pKeyPtr = NULL;
5141 int n = 0;
5142
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305143 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
5144 __func__, hdd_device_modetoString(pAdapter->device_mode),
5145 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005146
Gopichand Nakkalae7480202013-02-11 15:24:22 +05305147 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07005148 setKey.keyId = key_index; // Store Key ID
5149 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
5150 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
5151 setKey.paeRole = 0 ; // the PAE role
5152 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
5153 {
5154 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
5155 }
5156 else
5157 {
5158 isConnected = hdd_connIsConnected(pHddStaCtx);
5159 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
5160 }
5161 setKey.keyLength = key_Len;
5162 pKeyPtr = setKey.Key;
5163 memcpy( pKeyPtr, key, key_Len);
5164
Arif Hussain6d2a3322013-11-17 19:50:10 -08005165 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07005166 __func__, key_Len);
5167 for (n = 0 ; n < key_Len; n++)
5168 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
5169 __func__,n,setKey.Key[n]);
5170
5171 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5172 if ( isConnected )
5173 {
5174 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
5175 pAdapter->sessionId, &setKey, &roamId );
5176 }
5177 if ( status != 0 )
5178 {
5179 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5180 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5181 __LINE__, status );
5182 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5183 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05305184 /* Need to clear any trace of key value in the memory.
5185 * Thus zero out the memory even though it is local
5186 * variable.
5187 */
5188 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07005189}
5190#endif /* FEATURE_WLAN_WAPI*/
5191
5192#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305193int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005194 beacon_data_t **ppBeacon,
5195 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005196#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305197int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005198 beacon_data_t **ppBeacon,
5199 struct cfg80211_beacon_data *params,
5200 int dtim_period)
5201#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305202{
Jeff Johnson295189b2012-06-20 16:38:30 -07005203 int size;
5204 beacon_data_t *beacon = NULL;
5205 beacon_data_t *old = NULL;
5206 int head_len,tail_len;
5207
Jeff Johnsone7245742012-09-05 17:12:55 -07005208 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07005209 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305210 {
5211 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5212 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005213 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305214 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005215
5216 old = pAdapter->sessionCtx.ap.beacon;
5217
5218 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305219 {
5220 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5221 FL("session(%d) old and new heads points to NULL"),
5222 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005223 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305224 }
5225
5226 if (params->tail && !params->tail_len)
5227 {
5228 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5229 FL("tail_len is zero but tail is not NULL"));
5230 return -EINVAL;
5231 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005232
Jeff Johnson295189b2012-06-20 16:38:30 -07005233#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
5234 /* Kernel 3.0 is not updating dtim_period for set beacon */
5235 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305236 {
5237 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5238 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005239 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305240 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005241#endif
5242
5243 if(params->head)
5244 head_len = params->head_len;
5245 else
5246 head_len = old->head_len;
5247
5248 if(params->tail || !old)
5249 tail_len = params->tail_len;
5250 else
5251 tail_len = old->tail_len;
5252
5253 size = sizeof(beacon_data_t) + head_len + tail_len;
5254
5255 beacon = kzalloc(size, GFP_KERNEL);
5256
5257 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305258 {
5259 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5260 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005261 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305262 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005263
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005264#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07005265 if(params->dtim_period || !old )
5266 beacon->dtim_period = params->dtim_period;
5267 else
5268 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005269#else
5270 if(dtim_period || !old )
5271 beacon->dtim_period = dtim_period;
5272 else
5273 beacon->dtim_period = old->dtim_period;
5274#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305275
Jeff Johnson295189b2012-06-20 16:38:30 -07005276 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
5277 beacon->tail = beacon->head + head_len;
5278 beacon->head_len = head_len;
5279 beacon->tail_len = tail_len;
5280
5281 if(params->head) {
5282 memcpy (beacon->head,params->head,beacon->head_len);
5283 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305284 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07005285 if(old)
5286 memcpy (beacon->head,old->head,beacon->head_len);
5287 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305288
Jeff Johnson295189b2012-06-20 16:38:30 -07005289 if(params->tail) {
5290 memcpy (beacon->tail,params->tail,beacon->tail_len);
5291 }
5292 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305293 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07005294 memcpy (beacon->tail,old->tail,beacon->tail_len);
5295 }
5296
5297 *ppBeacon = beacon;
5298
5299 kfree(old);
5300
5301 return 0;
5302
5303}
Jeff Johnson295189b2012-06-20 16:38:30 -07005304
5305v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
5306{
5307 int left = length;
5308 v_U8_t *ptr = pIes;
5309 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305310
Jeff Johnson295189b2012-06-20 16:38:30 -07005311 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305312 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005313 elem_id = ptr[0];
5314 elem_len = ptr[1];
5315 left -= 2;
5316 if(elem_len > left)
5317 {
5318 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07005319 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005320 eid,elem_len,left);
5321 return NULL;
5322 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305323 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07005324 {
5325 return ptr;
5326 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305327
Jeff Johnson295189b2012-06-20 16:38:30 -07005328 left -= elem_len;
5329 ptr += (elem_len + 2);
5330 }
5331 return NULL;
5332}
5333
Jeff Johnson295189b2012-06-20 16:38:30 -07005334/* Check if rate is 11g rate or not */
5335static int wlan_hdd_rate_is_11g(u8 rate)
5336{
Sanjay Devnani28322e22013-06-21 16:13:40 -07005337 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005338 u8 i;
5339 for (i = 0; i < 8; i++)
5340 {
5341 if(rate == gRateArray[i])
5342 return TRUE;
5343 }
5344 return FALSE;
5345}
5346
5347/* Check for 11g rate and set proper 11g only mode */
5348static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
5349 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
5350{
5351 u8 i, num_rates = pIe[0];
5352
5353 pIe += 1;
5354 for ( i = 0; i < num_rates; i++)
5355 {
5356 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
5357 {
5358 /* If rate set have 11g rate than change the mode to 11G */
5359 *pSapHw_mode = eSAP_DOT11_MODE_11g;
5360 if (pIe[i] & BASIC_RATE_MASK)
5361 {
5362 /* If we have 11g rate as basic rate, it means mode
5363 is 11g only mode.
5364 */
5365 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
5366 *pCheckRatesfor11g = FALSE;
5367 }
5368 }
5369 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
5370 {
5371 *require_ht = TRUE;
5372 }
5373 }
5374 return;
5375}
5376
5377static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
5378{
5379 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
5380 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
5381 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
5382 u8 checkRatesfor11g = TRUE;
5383 u8 require_ht = FALSE;
5384 u8 *pIe=NULL;
5385
5386 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
5387
5388 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
5389 pBeacon->head_len, WLAN_EID_SUPP_RATES);
5390 if (pIe != NULL)
5391 {
5392 pIe += 1;
5393 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
5394 &pConfig->SapHw_mode);
5395 }
5396
5397 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
5398 WLAN_EID_EXT_SUPP_RATES);
5399 if (pIe != NULL)
5400 {
5401
5402 pIe += 1;
5403 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
5404 &pConfig->SapHw_mode);
5405 }
5406
5407 if( pConfig->channel > 14 )
5408 {
5409 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
5410 }
5411
5412 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
5413 WLAN_EID_HT_CAPABILITY);
5414
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305415 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07005416 {
5417 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
5418 if(require_ht)
5419 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
5420 }
5421}
5422
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305423static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
5424 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
5425{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07005426 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305427 v_U8_t *pIe = NULL;
5428 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
5429
5430 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
5431 pBeacon->tail, pBeacon->tail_len);
5432
5433 if (pIe)
5434 {
5435 ielen = pIe[1] + 2;
5436 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
5437 {
5438 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
5439 }
5440 else
5441 {
5442 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
5443 return -EINVAL;
5444 }
5445 *total_ielen += ielen;
5446 }
5447 return 0;
5448}
5449
Arif Hussaine7f3ea52013-09-12 21:56:36 -07005450static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
5451 v_U8_t *genie, v_U8_t *total_ielen)
5452{
5453 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
5454 int left = pBeacon->tail_len;
5455 v_U8_t *ptr = pBeacon->tail;
5456 v_U8_t elem_id, elem_len;
5457 v_U16_t ielen = 0;
5458
5459 if ( NULL == ptr || 0 == left )
5460 return;
5461
5462 while (left >= 2)
5463 {
5464 elem_id = ptr[0];
5465 elem_len = ptr[1];
5466 left -= 2;
5467 if (elem_len > left)
5468 {
5469 hddLog( VOS_TRACE_LEVEL_ERROR,
5470 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
5471 elem_id, elem_len, left);
5472 return;
5473 }
5474 if (IE_EID_VENDOR == elem_id)
5475 {
5476 /* skipping the VSIE's which we don't want to include or
5477 * it will be included by existing code
5478 */
5479 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
5480#ifdef WLAN_FEATURE_WFD
5481 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
5482#endif
5483 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
5484 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
5485 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
5486 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
5487 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
5488 {
5489 ielen = ptr[1] + 2;
5490 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
5491 {
5492 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
5493 *total_ielen += ielen;
5494 }
5495 else
5496 {
5497 hddLog( VOS_TRACE_LEVEL_ERROR,
5498 "IE Length is too big "
5499 "IEs eid=%d elem_len=%d total_ie_lent=%d",
5500 elem_id, elem_len, *total_ielen);
5501 }
5502 }
5503 }
5504
5505 left -= elem_len;
5506 ptr += (elem_len + 2);
5507 }
5508 return;
5509}
5510
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005511#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07005512static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
5513 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005514#else
5515static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
5516 struct cfg80211_beacon_data *params)
5517#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005518{
5519 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305520 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005521 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07005522 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005523
5524 genie = vos_mem_malloc(MAX_GENIE_LEN);
5525
5526 if(genie == NULL) {
5527
5528 return -ENOMEM;
5529 }
5530
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305531 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
5532 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005533 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305534 hddLog(LOGE,
5535 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305536 ret = -EINVAL;
5537 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005538 }
5539
5540#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305541 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
5542 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
5543 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305544 hddLog(LOGE,
5545 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305546 ret = -EINVAL;
5547 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005548 }
5549#endif
5550
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305551 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
5552 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005553 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305554 hddLog(LOGE,
5555 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305556 ret = -EINVAL;
5557 goto done;
5558 }
5559
5560 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
5561 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07005562 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005563 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005564
5565 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5566 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
5567 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
5568 {
5569 hddLog(LOGE,
5570 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005571 ret = -EINVAL;
5572 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005573 }
5574
5575 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5576 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
5577 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
5578 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
5579 ==eHAL_STATUS_FAILURE)
5580 {
5581 hddLog(LOGE,
5582 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005583 ret = -EINVAL;
5584 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005585 }
5586
5587 // Added for ProResp IE
5588 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
5589 {
5590 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
5591 u8 probe_rsp_ie_len[3] = {0};
5592 u8 counter = 0;
5593 /* Check Probe Resp Length if it is greater then 255 then Store
5594 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
5595 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
5596 Store More then 255 bytes into One Variable.
5597 */
5598 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
5599 {
5600 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
5601 {
5602 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
5603 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
5604 }
5605 else
5606 {
5607 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
5608 rem_probe_resp_ie_len = 0;
5609 }
5610 }
5611
5612 rem_probe_resp_ie_len = 0;
5613
5614 if (probe_rsp_ie_len[0] > 0)
5615 {
5616 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5617 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
5618 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
5619 probe_rsp_ie_len[0], NULL,
5620 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5621 {
5622 hddLog(LOGE,
5623 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005624 ret = -EINVAL;
5625 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005626 }
5627 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
5628 }
5629
5630 if (probe_rsp_ie_len[1] > 0)
5631 {
5632 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5633 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
5634 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
5635 probe_rsp_ie_len[1], NULL,
5636 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5637 {
5638 hddLog(LOGE,
5639 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005640 ret = -EINVAL;
5641 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005642 }
5643 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
5644 }
5645
5646 if (probe_rsp_ie_len[2] > 0)
5647 {
5648 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5649 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
5650 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
5651 probe_rsp_ie_len[2], NULL,
5652 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5653 {
5654 hddLog(LOGE,
5655 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005656 ret = -EINVAL;
5657 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 }
5659 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
5660 }
5661
5662 if (probe_rsp_ie_len[1] == 0 )
5663 {
5664 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5665 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
5666 eANI_BOOLEAN_FALSE) )
5667 {
5668 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005669 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005670 }
5671 }
5672
5673 if (probe_rsp_ie_len[2] == 0 )
5674 {
5675 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5676 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
5677 eANI_BOOLEAN_FALSE) )
5678 {
5679 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005680 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005681 }
5682 }
5683
5684 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5685 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
5686 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
5687 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
5688 == eHAL_STATUS_FAILURE)
5689 {
5690 hddLog(LOGE,
5691 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005692 ret = -EINVAL;
5693 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005694 }
5695 }
5696 else
5697 {
5698 // Reset WNI_CFG_PROBE_RSP Flags
5699 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
5700
5701 hddLog(VOS_TRACE_LEVEL_INFO,
5702 "%s: No Probe Response IE received in set beacon",
5703 __func__);
5704 }
5705
5706 // Added for AssocResp IE
5707 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
5708 {
5709 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5710 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
5711 params->assocresp_ies_len, NULL,
5712 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5713 {
5714 hddLog(LOGE,
5715 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005716 ret = -EINVAL;
5717 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005718 }
5719
5720 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5721 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
5722 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
5723 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
5724 == eHAL_STATUS_FAILURE)
5725 {
5726 hddLog(LOGE,
5727 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005728 ret = -EINVAL;
5729 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005730 }
5731 }
5732 else
5733 {
5734 hddLog(VOS_TRACE_LEVEL_INFO,
5735 "%s: No Assoc Response IE received in set beacon",
5736 __func__);
5737
5738 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5739 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
5740 eANI_BOOLEAN_FALSE) )
5741 {
5742 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005743 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005744 }
5745 }
5746
Jeff Johnsone7245742012-09-05 17:12:55 -07005747done:
Jeff Johnson295189b2012-06-20 16:38:30 -07005748 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305749 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07005750}
Jeff Johnson295189b2012-06-20 16:38:30 -07005751
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305752/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005753 * FUNCTION: wlan_hdd_validate_operation_channel
5754 * called by wlan_hdd_cfg80211_start_bss() and
5755 * wlan_hdd_cfg80211_set_channel()
5756 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305757 * channel list.
5758 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07005759VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07005760{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305761
Jeff Johnson295189b2012-06-20 16:38:30 -07005762 v_U32_t num_ch = 0;
5763 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
5764 u32 indx = 0;
5765 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05305766 v_U8_t fValidChannel = FALSE, count = 0;
5767 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305768
Jeff Johnson295189b2012-06-20 16:38:30 -07005769 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
5770
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05305771 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07005772 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05305773 /* Validate the channel */
5774 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005775 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05305776 if ( channel == rfChannels[count].channelNum )
5777 {
5778 fValidChannel = TRUE;
5779 break;
5780 }
5781 }
5782 if (fValidChannel != TRUE)
5783 {
5784 hddLog(VOS_TRACE_LEVEL_ERROR,
5785 "%s: Invalid Channel [%d]", __func__, channel);
5786 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005787 }
5788 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05305789 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005790 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05305791 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
5792 valid_ch, &num_ch))
5793 {
5794 hddLog(VOS_TRACE_LEVEL_ERROR,
5795 "%s: failed to get valid channel list", __func__);
5796 return VOS_STATUS_E_FAILURE;
5797 }
5798 for (indx = 0; indx < num_ch; indx++)
5799 {
5800 if (channel == valid_ch[indx])
5801 {
5802 break;
5803 }
5804 }
5805
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05305806 if (indx >= num_ch)
5807 {
5808 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
5809 {
5810 eCsrBand band;
5811 unsigned int freq;
5812
5813 sme_GetFreqBand(hHal, &band);
5814
5815 if (eCSR_BAND_5G == band)
5816 {
5817#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
5818 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
5819 {
5820 freq = ieee80211_channel_to_frequency(channel,
5821 IEEE80211_BAND_2GHZ);
5822 }
5823 else
5824 {
5825 freq = ieee80211_channel_to_frequency(channel,
5826 IEEE80211_BAND_5GHZ);
5827 }
5828#else
5829 freq = ieee80211_channel_to_frequency(channel);
5830#endif
5831 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
5832 return VOS_STATUS_SUCCESS;
5833 }
5834 }
5835
5836 hddLog(VOS_TRACE_LEVEL_ERROR,
5837 "%s: Invalid Channel [%d]", __func__, channel);
5838 return VOS_STATUS_E_FAILURE;
5839 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005840 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05305841
Jeff Johnson295189b2012-06-20 16:38:30 -07005842 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305843
Jeff Johnson295189b2012-06-20 16:38:30 -07005844}
5845
Viral Modi3a32cc52013-02-08 11:14:52 -08005846/**
5847 * FUNCTION: wlan_hdd_cfg80211_set_channel
5848 * This function is used to set the channel number
5849 */
5850static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
5851 struct ieee80211_channel *chan,
5852 enum nl80211_channel_type channel_type
5853 )
5854{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305855 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08005856 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07005857 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08005858 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305859 hdd_context_t *pHddCtx;
5860 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08005861
5862 ENTER();
5863
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305864
Viral Modi3a32cc52013-02-08 11:14:52 -08005865 if( NULL == dev )
5866 {
5867 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005868 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08005869 return -ENODEV;
5870 }
5871 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05305872
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305873 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
5874 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
5875 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08005876 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305877 "%s: device_mode = %s (%d) freq = %d", __func__,
5878 hdd_device_modetoString(pAdapter->device_mode),
5879 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305880
5881 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5882 status = wlan_hdd_validate_context(pHddCtx);
5883
5884 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08005885 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305886 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5887 "%s: HDD context is not valid", __func__);
5888 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08005889 }
5890
5891 /*
5892 * Do freq to chan conversion
5893 * TODO: for 11a
5894 */
5895
5896 channel = ieee80211_frequency_to_channel(freq);
5897
5898 /* Check freq range */
5899 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
5900 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
5901 {
5902 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005903 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08005904 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
5905 WNI_CFG_CURRENT_CHANNEL_STAMAX);
5906 return -EINVAL;
5907 }
5908
5909 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
5910
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05305911 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
5912 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08005913 {
5914 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
5915 {
5916 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005917 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08005918 return -EINVAL;
5919 }
5920 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5921 "%s: set channel to [%d] for device mode =%d",
5922 __func__, channel,pAdapter->device_mode);
5923 }
5924 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08005925 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08005926 )
5927 {
5928 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5929 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
5930 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5931
5932 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
5933 {
5934 /* Link is up then return cant set channel*/
5935 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005936 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08005937 return -EINVAL;
5938 }
5939
5940 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
5941 pHddStaCtx->conn_info.operationChannel = channel;
5942 pRoamProfile->ChannelInfo.ChannelList =
5943 &pHddStaCtx->conn_info.operationChannel;
5944 }
5945 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08005946 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08005947 )
5948 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05305949 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
5950 {
5951 if(VOS_STATUS_SUCCESS !=
5952 wlan_hdd_validate_operation_channel(pAdapter,channel))
5953 {
5954 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005955 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05305956 return -EINVAL;
5957 }
5958 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
5959 }
5960 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08005961 {
5962 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
5963
5964 /* If auto channel selection is configured as enable/ 1 then ignore
5965 channel set by supplicant
5966 */
5967 if ( cfg_param->apAutoChannelSelection )
5968 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05305969 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
5970 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08005971 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305972 "%s: set channel to auto channel (0) for device mode =%s (%d)",
5973 __func__, hdd_device_modetoString(pAdapter->device_mode),
5974 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08005975 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05305976 else
5977 {
5978 if(VOS_STATUS_SUCCESS !=
5979 wlan_hdd_validate_operation_channel(pAdapter,channel))
5980 {
5981 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005982 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05305983 return -EINVAL;
5984 }
5985 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
5986 }
Viral Modi3a32cc52013-02-08 11:14:52 -08005987 }
5988 }
5989 else
5990 {
5991 hddLog(VOS_TRACE_LEVEL_FATAL,
5992 "%s: Invalid device mode failed to set valid channel", __func__);
5993 return -EINVAL;
5994 }
5995 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305996 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08005997}
5998
Jeff Johnson295189b2012-06-20 16:38:30 -07005999#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
6000static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6001 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006002#else
6003static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6004 struct cfg80211_beacon_data *params,
6005 const u8 *ssid, size_t ssid_len,
6006 enum nl80211_hidden_ssid hidden_ssid)
6007#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006008{
6009 tsap_Config_t *pConfig;
6010 beacon_data_t *pBeacon = NULL;
6011 struct ieee80211_mgmt *pMgmt_frame;
6012 v_U8_t *pIe=NULL;
6013 v_U16_t capab_info;
6014 eCsrAuthType RSNAuthType;
6015 eCsrEncryptionType RSNEncryptType;
6016 eCsrEncryptionType mcRSNEncryptType;
6017 int status = VOS_STATUS_SUCCESS;
6018 tpWLAN_SAPEventCB pSapEventCallback;
6019 hdd_hostapd_state_t *pHostapdState;
6020 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
6021 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306022 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006023 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306024 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006025 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08006026 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05306027 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07006028 v_BOOL_t MFPCapable = VOS_FALSE;
6029 v_BOOL_t MFPRequired = VOS_FALSE;
Abhishek Singhf0ac1752014-03-05 17:47:09 +05306030 eHddDot11Mode sapDot11Mode =
6031 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07006032
6033 ENTER();
6034
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306035 iniConfig = pHddCtx->cfg_ini;
6036
Jeff Johnson295189b2012-06-20 16:38:30 -07006037 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
6038
6039 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6040
6041 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6042
6043 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
6044
6045 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
6046
6047 //channel is already set in the set_channel Call back
6048 //pConfig->channel = pCommitConfig->channel;
6049
6050 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306051 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07006052 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
6053
6054 pConfig->dtim_period = pBeacon->dtim_period;
6055
Arif Hussain6d2a3322013-11-17 19:50:10 -08006056 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07006057 pConfig->dtim_period);
6058
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08006059 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07006060 {
6061 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006062 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05306063 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
6064 {
6065 tANI_BOOLEAN restartNeeded;
6066 pConfig->ieee80211d = 1;
6067 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
6068 sme_setRegInfo(hHal, pConfig->countryCode);
6069 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
6070 }
6071 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07006072 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07006073 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006074 pConfig->ieee80211d = 1;
6075 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
6076 sme_setRegInfo(hHal, pConfig->countryCode);
6077 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07006078 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07006079 else
6080 {
6081 pConfig->ieee80211d = 0;
6082 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306083 /*
6084 * If auto channel is configured i.e. channel is 0,
6085 * so skip channel validation.
6086 */
6087 if( AUTO_CHANNEL_SELECT != pConfig->channel )
6088 {
6089 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
6090 {
6091 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006092 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306093 return -EINVAL;
6094 }
6095 }
6096 else
6097 {
6098 if(1 != pHddCtx->is_dynamic_channel_range_set)
6099 {
6100 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
6101 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
6102 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
6103 }
6104 pHddCtx->is_dynamic_channel_range_set = 0;
6105 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006106 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07006107 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006108 {
6109 pConfig->ieee80211d = 0;
6110 }
6111 pConfig->authType = eSAP_AUTO_SWITCH;
6112
6113 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306114
6115 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07006116 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
6117
6118 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
6119
6120 /*Set wps station to configured*/
6121 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
6122
6123 if(pIe)
6124 {
6125 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
6126 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006127 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07006128 return -EINVAL;
6129 }
6130 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
6131 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07006132 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07006133 /* Check 15 bit of WPS IE as it contain information for wps state
6134 * WPS state
6135 */
6136 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
6137 {
6138 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
6139 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
6140 {
6141 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
6142 }
6143 }
6144 }
6145 else
6146 {
6147 pConfig->wps_state = SAP_WPS_DISABLED;
6148 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306149 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07006150
c_hpothufe599e92014-06-16 11:38:55 +05306151 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
6152 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
6153 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
6154 eCSR_ENCRYPT_TYPE_NONE;
6155
Jeff Johnson295189b2012-06-20 16:38:30 -07006156 pConfig->RSNWPAReqIELength = 0;
6157 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306158 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006159 WLAN_EID_RSN);
6160 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306161 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006162 pConfig->RSNWPAReqIELength = pIe[1] + 2;
6163 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
6164 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306165 /* The actual processing may eventually be more extensive than
6166 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07006167 * by the app.
6168 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306169 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07006170 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
6171 &RSNEncryptType,
6172 &mcRSNEncryptType,
6173 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08006174 &MFPCapable,
6175 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07006176 pConfig->pRSNWPAReqIE[1]+2,
6177 pConfig->pRSNWPAReqIE );
6178
6179 if( VOS_STATUS_SUCCESS == status )
6180 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306181 /* Now copy over all the security attributes you have
6182 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07006183 * */
6184 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
6185 pConfig->mcRSNEncryptType = mcRSNEncryptType;
6186 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
6187 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05306188 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08006189 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006190 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
6191 }
6192 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306193
Jeff Johnson295189b2012-06-20 16:38:30 -07006194 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
6195 pBeacon->tail, pBeacon->tail_len);
6196
6197 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
6198 {
6199 if (pConfig->pRSNWPAReqIE)
6200 {
6201 /*Mixed mode WPA/WPA2*/
6202 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
6203 pConfig->RSNWPAReqIELength += pIe[1] + 2;
6204 }
6205 else
6206 {
6207 pConfig->RSNWPAReqIELength = pIe[1] + 2;
6208 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
6209 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306210 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07006211 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
6212 &RSNEncryptType,
6213 &mcRSNEncryptType,
6214 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08006215 &MFPCapable,
6216 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07006217 pConfig->pRSNWPAReqIE[1]+2,
6218 pConfig->pRSNWPAReqIE );
6219
6220 if( VOS_STATUS_SUCCESS == status )
6221 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306222 /* Now copy over all the security attributes you have
6223 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07006224 * */
6225 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
6226 pConfig->mcRSNEncryptType = mcRSNEncryptType;
6227 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
6228 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05306229 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08006230 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006231 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
6232 }
6233 }
6234 }
6235
Jeff Johnson4416a782013-03-25 14:17:50 -07006236 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
6237 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
6238 return -EINVAL;
6239 }
6240
Jeff Johnson295189b2012-06-20 16:38:30 -07006241 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
6242
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006243#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006244 if (params->ssid != NULL)
6245 {
6246 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
6247 pConfig->SSIDinfo.ssid.length = params->ssid_len;
6248 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
6249 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
6250 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006251#else
6252 if (ssid != NULL)
6253 {
6254 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
6255 pConfig->SSIDinfo.ssid.length = ssid_len;
6256 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
6257 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
6258 }
6259#endif
6260
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306261 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07006262 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306263
Jeff Johnson295189b2012-06-20 16:38:30 -07006264 /* default value */
6265 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
6266 pConfig->num_accept_mac = 0;
6267 pConfig->num_deny_mac = 0;
6268
6269 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
6270 pBeacon->tail, pBeacon->tail_len);
6271
6272 /* pIe for black list is following form:
6273 type : 1 byte
6274 length : 1 byte
6275 OUI : 4 bytes
6276 acl type : 1 byte
6277 no of mac addr in black list: 1 byte
6278 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306279 */
6280 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006281 {
6282 pConfig->SapMacaddr_acl = pIe[6];
6283 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08006284 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006285 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05306286 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
6287 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006288 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
6289 for (i = 0; i < pConfig->num_deny_mac; i++)
6290 {
6291 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
6292 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306293 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006294 }
6295 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
6296 pBeacon->tail, pBeacon->tail_len);
6297
6298 /* pIe for white list is following form:
6299 type : 1 byte
6300 length : 1 byte
6301 OUI : 4 bytes
6302 acl type : 1 byte
6303 no of mac addr in white list: 1 byte
6304 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306305 */
6306 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006307 {
6308 pConfig->SapMacaddr_acl = pIe[6];
6309 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08006310 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006311 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05306312 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
6313 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006314 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
6315 for (i = 0; i < pConfig->num_accept_mac; i++)
6316 {
6317 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
6318 acl_entry++;
6319 }
6320 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05306321
Jeff Johnson295189b2012-06-20 16:38:30 -07006322 wlan_hdd_set_sapHwmode(pHostapdAdapter);
6323
Jeff Johnsone7245742012-09-05 17:12:55 -07006324#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08006325 /* Overwrite the hostapd setting for HW mode only for 11ac.
Kiet Lam0f320422013-11-21 19:29:17 +05306326 * This is valid only if mode is set to 11n in hostapd, either AUTO or
6327 * 11ac in .ini and 11ac is supported by both host and firmware.
6328 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
6329 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08006330 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
6331 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Abhishek Singhf0ac1752014-03-05 17:47:09 +05306332 (( sapDot11Mode == eHDD_DOT11_MODE_AUTO ) ||
6333 ( sapDot11Mode == eHDD_DOT11_MODE_11ac ) ||
6334 ( sapDot11Mode == eHDD_DOT11_MODE_11ac_ONLY ) ) &&
6335 (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
6336 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07006337 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05306338 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07006339 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05306340 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07006341
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306342 /* If ACS disable and selected channel <= 14
6343 * OR
6344 * ACS enabled and ACS operating band is choosen as 2.4
6345 * AND
6346 * VHT in 2.4G Disabled
6347 * THEN
6348 * Fallback to 11N mode
6349 */
6350 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
6351 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05306352 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306353 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07006354 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05306355 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
6356 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07006357 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
6358 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006359 }
6360#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306361
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07006362 if ( AUTO_CHANNEL_SELECT != pConfig->channel )
6363 {
6364 sme_SelectCBMode(hHal,
6365 sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode),
6366 pConfig->channel);
6367 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006368 // ht_capab is not what the name conveys,this is used for protection bitmap
6369 pConfig->ht_capab =
6370 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
6371
6372 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
6373 {
6374 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
6375 return -EINVAL;
6376 }
6377
6378 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306379 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07006380 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
6381 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306382 pConfig->obssProtEnabled =
6383 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07006384
Chet Lanctot8cecea22014-02-11 19:09:36 -08006385#ifdef WLAN_FEATURE_11W
6386 pConfig->mfpCapable = MFPCapable;
6387 pConfig->mfpRequired = MFPRequired;
6388 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
6389 pConfig->mfpCapable, pConfig->mfpRequired);
6390#endif
6391
Arif Hussain6d2a3322013-11-17 19:50:10 -08006392 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07006393 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08006394 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
6395 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
6396 (int)pConfig->channel);
6397 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
6398 pConfig->SapHw_mode, pConfig->privacy,
6399 pConfig->authType);
6400 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
6401 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
6402 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
6403 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07006404
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306405 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07006406 {
6407 //Bss already started. just return.
6408 //TODO Probably it should update some beacon params.
6409 hddLog( LOGE, "Bss Already started...Ignore the request");
6410 EXIT();
6411 return 0;
6412 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306413
Agarwal Ashish51325b52014-06-16 16:50:49 +05306414 if (vos_max_concurrent_connections_reached()) {
6415 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
6416 return -EINVAL;
6417 }
6418
Jeff Johnson295189b2012-06-20 16:38:30 -07006419 pConfig->persona = pHostapdAdapter->device_mode;
6420
Peng Xu2446a892014-09-05 17:21:18 +05306421 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
6422 if ( NULL != psmeConfig)
6423 {
6424 sme_GetConfigParam(hHal, psmeConfig);
6425 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
6426 vos_mem_free(psmeConfig);
6427 }
Peng Xuafc34e32014-09-25 13:23:55 +05306428 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05306429
Jeff Johnson295189b2012-06-20 16:38:30 -07006430 pSapEventCallback = hdd_hostapd_SAPEventCB;
6431 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
6432 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
6433 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006434 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006435 return -EINVAL;
6436 }
6437
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306438 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07006439 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
6440
6441 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306442
Jeff Johnson295189b2012-06-20 16:38:30 -07006443 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306444 {
6445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006446 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07006447 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07006448 VOS_ASSERT(0);
6449 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306450
Jeff Johnson295189b2012-06-20 16:38:30 -07006451 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05306452 /* Initialize WMM configuation */
6453 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05306454 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006455
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07006456#ifdef WLAN_FEATURE_P2P_DEBUG
6457 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
6458 {
6459 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
6460 {
6461 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
6462 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08006463 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07006464 }
6465 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
6466 {
6467 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
6468 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08006469 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07006470 }
6471 }
6472#endif
6473
Jeff Johnson295189b2012-06-20 16:38:30 -07006474 pHostapdState->bCommit = TRUE;
6475 EXIT();
6476
6477 return 0;
6478}
6479
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006480#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306481static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
6482 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07006483 struct beacon_parameters *params)
6484{
6485 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306486 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306487 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006488
6489 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306490
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306491 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6492 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
6493 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306494 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
6495 hdd_device_modetoString(pAdapter->device_mode),
6496 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006497
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306498 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6499 status = wlan_hdd_validate_context(pHddCtx);
6500
6501 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006502 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306503 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6504 "%s: HDD context is not valid", __func__);
6505 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006506 }
6507
Agarwal Ashish51325b52014-06-16 16:50:49 +05306508 if (vos_max_concurrent_connections_reached()) {
6509 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
6510 return -EINVAL;
6511 }
6512
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306513 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07006514 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07006515 )
6516 {
6517 beacon_data_t *old,*new;
6518
6519 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306520
Jeff Johnson295189b2012-06-20 16:38:30 -07006521 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306522 {
6523 hddLog(VOS_TRACE_LEVEL_WARN,
6524 FL("already beacon info added to session(%d)"),
6525 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006526 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306527 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006528
6529 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
6530
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306531 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07006532 {
6533 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006534 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006535 return -EINVAL;
6536 }
6537
6538 pAdapter->sessionCtx.ap.beacon = new;
6539
6540 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
6541 }
6542
6543 EXIT();
6544 return status;
6545}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306546
6547static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006548 struct net_device *dev,
6549 struct beacon_parameters *params)
6550{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306551 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306552 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6553 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306554 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006555
6556 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306557 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6558 TRACE_CODE_HDD_CFG80211_SET_BEACON,
6559 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
6560 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
6561 __func__, hdd_device_modetoString(pAdapter->device_mode),
6562 pAdapter->device_mode);
6563
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306564 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6565 status = wlan_hdd_validate_context(pHddCtx);
6566
6567 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006568 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306569 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6570 "%s: HDD context is not valid", __func__);
6571 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006572 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306573
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306574 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07006575 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306576 )
Jeff Johnson295189b2012-06-20 16:38:30 -07006577 {
6578 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306579
Jeff Johnson295189b2012-06-20 16:38:30 -07006580 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306581
Jeff Johnson295189b2012-06-20 16:38:30 -07006582 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306583 {
6584 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6585 FL("session(%d) old and new heads points to NULL"),
6586 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006587 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306588 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006589
6590 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
6591
6592 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306593 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006594 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006595 return -EINVAL;
6596 }
6597
6598 pAdapter->sessionCtx.ap.beacon = new;
6599
6600 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
6601 }
6602
6603 EXIT();
6604 return status;
6605}
6606
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006607#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
6608
6609#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006610static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
6611 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006612#else
6613static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
6614 struct net_device *dev)
6615#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006616{
6617 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07006618 hdd_context_t *pHddCtx = NULL;
6619 hdd_scaninfo_t *pScanInfo = NULL;
6620 hdd_adapter_t *staAdapter = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306621 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306622 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006623
6624 ENTER();
6625
6626 if (NULL == pAdapter)
6627 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306628 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006629 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006630 return -ENODEV;
6631 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006632
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306633 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6634 TRACE_CODE_HDD_CFG80211_STOP_AP,
6635 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306636 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6637 status = wlan_hdd_validate_context(pHddCtx);
6638
6639 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006640 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306641 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6642 "%s: HDD context is not valid", __func__);
6643 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07006644 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006645
6646 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
6647 if (NULL == staAdapter)
6648 {
6649 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
6650 if (NULL == staAdapter)
6651 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07006652 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
6653 "%s: HDD adapter context for STA/P2P-CLI is Null",
6654 __func__);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006655 }
6656 }
6657
6658 pScanInfo = &pHddCtx->scan_info;
6659
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306660 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
6661 __func__, hdd_device_modetoString(pAdapter->device_mode),
6662 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006663
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306664 ret = wlan_hdd_scan_abort(pAdapter);
6665
Girish Gowli4bf7a632014-06-12 13:42:11 +05306666 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07006667 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306668 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6669 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306670
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306671 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07006672 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306673 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6674 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08006675
Jeff Johnsone7245742012-09-05 17:12:55 -07006676 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306677 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07006678 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306679 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07006680 }
6681
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05306682 /* Delete all associated STAs before stopping AP/P2P GO */
6683 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05306684 hdd_hostapd_stop(dev);
6685
Jeff Johnson295189b2012-06-20 16:38:30 -07006686 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07006687 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07006688 )
6689 {
6690 beacon_data_t *old;
6691
6692 old = pAdapter->sessionCtx.ap.beacon;
6693
6694 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306695 {
6696 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6697 FL("session(%d) beacon data points to NULL"),
6698 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006699 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306700 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006701
Jeff Johnson295189b2012-06-20 16:38:30 -07006702 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006703
6704 mutex_lock(&pHddCtx->sap_lock);
6705 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
6706 {
Jeff Johnson4416a782013-03-25 14:17:50 -07006707 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006708 {
6709 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
6710
6711 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
6712
6713 if (!VOS_IS_STATUS_SUCCESS(status))
6714 {
6715 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006716 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006717 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306718 }
6719 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006720 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05306721 /* BSS stopped, clear the active sessions for this device mode */
6722 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006723 }
6724 mutex_unlock(&pHddCtx->sap_lock);
6725
6726 if(status != VOS_STATUS_SUCCESS)
6727 {
6728 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006729 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006730 return -EINVAL;
6731 }
6732
Jeff Johnson4416a782013-03-25 14:17:50 -07006733 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07006734 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
6735 ==eHAL_STATUS_FAILURE)
6736 {
6737 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006738 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006739 }
6740
Jeff Johnson4416a782013-03-25 14:17:50 -07006741 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07006742 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
6743 eANI_BOOLEAN_FALSE) )
6744 {
6745 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006746 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006747 }
6748
6749 // Reset WNI_CFG_PROBE_RSP Flags
6750 wlan_hdd_reset_prob_rspies(pAdapter);
6751
6752 pAdapter->sessionCtx.ap.beacon = NULL;
6753 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07006754#ifdef WLAN_FEATURE_P2P_DEBUG
6755 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
6756 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
6757 {
6758 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
6759 "GO got removed");
6760 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
6761 }
6762#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006763 }
6764 EXIT();
6765 return status;
6766}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006767
6768#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
6769
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306770static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
6771 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006772 struct cfg80211_ap_settings *params)
6773{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306774 hdd_adapter_t *pAdapter;
6775 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306776 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006777
6778 ENTER();
6779
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306780 if (NULL == dev)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07006781 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306782 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306783 "%s: Device is Null", __func__);
6784 return -ENODEV;
6785 }
6786
6787 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6788 if (NULL == pAdapter)
6789 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306790 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306791 "%s: HDD adapter is Null", __func__);
6792 return -ENODEV;
6793 }
6794
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306795 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6796 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
6797 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306798 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
6799 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306800 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306801 "%s: HDD adapter magic is invalid", __func__);
6802 return -ENODEV;
6803 }
6804
6805 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306806 status = wlan_hdd_validate_context(pHddCtx);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306807
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306808 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306809 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306810 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6811 "%s: HDD context is not valid", __func__);
6812 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306813 }
6814
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306815 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
6816 __func__, hdd_device_modetoString(pAdapter->device_mode),
6817 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306818
6819 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006820 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006821 )
6822 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306823 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006824
6825 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306826
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006827 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306828 {
6829 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6830 FL("already beacon info added to session(%d)"),
6831 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006832 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306833 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006834
6835 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, &params->beacon, params->dtim_period);
6836
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306837 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006838 {
6839 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306840 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006841 return -EINVAL;
6842 }
6843 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08006844#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07006845 wlan_hdd_cfg80211_set_channel(wiphy, dev,
6846#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
6847 params->channel, params->channel_type);
6848#else
6849 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
6850#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08006851#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006852 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
6853 params->ssid_len, params->hidden_ssid);
6854 }
6855
6856 EXIT();
6857 return status;
6858}
6859
6860
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306861static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006862 struct net_device *dev,
6863 struct cfg80211_beacon_data *params)
6864{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306865 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306866 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306867 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006868
6869 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306870
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306871 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6872 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
6873 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08006874 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006875 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306876
6877 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6878 status = wlan_hdd_validate_context(pHddCtx);
6879
6880 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07006881 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306882 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6883 "%s: HDD context is not valid", __func__);
6884 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07006885 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006886
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306887 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006888 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306889 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006890 {
6891 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306892
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006893 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306894
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006895 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306896 {
6897 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6898 FL("session(%d) beacon data points to NULL"),
6899 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006900 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306901 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006902
6903 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
6904
6905 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306906 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006907 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006908 return -EINVAL;
6909 }
6910
6911 pAdapter->sessionCtx.ap.beacon = new;
6912
6913 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
6914 }
6915
6916 EXIT();
6917 return status;
6918}
6919
6920#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
6921
Jeff Johnson295189b2012-06-20 16:38:30 -07006922
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05306923static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006924 struct net_device *dev,
6925 struct bss_parameters *params)
6926{
6927 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6928
6929 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306930
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306931 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6932 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
6933 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306934 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
6935 __func__, hdd_device_modetoString(pAdapter->device_mode),
6936 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006937
6938 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07006939 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306940 )
Jeff Johnson295189b2012-06-20 16:38:30 -07006941 {
6942 /* ap_isolate == -1 means that in change bss, upper layer doesn't
6943 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306944 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07006945 {
6946 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306947 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006948 }
6949
6950 EXIT();
6951 return 0;
6952}
6953
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05306954static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
6955 struct net_device *dev,
6956 struct bss_parameters *params)
6957{
6958 int ret;
6959
6960 vos_ssr_protect(__func__);
6961 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
6962 vos_ssr_unprotect(__func__);
6963
6964 return ret;
6965}
Kiet Lam10841362013-11-01 11:36:50 +05306966/* FUNCTION: wlan_hdd_change_country_code_cd
6967* to wait for contry code completion
6968*/
6969void* wlan_hdd_change_country_code_cb(void *pAdapter)
6970{
6971 hdd_adapter_t *call_back_pAdapter = pAdapter;
6972 complete(&call_back_pAdapter->change_country_code);
6973 return NULL;
6974}
6975
Jeff Johnson295189b2012-06-20 16:38:30 -07006976/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05306977 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07006978 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
6979 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05306980int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006981 struct net_device *ndev,
6982 enum nl80211_iftype type,
6983 u32 *flags,
6984 struct vif_params *params
6985 )
6986{
6987 struct wireless_dev *wdev;
6988 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08006989 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07006990 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006991 tCsrRoamProfile *pRoamProfile = NULL;
6992 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306993 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006994 eMib_dot11DesiredBssType connectedBssType;
6995 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306996 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006997
6998 ENTER();
6999
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307000 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08007001 {
7002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7003 "%s: Adapter context is null", __func__);
7004 return VOS_STATUS_E_FAILURE;
7005 }
7006
7007 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7008 if (!pHddCtx)
7009 {
7010 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7011 "%s: HDD context is null", __func__);
7012 return VOS_STATUS_E_FAILURE;
7013 }
7014
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307015 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7016 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
7017 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307018 status = wlan_hdd_validate_context(pHddCtx);
7019
7020 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007021 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307022 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7023 "%s: HDD context is not valid", __func__);
7024 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007025 }
7026
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307027 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7028 __func__, hdd_device_modetoString(pAdapter->device_mode),
7029 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007030
Agarwal Ashish51325b52014-06-16 16:50:49 +05307031 if (vos_max_concurrent_connections_reached()) {
7032 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7033 return -EINVAL;
7034 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307035 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07007036 wdev = ndev->ieee80211_ptr;
7037
7038#ifdef WLAN_BTAMP_FEATURE
7039 if((NL80211_IFTYPE_P2P_CLIENT == type)||
7040 (NL80211_IFTYPE_ADHOC == type)||
7041 (NL80211_IFTYPE_AP == type)||
7042 (NL80211_IFTYPE_P2P_GO == type))
7043 {
7044 pHddCtx->isAmpAllowed = VOS_FALSE;
7045 // stop AMP traffic
7046 status = WLANBAP_StopAmp();
7047 if(VOS_STATUS_SUCCESS != status )
7048 {
7049 pHddCtx->isAmpAllowed = VOS_TRUE;
7050 hddLog(VOS_TRACE_LEVEL_FATAL,
7051 "%s: Failed to stop AMP", __func__);
7052 return -EINVAL;
7053 }
7054 }
7055#endif //WLAN_BTAMP_FEATURE
7056 /* Reset the current device mode bit mask*/
7057 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
7058
7059 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07007060 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07007061 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07007062 )
7063 {
7064 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08007065 if (!pWextState)
7066 {
7067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7068 "%s: pWextState is null", __func__);
7069 return VOS_STATUS_E_FAILURE;
7070 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007071 pRoamProfile = &pWextState->roamProfile;
7072 LastBSSType = pRoamProfile->BSSType;
7073
7074 switch (type)
7075 {
7076 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07007077 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07007078 hddLog(VOS_TRACE_LEVEL_INFO,
7079 "%s: setting interface Type to INFRASTRUCTURE", __func__);
7080 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07007081#ifdef WLAN_FEATURE_11AC
7082 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
7083 {
7084 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
7085 }
7086#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307087 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07007088 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007089 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08007090 //Check for sub-string p2p to confirm its a p2p interface
7091 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307092 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08007093 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
7094 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
7095 }
7096 else
7097 {
7098 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07007099 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08007100 }
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05307101#ifdef FEATURE_WLAN_TDLS
7102 /* The open adapter for the p2p shall skip initializations in
7103 * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for
7104 * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke
7105 * tdls_init when the change_iface sets the device mode to
7106 * WLAN_HDD_P2P_CLIENT.
7107 */
7108
7109 if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
7110 {
Agarwal Ashish4b87f922014-06-18 03:03:21 +05307111 if (0 != wlan_hdd_sta_tdls_init (pAdapter))
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05307112 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307113 hddLog(VOS_TRACE_LEVEL_ERROR,
7114 "%s: tdls initialization failed", __func__);
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05307115 return -EINVAL;
7116 }
7117 }
7118#endif
7119
Jeff Johnson295189b2012-06-20 16:38:30 -07007120 break;
7121 case NL80211_IFTYPE_ADHOC:
7122 hddLog(VOS_TRACE_LEVEL_INFO,
7123 "%s: setting interface Type to ADHOC", __func__);
7124 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
7125 pRoamProfile->phyMode =
7126 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07007127 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007128 wdev->iftype = type;
7129 break;
7130
7131 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07007132 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07007133 {
7134 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
7135 "%s: setting interface Type to %s", __func__,
7136 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
7137
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08007138 //Cancel any remain on channel for GO mode
7139 if (NL80211_IFTYPE_P2P_GO == type)
7140 {
7141 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
7142 }
Mohit Khanna0f232092012-09-11 14:46:08 -07007143 if (NL80211_IFTYPE_AP == type)
7144 {
7145 /* As Loading WLAN Driver one interface being created for p2p device
7146 * address. This will take one HW STA and the max number of clients
7147 * that can connect to softAP will be reduced by one. so while changing
7148 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
7149 * interface as it is not required in SoftAP mode.
7150 */
7151
7152 // Get P2P Adapter
7153 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
7154
7155 if (pP2pAdapter)
7156 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307157 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -07007158 hdd_deinit_adapter(pHddCtx, pP2pAdapter);
7159 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
7160 }
7161 }
Swaroop Goltia2e32212014-04-09 23:37:33 +05307162 //Disable IMPS & BMPS for SAP/GO
7163 if(VOS_STATUS_E_FAILURE ==
7164 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
7165 {
7166 //Fail to Exit BMPS
7167 VOS_ASSERT(0);
7168 }
Deepthi Gowri500fc472014-08-11 19:53:10 +05307169
7170 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
7171
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307172#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07007173
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307174 /* A Mutex Lock is introduced while changing the mode to
7175 * protect the concurrent access for the Adapters by TDLS
7176 * module.
7177 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05307178 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307179#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007180 //De-init the adapter.
Jeff Johnson295189b2012-06-20 16:38:30 -07007181 hdd_deinit_adapter( pHddCtx, pAdapter );
7182 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07007183 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
7184 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307185#ifdef FEATURE_WLAN_TDLS
7186 mutex_unlock(&pHddCtx->tdls_lock);
7187#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07007188 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
7189 (pConfig->apRandomBssidEnabled))
7190 {
7191 /* To meet Android requirements create a randomized
7192 MAC address of the form 02:1A:11:Fx:xx:xx */
7193 get_random_bytes(&ndev->dev_addr[3], 3);
7194 ndev->dev_addr[0] = 0x02;
7195 ndev->dev_addr[1] = 0x1A;
7196 ndev->dev_addr[2] = 0x11;
7197 ndev->dev_addr[3] |= 0xF0;
7198 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
7199 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08007200 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
7201 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07007202 }
7203
Jeff Johnson295189b2012-06-20 16:38:30 -07007204 hdd_set_ap_ops( pAdapter->dev );
7205
Kiet Lam10841362013-11-01 11:36:50 +05307206 /* This is for only SAP mode where users can
7207 * control country through ini.
7208 * P2P GO follows station country code
7209 * acquired during the STA scanning. */
7210 if((NL80211_IFTYPE_AP == type) &&
7211 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
7212 {
7213 int status = 0;
7214 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
7215 "%s: setting country code from INI ", __func__);
7216 init_completion(&pAdapter->change_country_code);
7217 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
7218 (void *)(tSmeChangeCountryCallback)
7219 wlan_hdd_change_country_code_cb,
7220 pConfig->apCntryCode, pAdapter,
7221 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05307222 eSIR_FALSE,
7223 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05307224 if (eHAL_STATUS_SUCCESS == status)
7225 {
7226 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307227 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05307228 &pAdapter->change_country_code,
7229 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307230 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05307231 {
7232 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307233 FL("SME Timed out while setting country code %ld"),
7234 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08007235
7236 if (pHddCtx->isLogpInProgress)
7237 {
7238 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7239 "%s: LOGP in Progress. Ignore!!!", __func__);
7240 return -EAGAIN;
7241 }
Kiet Lam10841362013-11-01 11:36:50 +05307242 }
7243 }
7244 else
7245 {
7246 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007247 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05307248 return -EINVAL;
7249 }
7250 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007251 status = hdd_init_ap_mode(pAdapter);
7252 if(status != VOS_STATUS_SUCCESS)
7253 {
7254 hddLog(VOS_TRACE_LEVEL_FATAL,
7255 "%s: Error initializing the ap mode", __func__);
7256 return -EINVAL;
7257 }
7258 hdd_set_conparam(1);
7259
Jeff Johnson295189b2012-06-20 16:38:30 -07007260 /*interface type changed update in wiphy structure*/
7261 if(wdev)
7262 {
7263 wdev->iftype = type;
7264 pHddCtx->change_iface = type;
7265 }
7266 else
7267 {
7268 hddLog(VOS_TRACE_LEVEL_ERROR,
7269 "%s: ERROR !!!! Wireless dev is NULL", __func__);
7270 return -EINVAL;
7271 }
7272 goto done;
7273 }
7274
7275 default:
7276 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
7277 __func__);
7278 return -EOPNOTSUPP;
7279 }
7280 }
7281 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007282 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007283 )
7284 {
7285 switch(type)
7286 {
7287 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07007288 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07007289 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +05307290
7291 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307292#ifdef FEATURE_WLAN_TDLS
7293
7294 /* A Mutex Lock is introduced while changing the mode to
7295 * protect the concurrent access for the Adapters by TDLS
7296 * module.
7297 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05307298 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307299#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07007300 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07007301 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08007302 //Check for sub-string p2p to confirm its a p2p interface
7303 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08007304 {
7305 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
7306 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
7307 }
7308 else
7309 {
7310 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07007311 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08007312 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007313 hdd_set_conparam(0);
7314 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07007315 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
7316 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307317#ifdef FEATURE_WLAN_TDLS
7318 mutex_unlock(&pHddCtx->tdls_lock);
7319#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05307320 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07007321 if( VOS_STATUS_SUCCESS != status )
7322 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07007323 /* In case of JB, for P2P-GO, only change interface will be called,
7324 * This is the right place to enable back bmps_imps()
7325 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05307326 if (pHddCtx->hdd_wlan_suspended)
7327 {
7328 hdd_set_pwrparams(pHddCtx);
7329 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007330 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007331 goto done;
7332 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07007333 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07007334 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07007335 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
7336 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07007337 goto done;
7338 default:
7339 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
7340 __func__);
7341 return -EOPNOTSUPP;
7342
7343 }
7344
7345 }
7346 else
7347 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307348 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
7349 __func__, hdd_device_modetoString(pAdapter->device_mode),
7350 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007351 return -EOPNOTSUPP;
7352 }
7353
7354
7355 if(pRoamProfile)
7356 {
7357 if ( LastBSSType != pRoamProfile->BSSType )
7358 {
7359 /*interface type changed update in wiphy structure*/
7360 wdev->iftype = type;
7361
7362 /*the BSS mode changed, We need to issue disconnect
7363 if connected or in IBSS disconnect state*/
7364 if ( hdd_connGetConnectedBssType(
7365 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
7366 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
7367 {
7368 /*need to issue a disconnect to CSR.*/
7369 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7370 if( eHAL_STATUS_SUCCESS ==
7371 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
7372 pAdapter->sessionId,
7373 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
7374 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307375 ret = wait_for_completion_interruptible_timeout(
7376 &pAdapter->disconnect_comp_var,
7377 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7378 if (ret <= 0)
7379 {
7380 hddLog(VOS_TRACE_LEVEL_ERROR,
7381 FL("wait on disconnect_comp_var failed %ld"), ret);
7382 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007383 }
7384 }
7385 }
7386 }
7387
7388done:
7389 /*set bitmask based on updated value*/
7390 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07007391
7392 /* Only STA mode support TM now
7393 * all other mode, TM feature should be disabled */
7394 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
7395 (~VOS_STA & pHddCtx->concurrency_mode) )
7396 {
7397 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
7398 }
7399
Jeff Johnson295189b2012-06-20 16:38:30 -07007400#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307401 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05307402 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07007403 {
7404 //we are ok to do AMP
7405 pHddCtx->isAmpAllowed = VOS_TRUE;
7406 }
7407#endif //WLAN_BTAMP_FEATURE
7408 EXIT();
7409 return 0;
7410}
7411
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05307412/*
7413 * FUNCTION: wlan_hdd_cfg80211_change_iface
7414 * wrapper function to protect the actual implementation from SSR.
7415 */
7416int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
7417 struct net_device *ndev,
7418 enum nl80211_iftype type,
7419 u32 *flags,
7420 struct vif_params *params
7421 )
7422{
7423 int ret;
7424
7425 vos_ssr_protect(__func__);
7426 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
7427 vos_ssr_unprotect(__func__);
7428
7429 return ret;
7430}
7431
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007432#ifdef FEATURE_WLAN_TDLS
7433static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
7434 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
7435{
7436 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7437 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7438 VOS_STATUS status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007439 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307440 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05307441 tANI_U16 numCurrTdlsPeers;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007442
7443 ENTER();
7444
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05307445 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007446 {
7447 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7448 "Invalid arguments");
7449 return -EINVAL;
7450 }
Hoonki Lee27511902013-03-14 18:19:06 -07007451
7452 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
7453 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
7454 {
7455 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7456 "%s: TDLS mode is disabled OR not enabled in FW."
7457 MAC_ADDRESS_STR " Request declined.",
7458 __func__, MAC_ADDR_ARRAY(mac));
7459 return -ENOTSUPP;
7460 }
7461
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007462 if (pHddCtx->isLogpInProgress)
7463 {
7464 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7465 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +05307466 wlan_hdd_tdls_set_link_status(pAdapter,
7467 mac,
7468 eTDLS_LINK_IDLE,
7469 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007470 return -EBUSY;
7471 }
7472
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05307473 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007474
7475 if ( NULL == pTdlsPeer ) {
7476 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7477 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
7478 __func__, MAC_ADDR_ARRAY(mac), update);
7479 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007480 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007481
7482 /* in add station, we accept existing valid staId if there is */
7483 if ((0 == update) &&
7484 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
7485 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007486 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007487 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007488 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007489 " link_status %d. staId %d. add station ignored.",
7490 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
7491 return 0;
7492 }
7493 /* in change station, we accept only when staId is valid */
7494 if ((1 == update) &&
7495 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
7496 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
7497 {
7498 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7499 "%s: " MAC_ADDRESS_STR
7500 " link status %d. staId %d. change station %s.",
7501 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
7502 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
7503 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007504 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007505
7506 /* when others are on-going, we want to change link_status to idle */
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307507 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007508 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007509 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7510 "%s: " MAC_ADDRESS_STR
7511 " TDLS setup is ongoing. Request declined.",
7512 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07007513 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007514 }
7515
7516 /* first to check if we reached to maximum supported TDLS peer.
7517 TODO: for now, return -EPERM looks working fine,
7518 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05307519 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
7520 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007521 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007522 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7523 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05307524 " TDLS Max peer already connected. Request declined."
7525 " Num of peers (%d), Max allowed (%d).",
7526 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
7527 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007528 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007529 }
7530 else
7531 {
7532 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307533 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007534 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007535 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007536 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7537 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
7538 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007539 return -EPERM;
7540 }
7541 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007542 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +05307543 wlan_hdd_tdls_set_link_status(pAdapter,
7544 mac,
7545 eTDLS_LINK_CONNECTING,
7546 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007547
Jeff Johnsond75fe012013-04-06 10:53:06 -07007548 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05307549 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007550 {
7551 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7552 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07007553 if(StaParams->htcap_present)
7554 {
7555 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7556 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
7557 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7558 "ht_capa->extended_capabilities: %0x",
7559 StaParams->HTCap.extendedHtCapInfo);
7560 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007561 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7562 "params->capability: %0x",StaParams->capability);
7563 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007564 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07007565 if(StaParams->vhtcap_present)
7566 {
7567 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7568 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
7569 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
7570 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
7571 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007572 {
7573 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007574 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007575 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
7576 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7577 "[%d]: %x ", i, StaParams->supported_rates[i]);
7578 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07007579 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05307580 else if ((1 == update) && (NULL == StaParams))
7581 {
7582 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7583 "%s : update is true, but staParams is NULL. Error!", __func__);
7584 return -EPERM;
7585 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007586
7587 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
7588
7589 if (!update)
7590 {
7591 status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
7592 pAdapter->sessionId, mac);
7593 }
7594 else
7595 {
7596 status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
7597 pAdapter->sessionId, mac, StaParams);
7598 }
7599
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307600 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007601 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
7602
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307603 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007604 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307606 "%s: timeout waiting for tdls add station indication %ld",
7607 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007608 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007609 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307610
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007611 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
7612 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007613 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007614 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007615 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007616 }
7617
7618 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07007619
7620error:
Atul Mittal115287b2014-07-08 13:26:33 +05307621 wlan_hdd_tdls_set_link_status(pAdapter,
7622 mac,
7623 eTDLS_LINK_IDLE,
7624 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007625 return -EPERM;
7626
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007627}
7628#endif
7629
Jeff Johnson295189b2012-06-20 16:38:30 -07007630static int wlan_hdd_change_station(struct wiphy *wiphy,
7631 struct net_device *dev,
7632 u8 *mac,
7633 struct station_parameters *params)
7634{
7635 VOS_STATUS status = VOS_STATUS_SUCCESS;
7636 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkala29149562013-05-10 21:43:41 +05307637 hdd_context_t *pHddCtx;
7638 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007639 v_MACADDR_t STAMacAddress;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07007640#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007641 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007642 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05307643 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07007644#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07007645 ENTER();
7646
Gopichand Nakkala29149562013-05-10 21:43:41 +05307647 if ((NULL == pAdapter))
7648 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307649 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05307650 "invalid adapter ");
7651 return -EINVAL;
7652 }
7653
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307654 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7655 TRACE_CODE_HDD_CHANGE_STATION,
7656 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05307657 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7658 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7659
7660 if ((NULL == pHddCtx) || (NULL == pHddStaCtx))
7661 {
7662 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7663 "invalid HDD state or HDD station context");
7664 return -EINVAL;
7665 }
7666
7667 if (pHddCtx->isLogpInProgress)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007668 {
7669 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7670 "%s:LOGP in Progress. Ignore!!!", __func__);
7671 return -EAGAIN;
7672 }
7673
Jeff Johnson295189b2012-06-20 16:38:30 -07007674 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
7675
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007676 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
7677 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07007678 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007679 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07007680 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307681 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07007682 WLANTL_STA_AUTHENTICATED);
7683
Gopichand Nakkala29149562013-05-10 21:43:41 +05307684 if (status != VOS_STATUS_SUCCESS)
7685 {
7686 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7687 "%s: Not able to change TL state to AUTHENTICATED", __func__);
7688 return -EINVAL;
7689 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007690 }
7691 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07007692 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
7693 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05307694#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007695 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
7696 StaParams.capability = params->capability;
7697 StaParams.uapsd_queues = params->uapsd_queues;
7698 StaParams.max_sp = params->max_sp;
7699
Naresh Jayaram3180aa42014-02-12 21:47:26 +05307700 /* Convert (first channel , number of channels) tuple to
7701 * the total list of channels. This goes with the assumption
7702 * that if the first channel is < 14, then the next channels
7703 * are an incremental of 1 else an incremental of 4 till the number
7704 * of channels.
7705 */
7706 if (0 != params->supported_channels_len) {
7707 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
7708 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
7709 {
7710 int wifi_chan_index;
7711 StaParams.supported_channels[j] = params->supported_channels[i];
7712 wifi_chan_index =
7713 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
7714 no_of_channels = params->supported_channels[i+1];
7715 for(k=1; k <= no_of_channels; k++)
7716 {
7717 StaParams.supported_channels[j+1] =
7718 StaParams.supported_channels[j] + wifi_chan_index;
7719 j+=1;
7720 }
7721 }
7722 StaParams.supported_channels_len = j;
7723 }
7724 vos_mem_copy(StaParams.supported_oper_classes,
7725 params->supported_oper_classes,
7726 params->supported_oper_classes_len);
7727 StaParams.supported_oper_classes_len =
7728 params->supported_oper_classes_len;
7729
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007730 if (0 != params->ext_capab_len)
7731 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
7732 sizeof(StaParams.extn_capability));
7733
7734 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07007735 {
7736 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007737 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07007738 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007739
7740 StaParams.supported_rates_len = params->supported_rates_len;
7741
7742 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
7743 * The supported_rates array , for all the structures propogating till Add Sta
7744 * to the firmware has to be modified , if the supplicant (ieee80211) is
7745 * modified to send more rates.
7746 */
7747
7748 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
7749 */
7750 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
7751 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
7752
7753 if (0 != StaParams.supported_rates_len) {
7754 int i = 0;
7755 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
7756 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007757 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007758 "Supported Rates with Length %d", StaParams.supported_rates_len);
7759 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007760 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007761 "[%d]: %0x", i, StaParams.supported_rates[i]);
7762 }
7763
7764 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07007765 {
7766 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007767 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07007768 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007769
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007770 if (0 != params->ext_capab_len ) {
7771 /*Define A Macro : TODO Sunil*/
7772 if ((1<<4) & StaParams.extn_capability[3]) {
7773 isBufSta = 1;
7774 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05307775 /* TDLS Channel Switching Support */
7776 if ((1<<6) & StaParams.extn_capability[3]) {
7777 isOffChannelSupported = 1;
7778 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007779 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05307780 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
7781 &StaParams, isBufSta,
7782 isOffChannelSupported);
7783
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307784 if (VOS_STATUS_SUCCESS != status) {
7785 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7786 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
7787 return -EINVAL;
7788 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007789 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
7790
7791 if (VOS_STATUS_SUCCESS != status) {
7792 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7793 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
7794 return -EINVAL;
7795 }
7796 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07007797#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05307798 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007799 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007800 return status;
7801}
7802
7803/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05307804 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -07007805 * This function is used to initialize the key information
7806 */
7807#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05307808static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007809 struct net_device *ndev,
7810 u8 key_index, bool pairwise,
7811 const u8 *mac_addr,
7812 struct key_params *params
7813 )
7814#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05307815static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007816 struct net_device *ndev,
7817 u8 key_index, const u8 *mac_addr,
7818 struct key_params *params
7819 )
7820#endif
7821{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007822 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07007823 tCsrRoamSetKey setKey;
7824 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307825 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007826 v_U32_t roamId= 0xFF;
7827 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07007828 hdd_hostapd_state_t *pHostapdState;
7829 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007830 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307831 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007832
7833 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307834
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307835 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7836 TRACE_CODE_HDD_CFG80211_ADD_KEY,
7837 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307838 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7839 status = wlan_hdd_validate_context(pHddCtx);
7840
7841 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007842 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307843 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7844 "%s: HDD context is not valid", __func__);
7845 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007846 }
7847
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307848 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7849 __func__, hdd_device_modetoString(pAdapter->device_mode),
7850 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007851
7852 if (CSR_MAX_NUM_KEY <= key_index)
7853 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007854 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007855 key_index);
7856
7857 return -EINVAL;
7858 }
7859
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007860 if (CSR_MAX_KEY_LEN < params->key_len)
7861 {
7862 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
7863 params->key_len);
7864
7865 return -EINVAL;
7866 }
7867
7868 hddLog(VOS_TRACE_LEVEL_INFO,
7869 "%s: called with key index = %d & key length %d",
7870 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07007871
7872 /*extract key idx, key len and key*/
7873 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
7874 setKey.keyId = key_index;
7875 setKey.keyLength = params->key_len;
7876 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
7877
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007878 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07007879 {
7880 case WLAN_CIPHER_SUITE_WEP40:
7881 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
7882 break;
7883
7884 case WLAN_CIPHER_SUITE_WEP104:
7885 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
7886 break;
7887
7888 case WLAN_CIPHER_SUITE_TKIP:
7889 {
7890 u8 *pKey = &setKey.Key[0];
7891 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
7892
7893 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
7894
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007895 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07007896
7897 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007898 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07007899 |--------------|----------|----------|
7900 <---16bytes---><--8bytes--><--8bytes-->
7901
7902 */
7903 /*Sme expects the 32 bytes key to be in the below order
7904
7905 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007906 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07007907 |--------------|----------|----------|
7908 <---16bytes---><--8bytes--><--8bytes-->
7909 */
7910 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007911 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07007912
7913 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007914 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07007915
7916 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007917 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07007918
7919
7920 break;
7921 }
7922
7923 case WLAN_CIPHER_SUITE_CCMP:
7924 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
7925 break;
7926
7927#ifdef FEATURE_WLAN_WAPI
7928 case WLAN_CIPHER_SUITE_SMS4:
7929 {
7930 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
7931 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
7932 params->key, params->key_len);
7933 return 0;
7934 }
7935#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007936
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007937#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07007938 case WLAN_CIPHER_SUITE_KRK:
7939 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
7940 break;
7941#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007942
7943#ifdef WLAN_FEATURE_11W
7944 case WLAN_CIPHER_SUITE_AES_CMAC:
7945 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07007946 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07007947#endif
7948
Jeff Johnson295189b2012-06-20 16:38:30 -07007949 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007950 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07007951 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05307952 status = -EOPNOTSUPP;
7953 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07007954 }
7955
7956 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
7957 __func__, setKey.encType);
7958
Shailender Karmuchi642e9812013-05-30 14:34:49 -07007959 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07007960#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7961 (!pairwise)
7962#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007963 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07007964#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07007965 )
7966 {
7967 /* set group key*/
7968 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7969 "%s- %d: setting Broadcast key",
7970 __func__, __LINE__);
7971 setKey.keyDirection = eSIR_RX_ONLY;
7972 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
7973 }
7974 else
7975 {
7976 /* set pairwise key*/
7977 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7978 "%s- %d: setting pairwise key",
7979 __func__, __LINE__);
7980 setKey.keyDirection = eSIR_TX_RX;
7981 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
7982 }
7983 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
7984 {
7985 setKey.keyDirection = eSIR_TX_RX;
7986 /*Set the group key*/
7987 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
7988 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007989
Shailender Karmuchi642e9812013-05-30 14:34:49 -07007990 if ( 0 != status )
7991 {
7992 hddLog(VOS_TRACE_LEVEL_ERROR,
7993 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05307994 status = -EINVAL;
7995 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07007996 }
7997 /*Save the keys here and call sme_RoamSetKey for setting
7998 the PTK after peer joins the IBSS network*/
7999 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
8000 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308001 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008002 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05308003 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
8004 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
8005 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008006 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008007 if( pHostapdState->bssState == BSS_START )
8008 {
c_hpothu7c55da62014-01-23 18:34:02 +05308009 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8010 vos_status = wlan_hdd_check_ula_done(pAdapter);
8011
8012 if ( vos_status != VOS_STATUS_SUCCESS )
8013 {
8014 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8015 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
8016 __LINE__, vos_status );
8017
8018 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
8019
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308020 status = -EINVAL;
8021 goto end;
c_hpothu7c55da62014-01-23 18:34:02 +05308022 }
8023
Jeff Johnson295189b2012-06-20 16:38:30 -07008024 status = WLANSAP_SetKeySta( pVosContext, &setKey);
8025
8026 if ( status != eHAL_STATUS_SUCCESS )
8027 {
8028 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8029 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
8030 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308031 status = -EINVAL;
8032 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07008033 }
8034 }
8035
8036 /* Saving WEP keys */
8037 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
8038 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
8039 {
8040 //Save the wep key in ap context. Issue setkey after the BSS is started.
8041 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
8042 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
8043 }
8044 else
8045 {
8046 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008047 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008048 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
8049 }
8050 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008051 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
8052 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008053 {
8054 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8055 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8056
Gopichand Nakkala3d295922013-05-07 16:19:14 +05308057#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8058 if (!pairwise)
8059#else
8060 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
8061#endif
8062 {
8063 /* set group key*/
8064 if (pHddStaCtx->roam_info.deferKeyComplete)
8065 {
8066 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8067 "%s- %d: Perform Set key Complete",
8068 __func__, __LINE__);
8069 hdd_PerformRoamSetKeyComplete(pAdapter);
8070 }
8071 }
8072
Jeff Johnson295189b2012-06-20 16:38:30 -07008073 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
8074
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08008075 pWextState->roamProfile.Keys.defaultIndex = key_index;
8076
8077
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008078 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07008079 params->key, params->key_len);
8080
Gopichand Nakkala3d295922013-05-07 16:19:14 +05308081
Jeff Johnson295189b2012-06-20 16:38:30 -07008082 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
8083
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308084 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07008085 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308086 __func__, setKey.peerMac[0], setKey.peerMac[1],
8087 setKey.peerMac[2], setKey.peerMac[3],
8088 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07008089 setKey.keyDirection);
8090
8091 vos_status = wlan_hdd_check_ula_done(pAdapter);
8092
8093 if ( vos_status != VOS_STATUS_SUCCESS )
8094 {
8095 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8096 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
8097 __LINE__, vos_status );
8098
8099 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
8100
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308101 status = -EINVAL;
8102 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07008103
8104 }
8105
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008106#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05308107 /* The supplicant may attempt to set the PTK once pre-authentication
8108 is done. Save the key in the UMAC and include it in the ADD BSS
8109 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008110 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05308111 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008112 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05308113 hddLog(VOS_TRACE_LEVEL_INFO_MED,
8114 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308115 status = 0;
8116 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +05308117 }
8118 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
8119 {
8120 hddLog(VOS_TRACE_LEVEL_ERROR,
8121 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308122 status = -EINVAL;
8123 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008124 }
8125#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07008126
8127 /* issue set key request to SME*/
8128 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
8129 pAdapter->sessionId, &setKey, &roamId );
8130
8131 if ( 0 != status )
8132 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308133 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07008134 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
8135 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308136 status = -EINVAL;
8137 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07008138 }
8139
8140
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308141 /* in case of IBSS as there was no information available about WEP keys during
8142 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07008143 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308144 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
8145 !( ( IW_AUTH_KEY_MGMT_802_1X
8146 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07008147 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
8148 )
8149 &&
8150 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
8151 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
8152 )
8153 )
8154 {
8155 setKey.keyDirection = eSIR_RX_ONLY;
8156 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
8157
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308158 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07008159 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308160 __func__, setKey.peerMac[0], setKey.peerMac[1],
8161 setKey.peerMac[2], setKey.peerMac[3],
8162 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07008163 setKey.keyDirection);
8164
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308165 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07008166 pAdapter->sessionId, &setKey, &roamId );
8167
8168 if ( 0 != status )
8169 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308170 hddLog(VOS_TRACE_LEVEL_ERROR,
8171 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008172 __func__, status);
8173 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308174 status = -EINVAL;
8175 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07008176 }
8177 }
8178 }
8179
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308180end:
8181 /* Need to clear any trace of key value in the memory.
8182 * Thus zero out the memory even though it is local
8183 * variable.
8184 */
8185 vos_mem_zero(&setKey, sizeof(setKey));
8186
8187 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008188}
8189
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308190#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8191static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
8192 struct net_device *ndev,
8193 u8 key_index, bool pairwise,
8194 const u8 *mac_addr,
8195 struct key_params *params
8196 )
8197#else
8198static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
8199 struct net_device *ndev,
8200 u8 key_index, const u8 *mac_addr,
8201 struct key_params *params
8202 )
8203#endif
8204{
8205 int ret;
8206 vos_ssr_protect(__func__);
8207#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8208 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
8209 mac_addr, params);
8210#else
8211 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
8212 params);
8213#endif
8214 vos_ssr_unprotect(__func__);
8215
8216 return ret;
8217}
8218
Jeff Johnson295189b2012-06-20 16:38:30 -07008219/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308220 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -07008221 * This function is used to get the key information
8222 */
8223#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308224static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308225 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008226 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308227 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07008228 const u8 *mac_addr, void *cookie,
8229 void (*callback)(void *cookie, struct key_params*)
8230 )
8231#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308232static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308233 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008234 struct net_device *ndev,
8235 u8 key_index, const u8 *mac_addr, void *cookie,
8236 void (*callback)(void *cookie, struct key_params*)
8237 )
8238#endif
8239{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308240 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308241 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8242 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008243 struct key_params params;
8244
8245 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308246
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308247 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8248 __func__, hdd_device_modetoString(pAdapter->device_mode),
8249 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308250
Jeff Johnson295189b2012-06-20 16:38:30 -07008251 memset(&params, 0, sizeof(params));
8252
8253 if (CSR_MAX_NUM_KEY <= key_index)
8254 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308255 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07008256 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308257 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008258
8259 switch(pRoamProfile->EncryptionType.encryptionType[0])
8260 {
8261 case eCSR_ENCRYPT_TYPE_NONE:
8262 params.cipher = IW_AUTH_CIPHER_NONE;
8263 break;
8264
8265 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
8266 case eCSR_ENCRYPT_TYPE_WEP40:
8267 params.cipher = WLAN_CIPHER_SUITE_WEP40;
8268 break;
8269
8270 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
8271 case eCSR_ENCRYPT_TYPE_WEP104:
8272 params.cipher = WLAN_CIPHER_SUITE_WEP104;
8273 break;
8274
8275 case eCSR_ENCRYPT_TYPE_TKIP:
8276 params.cipher = WLAN_CIPHER_SUITE_TKIP;
8277 break;
8278
8279 case eCSR_ENCRYPT_TYPE_AES:
8280 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
8281 break;
8282
8283 default:
8284 params.cipher = IW_AUTH_CIPHER_NONE;
8285 break;
8286 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308287
c_hpothuaaf19692014-05-17 17:01:48 +05308288 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8289 TRACE_CODE_HDD_CFG80211_GET_KEY,
8290 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308291
Jeff Johnson295189b2012-06-20 16:38:30 -07008292 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
8293 params.seq_len = 0;
8294 params.seq = NULL;
8295 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
8296 callback(cookie, &params);
8297 return 0;
8298}
8299
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308300#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8301static int wlan_hdd_cfg80211_get_key(
8302 struct wiphy *wiphy,
8303 struct net_device *ndev,
8304 u8 key_index, bool pairwise,
8305 const u8 *mac_addr, void *cookie,
8306 void (*callback)(void *cookie, struct key_params*)
8307 )
8308#else
8309static int wlan_hdd_cfg80211_get_key(
8310 struct wiphy *wiphy,
8311 struct net_device *ndev,
8312 u8 key_index, const u8 *mac_addr, void *cookie,
8313 void (*callback)(void *cookie, struct key_params*)
8314 )
8315#endif
8316{
8317 int ret;
8318
8319 vos_ssr_protect(__func__);
8320#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8321 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
8322 mac_addr, cookie, callback);
8323#else
8324 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
8325 callback);
8326#endif
8327 vos_ssr_unprotect(__func__);
8328
8329 return ret;
8330}
8331
Jeff Johnson295189b2012-06-20 16:38:30 -07008332/*
8333 * FUNCTION: wlan_hdd_cfg80211_del_key
8334 * This function is used to delete the key information
8335 */
8336#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308337static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008338 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308339 u8 key_index,
8340 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07008341 const u8 *mac_addr
8342 )
8343#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308344static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008345 struct net_device *ndev,
8346 u8 key_index,
8347 const u8 *mac_addr
8348 )
8349#endif
8350{
8351 int status = 0;
8352
8353 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308354 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07008355 //it is observed that this is invalidating peer
8356 //key index whenever re-key is done. This is affecting data link.
8357 //It should be ok to ignore del_key.
8358#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308359 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
8360 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008361 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
8362 tCsrRoamSetKey setKey;
8363 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308364
Jeff Johnson295189b2012-06-20 16:38:30 -07008365 ENTER();
8366
8367 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
8368 __func__,pAdapter->device_mode);
8369
8370 if (CSR_MAX_NUM_KEY <= key_index)
8371 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308372 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008373 key_index);
8374
8375 return -EINVAL;
8376 }
8377
8378 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8379 setKey.keyId = key_index;
8380
8381 if (mac_addr)
8382 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
8383 else
8384 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
8385
8386 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
8387
8388 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008389 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308390 )
8391 {
8392
8393 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07008394 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
8395 if( pHostapdState->bssState == BSS_START)
8396 {
8397 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308398
Jeff Johnson295189b2012-06-20 16:38:30 -07008399 if ( status != eHAL_STATUS_SUCCESS )
8400 {
8401 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8402 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
8403 __LINE__, status );
8404 }
8405 }
8406 }
8407 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308408 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07008409 )
8410 {
8411 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8412
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308413 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
8414
8415 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07008416 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308417 __func__, setKey.peerMac[0], setKey.peerMac[1],
8418 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07008419 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308420 if(pAdapter->sessionCtx.station.conn_info.connState ==
8421 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07008422 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308423 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07008424 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308425
Jeff Johnson295189b2012-06-20 16:38:30 -07008426 if ( 0 != status )
8427 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308428 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07008429 "%s: sme_RoamSetKey failure, returned %d",
8430 __func__, status);
8431 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
8432 return -EINVAL;
8433 }
8434 }
8435 }
8436#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008437 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008438 return status;
8439}
8440
8441/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308442 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -07008443 * This function is used to set the default tx key index
8444 */
8445#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308446static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008447 struct net_device *ndev,
8448 u8 key_index,
8449 bool unicast, bool multicast)
8450#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308451static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008452 struct net_device *ndev,
8453 u8 key_index)
8454#endif
8455{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308456 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308457 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308458 hdd_wext_state_t *pWextState;
8459 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308460 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008461
8462 ENTER();
8463
Gopichand Nakkala29149562013-05-10 21:43:41 +05308464 if ((NULL == pAdapter))
8465 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05308467 "invalid adapter");
8468 return -EINVAL;
8469 }
8470
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308471 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8472 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
8473 pAdapter->sessionId, key_index));
8474
Gopichand Nakkala29149562013-05-10 21:43:41 +05308475 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8476 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8477
8478 if ((NULL == pWextState) || (NULL == pHddStaCtx))
8479 {
8480 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8481 "invalid Wext state or HDD context");
8482 return -EINVAL;
8483 }
8484
Arif Hussain6d2a3322013-11-17 19:50:10 -08008485 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008486 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308487
Jeff Johnson295189b2012-06-20 16:38:30 -07008488 if (CSR_MAX_NUM_KEY <= key_index)
8489 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308490 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008491 key_index);
8492
8493 return -EINVAL;
8494 }
8495
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308496 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8497 status = wlan_hdd_validate_context(pHddCtx);
8498
8499 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008500 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308501 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8502 "%s: HDD context is not valid", __func__);
8503 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008504 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308505
Jeff Johnson295189b2012-06-20 16:38:30 -07008506 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07008507 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308508 )
Jeff Johnson295189b2012-06-20 16:38:30 -07008509 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05308510 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08008511 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308512 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08008513 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008514 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308515 {
8516 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07008517 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308518
Jeff Johnson295189b2012-06-20 16:38:30 -07008519 tCsrRoamSetKey setKey;
8520 v_U32_t roamId= 0xFF;
8521 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308522
8523 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008524 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308525
Jeff Johnson295189b2012-06-20 16:38:30 -07008526 Keys->defaultIndex = (u8)key_index;
8527 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8528 setKey.keyId = key_index;
8529 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308530
8531 vos_mem_copy(&setKey.Key[0],
8532 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07008533 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308534
Gopichand Nakkala29149562013-05-10 21:43:41 +05308535 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308536
8537 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07008538 &pHddStaCtx->conn_info.bssId[0],
8539 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308540
Gopichand Nakkala29149562013-05-10 21:43:41 +05308541 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
8542 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
8543 eCSR_ENCRYPT_TYPE_WEP104)
8544 {
8545 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
8546 even though ap is configured for WEP-40 encryption. In this canse the key length
8547 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
8548 type(104) and switching encryption type to 40*/
8549 pWextState->roamProfile.EncryptionType.encryptionType[0] =
8550 eCSR_ENCRYPT_TYPE_WEP40;
8551 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
8552 eCSR_ENCRYPT_TYPE_WEP40;
8553 }
8554
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308555 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07008556 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308557
Jeff Johnson295189b2012-06-20 16:38:30 -07008558 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308559 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07008560 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308561
Jeff Johnson295189b2012-06-20 16:38:30 -07008562 if ( 0 != status )
8563 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308564 hddLog(VOS_TRACE_LEVEL_ERROR,
8565 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008566 status);
8567 return -EINVAL;
8568 }
8569 }
8570 }
8571
8572 /* In SoftAp mode setting key direction for default mode */
8573 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
8574 {
8575 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
8576 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
8577 (eCSR_ENCRYPT_TYPE_AES !=
8578 pWextState->roamProfile.EncryptionType.encryptionType[0])
8579 )
8580 {
8581 /* Saving key direction for default key index to TX default */
8582 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
8583 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
8584 }
8585 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308586
Jeff Johnson295189b2012-06-20 16:38:30 -07008587 return status;
8588}
8589
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308590#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8591static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
8592 struct net_device *ndev,
8593 u8 key_index,
8594 bool unicast, bool multicast)
8595#else
8596static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
8597 struct net_device *ndev,
8598 u8 key_index)
8599#endif
8600{
8601 int ret;
8602 vos_ssr_protect(__func__);
8603#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8604 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
8605 multicast);
8606#else
8607 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
8608#endif
8609 vos_ssr_unprotect(__func__);
8610
8611 return ret;
8612}
8613
Jeff Johnson295189b2012-06-20 16:38:30 -07008614/*
8615 * FUNCTION: wlan_hdd_cfg80211_inform_bss
8616 * This function is used to inform the BSS details to nl80211 interface.
8617 */
8618static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
8619 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
8620{
8621 struct net_device *dev = pAdapter->dev;
8622 struct wireless_dev *wdev = dev->ieee80211_ptr;
8623 struct wiphy *wiphy = wdev->wiphy;
8624 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
8625 int chan_no;
8626 int ie_length;
8627 const char *ie;
8628 unsigned int freq;
8629 struct ieee80211_channel *chan;
8630 int rssi = 0;
8631 struct cfg80211_bss *bss = NULL;
8632
8633 ENTER();
8634
8635 if( NULL == pBssDesc )
8636 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008637 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008638 return bss;
8639 }
8640
8641 chan_no = pBssDesc->channelId;
8642 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
8643 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
8644
8645 if( NULL == ie )
8646 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008647 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008648 return bss;
8649 }
8650
8651#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
8652 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
8653 {
8654 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
8655 }
8656 else
8657 {
8658 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
8659 }
8660#else
8661 freq = ieee80211_channel_to_frequency(chan_no);
8662#endif
8663
8664 chan = __ieee80211_get_channel(wiphy, freq);
8665
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +05308666 if (!chan) {
8667 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
8668 return NULL;
8669 }
8670
Abhishek Singhaee43942014-06-16 18:55:47 +05308671 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -07008672
Abhishek Singhaee43942014-06-16 18:55:47 +05308673 return cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308674 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07008675 pBssDesc->capabilityInfo,
8676 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +05308677 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008678}
8679
8680
8681
8682/*
8683 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
8684 * This function is used to inform the BSS details to nl80211 interface.
8685 */
8686struct cfg80211_bss*
8687wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
8688 tSirBssDescription *bss_desc
8689 )
8690{
8691 /*
8692 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
8693 already exists in bss data base of cfg80211 for that particular BSS ID.
8694 Using cfg80211_inform_bss_frame to update the bss entry instead of
8695 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
8696 now there is no possibility to get the mgmt(probe response) frame from PE,
8697 converting bss_desc to ieee80211_mgmt(probe response) and passing to
8698 cfg80211_inform_bss_frame.
8699 */
8700 struct net_device *dev = pAdapter->dev;
8701 struct wireless_dev *wdev = dev->ieee80211_ptr;
8702 struct wiphy *wiphy = wdev->wiphy;
8703 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08008704#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
8705 qcom_ie_age *qie_age = NULL;
8706 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
8707#else
Jeff Johnson295189b2012-06-20 16:38:30 -07008708 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08008709#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008710 const char *ie =
8711 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
8712 unsigned int freq;
8713 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05308714 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008715 struct cfg80211_bss *bss_status = NULL;
8716 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
8717 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07008718 hdd_context_t *pHddCtx;
8719 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07008720#ifdef WLAN_OPEN_SOURCE
8721 struct timespec ts;
8722#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008723
Wilson Yangf80a0542013-10-07 13:02:37 -07008724 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8725 status = wlan_hdd_validate_context(pHddCtx);
8726
8727 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +05308728 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -07008729 {
8730 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8731 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
8732 return NULL;
8733 }
8734
8735
8736 if (0 != status)
8737 {
8738 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8739 "%s: HDD context is not valid", __func__);
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07008740 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07008741 }
8742
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05308743 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -07008744 if (!mgmt)
8745 {
8746 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8747 "%s: memory allocation failed ", __func__);
8748 return NULL;
8749 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07008750
Jeff Johnson295189b2012-06-20 16:38:30 -07008751 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07008752
8753#ifdef WLAN_OPEN_SOURCE
8754 /* Android does not want the timestamp from the frame.
8755 Instead it wants a monotonic increasing value */
8756 get_monotonic_boottime(&ts);
8757 mgmt->u.probe_resp.timestamp =
8758 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
8759#else
8760 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07008761 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
8762 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07008763
8764#endif
8765
Jeff Johnson295189b2012-06-20 16:38:30 -07008766 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
8767 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08008768
8769#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
8770 /* GPS Requirement: need age ie per entry. Using vendor specific. */
8771 /* Assuming this is the last IE, copy at the end */
8772 ie_length -=sizeof(qcom_ie_age);
8773 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
8774 qie_age->element_id = QCOM_VENDOR_IE_ID;
8775 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
8776 qie_age->oui_1 = QCOM_OUI1;
8777 qie_age->oui_2 = QCOM_OUI2;
8778 qie_age->oui_3 = QCOM_OUI3;
8779 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
8780 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
8781#endif
8782
Jeff Johnson295189b2012-06-20 16:38:30 -07008783 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05308784 if (bss_desc->fProbeRsp)
8785 {
8786 mgmt->frame_control |=
8787 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
8788 }
8789 else
8790 {
8791 mgmt->frame_control |=
8792 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
8793 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008794
8795#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308796 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07008797 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
8798 {
8799 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
8800 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308801 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07008802 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
8803
8804 {
8805 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
8806 }
8807 else
8808 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05308809 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
8810 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -07008811 kfree(mgmt);
8812 return NULL;
8813 }
8814#else
8815 freq = ieee80211_channel_to_frequency(chan_no);
8816#endif
8817 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08008818 /*when the band is changed on the fly using the GUI, three things are done
8819 * 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)
8820 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
8821 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
8822 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
8823 * and discards the channels correponding to previous band and calls back with zero bss results.
8824 * 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
8825 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
8826 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
8827 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
8828 * So drop the bss and continue to next bss.
8829 */
8830 if(chan == NULL)
8831 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05308832 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07008833 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08008834 return NULL;
8835 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008836 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308837 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07008838 * */
8839 if (( eConnectionState_Associated ==
8840 pAdapter->sessionCtx.station.conn_info.connState ) &&
8841 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
8842 pAdapter->sessionCtx.station.conn_info.bssId,
8843 WNI_CFG_BSSID_LEN)))
8844 {
8845 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
8846 rssi = (pAdapter->rssi * 100);
8847 }
8848 else
8849 {
8850 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
8851 }
8852
Nirav Shah20ac06f2013-12-12 18:14:06 +05308853 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
8854 "RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
8855 chan->center_freq, (int)(rssi/100));
8856
Jeff Johnson295189b2012-06-20 16:38:30 -07008857 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
8858 frame_len, rssi, GFP_KERNEL);
8859 kfree(mgmt);
8860 return bss_status;
8861}
8862
8863/*
8864 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
8865 * This function is used to update the BSS data base of CFG8011
8866 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308867struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07008868 tCsrRoamInfo *pRoamInfo
8869 )
8870{
8871 tCsrRoamConnectedProfile roamProfile;
8872 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8873 struct cfg80211_bss *bss = NULL;
8874
8875 ENTER();
8876
8877 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
8878 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
8879
8880 if (NULL != roamProfile.pBssDesc)
8881 {
Girish Gowlif4b68022014-08-28 23:18:57 +05308882 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
8883 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07008884
8885 if (NULL == bss)
8886 {
8887 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
8888 __func__);
8889 }
8890
8891 sme_RoamFreeConnectProfile(hHal, &roamProfile);
8892 }
8893 else
8894 {
8895 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
8896 __func__);
8897 }
8898 return bss;
8899}
8900
8901/*
8902 * FUNCTION: wlan_hdd_cfg80211_update_bss
8903 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308904static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
8905 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07008906 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308907{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308908 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008909 tCsrScanResultInfo *pScanResult;
8910 eHalStatus status = 0;
8911 tScanResultHandle pResult;
8912 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07008913 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008914
8915 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308916
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308917 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8918 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
8919 NO_SESSION, pAdapter->sessionId));
8920
Wilson Yangf80a0542013-10-07 13:02:37 -07008921 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8922
8923 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -07008924 {
Wilson Yangf80a0542013-10-07 13:02:37 -07008925 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8926 "%s:LOGP in Progress. Ignore!!!",__func__);
8927 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07008928 }
8929
Wilson Yangf80a0542013-10-07 13:02:37 -07008930
8931 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +05308932 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -07008933 {
8934 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8935 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
8936 return VOS_STATUS_E_PERM;
8937 }
8938
8939
Jeff Johnson295189b2012-06-20 16:38:30 -07008940 /*
8941 * start getting scan results and populate cgf80211 BSS database
8942 */
8943 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
8944
8945 /* no scan results */
8946 if (NULL == pResult)
8947 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05308948 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
8949 __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07008950 return status;
8951 }
8952
8953 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
8954
8955 while (pScanResult)
8956 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308957 /*
8958 * cfg80211_inform_bss() is not updating ie field of bss entry, if
8959 * entry already exists in bss data base of cfg80211 for that
8960 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
8961 * bss entry instead of cfg80211_inform_bss, But this call expects
8962 * mgmt packet as input. As of now there is no possibility to get
8963 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07008964 * ieee80211_mgmt(probe response) and passing to c
8965 * fg80211_inform_bss_frame.
8966 * */
8967
8968 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
8969 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308970
Jeff Johnson295189b2012-06-20 16:38:30 -07008971
8972 if (NULL == bss_status)
8973 {
8974 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008975 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008976 }
8977 else
8978 {
Yue Maf49ba872013-08-19 12:04:25 -07008979 cfg80211_put_bss(
8980#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
8981 wiphy,
8982#endif
8983 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07008984 }
8985
8986 pScanResult = sme_ScanResultGetNext(hHal, pResult);
8987 }
8988
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308989 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07008990
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308991 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008992}
8993
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008994void
8995hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
8996{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308997 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -08008998 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008999} /****** end hddPrintMacAddr() ******/
9000
9001void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07009002hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009003{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309004 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009005 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07009006 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
9007 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
9008 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009009} /****** end hddPrintPmkId() ******/
9010
9011//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
9012//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
9013
9014//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
9015//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
9016
9017#define dump_bssid(bssid) \
9018 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07009019 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
9020 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009021 }
9022
9023#define dump_pmkid(pMac, pmkid) \
9024 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07009025 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
9026 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009027 }
9028
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07009029#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009030/*
9031 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
9032 * This function is used to notify the supplicant of a new PMKSA candidate.
9033 */
9034int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309035 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009036 int index, bool preauth )
9037{
Jeff Johnsone7245742012-09-05 17:12:55 -07009038#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009039 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07009040 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009041
9042 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07009043 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009044
9045 if( NULL == pRoamInfo )
9046 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009047 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009048 return -EINVAL;
9049 }
9050
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07009051 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
9052 {
9053 dump_bssid(pRoamInfo->bssid);
9054 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009055 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07009056 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009057#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309058 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009059}
9060#endif //FEATURE_WLAN_LFR
9061
Yue Maef608272013-04-08 23:09:17 -07009062#ifdef FEATURE_WLAN_LFR_METRICS
9063/*
9064 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
9065 * 802.11r/LFR metrics reporting function to report preauth initiation
9066 *
9067 */
9068#define MAX_LFR_METRICS_EVENT_LENGTH 100
9069VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
9070 tCsrRoamInfo *pRoamInfo)
9071{
9072 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
9073 union iwreq_data wrqu;
9074
9075 ENTER();
9076
9077 if (NULL == pAdapter)
9078 {
9079 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
9080 return VOS_STATUS_E_FAILURE;
9081 }
9082
9083 /* create the event */
9084 memset(&wrqu, 0, sizeof(wrqu));
9085 memset(metrics_notification, 0, sizeof(metrics_notification));
9086
9087 wrqu.data.pointer = metrics_notification;
9088 wrqu.data.length = scnprintf(metrics_notification,
9089 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
9090 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
9091
9092 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
9093
9094 EXIT();
9095
9096 return VOS_STATUS_SUCCESS;
9097}
9098
9099/*
9100 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
9101 * 802.11r/LFR metrics reporting function to report preauth completion
9102 * or failure
9103 */
9104VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
9105 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
9106{
9107 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
9108 union iwreq_data wrqu;
9109
9110 ENTER();
9111
9112 if (NULL == pAdapter)
9113 {
9114 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
9115 return VOS_STATUS_E_FAILURE;
9116 }
9117
9118 /* create the event */
9119 memset(&wrqu, 0, sizeof(wrqu));
9120 memset(metrics_notification, 0, sizeof(metrics_notification));
9121
9122 scnprintf(metrics_notification, sizeof(metrics_notification),
9123 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
9124 MAC_ADDR_ARRAY(pRoamInfo->bssid));
9125
9126 if (1 == preauth_status)
9127 strncat(metrics_notification, " TRUE", 5);
9128 else
9129 strncat(metrics_notification, " FALSE", 6);
9130
9131 wrqu.data.pointer = metrics_notification;
9132 wrqu.data.length = strlen(metrics_notification);
9133
9134 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
9135
9136 EXIT();
9137
9138 return VOS_STATUS_SUCCESS;
9139}
9140
9141/*
9142 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
9143 * 802.11r/LFR metrics reporting function to report handover initiation
9144 *
9145 */
9146VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
9147 tCsrRoamInfo *pRoamInfo)
9148{
9149 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
9150 union iwreq_data wrqu;
9151
9152 ENTER();
9153
9154 if (NULL == pAdapter)
9155 {
9156 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
9157 return VOS_STATUS_E_FAILURE;
9158 }
9159
9160 /* create the event */
9161 memset(&wrqu, 0, sizeof(wrqu));
9162 memset(metrics_notification, 0, sizeof(metrics_notification));
9163
9164 wrqu.data.pointer = metrics_notification;
9165 wrqu.data.length = scnprintf(metrics_notification,
9166 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
9167 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
9168
9169 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
9170
9171 EXIT();
9172
9173 return VOS_STATUS_SUCCESS;
9174}
9175#endif
9176
Jeff Johnson295189b2012-06-20 16:38:30 -07009177/*
9178 * FUNCTION: hdd_cfg80211_scan_done_callback
9179 * scanning callback function, called after finishing scan
9180 *
9181 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309182static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -07009183 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
9184{
9185 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309186 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009187 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009188 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9189 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07009190 struct cfg80211_scan_request *req = NULL;
9191 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05309192 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309193 long waitRet = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009194
9195 ENTER();
9196
9197 hddLog(VOS_TRACE_LEVEL_INFO,
9198 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -08009199 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009200 __func__, halHandle, pContext, (int) scanId, (int) status);
9201
Kiet Lamac06e2c2013-10-23 16:25:07 +05309202 pScanInfo->mScanPendingCounter = 0;
9203
Jeff Johnson295189b2012-06-20 16:38:30 -07009204 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309205 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -07009206 &pScanInfo->scan_req_completion_event,
9207 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309208 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07009209 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309210 hddLog(VOS_TRACE_LEVEL_ERROR,
9211 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -07009212 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07009213 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07009214 }
9215
Yue Maef608272013-04-08 23:09:17 -07009216 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07009217 {
9218 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07009219 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07009220 }
9221
9222 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309223 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -07009224 {
9225 hddLog(VOS_TRACE_LEVEL_INFO,
9226 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -08009227 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -07009228 (int) scanId);
9229 }
9230
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309231 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009232 pAdapter);
9233
9234 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309235 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009236
9237
9238 /* If any client wait scan result through WEXT
9239 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009240 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07009241 {
9242 /* The other scan request waiting for current scan finish
9243 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009244 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07009245 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009246 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07009247 }
9248 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009249 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07009250 {
9251 struct net_device *dev = pAdapter->dev;
9252 union iwreq_data wrqu;
9253 int we_event;
9254 char *msg;
9255
9256 memset(&wrqu, '\0', sizeof(wrqu));
9257 we_event = SIOCGIWSCAN;
9258 msg = NULL;
9259 wireless_send_event(dev, we_event, &wrqu, msg);
9260 }
9261 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009262 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009263
9264 /* Get the Scan Req */
9265 req = pAdapter->request;
9266
9267 if (!req)
9268 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009269 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07009270 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07009271 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07009272 }
9273
9274 /*
9275 * setting up 0, just in case.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309276 */
Jeff Johnson295189b2012-06-20 16:38:30 -07009277 req->n_ssids = 0;
9278 req->n_channels = 0;
9279 req->ie = 0;
9280
Jeff Johnson295189b2012-06-20 16:38:30 -07009281 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07009282 /* Scan is no longer pending */
9283 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009284
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -07009285 /*
9286 * cfg80211_scan_done informing NL80211 about completion
9287 * of scanning
9288 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05309289 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
9290 {
9291 aborted = true;
9292 }
9293 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08009294 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07009295
Jeff Johnsone7245742012-09-05 17:12:55 -07009296allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07009297 /* release the wake lock at the end of the scan*/
9298 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07009299
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07009300 /* Acquire wakelock to handle the case where APP's tries to suspend
9301 * immediatly after the driver gets connect request(i.e after scan)
9302 * from supplicant, this result in app's is suspending and not able
9303 * to process the connect request to AP */
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05309304 hdd_prevent_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07009305
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07009306#ifdef FEATURE_WLAN_TDLS
c_hpothu3c8f8e82014-06-02 18:01:50 +05309307 if (!(eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode))
9308 {
9309 wlan_hdd_tdls_scan_done_callback(pAdapter);
9310 }
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07009311#endif
9312
Jeff Johnson295189b2012-06-20 16:38:30 -07009313 EXIT();
9314 return 0;
9315}
9316
9317/*
Rashmi Ramannab1429032014-04-26 14:59:09 +05309318 * FUNCTION: hdd_isConnectionInProgress
9319 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009320 *
9321 */
Ganesh Kondabattiniaeb7b772014-08-11 20:00:36 +05309322v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx, v_BOOL_t isRoC )
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009323{
9324 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
9325 hdd_station_ctx_t *pHddStaCtx = NULL;
9326 hdd_adapter_t *pAdapter = NULL;
9327 VOS_STATUS status = 0;
9328 v_U8_t staId = 0;
9329 v_U8_t *staMac = NULL;
9330
c_hpothu9b781ba2013-12-30 20:57:45 +05309331 if (TRUE == pHddCtx->btCoexModeSet)
9332 {
9333 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +05309334 FL("BTCoex Mode operation in progress"));
9335 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +05309336 }
9337
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009338 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
9339
9340 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
9341 {
9342 pAdapter = pAdapterNode->pAdapter;
9343
9344 if( pAdapter )
9345 {
9346 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309347 "%s: Adapter with device mode %s (%d) exists",
9348 __func__, hdd_device_modetoString(pAdapter->device_mode),
9349 pAdapter->device_mode);
Ganesh Kondabattiniaeb7b772014-08-11 20:00:36 +05309350 if ((((!isRoC) && (WLAN_HDD_INFRA_STATION == pAdapter->device_mode)) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +05309351 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
9352 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
9353 (eConnectionState_Connecting ==
9354 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
9355 {
9356 hddLog(VOS_TRACE_LEVEL_ERROR,
9357 "%s: %p(%d) Connection is in progress", __func__,
9358 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
9359 return VOS_TRUE;
9360 }
Ganesh Kondabattiniaeb7b772014-08-11 20:00:36 +05309361 if (((!isRoC) && (WLAN_HDD_INFRA_STATION == pAdapter->device_mode)) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309362 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
9363 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009364 {
9365 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9366 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309367 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009368 {
9369 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
9370 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08009371 "%s: client " MAC_ADDRESS_STR
9372 " is in the middle of WPS/EAPOL exchange.", __func__,
9373 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +05309374 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009375 }
9376 }
9377 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
9378 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
9379 {
9380 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
9381 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309382 if ((pAdapter->aStaInfo[staId].isUsed) &&
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009383 (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState))
9384 {
9385 staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
9386
9387 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08009388 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
9389 "middle of WPS/EAPOL exchange.", __func__,
9390 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +05309391 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009392 }
9393 }
9394 }
9395 }
9396 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
9397 pAdapterNode = pNext;
9398 }
Rashmi Ramannab1429032014-04-26 14:59:09 +05309399 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309400}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009401
9402/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05309403 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -07009404 * this scan respond to scan trigger and update cfg80211 scan database
9405 * later, scan dump command can be used to recieve scan results
9406 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05309407int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009408#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
9409 struct net_device *dev,
9410#endif
9411 struct cfg80211_scan_request *request)
9412{
Siddharth Bhal0c162d02014-05-06 19:50:42 +05309413 hdd_adapter_t *pAdapter = NULL;
9414 hdd_context_t *pHddCtx = NULL;
9415 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309416 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009417 tCsrScanRequest scanRequest;
9418 tANI_U8 *channelList = NULL, i;
9419 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309420 int status;
9421 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009422 v_U8_t* pP2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009423
Siddharth Bhal0c162d02014-05-06 19:50:42 +05309424#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
9425 struct net_device *dev = NULL;
9426 if (NULL == request)
9427 {
9428 hddLog(VOS_TRACE_LEVEL_ERROR,
9429 "%s: scan req param null", __func__);
9430 return -EINVAL;
9431 }
9432 dev = request->wdev->netdev;
9433#endif
9434
9435 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
9436 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
9437 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9438
Jeff Johnson295189b2012-06-20 16:38:30 -07009439 ENTER();
9440
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309441
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309442 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9443 __func__, hdd_device_modetoString(pAdapter->device_mode),
9444 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309445
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309446 status = wlan_hdd_validate_context(pHddCtx);
9447
9448 if (0 != status)
9449 {
9450 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9451 "%s: HDD context is not valid", __func__);
9452 return status;
9453 }
9454
Siddharth Bhal0c162d02014-05-06 19:50:42 +05309455 if (NULL == pwextBuf)
9456 {
9457 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
9458 __func__);
9459 return -EIO;
9460 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309461 cfg_param = pHddCtx->cfg_ini;
9462 pScanInfo = &pHddCtx->scan_info;
9463
Jeff Johnson295189b2012-06-20 16:38:30 -07009464#ifdef WLAN_BTAMP_FEATURE
9465 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009466 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -07009467 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08009468 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009469 "%s: No scanning when AMP is on", __func__);
9470 return -EOPNOTSUPP;
9471 }
9472#endif
9473 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009474 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009475 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009476 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309477 "%s: Not scanning on device_mode = %s (%d)",
9478 __func__, hdd_device_modetoString(pAdapter->device_mode),
9479 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009480 return -EOPNOTSUPP;
9481 }
9482
9483 if (TRUE == pScanInfo->mScanPending)
9484 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05309485 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
9486 {
9487 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
9488 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009489 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07009490 }
9491
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309492 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -07009493 //Channel and action frame is pending
9494 //Otherwise Cancel Remain On Channel and allow Scan
9495 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009496 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -07009497 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05309498 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009499 return -EBUSY;
9500 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009501#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07009502 /* if tdls disagree scan right now, return immediately.
9503 tdls will schedule the scan when scan is allowed. (return SUCCESS)
9504 or will reject the scan if any TDLS is in progress. (return -EBUSY)
9505 */
9506 status = wlan_hdd_tdls_scan_callback (pAdapter,
9507 wiphy,
9508#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
9509 dev,
Gopichand Nakkalac3c42b92013-03-20 19:42:34 -07009510#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07009511 request);
9512 if(status <= 0)
9513 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309514 if(!status)
9515 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
9516 "scan rejected %d", __func__, status);
9517 else
9518 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
9519 __func__, status);
9520
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07009521 return status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009522 }
9523#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07009524
Jeff Johnson295189b2012-06-20 16:38:30 -07009525 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
9526 {
9527 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -08009528 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009529 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309530 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009531 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
9532 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309533 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009534 "%s: MAX TM Level Scan not allowed", __func__);
9535 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309536 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07009537 }
9538 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
9539
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009540 /* Check if scan is allowed at this point of time.
9541 */
Ganesh Kondabattiniaeb7b772014-08-11 20:00:36 +05309542 if (hdd_isConnectionInProgress(pHddCtx, VOS_FALSE))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009543 {
9544 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
9545 return -EBUSY;
9546 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309547
Jeff Johnson295189b2012-06-20 16:38:30 -07009548 vos_mem_zero( &scanRequest, sizeof(scanRequest));
9549
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309550 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
9551 (int)request->n_ssids);
9552
9553 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
9554 * Becasue of this, driver is assuming that this is not wildcard scan and so
9555 * is not aging out the scan results.
9556 */
9557 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07009558 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309559 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009560 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309561
9562 if ((request->ssids) && (0 < request->n_ssids))
9563 {
9564 tCsrSSIDInfo *SsidInfo;
9565 int j;
9566 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
9567 /* Allocate num_ssid tCsrSSIDInfo structure */
9568 SsidInfo = scanRequest.SSIDs.SSIDList =
9569 ( tCsrSSIDInfo *)vos_mem_malloc(
9570 request->n_ssids*sizeof(tCsrSSIDInfo));
9571
9572 if(NULL == scanRequest.SSIDs.SSIDList)
9573 {
9574 hddLog(VOS_TRACE_LEVEL_ERROR,
9575 "%s: memory alloc failed SSIDInfo buffer", __func__);
9576 return -ENOMEM;
9577 }
9578
9579 /* copy all the ssid's and their length */
9580 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
9581 {
9582 /* get the ssid length */
9583 SsidInfo->SSID.length = request->ssids[j].ssid_len;
9584 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
9585 SsidInfo->SSID.length);
9586 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
9587 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
9588 j, SsidInfo->SSID.ssId);
9589 }
9590 /* set the scan type to active */
9591 scanRequest.scanType = eSIR_ACTIVE_SCAN;
9592 }
9593 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07009594 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +05309595 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9596 TRACE_CODE_HDD_CFG80211_SCAN,
9597 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07009598 /* set the scan type to active */
9599 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07009600 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309601 else
9602 {
9603 /*Set the scan type to default type, in this case it is ACTIVE*/
9604 scanRequest.scanType = pScanInfo->scan_mode;
9605 }
9606 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
9607 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07009608
9609 /* set BSSType to default type */
9610 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
9611
9612 /*TODO: scan the requested channels only*/
9613
9614 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309615 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -07009616 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309617 hddLog(VOS_TRACE_LEVEL_WARN,
9618 "No of Scan Channels exceeded limit: %d", request->n_channels);
9619 request->n_channels = MAX_CHANNEL;
9620 }
9621
9622 hddLog(VOS_TRACE_LEVEL_INFO,
9623 "No of Scan Channels: %d", request->n_channels);
9624
9625
9626 if( request->n_channels )
9627 {
9628 char chList [(request->n_channels*5)+1];
9629 int len;
9630 channelList = vos_mem_malloc( request->n_channels );
9631 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +05309632 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309633 hddLog(VOS_TRACE_LEVEL_ERROR,
9634 "%s: memory alloc failed channelList", __func__);
9635 status = -ENOMEM;
9636 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +05309637 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309638
9639 for( i = 0, len = 0; i < request->n_channels ; i++ )
9640 {
9641 channelList[i] = request->channels[i]->hw_value;
9642 len += snprintf(chList+len, 5, "%d ", channelList[i]);
9643 }
9644
Nirav Shah20ac06f2013-12-12 18:14:06 +05309645 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309646 "Channel-List: %s ", chList);
9647 }
c_hpothu53512302014-04-15 18:49:53 +05309648
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309649 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
9650 scanRequest.ChannelInfo.ChannelList = channelList;
9651
9652 /* set requestType to full scan */
9653 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
9654
9655 /* Flush the scan results(only p2p beacons) for STA scan and P2P
9656 * search (Flush on both full scan and social scan but not on single
9657 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
9658 */
9659
9660 /* Supplicant does single channel scan after 8-way handshake
9661 * and in that case driver shoudnt flush scan results. If
9662 * driver flushes the scan results here and unfortunately if
9663 * the AP doesnt respond to our probe req then association
9664 * fails which is not desired
9665 */
9666
9667 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
9668 {
9669 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
9670 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
9671 pAdapter->sessionId );
9672 }
9673
9674 if( request->ie_len )
9675 {
9676 /* save this for future association (join requires this) */
9677 /*TODO: Array needs to be converted to dynamic allocation,
9678 * as multiple ie.s can be sent in cfg80211_scan_request structure
9679 * CR 597966
9680 */
9681 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
9682 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
9683 pScanInfo->scanAddIE.length = request->ie_len;
9684
9685 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
9686 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
9687 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07009688 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309689 if ( request->ie_len <= SIR_MAC_MAX_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -07009690 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309691 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
9692 memcpy( pwextBuf->roamProfile.addIEScan,
9693 request->ie, request->ie_len);
9694 }
9695 else
9696 {
9697 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
9698 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07009699 }
9700
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309701 }
9702 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
9703 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
9704
9705 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
9706 request->ie_len);
9707 if (pP2pIe != NULL)
9708 {
9709#ifdef WLAN_FEATURE_P2P_DEBUG
9710 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
9711 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
9712 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +05309713 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309714 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
9715 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
9716 "Go nego completed to Connection is started");
9717 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
9718 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +05309719 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309720 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
9721 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07009722 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309723 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
9724 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
9725 "Disconnected state to Connection is started");
9726 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
9727 "for 4way Handshake");
9728 }
9729#endif
9730
9731 /* no_cck will be set during p2p find to disable 11b rates */
9732 if(TRUE == request->no_cck)
9733 {
9734 hddLog(VOS_TRACE_LEVEL_INFO,
9735 "%s: This is a P2P Search", __func__);
9736 scanRequest.p2pSearch = 1;
9737
9738 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +05309739 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309740 /* set requestType to P2P Discovery */
9741 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
9742 }
9743
9744 /*
9745 Skip Dfs Channel in case of P2P Search
9746 if it is set in ini file
9747 */
9748 if(cfg_param->skipDfsChnlInP2pSearch)
9749 {
9750 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +05309751 }
9752 else
9753 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309754 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05309755 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009756
Agarwal Ashish4f616132013-12-30 23:32:50 +05309757 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009758 }
9759 }
9760
9761 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
9762
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07009763 /* acquire the wakelock to avoid the apps suspend during the scan. To
9764 * address the following issues.
9765 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
9766 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
9767 * for long time, this result in apps running at full power for long time.
9768 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
9769 * be stuck in full power because of resume BMPS
9770 */
9771 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07009772
Nirav Shah20ac06f2013-12-12 18:14:06 +05309773 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9774 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309775 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
9776 scanRequest.requestType, scanRequest.scanType,
9777 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +05309778 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
9779
Jeff Johnsone7245742012-09-05 17:12:55 -07009780 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009781 pAdapter->sessionId, &scanRequest, &scanId,
9782 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -07009783
Jeff Johnson295189b2012-06-20 16:38:30 -07009784 if (eHAL_STATUS_SUCCESS != status)
9785 {
9786 hddLog(VOS_TRACE_LEVEL_ERROR,
9787 "%s: sme_ScanRequest returned error %d", __func__, status);
9788 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07009789 if(eHAL_STATUS_RESOURCES == status)
9790 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309791 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
9792 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07009793 status = -EBUSY;
9794 } else {
9795 status = -EIO;
9796 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07009797 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07009798 goto free_mem;
9799 }
9800
9801 pScanInfo->mScanPending = TRUE;
9802 pAdapter->request = request;
9803 pScanInfo->scanId = scanId;
9804
9805 complete(&pScanInfo->scan_req_completion_event);
9806
9807free_mem:
9808 if( scanRequest.SSIDs.SSIDList )
9809 {
9810 vos_mem_free(scanRequest.SSIDs.SSIDList);
9811 }
9812
9813 if( channelList )
9814 vos_mem_free( channelList );
9815
9816 EXIT();
9817
9818 return status;
9819}
9820
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05309821int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
9822#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
9823 struct net_device *dev,
9824#endif
9825 struct cfg80211_scan_request *request)
9826{
9827 int ret;
9828
9829 vos_ssr_protect(__func__);
9830 ret = __wlan_hdd_cfg80211_scan(wiphy,
9831#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
9832 dev,
9833#endif
9834 request);
9835 vos_ssr_unprotect(__func__);
9836
9837 return ret;
9838}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07009839
9840void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
9841{
9842 v_U8_t iniDot11Mode =
9843 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
9844 eHddDot11Mode hddDot11Mode = iniDot11Mode;
9845
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05309846 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
9847 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07009848 switch ( iniDot11Mode )
9849 {
9850 case eHDD_DOT11_MODE_AUTO:
9851 case eHDD_DOT11_MODE_11ac:
9852 case eHDD_DOT11_MODE_11ac_ONLY:
9853#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +05309854 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
9855 sme_IsFeatureSupportedByFW(DOT11AC) )
9856 hddDot11Mode = eHDD_DOT11_MODE_11ac;
9857 else
9858 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07009859#else
9860 hddDot11Mode = eHDD_DOT11_MODE_11n;
9861#endif
9862 break;
9863 case eHDD_DOT11_MODE_11n:
9864 case eHDD_DOT11_MODE_11n_ONLY:
9865 hddDot11Mode = eHDD_DOT11_MODE_11n;
9866 break;
9867 default:
9868 hddDot11Mode = iniDot11Mode;
9869 break;
9870 }
9871 /* This call decides required channel bonding mode */
9872 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
9873 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
9874 operationChannel);
9875}
9876
Jeff Johnson295189b2012-06-20 16:38:30 -07009877/*
9878 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309879 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -07009880 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309881int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -07009882 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07009883{
9884 int status = 0;
9885 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -08009886 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009887 v_U32_t roamId;
9888 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07009889 eCsrAuthType RSNAuthType;
9890
9891 ENTER();
9892
9893 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -08009894 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9895
9896 status = wlan_hdd_validate_context(pHddCtx);
9897 if (status)
9898 {
9899 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9900 "%s: HDD context is not valid!", __func__);
9901 return status;
9902 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309903
Jeff Johnson295189b2012-06-20 16:38:30 -07009904 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
9905 {
9906 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
9907 return -EINVAL;
9908 }
9909
9910 pRoamProfile = &pWextState->roamProfile;
9911
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309912 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07009913 {
Jeff Johnsone7245742012-09-05 17:12:55 -07009914 hdd_station_ctx_t *pHddStaCtx;
9915 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009916
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309917 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07009918 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
9919 {
9920 /*QoS not enabled in cfg file*/
9921 pRoamProfile->uapsd_mask = 0;
9922 }
9923 else
9924 {
9925 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309926 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -07009927 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
9928 }
9929
9930 pRoamProfile->SSIDs.numOfSSIDs = 1;
9931 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
9932 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309933 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009934 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
9935 ssid, ssid_len);
9936
9937 if (bssid)
9938 {
9939 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
9940 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
9941 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309942 /* Save BSSID in seperate variable as well, as RoamProfile
9943 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -07009944 case of join failure we should send valid BSSID to supplicant
9945 */
9946 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
9947 WNI_CFG_BSSID_LEN);
9948 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07009949 else
9950 {
9951 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
9952 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009953
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05309954 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
9955 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07009956 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
9957 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309958 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009959 /*set gen ie*/
9960 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
9961 /*set auth*/
9962 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
9963 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009964#ifdef FEATURE_WLAN_WAPI
9965 if (pAdapter->wapi_info.nWapiMode)
9966 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009967 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009968 switch (pAdapter->wapi_info.wapiAuthMode)
9969 {
9970 case WAPI_AUTH_MODE_PSK:
9971 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009972 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009973 pAdapter->wapi_info.wapiAuthMode);
9974 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
9975 break;
9976 }
9977 case WAPI_AUTH_MODE_CERT:
9978 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009979 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009980 pAdapter->wapi_info.wapiAuthMode);
9981 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
9982 break;
9983 }
9984 } // End of switch
9985 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
9986 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
9987 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009988 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009989 pRoamProfile->AuthType.numEntries = 1;
9990 pRoamProfile->EncryptionType.numEntries = 1;
9991 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
9992 pRoamProfile->mcEncryptionType.numEntries = 1;
9993 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
9994 }
9995 }
9996#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309997#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309998 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309999 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
10000 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
10001 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053010002 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
10003 sizeof (tSirGtkOffloadParams));
10004 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010005 }
10006#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010007 pRoamProfile->csrPersona = pAdapter->device_mode;
10008
Jeff Johnson32d95a32012-09-10 13:15:23 -070010009 if( operatingChannel )
10010 {
10011 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
10012 pRoamProfile->ChannelInfo.numOfChannels = 1;
10013 }
Chet Lanctot186b5732013-03-18 10:26:30 -070010014 else
10015 {
10016 pRoamProfile->ChannelInfo.ChannelList = NULL;
10017 pRoamProfile->ChannelInfo.numOfChannels = 0;
10018 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010019 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
10020 {
10021 hdd_select_cbmode(pAdapter,operatingChannel);
10022 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053010023
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080010024 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
10025 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010026 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080010027 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080010028 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
10029 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053010030 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
10031 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053010032 {
10033 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10034 "%s: Set HDD connState to eConnectionState_Connecting",
10035 __func__);
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080010036 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
10037 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053010038 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010039 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070010040 pAdapter->sessionId, pRoamProfile, &roamId);
10041
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053010042 if ((eHAL_STATUS_SUCCESS != status) &&
10043 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
10044 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053010045
10046 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080010047 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
10048 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
10049 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053010050 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080010051 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053010052 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080010053
10054 pRoamProfile->ChannelInfo.ChannelList = NULL;
10055 pRoamProfile->ChannelInfo.numOfChannels = 0;
10056
Jeff Johnson295189b2012-06-20 16:38:30 -070010057 }
10058 else
10059 {
10060 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
10061 return -EINVAL;
10062 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080010063 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010064 return status;
10065}
10066
10067/*
10068 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
10069 * This function is used to set the authentication type (OPEN/SHARED).
10070 *
10071 */
10072static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
10073 enum nl80211_auth_type auth_type)
10074{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010075 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010076 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10077
10078 ENTER();
10079
10080 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010081 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070010082 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010083 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053010084 hddLog(VOS_TRACE_LEVEL_INFO,
10085 "%s: set authentication type to AUTOSWITCH", __func__);
10086 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
10087 break;
10088
10089 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070010090#ifdef WLAN_FEATURE_VOWIFI_11R
10091 case NL80211_AUTHTYPE_FT:
10092#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010093 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070010094 "%s: set authentication type to OPEN", __func__);
10095 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
10096 break;
10097
10098 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010099 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070010100 "%s: set authentication type to SHARED", __func__);
10101 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
10102 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010103#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010104 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010105 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070010106 "%s: set authentication type to CCKM WPA", __func__);
10107 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
10108 break;
10109#endif
10110
10111
10112 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010113 hddLog(VOS_TRACE_LEVEL_ERROR,
10114 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070010115 auth_type);
10116 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
10117 return -EINVAL;
10118 }
10119
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010120 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070010121 pHddStaCtx->conn_info.authType;
10122 return 0;
10123}
10124
10125/*
10126 * FUNCTION: wlan_hdd_set_akm_suite
10127 * This function is used to set the key mgmt type(PSK/8021x).
10128 *
10129 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010130static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070010131 u32 key_mgmt
10132 )
10133{
10134 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10135 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053010136 /* Should be in ieee802_11_defs.h */
10137#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
10138#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070010139 /*set key mgmt type*/
10140 switch(key_mgmt)
10141 {
10142 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053010143 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053010144#ifdef WLAN_FEATURE_VOWIFI_11R
10145 case WLAN_AKM_SUITE_FT_PSK:
10146#endif
10147 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070010148 __func__);
10149 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
10150 break;
10151
10152 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053010153 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053010154#ifdef WLAN_FEATURE_VOWIFI_11R
10155 case WLAN_AKM_SUITE_FT_8021X:
10156#endif
10157 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070010158 __func__);
10159 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
10160 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010161#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010162#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
10163#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
10164 case WLAN_AKM_SUITE_CCKM:
10165 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
10166 __func__);
10167 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
10168 break;
10169#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070010170#ifndef WLAN_AKM_SUITE_OSEN
10171#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
10172 case WLAN_AKM_SUITE_OSEN:
10173 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
10174 __func__);
10175 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
10176 break;
10177#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010178
10179 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010180 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010181 __func__, key_mgmt);
10182 return -EINVAL;
10183
10184 }
10185 return 0;
10186}
10187
10188/*
10189 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010190 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070010191 * (NONE/WEP40/WEP104/TKIP/CCMP).
10192 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010193static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
10194 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070010195 bool ucast
10196 )
10197{
10198 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010199 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010200 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10201
10202 ENTER();
10203
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010204 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070010205 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010206 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070010207 __func__, cipher);
10208 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
10209 }
10210 else
10211 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010212
Jeff Johnson295189b2012-06-20 16:38:30 -070010213 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010214 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070010215 {
10216 case IW_AUTH_CIPHER_NONE:
10217 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
10218 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010219
Jeff Johnson295189b2012-06-20 16:38:30 -070010220 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053010221 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070010222 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010223
Jeff Johnson295189b2012-06-20 16:38:30 -070010224 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053010225 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070010226 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010227
Jeff Johnson295189b2012-06-20 16:38:30 -070010228 case WLAN_CIPHER_SUITE_TKIP:
10229 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
10230 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010231
Jeff Johnson295189b2012-06-20 16:38:30 -070010232 case WLAN_CIPHER_SUITE_CCMP:
10233 encryptionType = eCSR_ENCRYPT_TYPE_AES;
10234 break;
10235#ifdef FEATURE_WLAN_WAPI
10236 case WLAN_CIPHER_SUITE_SMS4:
10237 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
10238 break;
10239#endif
10240
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010241#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010242 case WLAN_CIPHER_SUITE_KRK:
10243 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
10244 break;
10245#endif
10246 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010247 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010248 __func__, cipher);
10249 return -EOPNOTSUPP;
10250 }
10251 }
10252
10253 if (ucast)
10254 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010255 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010256 __func__, encryptionType);
10257 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
10258 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010259 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070010260 encryptionType;
10261 }
10262 else
10263 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010264 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010265 __func__, encryptionType);
10266 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
10267 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
10268 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
10269 }
10270
10271 return 0;
10272}
10273
10274
10275/*
10276 * FUNCTION: wlan_hdd_cfg80211_set_ie
10277 * This function is used to parse WPA/RSN IE's.
10278 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010279int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
10280 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -070010281 size_t ie_len
10282 )
10283{
10284 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10285 u8 *genie = ie;
10286 v_U16_t remLen = ie_len;
10287#ifdef FEATURE_WLAN_WAPI
10288 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
10289 u16 *tmp;
10290 v_U16_t akmsuiteCount;
10291 int *akmlist;
10292#endif
10293 ENTER();
10294
10295 /* clear previous assocAddIE */
10296 pWextState->assocAddIE.length = 0;
10297 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070010298 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010299
10300 while (remLen >= 2)
10301 {
10302 v_U16_t eLen = 0;
10303 v_U8_t elementId;
10304 elementId = *genie++;
10305 eLen = *genie++;
10306 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010307
Arif Hussain6d2a3322013-11-17 19:50:10 -080010308 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070010309 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010310
10311 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070010312 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010313 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010314 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 -070010315 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010316 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010317 "%s: Invalid WPA IE", __func__);
10318 return -EINVAL;
10319 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010320 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070010321 {
10322 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010323 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070010324 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010325
Jeff Johnson295189b2012-06-20 16:38:30 -070010326 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
10327 {
Jeff Johnson902c9832012-12-10 14:28:09 -080010328 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
10329 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070010330 VOS_ASSERT(0);
10331 return -ENOMEM;
10332 }
10333 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
10334 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
10335 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010336
Jeff Johnson295189b2012-06-20 16:38:30 -070010337 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
10338 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
10339 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
10340 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010341 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
10342 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010343 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
10344 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
10345 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
10346 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
10347 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
10348 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010349 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053010350 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070010351 {
10352 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010353 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070010354 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010355
Jeff Johnson295189b2012-06-20 16:38:30 -070010356 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
10357 {
Jeff Johnson902c9832012-12-10 14:28:09 -080010358 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
10359 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070010360 VOS_ASSERT(0);
10361 return -ENOMEM;
10362 }
10363 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
10364 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
10365 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010366
Jeff Johnson295189b2012-06-20 16:38:30 -070010367 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
10368 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
10369 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010370#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010371 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
10372 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070010373 /*Consider WFD IE, only for P2P Client */
10374 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
10375 {
10376 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010377 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070010378 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010379
Jeff Johnson295189b2012-06-20 16:38:30 -070010380 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
10381 {
Jeff Johnson902c9832012-12-10 14:28:09 -080010382 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
10383 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070010384 VOS_ASSERT(0);
10385 return -ENOMEM;
10386 }
10387 // WFD IE is saved to Additional IE ; it should be accumulated to handle
10388 // WPS IE + P2P IE + WFD IE
10389 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
10390 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010391
Jeff Johnson295189b2012-06-20 16:38:30 -070010392 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
10393 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
10394 }
10395#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010396 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010397 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070010398 HS20_OUI_TYPE_SIZE)) )
10399 {
10400 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010401 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070010402 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010403
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070010404 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
10405 {
Jeff Johnson902c9832012-12-10 14:28:09 -080010406 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
10407 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070010408 VOS_ASSERT(0);
10409 return -ENOMEM;
10410 }
10411 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
10412 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010413
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070010414 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
10415 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
10416 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070010417 /* Appending OSEN Information Element in Assiciation Request */
10418 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
10419 OSEN_OUI_TYPE_SIZE)) )
10420 {
10421 v_U16_t curAddIELen = pWextState->assocAddIE.length;
10422 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
10423 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010424
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070010425 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
10426 {
10427 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
10428 "Need bigger buffer space");
10429 VOS_ASSERT(0);
10430 return -ENOMEM;
10431 }
10432 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
10433 pWextState->assocAddIE.length += eLen + 2;
10434
10435 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
10436 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
10437 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
10438 }
10439
10440 break;
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070010441 if (WLAN_HDD_IBSS == pAdapter->device_mode) {
10442
10443 /* populating as ADDIE in beacon frames */
10444 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
10445 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
10446 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
10447 {
10448 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
10449 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
10450 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
10451 {
10452 hddLog(LOGE,
10453 "Coldn't pass "
10454 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
10455 }
10456 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
10457 else
10458 hddLog(LOGE,
10459 "Could not pass on "
10460 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
10461
10462 /* IBSS mode doesn't contain params->proberesp_ies still
10463 beaconIE's need to be populated in probe response frames */
10464 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
10465 {
10466 u16 rem_probe_resp_ie_len = eLen + 2;
10467 u8 probe_rsp_ie_len[3] = {0};
10468 u8 counter = 0;
10469
10470 /* Check Probe Resp Length if it is greater then 255 then
10471 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
10472 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
10473 not able Store More then 255 bytes into One Variable */
10474
10475 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
10476 {
10477 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
10478 {
10479 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
10480 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
10481 }
10482 else
10483 {
10484 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
10485 rem_probe_resp_ie_len = 0;
10486 }
10487 }
10488
10489 rem_probe_resp_ie_len = 0;
10490
10491 if (probe_rsp_ie_len[0] > 0)
10492 {
10493 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
10494 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
10495 (tANI_U8*)(genie - 2),
10496 probe_rsp_ie_len[0], NULL,
10497 eANI_BOOLEAN_FALSE)
10498 == eHAL_STATUS_FAILURE)
10499 {
10500 hddLog(LOGE,
10501 "Could not pass"
10502 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
10503 }
10504 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
10505 }
10506
10507 if (probe_rsp_ie_len[1] > 0)
10508 {
10509 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
10510 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
10511 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
10512 probe_rsp_ie_len[1], NULL,
10513 eANI_BOOLEAN_FALSE)
10514 == eHAL_STATUS_FAILURE)
10515 {
10516 hddLog(LOGE,
10517 "Could not pass"
10518 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
10519 }
10520 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
10521 }
10522
10523 if (probe_rsp_ie_len[2] > 0)
10524 {
10525 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
10526 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
10527 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
10528 probe_rsp_ie_len[2], NULL,
10529 eANI_BOOLEAN_FALSE)
10530 == eHAL_STATUS_FAILURE)
10531 {
10532 hddLog(LOGE,
10533 "Could not pass"
10534 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
10535 }
10536 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
10537 }
10538
10539 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
10540 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
10541 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
10542 {
10543 hddLog(LOGE,
10544 "Could not pass"
10545 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
10546 }
10547 }
10548 else
10549 {
10550 // Reset WNI_CFG_PROBE_RSP Flags
10551 wlan_hdd_reset_prob_rspies(pAdapter);
10552
10553 hddLog(VOS_TRACE_LEVEL_INFO,
10554 "%s: No Probe Response IE received in set beacon",
10555 __func__);
10556 }
10557 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070010558 break;
10559 case DOT11F_EID_RSN:
10560 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
10561 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
10562 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
10563 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
10564 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
10565 break;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010566 /* Appending Extended Capabilities with Interworking bit set in Assoc Req */
10567 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010568 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010569 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010570 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010571 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010572
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010573 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
10574 {
Jeff Johnson902c9832012-12-10 14:28:09 -080010575 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
10576 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010577 VOS_ASSERT(0);
10578 return -ENOMEM;
10579 }
10580 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
10581 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010582
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010583 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
10584 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
10585 break;
10586 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010587#ifdef FEATURE_WLAN_WAPI
10588 case WLAN_EID_WAPI:
10589 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070010590 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070010591 pAdapter->wapi_info.nWapiMode);
10592 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010593 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070010594 akmsuiteCount = WPA_GET_LE16(tmp);
10595 tmp = tmp + 1;
10596 akmlist = (int *)(tmp);
10597 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
10598 {
10599 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
10600 }
10601 else
10602 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010603 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070010604 VOS_ASSERT(0);
10605 return -EINVAL;
10606 }
10607
10608 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
10609 {
10610 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010611 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010612 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010613 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010614 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010615 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010616 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010617 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010618 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
10619 }
10620 break;
10621#endif
10622 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010623 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010624 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010625 /* when Unknown IE is received we should break and continue
10626 * to the next IE in the buffer instead we were returning
10627 * so changing this to break */
10628 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010629 }
10630 genie += eLen;
10631 remLen -= eLen;
10632 }
10633 EXIT();
10634 return 0;
10635}
10636
10637/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053010638 * FUNCTION: hdd_isWPAIEPresent
10639 * Parse the received IE to find the WPA IE
10640 *
10641 */
10642static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
10643{
10644 v_U8_t eLen = 0;
10645 v_U16_t remLen = ie_len;
10646 v_U8_t elementId = 0;
10647
10648 while (remLen >= 2)
10649 {
10650 elementId = *ie++;
10651 eLen = *ie++;
10652 remLen -= 2;
10653 if (eLen > remLen)
10654 {
10655 hddLog(VOS_TRACE_LEVEL_ERROR,
10656 "%s: IE length is wrong %d", __func__, eLen);
10657 return FALSE;
10658 }
10659 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
10660 {
10661 /* OUI - 0x00 0X50 0XF2
10662 WPA Information Element - 0x01
10663 WPA version - 0x01*/
10664 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
10665 return TRUE;
10666 }
10667 ie += eLen;
10668 remLen -= eLen;
10669 }
10670 return FALSE;
10671}
10672
10673/*
Jeff Johnson295189b2012-06-20 16:38:30 -070010674 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010675 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070010676 * parameters during connect operation.
10677 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010678int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070010679 struct cfg80211_connect_params *req
10680 )
10681{
10682 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010683 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010684 ENTER();
10685
10686 /*set wpa version*/
10687 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
10688
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010689 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070010690 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053010691 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070010692 {
10693 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
10694 }
10695 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
10696 {
10697 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
10698 }
10699 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010700
10701 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070010702 pWextState->wpaVersion);
10703
10704 /*set authentication type*/
10705 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
10706
10707 if (0 > status)
10708 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010709 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010710 "%s: failed to set authentication type ", __func__);
10711 return status;
10712 }
10713
10714 /*set key mgmt type*/
10715 if (req->crypto.n_akm_suites)
10716 {
10717 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
10718 if (0 > status)
10719 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010720 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070010721 __func__);
10722 return status;
10723 }
10724 }
10725
10726 /*set pairwise cipher type*/
10727 if (req->crypto.n_ciphers_pairwise)
10728 {
10729 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
10730 req->crypto.ciphers_pairwise[0], true);
10731 if (0 > status)
10732 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010733 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010734 "%s: failed to set unicast cipher type", __func__);
10735 return status;
10736 }
10737 }
10738 else
10739 {
10740 /*Reset previous cipher suite to none*/
10741 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
10742 if (0 > status)
10743 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010744 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010745 "%s: failed to set unicast cipher type", __func__);
10746 return status;
10747 }
10748 }
10749
10750 /*set group cipher type*/
10751 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
10752 false);
10753
10754 if (0 > status)
10755 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010756 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070010757 __func__);
10758 return status;
10759 }
10760
Chet Lanctot186b5732013-03-18 10:26:30 -070010761#ifdef WLAN_FEATURE_11W
10762 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
10763#endif
10764
Jeff Johnson295189b2012-06-20 16:38:30 -070010765 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
10766 if (req->ie_len)
10767 {
10768 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
10769 if ( 0 > status)
10770 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010771 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070010772 __func__);
10773 return status;
10774 }
10775 }
10776
10777 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010778 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070010779 {
10780 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
10781 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
10782 )
10783 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010784 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070010785 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
10786 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010787 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070010788 __func__);
10789 return -EOPNOTSUPP;
10790 }
10791 else
10792 {
10793 u8 key_len = req->key_len;
10794 u8 key_idx = req->key_idx;
10795
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010796 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070010797 && (CSR_MAX_NUM_KEY > key_idx)
10798 )
10799 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010800 hddLog(VOS_TRACE_LEVEL_INFO,
10801 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070010802 __func__, key_idx, key_len);
10803 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010804 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070010805 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010806 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070010807 (u8)key_len;
10808 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
10809 }
10810 }
10811 }
10812 }
10813
10814 return status;
10815}
10816
10817/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053010818 * FUNCTION: wlan_hdd_try_disconnect
10819 * This function is used to disconnect from previous
10820 * connection
10821 */
10822static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
10823{
10824 long ret = 0;
10825 hdd_station_ctx_t *pHddStaCtx;
10826 eMib_dot11DesiredBssType connectedBssType;
10827
10828 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10829
10830 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
10831
10832 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
10833 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
10834 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
10835 {
10836 /* Issue disconnect to CSR */
10837 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10838 if( eHAL_STATUS_SUCCESS ==
10839 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10840 pAdapter->sessionId,
10841 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
10842 {
10843 ret = wait_for_completion_interruptible_timeout(
10844 &pAdapter->disconnect_comp_var,
10845 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10846 if (0 >= ret)
10847 {
10848 hddLog(LOGE, FL("Failed to receive disconnect event"));
10849 return -EALREADY;
10850 }
10851 }
10852 }
10853 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
10854 {
10855 ret = wait_for_completion_interruptible_timeout(
10856 &pAdapter->disconnect_comp_var,
10857 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10858 if (0 >= ret)
10859 {
10860 hddLog(LOGE, FL("Failed to receive disconnect event"));
10861 return -EALREADY;
10862 }
10863 }
10864
10865 return 0;
10866}
10867
10868/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053010869 * FUNCTION: __wlan_hdd_cfg80211_connect
10870 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070010871 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010872static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010873 struct net_device *ndev,
10874 struct cfg80211_connect_params *req
10875 )
10876{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010877 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010878 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070010879 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053010880 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010881
10882 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010883
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010884 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10885 TRACE_CODE_HDD_CFG80211_CONNECT,
10886 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010887 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010888 "%s: device_mode = %s (%d)", __func__,
10889 hdd_device_modetoString(pAdapter->device_mode),
10890 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010891
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010892 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010893 if (!pHddCtx)
10894 {
10895 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10896 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053010897 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010898 }
10899
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010900 status = wlan_hdd_validate_context(pHddCtx);
10901
10902 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070010903 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010904 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10905 "%s: HDD context is not valid", __func__);
10906 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010907 }
10908
Agarwal Ashish51325b52014-06-16 16:50:49 +053010909 if (vos_max_concurrent_connections_reached()) {
10910 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
10911 return -ECONNREFUSED;
10912 }
10913
Jeff Johnson295189b2012-06-20 16:38:30 -070010914#ifdef WLAN_BTAMP_FEATURE
10915 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010916 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070010917 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010918 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010919 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080010920 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010921 }
10922#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053010923
10924 //If Device Mode is Station Concurrent Sessions Exit BMps
10925 //P2P Mode will be taken care in Open/close adapter
10926 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053010927 (vos_concurrent_open_sessions_running())) {
10928 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
10929 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053010930 }
10931
10932 /*Try disconnecting if already in connected state*/
10933 status = wlan_hdd_try_disconnect(pAdapter);
10934 if ( 0 > status)
10935 {
10936 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
10937 " connection"));
10938 return -EALREADY;
10939 }
10940
Jeff Johnson295189b2012-06-20 16:38:30 -070010941 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010942 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070010943
10944 if ( 0 > status)
10945 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010946 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070010947 __func__);
10948 return status;
10949 }
Mohit Khanna765234a2012-09-11 15:08:35 -070010950 if ( req->channel )
10951 {
10952 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
10953 req->ssid_len, req->bssid,
10954 req->channel->hw_value);
10955 }
10956 else
10957 {
10958 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010959 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -070010960 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010961
10962 if (0 > status)
10963 {
10964 //ReEnable BMPS if disabled
10965 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
10966 (NULL != pHddCtx))
10967 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053010968 if (pHddCtx->hdd_wlan_suspended)
10969 {
10970 hdd_set_pwrparams(pHddCtx);
10971 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010972 //ReEnable Bmps and Imps back
10973 hdd_enable_bmps_imps(pHddCtx);
10974 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053010975 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010976 return status;
10977 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010978 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010979 EXIT();
10980 return status;
10981}
10982
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010983static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
10984 struct net_device *ndev,
10985 struct cfg80211_connect_params *req)
10986{
10987 int ret;
10988 vos_ssr_protect(__func__);
10989 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
10990 vos_ssr_unprotect(__func__);
10991
10992 return ret;
10993}
Jeff Johnson295189b2012-06-20 16:38:30 -070010994
10995/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053010996 * FUNCTION: wlan_hdd_disconnect
10997 * This function is used to issue a disconnect request to SME
10998 */
10999int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
11000{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011001 int status;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011002 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011003 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011004 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011005
11006 status = wlan_hdd_validate_context(pHddCtx);
11007
11008 if (0 != status)
11009 {
11010 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11011 "%s: HDD context is not valid", __func__);
11012 return status;
11013 }
11014
11015 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053011016
Agarwal Ashish47d18112014-08-04 19:55:07 +053011017 /* Need to apply spin lock before decreasing active sessions
11018 * as there can be chance for double decrement if context switch
11019 * Calls hdd_DisConnectHandler.
11020 */
11021
11022 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053011023 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
11024 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053011025 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
11026 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053011027 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
11028 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053011029
Abhishek Singhf4669da2014-05-26 15:07:49 +053011030 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053011031 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
11032
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011033 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011034
Mihir Shete182a0b22014-08-18 16:08:48 +053011035 /*
11036 * stop tx queues before deleting STA/BSS context from the firmware.
11037 * tx has to be disabled because the firmware can get busy dropping
11038 * the tx frames after BSS/STA has been deleted and will not send
11039 * back a response resulting in WDI timeout
11040 */
11041 netif_tx_disable(pAdapter->dev);
11042 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011043
Mihir Shete182a0b22014-08-18 16:08:48 +053011044 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011045 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
11046 pAdapter->sessionId, reason);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011047 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
11048 {
11049 hddLog(VOS_TRACE_LEVEL_INFO,
11050 FL("status = %d, already disconnected"),
11051 (int)status );
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011052
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011053 }
11054 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011055 {
11056 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011057 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011058 __func__, (int)status );
11059 return -EINVAL;
11060 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011061 ret = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011062 &pAdapter->disconnect_comp_var,
11063 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011064 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status ))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011065 {
11066 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053011067 "%s: Failed to disconnect, timed out", __func__);
11068 return -ETIMEDOUT;
11069 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011070 else if (ret == -ERESTARTSYS)
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053011071 {
11072 hddLog(VOS_TRACE_LEVEL_ERROR,
11073 "%s: Failed to disconnect, wait interrupted", __func__);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011074 return ret;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011075 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011076 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11077 FL("Set HDD connState to eConnectionState_NotConnected"));
11078 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
11079
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053011080 return 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011081}
11082
11083
11084/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011085 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070011086 * This function is used to issue a disconnect request to SME
11087 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011088static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011089 struct net_device *dev,
11090 u16 reason
11091 )
11092{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011093 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011094 tCsrRoamProfile *pRoamProfile =
11095 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011096 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011097 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11098 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053011099#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080011100 tANI_U8 staIdx;
11101#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011102
Jeff Johnson295189b2012-06-20 16:38:30 -070011103 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011104
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011105 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11106 TRACE_CODE_HDD_CFG80211_DISCONNECT,
11107 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011108 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
11109 __func__, hdd_device_modetoString(pAdapter->device_mode),
11110 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011111
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011112 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
11113 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070011114
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011115 status = wlan_hdd_validate_context(pHddCtx);
11116
11117 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070011118 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011119 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11120 "%s: HDD context is not valid", __func__);
11121 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011122 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011123
Jeff Johnson295189b2012-06-20 16:38:30 -070011124 if (NULL != pRoamProfile)
11125 {
11126 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053011127 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
11128 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070011129 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011130 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070011131 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053011132 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070011133 switch(reason)
11134 {
11135 case WLAN_REASON_MIC_FAILURE:
11136 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
11137 break;
11138
11139 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
11140 case WLAN_REASON_DISASSOC_AP_BUSY:
11141 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
11142 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
11143 break;
11144
11145 case WLAN_REASON_PREV_AUTH_NOT_VALID:
11146 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053011147 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070011148 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
11149 break;
11150
Jeff Johnson295189b2012-06-20 16:38:30 -070011151 default:
11152 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
11153 break;
11154 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053011155 pScanInfo = &pHddCtx->scan_info;
11156 if (pScanInfo->mScanPending)
11157 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053011158 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053011159 "Aborting Scan");
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053011160 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
11161 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053011162 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011163
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080011164#ifdef FEATURE_WLAN_TDLS
11165 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080011166 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080011167 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080011168 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
11169 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080011170 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080011171 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080011172 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080011173 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011174 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080011175 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011176 MAC_ADDR_ARRAY(mac));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080011177 sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala4327a152013-03-04 23:22:42 -080011178 pAdapter->sessionId,
11179 mac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080011180 }
11181 }
11182#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011183 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011184 status = wlan_hdd_disconnect(pAdapter, reasonCode);
11185 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070011186 {
11187 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011188 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011189 __func__, (int)status );
11190 return -EINVAL;
11191 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011192 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053011193 else
11194 {
11195 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
11196 "called while in %d state", __func__,
11197 pHddStaCtx->conn_info.connState);
11198 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011199 }
11200 else
11201 {
11202 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
11203 }
11204
11205 return status;
11206}
11207
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011208static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
11209 struct net_device *dev,
11210 u16 reason
11211 )
11212{
11213 int ret;
11214 vos_ssr_protect(__func__);
11215 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
11216 vos_ssr_unprotect(__func__);
11217
11218 return ret;
11219}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011220
Jeff Johnson295189b2012-06-20 16:38:30 -070011221/*
11222 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011223 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070011224 * settings in IBSS mode.
11225 */
11226static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011227 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011228 struct cfg80211_ibss_params *params
11229 )
11230{
11231 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011232 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011233 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11234 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011235
Jeff Johnson295189b2012-06-20 16:38:30 -070011236 ENTER();
11237
11238 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070011239 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070011240
11241 if (params->ie_len && ( NULL != params->ie) )
11242 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070011243 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
11244 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070011245 {
11246 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
11247 encryptionType = eCSR_ENCRYPT_TYPE_AES;
11248 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070011249 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070011250 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011251 tDot11fIEWPA dot11WPAIE;
11252 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070011253 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011254
Wilson Yang00256342013-10-10 23:13:38 -070011255 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070011256 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
11257 params->ie_len, DOT11F_EID_WPA);
11258 if ( NULL != ie )
11259 {
11260 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
11261 // Unpack the WPA IE
11262 //Skip past the EID byte and length byte - and four byte WiFi OUI
11263 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
11264 &ie[2+4],
11265 ie[1] - 4,
11266 &dot11WPAIE);
11267 /*Extract the multicast cipher, the encType for unicast
11268 cipher for wpa-none is none*/
11269 encryptionType =
11270 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
11271 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011272 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070011273
Jeff Johnson295189b2012-06-20 16:38:30 -070011274 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
11275
11276 if (0 > status)
11277 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011278 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070011279 __func__);
11280 return status;
11281 }
11282 }
11283
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011284 pWextState->roamProfile.AuthType.authType[0] =
11285 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070011286 eCSR_AUTH_TYPE_OPEN_SYSTEM;
11287
11288 if (params->privacy)
11289 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011290 /* Security enabled IBSS, At this time there is no information available
11291 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070011292 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011293 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070011294 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011295 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070011296 *enable privacy bit in beacons */
11297
11298 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
11299 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011300 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
11301 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011302 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
11303 pWextState->roamProfile.EncryptionType.numEntries = 1;
11304 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070011305 return status;
11306}
11307
11308/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011309 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011310 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070011311 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011312static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011313 struct net_device *dev,
11314 struct cfg80211_ibss_params *params
11315 )
11316{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011317 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070011318 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11319 tCsrRoamProfile *pRoamProfile;
11320 int status;
krunal sonie9002db2013-11-25 14:24:17 -080011321 bool alloc_bssid = VOS_FALSE;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011322 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11323 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011324
11325 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011326
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011327 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11328 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
11329 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011330 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011331 "%s: device_mode = %s (%d)", __func__,
11332 hdd_device_modetoString(pAdapter->device_mode),
11333 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011334
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011335 status = wlan_hdd_validate_context(pHddCtx);
11336
11337 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070011338 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011339 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11340 "%s: HDD context is not valid", __func__);
11341 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011342 }
11343
11344 if (NULL == pWextState)
11345 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011346 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070011347 __func__);
11348 return -EIO;
11349 }
11350
Agarwal Ashish51325b52014-06-16 16:50:49 +053011351 if (vos_max_concurrent_connections_reached()) {
11352 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
11353 return -ECONNREFUSED;
11354 }
11355
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053011356 /*Try disconnecting if already in connected state*/
11357 status = wlan_hdd_try_disconnect(pAdapter);
11358 if ( 0 > status)
11359 {
11360 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
11361 " IBSS connection"));
11362 return -EALREADY;
11363 }
11364
Jeff Johnson295189b2012-06-20 16:38:30 -070011365 pRoamProfile = &pWextState->roamProfile;
11366
11367 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
11368 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011369 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011370 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011371 return -EINVAL;
11372 }
11373
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070011374 /* BSSID is provided by upper layers hence no need to AUTO generate */
11375 if (NULL != params->bssid) {
11376 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
11377 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
11378 hddLog (VOS_TRACE_LEVEL_ERROR,
11379 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
11380 return -EIO;
11381 }
11382 }
krunal sonie9002db2013-11-25 14:24:17 -080011383 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
11384 {
11385 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
11386 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
11387 {
11388 hddLog (VOS_TRACE_LEVEL_ERROR,
11389 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
11390 return -EIO;
11391 }
11392 params->bssid = vos_mem_malloc(sizeof(VOS_MAC_ADDR_SIZE));
11393 if (!params->bssid)
11394 {
11395 hddLog (VOS_TRACE_LEVEL_ERROR,
11396 "%s:Failed memory allocation", __func__);
11397 return -EIO;
11398 }
11399 vos_mem_copy((v_U8_t *)params->bssid,
11400 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
11401 VOS_MAC_ADDR_SIZE);
11402 alloc_bssid = VOS_TRUE;
11403 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070011404
Jeff Johnson295189b2012-06-20 16:38:30 -070011405 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070011406 if (NULL !=
11407#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
11408 params->chandef.chan)
11409#else
11410 params->channel)
11411#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011412 {
11413 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011414 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
11415 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
11416 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11417 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011418
11419 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011420 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070011421 ieee80211_frequency_to_channel(
11422#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
11423 params->chandef.chan->center_freq);
11424#else
11425 params->channel->center_freq);
11426#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011427
11428 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
11429 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070011430 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011431 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
11432 __func__);
11433 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070011434 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011435
11436 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070011437 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011438 if (channelNum == validChan[indx])
11439 {
11440 break;
11441 }
11442 }
11443 if (indx >= numChans)
11444 {
11445 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011446 __func__, channelNum);
11447 return -EINVAL;
11448 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011449 /* Set the Operational Channel */
11450 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
11451 channelNum);
11452 pRoamProfile->ChannelInfo.numOfChannels = 1;
11453 pHddStaCtx->conn_info.operationChannel = channelNum;
11454 pRoamProfile->ChannelInfo.ChannelList =
11455 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070011456 }
11457
11458 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011459 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070011460 if (status < 0)
11461 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011462 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070011463 __func__);
11464 return status;
11465 }
11466
11467 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011468 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011469 params->ssid_len, params->bssid,
11470 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070011471
11472 if (0 > status)
11473 {
11474 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
11475 return status;
11476 }
11477
krunal sonie9002db2013-11-25 14:24:17 -080011478 if (NULL != params->bssid &&
11479 pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 &&
11480 alloc_bssid == VOS_TRUE)
11481 {
11482 vos_mem_free(params->bssid);
11483 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011484 return 0;
11485}
11486
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011487static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
11488 struct net_device *dev,
11489 struct cfg80211_ibss_params *params
11490 )
11491{
11492 int ret = 0;
11493
11494 vos_ssr_protect(__func__);
11495 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
11496 vos_ssr_unprotect(__func__);
11497
11498 return ret;
11499}
11500
Jeff Johnson295189b2012-06-20 16:38:30 -070011501/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011502 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011503 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070011504 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011505static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011506 struct net_device *dev
11507 )
11508{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011509 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011510 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11511 tCsrRoamProfile *pRoamProfile;
11512 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011513 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011514
11515 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011516
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011517 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11518 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
11519 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011520 status = wlan_hdd_validate_context(pHddCtx);
11521
11522 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011523 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011524 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11525 "%s: HDD context is not valid", __func__);
11526 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011527 }
11528
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011529 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
11530 hdd_device_modetoString(pAdapter->device_mode),
11531 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011532 if (NULL == pWextState)
11533 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011534 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070011535 __func__);
11536 return -EIO;
11537 }
11538
11539 pRoamProfile = &pWextState->roamProfile;
11540
11541 /* Issue disconnect only if interface type is set to IBSS */
11542 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
11543 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011544 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070011545 __func__);
11546 return -EINVAL;
11547 }
11548
11549 /* Issue Disconnect request */
11550 INIT_COMPLETION(pAdapter->disconnect_comp_var);
11551 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
11552 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
11553
11554 return 0;
11555}
11556
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011557static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
11558 struct net_device *dev
11559 )
11560{
11561 int ret = 0;
11562
11563 vos_ssr_protect(__func__);
11564 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
11565 vos_ssr_unprotect(__func__);
11566
11567 return ret;
11568}
11569
Jeff Johnson295189b2012-06-20 16:38:30 -070011570/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053011571 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070011572 * This function is used to set the phy parameters
11573 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
11574 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053011575static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011576 u32 changed)
11577{
11578 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
11579 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011580 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011581
11582 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011583 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11584 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
11585 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011586 status = wlan_hdd_validate_context(pHddCtx);
11587
11588 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011589 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011590 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11591 "%s: HDD context is not valid", __func__);
11592 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011593 }
11594
Jeff Johnson295189b2012-06-20 16:38:30 -070011595 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
11596 {
11597 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
11598 WNI_CFG_RTS_THRESHOLD_STAMAX :
11599 wiphy->rts_threshold;
11600
11601 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011602 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070011603 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011604 hddLog(VOS_TRACE_LEVEL_ERROR,
11605 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011606 __func__, rts_threshold);
11607 return -EINVAL;
11608 }
11609
11610 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
11611 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011612 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011613 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011614 hddLog(VOS_TRACE_LEVEL_ERROR,
11615 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011616 __func__, rts_threshold);
11617 return -EIO;
11618 }
11619
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011620 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011621 rts_threshold);
11622 }
11623
11624 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
11625 {
11626 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
11627 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
11628 wiphy->frag_threshold;
11629
11630 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011631 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011632 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011633 hddLog(VOS_TRACE_LEVEL_ERROR,
11634 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011635 frag_threshold);
11636 return -EINVAL;
11637 }
11638
11639 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
11640 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011641 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011642 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011643 hddLog(VOS_TRACE_LEVEL_ERROR,
11644 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011645 __func__, frag_threshold);
11646 return -EIO;
11647 }
11648
11649 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
11650 frag_threshold);
11651 }
11652
11653 if ((changed & WIPHY_PARAM_RETRY_SHORT)
11654 || (changed & WIPHY_PARAM_RETRY_LONG))
11655 {
11656 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
11657 wiphy->retry_short :
11658 wiphy->retry_long;
11659
11660 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
11661 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
11662 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011663 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011664 __func__, retry_value);
11665 return -EINVAL;
11666 }
11667
11668 if (changed & WIPHY_PARAM_RETRY_SHORT)
11669 {
11670 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
11671 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011672 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011673 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011674 hddLog(VOS_TRACE_LEVEL_ERROR,
11675 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011676 __func__, retry_value);
11677 return -EIO;
11678 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011679 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011680 __func__, retry_value);
11681 }
11682 else if (changed & WIPHY_PARAM_RETRY_SHORT)
11683 {
11684 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
11685 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011686 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011687 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011688 hddLog(VOS_TRACE_LEVEL_ERROR,
11689 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011690 __func__, retry_value);
11691 return -EIO;
11692 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011693 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011694 __func__, retry_value);
11695 }
11696 }
11697
11698 return 0;
11699}
11700
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053011701static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
11702 u32 changed)
11703{
11704 int ret;
11705
11706 vos_ssr_protect(__func__);
11707 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
11708 vos_ssr_unprotect(__func__);
11709
11710 return ret;
11711}
11712
Jeff Johnson295189b2012-06-20 16:38:30 -070011713/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053011714 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070011715 * This function is used to set the txpower
11716 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053011717static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070011718#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
11719 struct wireless_dev *wdev,
11720#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011721#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011722 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070011723#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011724 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070011725#endif
11726 int dbm)
11727{
11728 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011729 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011730 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
11731 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011732 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011733
11734 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011735 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11736 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
11737 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011738 status = wlan_hdd_validate_context(pHddCtx);
11739
11740 if (0 != status)
11741 {
11742 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11743 "%s: HDD context is not valid", __func__);
11744 return status;
11745 }
11746
11747 hHal = pHddCtx->hHal;
11748
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011749 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
11750 dbm, ccmCfgSetCallback,
11751 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011752 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011753 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011754 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
11755 return -EIO;
11756 }
11757
11758 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
11759 dbm);
11760
11761 switch(type)
11762 {
11763 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
11764 /* Fall through */
11765 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
11766 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
11767 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011768 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
11769 __func__);
11770 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070011771 }
11772 break;
11773 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011774 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070011775 __func__);
11776 return -EOPNOTSUPP;
11777 break;
11778 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011779 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
11780 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011781 return -EIO;
11782 }
11783
11784 return 0;
11785}
11786
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053011787static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
11788#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
11789 struct wireless_dev *wdev,
11790#endif
11791#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
11792 enum tx_power_setting type,
11793#else
11794 enum nl80211_tx_power_setting type,
11795#endif
11796 int dbm)
11797{
11798 int ret;
11799 vos_ssr_protect(__func__);
11800 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
11801#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
11802 wdev,
11803#endif
11804#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
11805 type,
11806#else
11807 type,
11808#endif
11809 dbm);
11810 vos_ssr_unprotect(__func__);
11811
11812 return ret;
11813}
11814
Jeff Johnson295189b2012-06-20 16:38:30 -070011815/*
11816 * FUNCTION: wlan_hdd_cfg80211_get_txpower
11817 * This function is used to read the txpower
11818 */
Yue Maf49ba872013-08-19 12:04:25 -070011819static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
11820#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
11821 struct wireless_dev *wdev,
11822#endif
11823 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070011824{
11825
11826 hdd_adapter_t *pAdapter;
11827 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011828 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011829
Jeff Johnsone7245742012-09-05 17:12:55 -070011830 ENTER();
11831
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011832 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070011833
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011834 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011835 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011836 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11837 "%s: HDD context is not valid", __func__);
11838 *dbm = 0;
11839 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011840 }
11841
Jeff Johnson295189b2012-06-20 16:38:30 -070011842 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
11843 if (NULL == pAdapter)
11844 {
11845 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
11846 return -ENOENT;
11847 }
11848
11849 wlan_hdd_get_classAstats(pAdapter);
11850 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
11851
Jeff Johnsone7245742012-09-05 17:12:55 -070011852 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011853 return 0;
11854}
11855
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011856static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070011857 u8* mac, struct station_info *sinfo)
11858{
11859 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
11860 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11861 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053011862 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070011863
11864 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
11865 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070011866
11867 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
11868 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
11869 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
11870 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
11871 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
11872 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
11873 tANI_U16 maxRate = 0;
11874 tANI_U16 myRate;
11875 tANI_U16 currentRate = 0;
11876 tANI_U8 maxSpeedMCS = 0;
11877 tANI_U8 maxMCSIdx = 0;
11878 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053011879 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070011880 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011881 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011882
Leo Chang6f8870f2013-03-26 18:11:36 -070011883#ifdef WLAN_FEATURE_11AC
11884 tANI_U32 vht_mcs_map;
11885 eDataRate11ACMaxMcs vhtMaxMcs;
11886#endif /* WLAN_FEATURE_11AC */
11887
Jeff Johnsone7245742012-09-05 17:12:55 -070011888 ENTER();
11889
Jeff Johnson295189b2012-06-20 16:38:30 -070011890 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
11891 (0 == ssidlen))
11892 {
11893 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
11894 " Invalid ssidlen, %d", __func__, ssidlen);
11895 /*To keep GUI happy*/
11896 return 0;
11897 }
11898
Mukul Sharma811205f2014-07-09 21:07:30 +053011899 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
11900 {
11901 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11902 "%s: Roaming in progress, so unable to proceed this request", __func__);
11903 return 0;
11904 }
11905
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011906 status = wlan_hdd_validate_context(pHddCtx);
11907
11908 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011909 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011910 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11911 "%s: HDD context is not valid", __func__);
11912 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011913 }
11914
Jeff Johnson295189b2012-06-20 16:38:30 -070011915
Kiet Lam3b17fc82013-09-27 05:24:08 +053011916 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
11917 sinfo->filled |= STATION_INFO_SIGNAL;
11918
c_hpothu09f19542014-05-30 21:53:31 +053011919 wlan_hdd_get_station_stats(pAdapter);
11920 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
11921
11922 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053011923 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
11924 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053011925 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053011926 {
11927 rate_flags = pAdapter->maxRateFlags;
11928 }
c_hpothu44ff4e02014-05-08 00:13:57 +053011929
Jeff Johnson295189b2012-06-20 16:38:30 -070011930 //convert to the UI units of 100kbps
11931 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
11932
11933#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070011934 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 -070011935 sinfo->signal,
11936 pCfg->reportMaxLinkSpeed,
11937 myRate,
11938 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070011939 (int) pCfg->linkSpeedRssiMid,
11940 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070011941 (int) rate_flags,
11942 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070011943#endif //LINKSPEED_DEBUG_ENABLED
11944
11945 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
11946 {
11947 // we do not want to necessarily report the current speed
11948 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
11949 {
11950 // report the max possible speed
11951 rssidx = 0;
11952 }
11953 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
11954 {
11955 // report the max possible speed with RSSI scaling
11956 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
11957 {
11958 // report the max possible speed
11959 rssidx = 0;
11960 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070011961 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070011962 {
11963 // report middle speed
11964 rssidx = 1;
11965 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070011966 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
11967 {
11968 // report middle speed
11969 rssidx = 2;
11970 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011971 else
11972 {
11973 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070011974 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070011975 }
11976 }
11977 else
11978 {
11979 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
11980 hddLog(VOS_TRACE_LEVEL_ERROR,
11981 "%s: Invalid value for reportMaxLinkSpeed: %u",
11982 __func__, pCfg->reportMaxLinkSpeed);
11983 rssidx = 0;
11984 }
11985
11986 maxRate = 0;
11987
11988 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053011989 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
11990 OperationalRates, &ORLeng))
11991 {
11992 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
11993 /*To keep GUI happy*/
11994 return 0;
11995 }
11996
Jeff Johnson295189b2012-06-20 16:38:30 -070011997 for (i = 0; i < ORLeng; i++)
11998 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011999 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070012000 {
12001 /* Validate Rate Set */
12002 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
12003 {
12004 currentRate = supported_data_rate[j].supported_rate[rssidx];
12005 break;
12006 }
12007 }
12008 /* Update MAX rate */
12009 maxRate = (currentRate > maxRate)?currentRate:maxRate;
12010 }
12011
12012 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053012013 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
12014 ExtendedRates, &ERLeng))
12015 {
12016 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
12017 /*To keep GUI happy*/
12018 return 0;
12019 }
12020
Jeff Johnson295189b2012-06-20 16:38:30 -070012021 for (i = 0; i < ERLeng; i++)
12022 {
Jeff Johnsone7245742012-09-05 17:12:55 -070012023 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070012024 {
12025 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
12026 {
12027 currentRate = supported_data_rate[j].supported_rate[rssidx];
12028 break;
12029 }
12030 }
12031 /* Update MAX rate */
12032 maxRate = (currentRate > maxRate)?currentRate:maxRate;
12033 }
c_hpothu79aab322014-07-14 21:11:01 +053012034
Kiet Lamb69f8dc2013-11-15 15:34:27 +053012035 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053012036 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053012037 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053012038 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070012039 {
c_hpothu79aab322014-07-14 21:11:01 +053012040 if (rate_flags & eHAL_TX_RATE_VHT80)
12041 mode = 2;
12042 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
12043 mode = 1;
12044 else
12045 mode = 0;
12046
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053012047 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
12048 MCSRates, &MCSLeng))
12049 {
12050 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
12051 /*To keep GUI happy*/
12052 return 0;
12053 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012054 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070012055#ifdef WLAN_FEATURE_11AC
12056 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012057 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070012058 {
Leo Chang6f8870f2013-03-26 18:11:36 -070012059 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012060 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070012061 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070012062 {
Leo Chang6f8870f2013-03-26 18:11:36 -070012063 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070012064 }
Leo Chang6f8870f2013-03-26 18:11:36 -070012065 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070012066 {
Leo Chang6f8870f2013-03-26 18:11:36 -070012067 maxMCSIdx = 7;
12068 }
12069 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
12070 {
12071 maxMCSIdx = 8;
12072 }
12073 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
12074 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012075 //VHT20 is supporting 0~8
12076 if (rate_flags & eHAL_TX_RATE_VHT20)
12077 maxMCSIdx = 8;
12078 else
12079 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070012080 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012081
c_hpothu79aab322014-07-14 21:11:01 +053012082 if (0 != rssidx)/*check for scaled */
12083 {
12084 //get middle rate MCS index if rssi=1/2
12085 for (i=0; i <= maxMCSIdx; i++)
12086 {
12087 if (sinfo->signal <= rssiMcsTbl[mode][i])
12088 {
12089 maxMCSIdx = i;
12090 break;
12091 }
12092 }
12093 }
12094
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012095 if (rate_flags & eHAL_TX_RATE_VHT80)
12096 {
12097 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
12098 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
12099 }
12100 else if (rate_flags & eHAL_TX_RATE_VHT40)
12101 {
12102 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
12103 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
12104 }
12105 else if (rate_flags & eHAL_TX_RATE_VHT20)
12106 {
12107 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
12108 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
12109 }
12110
Leo Chang6f8870f2013-03-26 18:11:36 -070012111 maxSpeedMCS = 1;
12112 if (currentRate > maxRate)
12113 {
12114 maxRate = currentRate;
12115 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012116
Leo Chang6f8870f2013-03-26 18:11:36 -070012117 }
12118 else
12119#endif /* WLAN_FEATURE_11AC */
12120 {
12121 if (rate_flags & eHAL_TX_RATE_HT40)
12122 {
12123 rateFlag |= 1;
12124 }
12125 if (rate_flags & eHAL_TX_RATE_SGI)
12126 {
12127 rateFlag |= 2;
12128 }
12129
Girish Gowli01abcee2014-07-31 20:18:55 +053012130 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053012131 if (rssidx == 1 || rssidx == 2)
12132 {
12133 //get middle rate MCS index if rssi=1/2
12134 for (i=0; i <= 7; i++)
12135 {
12136 if (sinfo->signal <= rssiMcsTbl[mode][i])
12137 {
12138 temp = i+1;
12139 break;
12140 }
12141 }
12142 }
c_hpothu79aab322014-07-14 21:11:01 +053012143
12144 for (i = 0; i < MCSLeng; i++)
12145 {
Leo Chang6f8870f2013-03-26 18:11:36 -070012146 for (j = 0; j < temp; j++)
12147 {
12148 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
12149 {
12150 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
12151 break;
12152 }
12153 }
12154 if ((j < temp) && (currentRate > maxRate))
12155 {
12156 maxRate = currentRate;
12157 maxSpeedMCS = 1;
12158 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
12159 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012160 }
12161 }
12162 }
12163
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012164 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
12165 {
12166 maxRate = myRate;
12167 maxSpeedMCS = 1;
12168 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
12169 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012170 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053012171 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070012172 {
12173 maxRate = myRate;
12174 if (rate_flags & eHAL_TX_RATE_LEGACY)
12175 {
12176 maxSpeedMCS = 0;
12177 }
12178 else
12179 {
12180 maxSpeedMCS = 1;
12181 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
12182 }
12183 }
12184
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012185 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070012186 {
12187 sinfo->txrate.legacy = maxRate;
12188#ifdef LINKSPEED_DEBUG_ENABLED
12189 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
12190#endif //LINKSPEED_DEBUG_ENABLED
12191 }
12192 else
12193 {
12194 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070012195#ifdef WLAN_FEATURE_11AC
12196 sinfo->txrate.nss = 1;
12197 if (rate_flags & eHAL_TX_RATE_VHT80)
12198 {
12199 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012200 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070012201 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012202 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070012203 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012204 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
12205 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
12206 }
12207 else if (rate_flags & eHAL_TX_RATE_VHT20)
12208 {
12209 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
12210 }
12211#endif /* WLAN_FEATURE_11AC */
12212 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
12213 {
12214 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
12215 if (rate_flags & eHAL_TX_RATE_HT40)
12216 {
12217 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
12218 }
Leo Chang6f8870f2013-03-26 18:11:36 -070012219 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012220 if (rate_flags & eHAL_TX_RATE_SGI)
12221 {
12222 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
12223 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012224
Jeff Johnson295189b2012-06-20 16:38:30 -070012225#ifdef LINKSPEED_DEBUG_ENABLED
12226 pr_info("Reporting MCS rate %d flags %x\n",
12227 sinfo->txrate.mcs,
12228 sinfo->txrate.flags );
12229#endif //LINKSPEED_DEBUG_ENABLED
12230 }
12231 }
12232 else
12233 {
12234 // report current rate instead of max rate
12235
12236 if (rate_flags & eHAL_TX_RATE_LEGACY)
12237 {
12238 //provide to the UI in units of 100kbps
12239 sinfo->txrate.legacy = myRate;
12240#ifdef LINKSPEED_DEBUG_ENABLED
12241 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
12242#endif //LINKSPEED_DEBUG_ENABLED
12243 }
12244 else
12245 {
12246 //must be MCS
12247 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070012248#ifdef WLAN_FEATURE_11AC
12249 sinfo->txrate.nss = 1;
12250 if (rate_flags & eHAL_TX_RATE_VHT80)
12251 {
12252 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
12253 }
12254 else
12255#endif /* WLAN_FEATURE_11AC */
12256 {
12257 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
12258 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012259 if (rate_flags & eHAL_TX_RATE_SGI)
12260 {
12261 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
12262 }
12263 if (rate_flags & eHAL_TX_RATE_HT40)
12264 {
12265 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
12266 }
Leo Chang6f8870f2013-03-26 18:11:36 -070012267#ifdef WLAN_FEATURE_11AC
12268 else if (rate_flags & eHAL_TX_RATE_VHT80)
12269 {
12270 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
12271 }
12272#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070012273#ifdef LINKSPEED_DEBUG_ENABLED
12274 pr_info("Reporting actual MCS rate %d flags %x\n",
12275 sinfo->txrate.mcs,
12276 sinfo->txrate.flags );
12277#endif //LINKSPEED_DEBUG_ENABLED
12278 }
12279 }
12280 sinfo->filled |= STATION_INFO_TX_BITRATE;
12281
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070012282 sinfo->tx_packets =
12283 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
12284 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
12285 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
12286 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
12287
12288 sinfo->tx_retries =
12289 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
12290 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
12291 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
12292 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
12293
12294 sinfo->tx_failed =
12295 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
12296 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
12297 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
12298 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
12299
12300 sinfo->filled |=
12301 STATION_INFO_TX_PACKETS |
12302 STATION_INFO_TX_RETRIES |
12303 STATION_INFO_TX_FAILED;
12304
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012305 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12306 TRACE_CODE_HDD_CFG80211_GET_STA,
12307 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070012308 EXIT();
12309 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012310}
12311
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012312static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
12313 u8* mac, struct station_info *sinfo)
12314{
12315 int ret;
12316
12317 vos_ssr_protect(__func__);
12318 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
12319 vos_ssr_unprotect(__func__);
12320
12321 return ret;
12322}
12323
12324static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070012325 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070012326{
12327 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053012328 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012329 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012330 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012331
Jeff Johnsone7245742012-09-05 17:12:55 -070012332 ENTER();
12333
Jeff Johnson295189b2012-06-20 16:38:30 -070012334 if (NULL == pAdapter)
12335 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012336 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012337 return -ENODEV;
12338 }
12339
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012340 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12341 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
12342 pAdapter->sessionId, timeout));
12343
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053012344 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012345 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053012346
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012347 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012348 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012349 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12350 "%s: HDD context is not valid", __func__);
12351 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012352 }
12353
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053012354 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
12355 (TRUE == pHddCtx->hdd_wlan_suspended) &&
12356 (pHddCtx->cfg_ini->fhostArpOffload) &&
12357 (eConnectionState_Associated ==
12358 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
12359 {
Amar Singhald53568e2013-09-26 11:03:45 -070012360
12361 hddLog(VOS_TRACE_LEVEL_INFO,
12362 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053012363 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053012364 if (!VOS_IS_STATUS_SUCCESS(vos_status))
12365 {
12366 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012367 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053012368 __func__, vos_status);
12369 }
12370 }
12371
Jeff Johnson295189b2012-06-20 16:38:30 -070012372 /**The get power cmd from the supplicant gets updated by the nl only
12373 *on successful execution of the function call
12374 *we are oppositely mapped w.r.t mode in the driver
12375 **/
12376 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
12377
Jeff Johnsone7245742012-09-05 17:12:55 -070012378 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012379 if (VOS_STATUS_E_FAILURE == vos_status)
12380 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012381 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12382 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012383 return -EINVAL;
12384 }
12385 return 0;
12386}
12387
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012388static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
12389 struct net_device *dev, bool mode, int timeout)
12390{
12391 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070012392
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012393 vos_ssr_protect(__func__);
12394 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
12395 vos_ssr_unprotect(__func__);
12396
12397 return ret;
12398}
Jeff Johnson295189b2012-06-20 16:38:30 -070012399#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12400static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
12401 struct net_device *netdev,
12402 u8 key_index)
12403{
Jeff Johnsone7245742012-09-05 17:12:55 -070012404 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070012405 return 0;
12406}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012407#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070012408
12409#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
12410static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
12411 struct net_device *dev,
12412 struct ieee80211_txq_params *params)
12413{
Jeff Johnsone7245742012-09-05 17:12:55 -070012414 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070012415 return 0;
12416}
12417#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12418static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
12419 struct ieee80211_txq_params *params)
12420{
Jeff Johnsone7245742012-09-05 17:12:55 -070012421 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070012422 return 0;
12423}
12424#endif //LINUX_VERSION_CODE
12425
Naresh Jayaram69e3f282014-10-14 12:29:12 +053012426#ifdef CFG80211_DEL_STA_V2
12427static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
12428 struct net_device *dev,
12429 struct station_del_parameters *param)
12430#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012431static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012432 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053012433#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012434{
12435 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012436 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012437 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012438 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012439 v_U8_t staId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012440
Jeff Johnsone7245742012-09-05 17:12:55 -070012441 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012442
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012443 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070012444 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012445 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012446 return -EINVAL;
12447 }
12448
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012449 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12450 TRACE_CODE_HDD_CFG80211_DEL_STA,
12451 pAdapter->sessionId, pAdapter->device_mode));
12452
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012453 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12454 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070012455
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012456 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012457 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012458 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12459 "%s: HDD context is not valid", __func__);
12460 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012461 }
12462
Jeff Johnson295189b2012-06-20 16:38:30 -070012463 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070012464 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070012465 )
12466 {
12467 if( NULL == mac )
12468 {
12469 v_U16_t i;
12470 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
12471 {
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070012472 if ((pAdapter->aStaInfo[i].isUsed) &&
12473 (!pAdapter->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070012474 {
12475 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
12476 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080012477 "%s: Delete STA with MAC::"
12478 MAC_ADDRESS_STR,
12479 __func__, MAC_ADDR_ARRAY(macAddr));
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070012480 vos_status = hdd_softap_sta_deauth(pAdapter, macAddr);
12481 if (VOS_IS_STATUS_SUCCESS(vos_status))
12482 pAdapter->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012483 }
12484 }
12485 }
12486 else
12487 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012488
12489 vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId);
12490 if (!VOS_IS_STATUS_SUCCESS(vos_status))
12491 {
12492 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080012493 "%s: Skip this DEL STA as this is not used::"
12494 MAC_ADDRESS_STR,
12495 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012496 return -ENOENT;
12497 }
12498
12499 if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE)
12500 {
12501 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080012502 "%s: Skip this DEL STA as deauth is in progress::"
12503 MAC_ADDRESS_STR,
12504 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012505 return -ENOENT;
12506 }
12507
12508 pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE;
12509
Jeff Johnson295189b2012-06-20 16:38:30 -070012510 hddLog(VOS_TRACE_LEVEL_INFO,
12511 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080012512 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012513 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -080012514 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012515
12516 vos_status = hdd_softap_sta_deauth(pAdapter, mac);
12517 if (!VOS_IS_STATUS_SUCCESS(vos_status))
12518 {
12519 pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE;
12520 hddLog(VOS_TRACE_LEVEL_INFO,
12521 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080012522 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012523 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -080012524 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012525 return -ENOENT;
12526 }
12527
Jeff Johnson295189b2012-06-20 16:38:30 -070012528 }
12529 }
12530
12531 EXIT();
12532
12533 return 0;
12534}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053012535
12536#ifdef CFG80211_DEL_STA_V2
12537static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
12538 struct net_device *dev,
12539 struct station_del_parameters *param)
12540#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012541static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
12542 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053012543#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012544{
12545 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070012546
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012547 vos_ssr_protect(__func__);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053012548#ifdef CFG80211_DEL_STA_V2
12549 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, param);
12550#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012551 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, mac);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053012552#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012553 vos_ssr_unprotect(__func__);
12554
12555 return ret;
12556}
12557
12558static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012559 struct net_device *dev, u8 *mac, struct station_parameters *params)
12560{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012561 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalab977a972013-02-18 19:15:09 -080012562 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012563#ifdef FEATURE_WLAN_TDLS
12564 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012565 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012566
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012567 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12568 TRACE_CODE_HDD_CFG80211_ADD_STA,
12569 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012570 mask = params->sta_flags_mask;
12571
12572 set = params->sta_flags_set;
12573
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012574#ifdef WLAN_FEATURE_TDLS_DEBUG
12575 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12576 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
12577 __func__, mask, set, MAC_ADDR_ARRAY(mac));
12578#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012579
12580 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
12581 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012582 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012583 }
12584 }
12585#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -080012586 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012587}
12588
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012589static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
12590 struct net_device *dev, u8 *mac, struct station_parameters *params)
12591{
12592 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012593
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012594 vos_ssr_protect(__func__);
12595 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
12596 vos_ssr_unprotect(__func__);
12597
12598 return ret;
12599}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012600#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070012601
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053012602static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070012603 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012604{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012605 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12606 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012607 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012608 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012609 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012610 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070012611
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012612 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012613 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012614 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012615 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012616 return -EINVAL;
12617 }
12618
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012619 if (!pmksa) {
12620 hddLog(LOGE, FL("pmksa is NULL"));
12621 return -EINVAL;
12622 }
12623
12624 if (!pmksa->bssid || !pmksa->pmkid) {
12625 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
12626 pmksa->bssid, pmksa->pmkid);
12627 return -EINVAL;
12628 }
12629
12630 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
12631 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
12632
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012633 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12634 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012635
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012636 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012637 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012638 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12639 "%s: HDD context is not valid", __func__);
12640 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012641 }
12642
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012643 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012644 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
12645
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012646 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
12647 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012648
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012649 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012650 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012651 &pmk_id, 1, FALSE);
12652
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012653 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12654 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
12655 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012656
12657 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012658}
12659
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053012660static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
12661 struct cfg80211_pmksa *pmksa)
12662{
12663 int ret;
12664
12665 vos_ssr_protect(__func__);
12666 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
12667 vos_ssr_unprotect(__func__);
12668
12669 return ret;
12670}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012671
Wilson Yang6507c4e2013-10-01 20:11:19 -070012672
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053012673static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070012674 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012675{
Wilson Yang6507c4e2013-10-01 20:11:19 -070012676 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12677 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070012678 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080012679 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070012680
Jeff Johnson0299d0a2013-10-30 12:37:43 -070012681 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
12682 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -070012683
12684 /* Validate pAdapter */
12685 if (NULL == pAdapter)
12686 {
12687 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
12688 return -EINVAL;
12689 }
12690
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012691 if (!pmksa) {
12692 hddLog(LOGE, FL("pmksa is NULL"));
12693 return -EINVAL;
12694 }
12695
12696 if (!pmksa->bssid) {
12697 hddLog(LOGE, FL("pmksa->bssid is NULL"));
12698 return -EINVAL;
12699 }
12700
Wilson Yang6507c4e2013-10-01 20:11:19 -070012701 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12702 status = wlan_hdd_validate_context(pHddCtx);
12703
12704 if (0 != status)
12705 {
12706 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12707 "%s: HDD context is not valid", __func__);
12708 return status;
12709 }
12710
12711 /*Retrieve halHandle*/
12712 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
12713
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012714 /* Delete the PMKID CSR cache */
12715 if (eHAL_STATUS_SUCCESS !=
12716 sme_RoamDelPMKIDfromCache(halHandle,
12717 pAdapter->sessionId, pmksa->bssid, FALSE)) {
12718 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
12719 MAC_ADDR_ARRAY(pmksa->bssid));
12720 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070012721 }
12722
Wilson Yangef657d32014-01-15 19:19:23 -080012723 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012724}
12725
Wilson Yang6507c4e2013-10-01 20:11:19 -070012726
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053012727static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
12728 struct cfg80211_pmksa *pmksa)
12729{
12730 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070012731
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053012732 vos_ssr_protect(__func__);
12733 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
12734 vos_ssr_unprotect(__func__);
12735
12736 return ret;
12737
12738}
12739
12740static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012741{
Wilson Yang6507c4e2013-10-01 20:11:19 -070012742 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12743 tHalHandle halHandle;
12744 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080012745 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070012746
12747 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__);
12748
12749 /* Validate pAdapter */
12750 if (NULL == pAdapter)
12751 {
12752 hddLog(VOS_TRACE_LEVEL_ERROR,
12753 "%s: Invalid Adapter" ,__func__);
12754 return -EINVAL;
12755 }
12756
12757 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12758 status = wlan_hdd_validate_context(pHddCtx);
12759
12760 if (0 != status)
12761 {
12762 hddLog(VOS_TRACE_LEVEL_ERROR,
12763 "%s: HDD context is not valid", __func__);
12764 return status;
12765 }
12766
12767 /*Retrieve halHandle*/
12768 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
12769
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012770 /* Flush the PMKID cache in CSR */
12771 if (eHAL_STATUS_SUCCESS !=
12772 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
12773 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
12774 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070012775 }
12776
Wilson Yangef657d32014-01-15 19:19:23 -080012777 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012778}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053012779
12780static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
12781{
12782 int ret;
12783
12784 vos_ssr_protect(__func__);
12785 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
12786 vos_ssr_unprotect(__func__);
12787
12788 return ret;
12789}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012790#endif
12791
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012792#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012793static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
12794 struct net_device *dev,
12795 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012796{
12797 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12798 hdd_station_ctx_t *pHddStaCtx;
12799
12800 if (NULL == pAdapter)
12801 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012802 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012803 return -ENODEV;
12804 }
12805
12806 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12807
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012808 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12809 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
12810 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012811 // Added for debug on reception of Re-assoc Req.
12812 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
12813 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012814 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012815 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080012816 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012817 }
12818
12819#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080012820 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012821 ftie->ie_len);
12822#endif
12823
12824 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053012825 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
12826 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012827 ftie->ie_len);
12828 return 0;
12829}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012830
12831static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
12832 struct net_device *dev,
12833 struct cfg80211_update_ft_ies_params *ftie)
12834{
12835 int ret;
12836
12837 vos_ssr_protect(__func__);
12838 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
12839 vos_ssr_unprotect(__func__);
12840
12841 return ret;
12842}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012843#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012844
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012845#ifdef FEATURE_WLAN_SCAN_PNO
12846
12847void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
12848 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
12849{
12850 int ret;
12851 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
12852 hdd_context_t *pHddCtx;
12853
Nirav Shah80830bf2013-12-31 16:35:12 +053012854 ENTER();
12855
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012856 if (NULL == pAdapter)
12857 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053012858 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012859 "%s: HDD adapter is Null", __func__);
12860 return ;
12861 }
12862
12863 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12864 if (NULL == pHddCtx)
12865 {
12866 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12867 "%s: HDD context is Null!!!", __func__);
12868 return ;
12869 }
12870
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053012871 spin_lock(&pHddCtx->schedScan_lock);
12872 if (TRUE == pHddCtx->isWiphySuspended)
12873 {
12874 pHddCtx->isSchedScanUpdatePending = TRUE;
12875 spin_unlock(&pHddCtx->schedScan_lock);
12876 hddLog(VOS_TRACE_LEVEL_INFO,
12877 "%s: Update cfg80211 scan database after it resume", __func__);
12878 return ;
12879 }
12880 spin_unlock(&pHddCtx->schedScan_lock);
12881
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012882 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
12883
12884 if (0 > ret)
12885 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
12886
12887 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053012888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12889 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012890}
12891
12892/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012893 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053012894 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012895 */
12896static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
12897{
12898 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
12899 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053012900 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012901 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12902 int status = 0;
12903 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
12904
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053012905 /* The current firmware design does not allow PNO during any
12906 * active sessions. Hence, determine the active sessions
12907 * and return a failure.
12908 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012909 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
12910 {
12911 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053012912 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012913
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053012914 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
12915 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
12916 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
12917 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
12918 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
12919 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012920 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053012921 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012922 }
12923 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
12924 pAdapterNode = pNext;
12925 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053012926 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012927}
12928
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053012929void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
12930{
12931 hdd_adapter_t *pAdapter = callbackContext;
12932 hdd_context_t *pHddCtx;
12933
12934 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
12935 {
12936 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12937 FL("Invalid adapter or adapter has invalid magic"));
12938 return;
12939 }
12940
12941 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12942 if (0 != wlan_hdd_validate_context(pHddCtx))
12943 {
12944 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12945 FL("HDD context is not valid"));
12946 return;
12947 }
12948
c_hpothub53c45d2014-08-18 16:53:14 +053012949 if (VOS_STATUS_SUCCESS != status)
12950 {
12951 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053012952 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053012953 pHddCtx->isPnoEnable = FALSE;
12954 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053012955
12956 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
12957 complete(&pAdapter->pno_comp_var);
12958}
12959
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012960/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053012961 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
12962 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012963 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053012964static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012965 struct net_device *dev, struct cfg80211_sched_scan_request *request)
12966{
12967 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12968 tpSirPNOScanReq pPnoRequest = NULL;
12969 hdd_context_t *pHddCtx;
12970 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053012971 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053012972 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
12973 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012974 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
12975 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053012976 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012977
12978 if (NULL == pAdapter)
12979 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012980 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012981 "%s: HDD adapter is Null", __func__);
12982 return -ENODEV;
12983 }
12984
12985 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053012986 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012987
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053012988 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012989 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053012990 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12991 "%s: HDD context is not valid", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053012992 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012993 }
12994
12995 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12996 if (NULL == hHal)
12997 {
12998 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12999 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013000 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013001 }
Sushant Kaushik2fe89932014-09-03 10:58:09 +053013002 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053013003 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053013004 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053013005 {
13006 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13007 "%s: aborting the existing scan is unsuccessfull", __func__);
13008 return -EBUSY;
13009 }
13010
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053013011 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013012 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053013013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053013014 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013015 return -EBUSY;
13016 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013017
c_hpothu37f21312014-04-09 21:49:54 +053013018 if (TRUE == pHddCtx->isPnoEnable)
13019 {
13020 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
13021 FL("already PNO is enabled"));
13022 return -EBUSY;
13023 }
13024 pHddCtx->isPnoEnable = TRUE;
13025
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013026 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
13027 if (NULL == pPnoRequest)
13028 {
13029 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
13030 "%s: vos_mem_malloc failed", __func__);
c_hpothu37f21312014-04-09 21:49:54 +053013031 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013032 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013033 }
13034
Madan Mohan Koyyalamudic3f04352013-09-26 19:21:48 +053013035 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013036 pPnoRequest->enable = 1; /*Enable PNO */
13037 pPnoRequest->ucNetworksCount = request->n_match_sets;
13038
13039 if (( !pPnoRequest->ucNetworksCount ) ||
13040 ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
13041 {
13042 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053013043 "%s: Network input is not correct %d Max Network supported is %d",
13044 __func__, pPnoRequest->ucNetworksCount,
13045 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013046 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013047 goto error;
13048 }
13049
13050 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
13051 {
13052 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053013053 "%s: Incorrect number of channels %d",
13054 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013055 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013056 goto error;
13057 }
13058
13059 /* Framework provides one set of channels(all)
13060 * common for all saved profile */
13061 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
13062 channels_allowed, &num_channels_allowed))
13063 {
13064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13065 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013066 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013067 goto error;
13068 }
13069 /* Checking each channel against allowed channel list */
13070 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053013071 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013072 {
Nirav Shah80830bf2013-12-31 16:35:12 +053013073 char chList [(request->n_channels*5)+1];
13074 int len;
13075 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013076 {
Nirav Shah80830bf2013-12-31 16:35:12 +053013077 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013078 {
Nirav Shah80830bf2013-12-31 16:35:12 +053013079 if (request->channels[i]->hw_value == channels_allowed[indx])
13080 {
13081 valid_ch[num_ch++] = request->channels[i]->hw_value;
13082 len += snprintf(chList+len, 5, "%d ",
13083 request->channels[i]->hw_value);
13084 break ;
13085 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013086 }
13087 }
Nirav Shah80830bf2013-12-31 16:35:12 +053013088 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
13089 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013090
13091 /* Filling per profile params */
13092 for (i = 0; i < pPnoRequest->ucNetworksCount; i++)
13093 {
13094 pPnoRequest->aNetworks[i].ssId.length =
13095 request->match_sets[i].ssid.ssid_len;
13096
13097 if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) ||
13098 ( pPnoRequest->aNetworks[i].ssId.length > 32 ) )
13099 {
13100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053013101 "%s: SSID Len %d is not correct for network %d",
13102 __func__, pPnoRequest->aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013103 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013104 goto error;
13105 }
13106
13107 memcpy(pPnoRequest->aNetworks[i].ssId.ssId,
13108 request->match_sets[i].ssid.ssid,
13109 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053013110 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13111 "%s: SSID of network %d is %s ", __func__,
13112 i, pPnoRequest->aNetworks[i].ssId.ssId);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013113 pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
13114 pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/
13115 pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
13116
13117 /*Copying list of valid channel into request */
13118 memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch);
13119 pPnoRequest->aNetworks[i].ucChannelCount = num_ch;
13120
13121 pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value
13122 }
13123
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053013124 for (i = 0; i < request->n_ssids; i++)
13125 {
13126 j = 0;
13127 while (j < pPnoRequest->ucNetworksCount)
13128 {
13129 if ((pPnoRequest->aNetworks[j].ssId.length ==
13130 request->ssids[i].ssid_len) &&
13131 (0 == memcmp(pPnoRequest->aNetworks[j].ssId.ssId,
13132 request->ssids[i].ssid,
13133 pPnoRequest->aNetworks[j].ssId.length)))
13134 {
13135 pPnoRequest->aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
13136 break;
13137 }
13138 j++;
13139 }
13140 }
13141 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13142 "Number of hidden networks being Configured = %d",
13143 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053013144 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080013145 "request->ie_len = %zu", request->ie_len);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053013146 if ((0 < request->ie_len) && (NULL != request->ie))
13147 {
13148 pPnoRequest->us24GProbeTemplateLen = request->ie_len;
13149 memcpy(&pPnoRequest->p24GProbeTemplate, request->ie,
13150 pPnoRequest->us24GProbeTemplateLen);
13151
13152 pPnoRequest->us5GProbeTemplateLen = request->ie_len;
13153 memcpy(&pPnoRequest->p5GProbeTemplate, request->ie,
13154 pPnoRequest->us5GProbeTemplateLen);
13155 }
13156
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053013157 /* Driver gets only one time interval which is hardcoded in
13158 * supplicant for 10000ms. Taking power consumption into account 6 timers
13159 * will be used, Timervalue is increased exponentially i.e 10,20,40,
13160 * 80,160,320 secs. And number of scan cycle for each timer
13161 * is configurable through INI param gPNOScanTimerRepeatValue.
13162 * If it is set to 0 only one timer will be used and PNO scan cycle
13163 * will be repeated after each interval specified by supplicant
13164 * till PNO is disabled.
13165 */
13166 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
13167 pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
13168 else
13169 pPnoRequest->scanTimers.ucScanTimersCount =
13170 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
13171
13172 tempInterval = (request->interval)/1000;
13173 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13174 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
13175 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
13176 for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++)
13177 {
13178 pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat =
13179 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
13180 pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval;
13181 tempInterval *= 2;
13182 }
13183 //Repeat last timer until pno disabled.
13184 pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
13185
Madan Mohan Koyyalamudid206c7b2013-09-26 22:54:51 +053013186 pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013187
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013188 INIT_COMPLETION(pAdapter->pno_comp_var);
13189 pPnoRequest->statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
13190 pPnoRequest->callbackContext = pAdapter;
13191 pAdapter->pno_req_status = 0;
13192
Nirav Shah80830bf2013-12-31 16:35:12 +053013193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13194 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
13195 pAdapter->sessionId, pPnoRequest->enable, pPnoRequest->modePNO,
13196 pPnoRequest->scanTimers.ucScanTimersCount);
13197
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013198 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
13199 pPnoRequest, pAdapter->sessionId,
13200 hdd_cfg80211_sched_scan_done_callback, pAdapter);
13201 if (eHAL_STATUS_SUCCESS != status)
13202 {
13203 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053013204 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013205 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013206 goto error;
13207 }
13208
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013209 ret = wait_for_completion_timeout(
13210 &pAdapter->pno_comp_var,
13211 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
13212 if (0 >= ret)
13213 {
13214 // Did not receive the response for PNO enable in time.
13215 // Assuming the PNO enable was success.
13216 // Returning error from here, because we timeout, results
13217 // in side effect of Wifi (Wifi Setting) not to work.
13218 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13219 FL("Timed out waiting for PNO to be Enabled"));
13220 ret = 0;
13221 goto error;
13222 }
13223
c_hpothu3c986b22014-07-09 14:45:09 +053013224 vos_mem_free(pPnoRequest);
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013225 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053013226 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013227
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013228error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013229 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13230 FL("PNO scanRequest offloaded ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013231 vos_mem_free(pPnoRequest);
c_hpothu37f21312014-04-09 21:49:54 +053013232 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013233 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013234}
13235
13236/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053013237 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
13238 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013239 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053013240static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
13241 struct net_device *dev, struct cfg80211_sched_scan_request *request)
13242{
13243 int ret;
13244
13245 vos_ssr_protect(__func__);
13246 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
13247 vos_ssr_unprotect(__func__);
13248
13249 return ret;
13250}
13251
13252/*
13253 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
13254 * Function to disable PNO
13255 */
13256static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013257 struct net_device *dev)
13258{
13259 eHalStatus status = eHAL_STATUS_FAILURE;
13260 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13261 hdd_context_t *pHddCtx;
13262 tHalHandle hHal;
13263 tpSirPNOScanReq pPnoRequest = NULL;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013264 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013265
13266 ENTER();
13267
13268 if (NULL == pAdapter)
13269 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013270 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013271 "%s: HDD adapter is Null", __func__);
13272 return -ENODEV;
13273 }
13274
13275 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013276
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013277 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013278 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053013279 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013280 "%s: HDD context is Null", __func__);
13281 return -ENODEV;
13282 }
13283
13284 /* The return 0 is intentional when isLogpInProgress and
13285 * isLoadUnloadInProgress. We did observe a crash due to a return of
13286 * failure in sched_scan_stop , especially for a case where the unload
13287 * of the happens at the same time. The function __cfg80211_stop_sched_scan
13288 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
13289 * success. If it returns a failure , then its next invocation due to the
13290 * clean up of the second interface will have the dev pointer corresponding
13291 * to the first one leading to a crash.
13292 */
13293 if (pHddCtx->isLogpInProgress)
13294 {
13295 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13296 "%s: LOGP in Progress. Ignore!!!", __func__);
13297 return ret;
13298 }
13299
Mihir Shete18156292014-03-11 15:38:30 +053013300 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013301 {
13302 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13303 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
13304 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013305 }
13306
13307 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
13308 if (NULL == hHal)
13309 {
13310 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13311 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013312 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013313 }
13314
13315 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
13316 if (NULL == pPnoRequest)
13317 {
13318 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
13319 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013320 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013321 }
13322
13323 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
13324 pPnoRequest->enable = 0; /* Disable PNO */
13325 pPnoRequest->ucNetworksCount = 0;
13326
13327 status = sme_SetPreferredNetworkList(hHal, pPnoRequest,
13328 pAdapter->sessionId,
13329 NULL, pAdapter);
13330 if (eHAL_STATUS_SUCCESS != status)
13331 {
13332 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13333 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013334 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013335 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013336 }
c_hpothu37f21312014-04-09 21:49:54 +053013337 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013338
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013339error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013340 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013341 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013342 vos_mem_free(pPnoRequest);
13343
13344 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013345 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013346}
13347
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053013348/*
13349 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
13350 * NL interface to disable PNO
13351 */
13352static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
13353 struct net_device *dev)
13354{
13355 int ret;
13356
13357 vos_ssr_protect(__func__);
13358 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
13359 vos_ssr_unprotect(__func__);
13360
13361 return ret;
13362}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013363#endif /*FEATURE_WLAN_SCAN_PNO*/
13364
13365
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013366#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053013367#if TDLS_MGMT_VERSION2
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013368static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
13369 u8 *peer, u8 action_code, u8 dialog_token,
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053013370 u16 status_code, u32 peer_capability, const u8 *buf, size_t len)
13371#else
13372static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
13373 u8 *peer, u8 action_code, u8 dialog_token,
13374 u16 status_code, const u8 *buf, size_t len)
13375#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013376{
13377
13378 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13379 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013380 u8 peerMac[6];
13381 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070013382 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080013383 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070013384 long rc;
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053013385#if !(TDLS_MGMT_VERSION2)
13386 u32 peer_capability = 0;
13387#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053013388 tANI_U16 numCurrTdlsPeers;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013389
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013390 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13391 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
13392 pAdapter->sessionId, action_code));
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013393 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013394 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013395 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013396 "Invalid arguments");
13397 return -EINVAL;
13398 }
13399
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080013400 if (pHddCtx->isLogpInProgress)
13401 {
13402 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13403 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053013404 wlan_hdd_tdls_set_link_status(pAdapter,
13405 peer,
13406 eTDLS_LINK_IDLE,
13407 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080013408 return -EBUSY;
13409 }
13410
Hoonki Lee27511902013-03-14 18:19:06 -070013411 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013412 {
Hoonki Lee27511902013-03-14 18:19:06 -070013413 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
13414 "%s: TDLS mode is disabled OR not enabled in FW."
13415 MAC_ADDRESS_STR " action %d declined.",
13416 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013417 return -ENOTSUPP;
13418 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080013419
Hoonki Lee27511902013-03-14 18:19:06 -070013420 /* other than teardown frame, other mgmt frames are not sent if disabled */
13421 if (SIR_MAC_TDLS_TEARDOWN != action_code)
13422 {
13423 /* if tdls_mode is disabled to respond to peer's request */
13424 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
13425 {
13426 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
13427 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070013428 " TDLS mode is disabled. action %d declined.",
13429 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070013430
13431 return -ENOTSUPP;
13432 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053013433
13434 if (vos_max_concurrent_connections_reached())
13435 {
13436 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
13437 return -EINVAL;
13438 }
Hoonki Lee27511902013-03-14 18:19:06 -070013439 }
13440
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013441 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
13442 {
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053013443 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013444 {
13445 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013446 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070013447 " TDLS setup is ongoing. action %d declined.",
13448 __func__, MAC_ADDR_ARRAY(peer), action_code);
13449 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013450 }
13451 }
13452
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013453 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
13454 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080013455 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053013456 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
13457 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080013458 {
13459 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
13460 we return error code at 'add_station()'. Hence we have this
13461 check again in addtion to add_station().
13462 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013463 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080013464 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013465 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13466 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053013467 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
13468 __func__, MAC_ADDR_ARRAY(peer), action_code,
13469 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053013470 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080013471 }
13472 else
13473 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013474 /* maximum reached. tweak to send error code to peer and return
13475 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080013476 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013477 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13478 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053013479 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
13480 __func__, MAC_ADDR_ARRAY(peer), status_code,
13481 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070013482 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013483 /* fall through to send setup resp with failure status
13484 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080013485 }
13486 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013487 else
13488 {
13489 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053013490 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013491 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013492 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013493 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070013494 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
13495 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013496 return -EPERM;
13497 }
13498 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080013499 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013500 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013501
Hoonki Lee1090c6a2013-01-16 17:40:54 -080013502#ifdef WLAN_FEATURE_TDLS_DEBUG
13503 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053013504 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013505 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
13506 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -080013507#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013508
Hoonki Leea34dd892013-02-05 22:56:02 -080013509 /*Except teardown responder will not be used so just make 0*/
13510 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013511 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080013512 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070013513
13514 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053013515 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070013516
13517 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
13518 responder = pTdlsPeer->is_responder;
13519 else
Hoonki Leea34dd892013-02-05 22:56:02 -080013520 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070013521 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053013522 "%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 -070013523 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
13524 dialog_token, status_code, len);
13525 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080013526 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013527 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013528
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053013529 /* For explicit trigger of DIS_REQ come out of BMPS for
13530 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070013531 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053013532 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
13533 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070013534 {
13535 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
13536 {
13537 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053013538 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Hoonki Lee14621352013-04-16 17:51:19 -070013539 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
13540 }
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053013541 if (SIR_MAC_TDLS_DIS_REQ != action_code)
13542 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
Hoonki Lee14621352013-04-16 17:51:19 -070013543 }
13544
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013545 /* make sure doesn't call send_mgmt() while it is pending */
13546 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
13547 {
13548 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080013549 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013550 __func__, MAC_ADDR_ARRAY(peer), action_code);
13551 return -EBUSY;
13552 }
13553
13554 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013555 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
13556
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013557 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +053013558 peerMac, action_code, dialog_token, status_code, peer_capability, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013559
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013560 if (VOS_STATUS_SUCCESS != status)
13561 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013562 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13563 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013564 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -070013565 wlan_hdd_tdls_check_bmps(pAdapter);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053013566 return -EINVAL;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013567 }
13568
Hoonki Leed37cbb32013-04-20 00:31:14 -070013569 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
13570 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
13571
13572 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013573 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070013574 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070013575 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070013576 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013577 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080013578
13579 if (pHddCtx->isLogpInProgress)
13580 {
13581 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13582 "%s: LOGP in Progress. Ignore!!!", __func__);
13583 return -EAGAIN;
13584 }
13585
Hoonki Leed37cbb32013-04-20 00:31:14 -070013586 wlan_hdd_tdls_check_bmps(pAdapter);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053013587 return -EINVAL;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013588 }
13589
Gopichand Nakkala05922802013-03-14 12:23:19 -070013590 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070013591 {
13592 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -070013593 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070013594 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013595
Hoonki Leea34dd892013-02-05 22:56:02 -080013596 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
13597 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080013598 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -080013599 }
13600 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
13601 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080013602 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -080013603 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013604
13605 return 0;
13606}
13607
Atul Mittal115287b2014-07-08 13:26:33 +053013608
13609int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
13610 u8 *peer,
13611 cfg80211_exttdls_callback callback)
13612{
13613
13614 hddTdlsPeer_t *pTdlsPeer;
13615 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13617 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
13618 __func__, MAC_ADDR_ARRAY(peer));
13619
13620 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
13621 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
13622
13623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13624 " %s TDLS External control and Implicit Trigger not enabled ",
13625 __func__);
13626 return -ENOTSUPP;
13627 }
13628
13629 /* To cater the requirement of establishing the TDLS link
13630 * irrespective of the data traffic , get an entry of TDLS peer.
13631 */
13632 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
13633 if (pTdlsPeer == NULL) {
13634 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13635 "%s: peer " MAC_ADDRESS_STR " not existing",
13636 __func__, MAC_ADDR_ARRAY(peer));
13637 return -EINVAL;
13638 }
13639
13640 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
13641
13642 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13643 " %s TDLS Add Force Peer Failed",
13644 __func__);
13645 return -EINVAL;
13646 }
13647 /*EXT TDLS*/
13648
13649 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
13650 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13651 " %s TDLS set callback Failed",
13652 __func__);
13653 return -EINVAL;
13654 }
13655
13656 return(0);
13657
13658}
13659
13660int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter, u8 *peer)
13661{
13662
13663 hddTdlsPeer_t *pTdlsPeer;
13664 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13665 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13666 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
13667 __func__, MAC_ADDR_ARRAY(peer));
13668
13669 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
13670 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
13671
13672 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13673 " %s TDLS External control and Implicit Trigger not enabled ",
13674 __func__);
13675 return -ENOTSUPP;
13676 }
13677
13678
13679 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
13680
13681 if ( NULL == pTdlsPeer ) {
13682 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
13683 " peer not exsting",
13684 __func__, MAC_ADDR_ARRAY(peer));
13685 return -EINVAL;
13686 }
13687 else {
13688 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
13689 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
13690 }
13691
13692 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) )
13693 return -EINVAL;
13694
13695 /*EXT TDLS*/
13696
13697 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
13698
13699 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13700 " %s TDLS set callback Failed",
13701 __func__);
13702 return -EINVAL;
13703 }
13704 return(0);
13705
13706}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013707static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013708 u8 *peer, enum nl80211_tdls_operation oper)
13709{
13710 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13711 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013712 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013713 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013714
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013715 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13716 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
13717 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013718 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013719 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013720 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070013721 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013722 return -EINVAL;
13723 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080013724
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013725 status = wlan_hdd_validate_context(pHddCtx);
13726
13727 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080013728 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013729 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13730 "%s: HDD context is not valid", __func__);
13731 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080013732 }
13733
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013734
13735 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080013736 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013737 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080013738 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070013739 "TDLS Disabled in INI OR not enabled in FW. "
13740 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013741 return -ENOTSUPP;
13742 }
13743
13744 switch (oper) {
13745 case NL80211_TDLS_ENABLE_LINK:
13746 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013747 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013748 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053013749 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013750
Sunil Dutt41de4e22013-11-14 18:09:02 +053013751 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
13752
13753 if ( NULL == pTdlsPeer ) {
13754 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
13755 " (oper %d) not exsting. ignored",
13756 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
13757 return -EINVAL;
13758 }
13759
13760 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13761 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
13762 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
13763 "NL80211_TDLS_ENABLE_LINK");
13764
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070013765 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
13766 {
13767 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
13768 MAC_ADDRESS_STR " failed",
13769 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
13770 return -EINVAL;
13771 }
13772
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013773 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013774 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053013775 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053013776
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053013777 if (0 != wlan_hdd_tdls_get_link_establish_params(
13778 pAdapter, peer,&tdlsLinkEstablishParams)) {
13779 return -EINVAL;
13780 }
13781 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053013782
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053013783 sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter),
13784 pAdapter->sessionId, peer, &tdlsLinkEstablishParams);
13785 /* Send TDLS peer UAPSD capabilities to the firmware and
13786 * register with the TL on after the response for this operation
13787 * is received .
13788 */
13789 ret = wait_for_completion_interruptible_timeout(
13790 &pAdapter->tdls_link_establish_req_comp,
13791 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
13792 if (ret <= 0)
13793 {
13794 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13795 "%s: Link Establish Request Faled Status %ld",
13796 __func__, ret);
13797 return -EINVAL;
13798 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053013799 }
Atul Mittal115287b2014-07-08 13:26:33 +053013800 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
13801 eTDLS_LINK_CONNECTED,
13802 eTDLS_LINK_SUCCESS);
Gopichand Nakkala471708b2013-06-04 20:03:01 +053013803 /* Mark TDLS client Authenticated .*/
13804 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
13805 pTdlsPeer->staId,
13806 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070013807 if (VOS_STATUS_SUCCESS == status)
13808 {
Hoonki Lee14621352013-04-16 17:51:19 -070013809 if (pTdlsPeer->is_responder == 0)
13810 {
13811 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
13812
13813 wlan_hdd_tdls_timer_restart(pAdapter,
13814 &pTdlsPeer->initiatorWaitTimeoutTimer,
13815 WAIT_TIME_TDLS_INITIATOR);
13816 /* suspend initiator TX until it receives direct packet from the
13817 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
13818 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
13819 &staId, NULL);
13820 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070013821 wlan_hdd_tdls_increment_peer_count(pAdapter);
13822 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013823 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053013824
13825 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053013826 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
13827 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053013828 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053013829 int ac;
13830 uint8 ucAc[4] = { WLANTL_AC_VO,
13831 WLANTL_AC_VI,
13832 WLANTL_AC_BK,
13833 WLANTL_AC_BE };
13834 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
13835 for(ac=0; ac < 4; ac++)
13836 {
13837 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
13838 pTdlsPeer->staId, ucAc[ac],
13839 tlTid[ac], tlTid[ac], 0, 0,
13840 WLANTL_BI_DIR );
13841 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053013842 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013843 }
13844
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013845 }
13846 break;
13847 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080013848 {
Sunil Dutt41de4e22013-11-14 18:09:02 +053013849 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
13850
13851 if ( NULL == pTdlsPeer ) {
13852 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
13853 " (oper %d) not exsting. ignored",
13854 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
13855 return -EINVAL;
13856 }
13857
13858 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13859 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
13860 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
13861 "NL80211_TDLS_DISABLE_LINK");
13862
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013863 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080013864 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013865 long status;
13866
Atul Mittal271a7652014-09-12 13:18:22 +053013867
13868 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
13869 eTDLS_LINK_TEARING,
13870 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
13871 eTDLS_LINK_UNSPECIFIED:
13872 eTDLS_LINK_DROPPED_BY_REMOTE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013873 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
13874
Lee Hoonkic1262f22013-01-24 21:59:00 -080013875 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
13876 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013877
13878 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
13879 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Atul Mittal271a7652014-09-12 13:18:22 +053013880 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053013881 eTDLS_LINK_IDLE,
13882 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013883 if (status <= 0)
13884 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013885 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13886 "%s: Del station failed status %ld",
13887 __func__, status);
13888 return -EPERM;
13889 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080013890 }
13891 else
13892 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13894 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080013895 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080013896 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013897 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013898 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053013899 {
Atul Mittal115287b2014-07-08 13:26:33 +053013900 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053013901
Atul Mittal115287b2014-07-08 13:26:33 +053013902 if (0 != status)
13903 {
13904 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13905 "%s: Error in TDLS Teardown", __func__);
13906 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053013907 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053013908 break;
13909 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013910 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053013911 {
Atul Mittal115287b2014-07-08 13:26:33 +053013912 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
13913 peer,
13914 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053013915
Atul Mittal115287b2014-07-08 13:26:33 +053013916 if (0 != status)
13917 {
13918 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13919 "%s: Error in TDLS Setup", __func__);
13920 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053013921 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053013922 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053013923 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013924 case NL80211_TDLS_DISCOVERY_REQ:
13925 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013926 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
13927 "%s: We don't support in-driver setup/teardown/discovery "
13928 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013929 return -ENOTSUPP;
13930 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013931 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13932 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013933 return -ENOTSUPP;
13934 }
13935 return 0;
13936}
Chilam NG571c65a2013-01-19 12:27:36 +053013937
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013938static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
13939 u8 *peer, enum nl80211_tdls_operation oper)
13940{
13941 int ret;
13942
13943 vos_ssr_protect(__func__);
13944 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
13945 vos_ssr_unprotect(__func__);
13946
13947 return ret;
13948}
13949
Chilam NG571c65a2013-01-19 12:27:36 +053013950int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
13951 struct net_device *dev, u8 *peer)
13952{
Arif Hussaina7c8e412013-11-20 11:06:42 -080013953 hddLog(VOS_TRACE_LEVEL_INFO,
13954 "tdls send discover req: "MAC_ADDRESS_STR,
13955 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053013956
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053013957#if TDLS_MGMT_VERSION2
13958 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
13959 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
13960#else
Chilam NG571c65a2013-01-19 12:27:36 +053013961 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
13962 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053013963#endif
Chilam NG571c65a2013-01-19 12:27:36 +053013964}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013965#endif
13966
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013967#ifdef WLAN_FEATURE_GTK_OFFLOAD
13968/*
13969 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
13970 * Callback rountine called upon receiving response for
13971 * get offload info
13972 */
13973void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
13974 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
13975{
13976
13977 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053013978 tANI_U8 tempReplayCounter[8];
13979 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013980
13981 ENTER();
13982
13983 if (NULL == pAdapter)
13984 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053013985 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013986 "%s: HDD adapter is Null", __func__);
13987 return ;
13988 }
13989
13990 if (NULL == pGtkOffloadGetInfoRsp)
13991 {
13992 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13993 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
13994 return ;
13995 }
13996
13997 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
13998 {
13999 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14000 "%s: wlan Failed to get replay counter value",
14001 __func__);
14002 return ;
14003 }
14004
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014005 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14006 /* Update replay counter */
14007 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
14008 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
14009
14010 {
14011 /* changing from little to big endian since supplicant
14012 * works on big endian format
14013 */
14014 int i;
14015 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
14016
14017 for (i = 0; i < 8; i++)
14018 {
14019 tempReplayCounter[7-i] = (tANI_U8)p[i];
14020 }
14021 }
14022
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014023 /* Update replay counter to NL */
14024 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014025 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014026}
14027
14028/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014029 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014030 * This function is used to offload GTK rekeying job to the firmware.
14031 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014032int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014033 struct cfg80211_gtk_rekey_data *data)
14034{
14035 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14036 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
14037 hdd_station_ctx_t *pHddStaCtx;
14038 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014039 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014040 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014041 eHalStatus status = eHAL_STATUS_FAILURE;
14042
14043 ENTER();
14044
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014045
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014046 if (NULL == pAdapter)
14047 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014048 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014049 "%s: HDD adapter is Null", __func__);
14050 return -ENODEV;
14051 }
14052
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014053 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14054 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
14055 pAdapter->sessionId, pAdapter->device_mode));
14056
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014057 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014058
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014059 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014060 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014061 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14062 "%s: HDD context is not valid", __func__);
14063 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014064 }
14065
14066 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14067 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14068 if (NULL == hHal)
14069 {
14070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14071 "%s: HAL context is Null!!!", __func__);
14072 return -EAGAIN;
14073 }
14074
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014075 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
14076 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
14077 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
14078 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014079 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014080 {
14081 /* changing from big to little endian since driver
14082 * works on little endian format
14083 */
14084 tANI_U8 *p =
14085 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
14086 int i;
14087
14088 for (i = 0; i < 8; i++)
14089 {
14090 p[7-i] = data->replay_ctr[i];
14091 }
14092 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014093
14094 if (TRUE == pHddCtx->hdd_wlan_suspended)
14095 {
14096 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014097 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
14098 sizeof (tSirGtkOffloadParams));
14099 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014100 pAdapter->sessionId);
14101
14102 if (eHAL_STATUS_SUCCESS != status)
14103 {
14104 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14105 "%s: sme_SetGTKOffload failed, returned %d",
14106 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053014107
14108 /* Need to clear any trace of key value in the memory.
14109 * Thus zero out the memory even though it is local
14110 * variable.
14111 */
14112 vos_mem_zero(&hddGtkOffloadReqParams,
14113 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014114 return status;
14115 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14117 "%s: sme_SetGTKOffload successfull", __func__);
14118 }
14119 else
14120 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014121 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14122 "%s: wlan not suspended GTKOffload request is stored",
14123 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014124 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014125
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053014126 /* Need to clear any trace of key value in the memory.
14127 * Thus zero out the memory even though it is local
14128 * variable.
14129 */
14130 vos_mem_zero(&hddGtkOffloadReqParams,
14131 sizeof(hddGtkOffloadReqParams));
14132
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014133 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014134}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014135
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014136int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
14137 struct cfg80211_gtk_rekey_data *data)
14138{
14139 int ret;
14140
14141 vos_ssr_protect(__func__);
14142 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
14143 vos_ssr_unprotect(__func__);
14144
14145 return ret;
14146}
14147#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014148/*
14149 * FUNCTION: wlan_hdd_cfg80211_set_mac_acl
14150 * This function is used to set access control policy
14151 */
14152static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
14153 struct net_device *dev, const struct cfg80211_acl_data *params)
14154{
14155 int i;
14156 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14157 hdd_hostapd_state_t *pHostapdState;
14158 tsap_Config_t *pConfig;
14159 v_CONTEXT_t pVosContext = NULL;
14160 hdd_context_t *pHddCtx;
14161 int status;
14162
14163 ENTER();
14164
14165 if (NULL == pAdapter)
14166 {
14167 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14168 "%s: HDD adapter is Null", __func__);
14169 return -ENODEV;
14170 }
14171
14172 if (NULL == params)
14173 {
14174 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14175 "%s: params is Null", __func__);
14176 return -EINVAL;
14177 }
14178
14179 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14180 status = wlan_hdd_validate_context(pHddCtx);
14181
14182 if (0 != status)
14183 {
14184 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14185 "%s: HDD context is not valid", __func__);
14186 return status;
14187 }
14188
14189 pVosContext = pHddCtx->pvosContext;
14190 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
14191
14192 if (NULL == pHostapdState)
14193 {
14194 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14195 "%s: pHostapdState is Null", __func__);
14196 return -EINVAL;
14197 }
14198
14199 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
14200 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
14201
14202 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
14203 {
14204 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
14205
14206 /* default value */
14207 pConfig->num_accept_mac = 0;
14208 pConfig->num_deny_mac = 0;
14209
14210 /**
14211 * access control policy
14212 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
14213 * listed in hostapd.deny file.
14214 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
14215 * listed in hostapd.accept file.
14216 */
14217 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
14218 {
14219 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
14220 }
14221 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
14222 {
14223 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
14224 }
14225 else
14226 {
14227 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14228 "%s:Acl Policy : %d is not supported",
14229 __func__, params->acl_policy);
14230 return -ENOTSUPP;
14231 }
14232
14233 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
14234 {
14235 pConfig->num_accept_mac = params->n_acl_entries;
14236 for (i = 0; i < params->n_acl_entries; i++)
14237 {
14238 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14239 "** Add ACL MAC entry %i in WhiletList :"
14240 MAC_ADDRESS_STR, i,
14241 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
14242
14243 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
14244 sizeof(qcmacaddr));
14245 }
14246 }
14247 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
14248 {
14249 pConfig->num_deny_mac = params->n_acl_entries;
14250 for (i = 0; i < params->n_acl_entries; i++)
14251 {
14252 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14253 "** Add ACL MAC entry %i in BlackList :"
14254 MAC_ADDRESS_STR, i,
14255 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
14256
14257 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
14258 sizeof(qcmacaddr));
14259 }
14260 }
14261
14262 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
14263 {
14264 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14265 "%s: SAP Set Mac Acl fail", __func__);
14266 return -EINVAL;
14267 }
14268 }
14269 else
14270 {
14271 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053014272 "%s: Invalid device_mode = %s (%d)",
14273 __func__, hdd_device_modetoString(pAdapter->device_mode),
14274 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014275 return -EINVAL;
14276 }
14277
14278 return 0;
14279}
14280
Leo Chang9056f462013-08-01 19:21:11 -070014281#ifdef WLAN_NL80211_TESTMODE
14282#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070014283void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070014284(
14285 void *pAdapter,
14286 void *indCont
14287)
14288{
Leo Changd9df8aa2013-09-26 13:32:26 -070014289 tSirLPHBInd *lphbInd;
14290 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053014291 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070014292
14293 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070014294 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070014295
c_hpothu73f35e62014-04-18 13:40:08 +053014296 if (pAdapter == NULL)
14297 {
14298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14299 "%s: pAdapter is NULL\n",__func__);
14300 return;
14301 }
14302
Leo Chang9056f462013-08-01 19:21:11 -070014303 if (NULL == indCont)
14304 {
14305 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070014306 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070014307 return;
14308 }
14309
c_hpothu73f35e62014-04-18 13:40:08 +053014310 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070014311 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070014312 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053014313 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070014314 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070014315 GFP_ATOMIC);
14316 if (!skb)
14317 {
14318 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14319 "LPHB timeout, NL buffer alloc fail");
14320 return;
14321 }
14322
Leo Changac3ba772013-10-07 09:47:04 -070014323 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070014324 {
14325 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14326 "WLAN_HDD_TM_ATTR_CMD put fail");
14327 goto nla_put_failure;
14328 }
Leo Changac3ba772013-10-07 09:47:04 -070014329 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070014330 {
14331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14332 "WLAN_HDD_TM_ATTR_TYPE put fail");
14333 goto nla_put_failure;
14334 }
Leo Changac3ba772013-10-07 09:47:04 -070014335 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070014336 sizeof(tSirLPHBInd), lphbInd))
14337 {
14338 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14339 "WLAN_HDD_TM_ATTR_DATA put fail");
14340 goto nla_put_failure;
14341 }
Leo Chang9056f462013-08-01 19:21:11 -070014342 cfg80211_testmode_event(skb, GFP_ATOMIC);
14343 return;
14344
14345nla_put_failure:
14346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14347 "NLA Put fail");
14348 kfree_skb(skb);
14349
14350 return;
14351}
14352#endif /* FEATURE_WLAN_LPHB */
14353
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014354static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070014355{
14356 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
14357 int err = 0;
14358#ifdef FEATURE_WLAN_LPHB
14359 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070014360 eHalStatus smeStatus;
Leo Chang9056f462013-08-01 19:21:11 -070014361#endif /* FEATURE_WLAN_LPHB */
14362
14363 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
14364 if (err)
14365 {
14366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14367 "%s Testmode INV ATTR", __func__);
14368 return err;
14369 }
14370
14371 if (!tb[WLAN_HDD_TM_ATTR_CMD])
14372 {
14373 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14374 "%s Testmode INV CMD", __func__);
14375 return -EINVAL;
14376 }
14377
14378 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
14379 {
14380#ifdef FEATURE_WLAN_LPHB
14381 /* Low Power Heartbeat configuration request */
14382 case WLAN_HDD_TM_CMD_WLAN_HB:
14383 {
14384 int buf_len;
14385 void *buf;
14386 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080014387 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070014388
14389 if (!tb[WLAN_HDD_TM_ATTR_DATA])
14390 {
14391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14392 "%s Testmode INV DATA", __func__);
14393 return -EINVAL;
14394 }
14395
14396 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
14397 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080014398
14399 hb_params_temp =(tSirLPHBReq *)buf;
14400 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
14401 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
14402 return -EINVAL;
14403
Leo Chang9056f462013-08-01 19:21:11 -070014404 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
14405 if (NULL == hb_params)
14406 {
14407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14408 "%s Request Buffer Alloc Fail", __func__);
14409 return -EINVAL;
14410 }
14411
14412 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070014413 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
14414 hb_params,
14415 wlan_hdd_cfg80211_lphb_ind_handler);
14416 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070014417 {
Leo Changd9df8aa2013-09-26 13:32:26 -070014418 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14419 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070014420 vos_mem_free(hb_params);
14421 }
Leo Chang9056f462013-08-01 19:21:11 -070014422 return 0;
14423 }
14424#endif /* FEATURE_WLAN_LPHB */
14425 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014426 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14427 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070014428 return -EOPNOTSUPP;
14429 }
14430
14431 return err;
14432}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014433
14434static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
14435{
14436 int ret;
14437
14438 vos_ssr_protect(__func__);
14439 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
14440 vos_ssr_unprotect(__func__);
14441
14442 return ret;
14443}
Leo Chang9056f462013-08-01 19:21:11 -070014444#endif /* CONFIG_NL80211_TESTMODE */
14445
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014446static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014447 struct net_device *dev,
14448 int idx, struct survey_info *survey)
14449{
14450 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14451 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053014452 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014453 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053014454 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014455 v_S7_t snr,rssi;
14456 int status, i, j, filled = 0;
14457
14458 ENTER();
14459
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014460 if (NULL == pAdapter)
14461 {
14462 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14463 "%s: HDD adapter is Null", __func__);
14464 return -ENODEV;
14465 }
14466
14467 if (NULL == wiphy)
14468 {
14469 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14470 "%s: wiphy is Null", __func__);
14471 return -ENODEV;
14472 }
14473
14474 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14475 status = wlan_hdd_validate_context(pHddCtx);
14476
14477 if (0 != status)
14478 {
14479 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14480 "%s: HDD context is not valid", __func__);
14481 return status;
14482 }
14483
Mihir Sheted9072e02013-08-21 17:02:29 +053014484 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14485
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014486 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053014487 0 != pAdapter->survey_idx ||
14488 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014489 {
14490 /* The survey dump ops when implemented completely is expected to
14491 * return a survey of all channels and the ops is called by the
14492 * kernel with incremental values of the argument 'idx' till it
14493 * returns -ENONET. But we can only support the survey for the
14494 * operating channel for now. survey_idx is used to track
14495 * that the ops is called only once and then return -ENONET for
14496 * the next iteration
14497 */
14498 pAdapter->survey_idx = 0;
14499 return -ENONET;
14500 }
14501
14502 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14503
14504 wlan_hdd_get_snr(pAdapter, &snr);
14505 wlan_hdd_get_rssi(pAdapter, &rssi);
14506
14507 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
14508 hdd_wlan_get_freq(channel, &freq);
14509
14510
14511 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
14512 {
14513 if (NULL == wiphy->bands[i])
14514 {
14515 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
14516 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
14517 continue;
14518 }
14519
14520 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
14521 {
14522 struct ieee80211_supported_band *band = wiphy->bands[i];
14523
14524 if (band->channels[j].center_freq == (v_U16_t)freq)
14525 {
14526 survey->channel = &band->channels[j];
14527 /* The Rx BDs contain SNR values in dB for the received frames
14528 * while the supplicant expects noise. So we calculate and
14529 * return the value of noise (dBm)
14530 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
14531 */
14532 survey->noise = rssi - snr;
14533 survey->filled = SURVEY_INFO_NOISE_DBM;
14534 filled = 1;
14535 }
14536 }
14537 }
14538
14539 if (filled)
14540 pAdapter->survey_idx = 1;
14541 else
14542 {
14543 pAdapter->survey_idx = 0;
14544 return -ENONET;
14545 }
14546
14547 return 0;
14548}
14549
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014550static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
14551 struct net_device *dev,
14552 int idx, struct survey_info *survey)
14553{
14554 int ret;
14555
14556 vos_ssr_protect(__func__);
14557 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
14558 vos_ssr_unprotect(__func__);
14559
14560 return ret;
14561}
14562
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014563/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053014564 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014565 * this is called when cfg80211 driver resume
14566 * driver updates latest sched_scan scan result(if any) to cfg80211 database
14567 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053014568int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014569{
14570 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
14571 hdd_adapter_t *pAdapter;
14572 hdd_adapter_list_node_t *pAdapterNode, *pNext;
14573 VOS_STATUS status = VOS_STATUS_SUCCESS;
14574
14575 ENTER();
14576
14577 if ( NULL == pHddCtx )
14578 {
14579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14580 "%s: HddCtx validation failed", __func__);
14581 return 0;
14582 }
14583
14584 if (pHddCtx->isLogpInProgress)
14585 {
14586 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14587 "%s: LOGP in Progress. Ignore!!!", __func__);
14588 return 0;
14589 }
14590
Mihir Shete18156292014-03-11 15:38:30 +053014591 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014592 {
14593 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14594 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14595 return 0;
14596 }
14597
14598 spin_lock(&pHddCtx->schedScan_lock);
14599 pHddCtx->isWiphySuspended = FALSE;
14600 if (TRUE != pHddCtx->isSchedScanUpdatePending)
14601 {
14602 spin_unlock(&pHddCtx->schedScan_lock);
14603 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14604 "%s: Return resume is not due to PNO indication", __func__);
14605 return 0;
14606 }
14607 // Reset flag to avoid updatating cfg80211 data old results again
14608 pHddCtx->isSchedScanUpdatePending = FALSE;
14609 spin_unlock(&pHddCtx->schedScan_lock);
14610
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053014611
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014612 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
14613
14614 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
14615 {
14616 pAdapter = pAdapterNode->pAdapter;
14617 if ( (NULL != pAdapter) &&
14618 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
14619 {
14620 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053014621 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014622 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
14623 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053014624 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014625 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053014626 {
14627 /* Acquire wakelock to handle the case where APP's tries to
14628 * suspend immediately after updating the scan results. Whis
14629 * results in app's is in suspended state and not able to
14630 * process the connect request to AP
14631 */
14632 hdd_prevent_suspend_timeout(2000);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014633 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053014634 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014635
14636 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14637 "%s : cfg80211 scan result database updated", __func__);
14638
14639 return 0;
14640
14641 }
14642 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
14643 pAdapterNode = pNext;
14644 }
14645
14646 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14647 "%s: Failed to find Adapter", __func__);
14648 return 0;
14649}
14650
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053014651int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
14652{
14653 int ret;
14654
14655 vos_ssr_protect(__func__);
14656 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
14657 vos_ssr_unprotect(__func__);
14658
14659 return ret;
14660}
14661
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014662/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053014663 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014664 * this is called when cfg80211 driver suspends
14665 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053014666int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014667 struct cfg80211_wowlan *wow)
14668{
14669 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
14670
14671 ENTER();
14672 if (NULL == pHddCtx)
14673 {
14674 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14675 "%s: HddCtx validation failed", __func__);
14676 return 0;
14677 }
14678
14679 pHddCtx->isWiphySuspended = TRUE;
14680
14681 EXIT();
14682
14683 return 0;
14684}
14685
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053014686int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
14687 struct cfg80211_wowlan *wow)
14688{
14689 int ret;
14690
14691 vos_ssr_protect(__func__);
14692 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
14693 vos_ssr_unprotect(__func__);
14694
14695 return ret;
14696}
Jeff Johnson295189b2012-06-20 16:38:30 -070014697/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014698static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070014699{
14700 .add_virtual_intf = wlan_hdd_add_virtual_intf,
14701 .del_virtual_intf = wlan_hdd_del_virtual_intf,
14702 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
14703 .change_station = wlan_hdd_change_station,
14704#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
14705 .add_beacon = wlan_hdd_cfg80211_add_beacon,
14706 .del_beacon = wlan_hdd_cfg80211_del_beacon,
14707 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014708#else
14709 .start_ap = wlan_hdd_cfg80211_start_ap,
14710 .change_beacon = wlan_hdd_cfg80211_change_beacon,
14711 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070014712#endif
14713 .change_bss = wlan_hdd_cfg80211_change_bss,
14714 .add_key = wlan_hdd_cfg80211_add_key,
14715 .get_key = wlan_hdd_cfg80211_get_key,
14716 .del_key = wlan_hdd_cfg80211_del_key,
14717 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080014718#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070014719 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080014720#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014721 .scan = wlan_hdd_cfg80211_scan,
14722 .connect = wlan_hdd_cfg80211_connect,
14723 .disconnect = wlan_hdd_cfg80211_disconnect,
14724 .join_ibss = wlan_hdd_cfg80211_join_ibss,
14725 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
14726 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
14727 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
14728 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070014729 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
14730 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053014731 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070014732#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
14733 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
14734 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
14735 .set_txq_params = wlan_hdd_set_txq_params,
14736#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014737 .get_station = wlan_hdd_cfg80211_get_station,
14738 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
14739 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014740 .add_station = wlan_hdd_cfg80211_add_station,
14741#ifdef FEATURE_WLAN_LFR
14742 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
14743 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
14744 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
14745#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014746#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
14747 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
14748#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014749#ifdef FEATURE_WLAN_TDLS
14750 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
14751 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
14752#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014753#ifdef WLAN_FEATURE_GTK_OFFLOAD
14754 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
14755#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014756#ifdef FEATURE_WLAN_SCAN_PNO
14757 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
14758 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
14759#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014760 .resume = wlan_hdd_cfg80211_resume_wlan,
14761 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014762 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070014763#ifdef WLAN_NL80211_TESTMODE
14764 .testmode_cmd = wlan_hdd_cfg80211_testmode,
14765#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014766 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070014767};
14768