blob: 87be760deb518094875e3a962e015d323db88db1 [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 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05303966 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
3967 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
3968 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05303969
3970};
3971
3972static const struct nla_policy
3973wlan_hdd_tdls_config_get_status_policy[
3974 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
3975{
3976 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
3977 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
3978 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05303979 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
3980 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
3981 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05303982
3983};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05303984
3985static const struct nla_policy
3986wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
3987{
3988 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
3989};
3990
3991static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
3992 struct wireless_dev *wdev,
3993 void *data,
3994 int data_len)
3995{
3996
3997 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3998 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
3999
4000 if (0 != wlan_hdd_validate_context(pHddCtx)){
4001 hddLog(VOS_TRACE_LEVEL_ERROR, FL("hdd Ctx invalid while spoof macAddr"));
4002 return -EINVAL;
4003 }
4004 if (FALSE == pHddCtx->cfg_ini->enableMacSpoofing) {
4005 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MAC_SPOOFED_SCAN disabled in ini"));
4006 return -ENOTSUPP;
4007 }
4008 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
4009 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MAC_SPOOFED_SCAN not supported by FW"));
4010 return -ENOTSUPP;
4011 }
4012
4013 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
4014 data, data_len, wlan_hdd_mac_config)) {
4015 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4016 return -EINVAL;
4017 }
4018
4019 /* Parse and fetch mac address */
4020 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
4021 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4022 return -EINVAL;
4023 }
4024
4025 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
4026 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4027 VOS_MAC_ADDR_LAST_3_BYTES);
4028
4029 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,nla_data(
4030 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4031 VOS_MAC_ADDR_FIRST_3_BYTES);
4032
4033 if (VOS_STATUS_SUCCESS != vos_randomize_n_bytes(
4034 (void *)(&pHddCtx->spoofMacAddr.randomMacAddr.bytes[3]),
4035 VOS_MAC_ADDR_LAST_3_BYTES)) {
4036 hddLog(LOGE, FL("Failed to generate random Mac Addr"));
4037 }
4038 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4039 pHddCtx->spoofMacAddr.randomMacAddr.bytes,
4040 VOS_MAC_ADDR_SIZE);
4041
4042 if (eHAL_STATUS_SUCCESS != sme_SpoofMacAddrReq(pHddCtx->hHal,
4043 &pHddCtx->spoofMacAddr.randomMacAddr)) {
4044 hddLog(LOGE, FL("Failed to send Spoof Mac Addr to FW"));
4045 }
4046
4047 return 0;
4048}
4049
Atul Mittal115287b2014-07-08 13:26:33 +05304050static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
4051 struct wireless_dev *wdev,
4052 void *data,
4053 int data_len)
4054{
4055 u8 peer[6] = {0};
4056 struct net_device *dev = wdev->netdev;
4057 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4058 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4059 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
4060 eHalStatus ret;
4061 tANI_S32 state;
4062 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304063 tANI_S32 global_operating_class = 0;
4064 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05304065 struct sk_buff *skb = NULL;
4066
4067 ret = wlan_hdd_validate_context(pHddCtx);
4068 if (0 != ret) {
4069
4070 return -EINVAL;
4071 }
4072 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
4073
4074 return -ENOTSUPP;
4075 }
4076 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
4077 data, data_len,
4078 wlan_hdd_tdls_config_get_status_policy)) {
4079 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4080 return -EINVAL;
4081 }
4082
4083 /* Parse and fetch mac address */
4084 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
4085 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4086 return -EINVAL;
4087 }
4088
4089 memcpy(peer, nla_data(
4090 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
4091 sizeof(peer));
4092 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4093
4094 ret = wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
4095
4096 if (0 != ret) {
4097 hddLog(VOS_TRACE_LEVEL_ERROR,
4098 FL("get status Failed"));
4099 return -EINVAL;
4100 }
4101 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304102 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05304103 NLMSG_HDRLEN);
4104
4105 if (!skb) {
4106 hddLog(VOS_TRACE_LEVEL_ERROR,
4107 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
4108 return -EINVAL;
4109 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304110 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reason (%d) Status (%d) class (%d) channel (%d) peer" MAC_ADDRESS_STR),
Atul Mittal115287b2014-07-08 13:26:33 +05304111 reason,
4112 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304113 global_operating_class,
4114 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05304115 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304116 if (nla_put_s32(skb,
4117 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
4118 state) ||
4119 nla_put_s32(skb,
4120 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
4121 reason) ||
4122 nla_put_s32(skb,
4123 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
4124 global_operating_class) ||
4125 nla_put_s32(skb,
4126 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
4127 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05304128
4129 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4130 goto nla_put_failure;
4131 }
4132
4133 return cfg80211_vendor_cmd_reply(skb);
4134
4135nla_put_failure:
4136 kfree_skb(skb);
4137 return -EINVAL;
4138}
4139
4140static int wlan_hdd_cfg80211_exttdls_callback(tANI_U8* mac,
4141 tANI_S32 state,
4142 tANI_S32 reason,
4143 void *ctx)
4144{
4145 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
4146 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4147 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304148 tANI_S32 global_operating_class = 0;
4149 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05304150
4151 if (wlan_hdd_validate_context(pHddCtx)) {
4152 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "));
4153 return -EINVAL;
4154 }
4155
4156 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
4157
4158 return -ENOTSUPP;
4159 }
4160 skb = cfg80211_vendor_event_alloc(
4161 pHddCtx->wiphy,
4162 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
4163 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
4164 GFP_KERNEL);
4165
4166 if (!skb) {
4167 hddLog(VOS_TRACE_LEVEL_ERROR,
4168 FL("cfg80211_vendor_event_alloc failed"));
4169 return -EINVAL;
4170 }
4171 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304172 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
4173 reason,
4174 state,
4175 global_operating_class,
4176 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05304177 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
4178 MAC_ADDR_ARRAY(mac));
4179
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304180 if (nla_put(skb,
4181 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
4182 VOS_MAC_ADDR_SIZE, mac) ||
4183 nla_put_s32(skb,
4184 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
4185 state) ||
4186 nla_put_s32(skb,
4187 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
4188 reason) ||
4189 nla_put_s32(skb,
4190 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
4191 channel) ||
4192 nla_put_s32(skb,
4193 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
4194 global_operating_class)
4195 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05304196 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4197 goto nla_put_failure;
4198 }
4199
4200 cfg80211_vendor_event(skb, GFP_KERNEL);
4201 return (0);
4202
4203nla_put_failure:
4204 kfree_skb(skb);
4205 return -EINVAL;
4206}
4207
4208static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
4209 struct wireless_dev *wdev,
4210 void *data,
4211 int data_len)
4212{
4213 u8 peer[6] = {0};
4214 struct net_device *dev = wdev->netdev;
4215 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4216 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4217 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
4218 eHalStatus status;
4219 tdls_req_params_t pReqMsg = {0};
4220
4221 status = wlan_hdd_validate_context(pHddCtx);
4222 if (0 != status) {
4223 hddLog(VOS_TRACE_LEVEL_ERROR,
4224 FL("HDD context is not valid"));
4225 return -EINVAL;
4226 }
4227 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
4228
4229 return -ENOTSUPP;
4230 }
4231 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
4232 data, data_len,
4233 wlan_hdd_tdls_config_enable_policy)) {
4234 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4235 return -EINVAL;
4236 }
4237
4238 /* Parse and fetch mac address */
4239 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
4240 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4241 return -EINVAL;
4242 }
4243
4244 memcpy(peer, nla_data(
4245 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
4246 sizeof(peer));
4247 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4248
4249 /* Parse and fetch channel */
4250 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
4251 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4252 return -EINVAL;
4253 }
4254 pReqMsg.channel = nla_get_s32(
4255 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
4256 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
4257
4258 /* Parse and fetch global operating class */
4259 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
4260 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
4261 return -EINVAL;
4262 }
4263 pReqMsg.global_operating_class = nla_get_s32(
4264 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
4265 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
4266 pReqMsg.global_operating_class);
4267
4268 /* Parse and fetch latency ms */
4269 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
4270 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
4271 return -EINVAL;
4272 }
4273 pReqMsg.max_latency_ms = nla_get_s32(
4274 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
4275 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
4276 pReqMsg.max_latency_ms);
4277
4278 /* Parse and fetch required bandwidth kbps */
4279 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
4280 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
4281 return -EINVAL;
4282 }
4283
4284 pReqMsg.min_bandwidth_kbps = nla_get_s32(
4285 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
4286 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
4287 pReqMsg.min_bandwidth_kbps);
4288
4289 return (wlan_hdd_tdls_extctrl_config_peer(pAdapter,
4290 peer,
4291 wlan_hdd_cfg80211_exttdls_callback));
4292}
4293
4294static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
4295 struct wireless_dev *wdev,
4296 void *data,
4297 int data_len)
4298{
4299 u8 peer[6] = {0};
4300 struct net_device *dev = wdev->netdev;
4301 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4302 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4303 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
4304 eHalStatus status;
4305
4306 status = wlan_hdd_validate_context(pHddCtx);
4307 if (0 != status) {
4308 hddLog(VOS_TRACE_LEVEL_ERROR,
4309 FL("HDD context is not valid"));
4310 return -EINVAL;
4311 }
4312 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
4313
4314 return -ENOTSUPP;
4315 }
4316 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
4317 data, data_len,
4318 wlan_hdd_tdls_config_disable_policy)) {
4319 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4320 return -EINVAL;
4321 }
4322 /* Parse and fetch mac address */
4323 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
4324 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4325 return -EINVAL;
4326 }
4327
4328 memcpy(peer, nla_data(
4329 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
4330 sizeof(peer));
4331 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4332
4333 return (wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer));
4334}
4335
Dasari Srinivas7875a302014-09-26 17:50:57 +05304336static int
4337wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
4338 struct wireless_dev *wdev,
4339 void *data, int data_len)
4340{
4341 struct net_device *dev = wdev->netdev;
4342 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4343 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4344 struct sk_buff *skb = NULL;
4345 tANI_U32 fset = 0;
4346
4347 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
4348 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
4349 fset |= WIFI_FEATURE_INFRA;
4350 }
4351
4352 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
4353 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
4354 fset |= WIFI_FEATURE_INFRA_5G;
4355 }
4356
4357#ifdef WLAN_FEATURE_P2P
4358 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
4359 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
4360 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
4361 fset |= WIFI_FEATURE_P2P;
4362 }
4363#endif
4364
4365 /* Soft-AP is supported currently by default */
4366 fset |= WIFI_FEATURE_SOFT_AP;
4367
4368#ifdef WLAN_FEATURE_EXTSCAN
4369 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
4370 sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) {
4371 hddLog(LOG1, FL("EXTScan is supported by firmware"));
4372 fset |= WIFI_FEATURE_EXTSCAN;
4373 }
4374#endif
4375
4376#ifdef WLAN_FEATURE_NAN
4377 if (sme_IsFeatureSupportedByFW(NAN)) {
4378 hddLog(LOG1, FL("NAN is supported by firmware"));
4379 fset |= WIFI_FEATURE_NAN;
4380 }
4381#endif
4382
4383 /* D2D RTT is not supported currently by default */
4384 if (sme_IsFeatureSupportedByFW(RTT)) {
4385 hddLog(LOG1, FL("RTT is supported by firmware"));
4386 fset |= WIFI_FEATURE_D2AP_RTT;
4387 }
4388
4389#ifdef FEATURE_WLAN_BATCH_SCAN
4390 if (fset & WIFI_FEATURE_EXTSCAN) {
4391 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
4392 fset &= ~WIFI_FEATURE_BATCH_SCAN;
4393 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
4394 hddLog(LOG1, FL("Batch scan is supported by firmware"));
4395 fset |= WIFI_FEATURE_BATCH_SCAN;
4396 }
4397#endif
4398
4399#ifdef FEATURE_WLAN_SCAN_PNO
4400 if (pHddCtx->cfg_ini->configPNOScanSupport &&
4401 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
4402 hddLog(LOG1, FL("PNO is supported by firmware"));
4403 fset |= WIFI_FEATURE_PNO;
4404 }
4405#endif
4406
4407 /* STA+STA is supported currently by default */
4408 fset |= WIFI_FEATURE_ADDITIONAL_STA;
4409
4410#ifdef FEATURE_WLAN_TDLS
4411 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
4412 sme_IsFeatureSupportedByFW(TDLS)) {
4413 hddLog(LOG1, FL("TDLS is supported by firmware"));
4414 fset |= WIFI_FEATURE_TDLS;
4415 }
4416
4417 /* TDLS_OFFCHANNEL is not supported currently by default */
4418#endif
4419
4420#ifdef WLAN_AP_STA_CONCURRENCY
4421 /* AP+STA concurrency is supported currently by default */
4422 fset |= WIFI_FEATURE_AP_STA;
4423#endif
4424
4425 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
4426 NLMSG_HDRLEN);
4427
4428 if (!skb) {
4429 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
4430 return -EINVAL;
4431 }
4432 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
4433
4434 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
4435 hddLog(LOGE, FL("nla put fail"));
4436 goto nla_put_failure;
4437 }
4438
4439 return cfg80211_vendor_cmd_reply(skb);
4440
4441nla_put_failure:
4442 kfree_skb(skb);
4443 return -EINVAL;
4444}
4445
Agarwal Ashish738843c2014-09-25 12:27:56 +05304446static const struct nla_policy
4447wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
4448 +1] =
4449{
4450 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
4451};
4452
4453static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
4454 struct wireless_dev *wdev,
4455 void *data,
4456 int data_len)
4457{
4458 struct net_device *dev = wdev->netdev;
4459 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4460 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4461 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4462 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
4463 eHalStatus status;
4464 u32 dfsFlag = 0;
4465
4466 status = wlan_hdd_validate_context(pHddCtx);
4467 if (0 != status) {
4468 hddLog(VOS_TRACE_LEVEL_ERROR,
4469 FL("HDD context is not valid"));
4470 return -EINVAL;
4471 }
4472 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
4473 data, data_len,
4474 wlan_hdd_set_no_dfs_flag_config_policy)) {
4475 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4476 return -EINVAL;
4477 }
4478
4479 /* Parse and fetch required bandwidth kbps */
4480 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
4481 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
4482 return -EINVAL;
4483 }
4484
4485 dfsFlag = nla_get_u32(
4486 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
4487 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
4488 dfsFlag);
4489
4490 pHddCtx->disable_dfs_flag = dfsFlag;
4491
4492 sme_disable_dfs_channel(hHal, dfsFlag);
4493 sme_FilterScanResults(hHal, pAdapter->sessionId);
4494 return 0;
4495}
Atul Mittal115287b2014-07-08 13:26:33 +05304496
Sunil Duttc69bccb2014-05-26 21:30:20 +05304497const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
4498{
4499#ifdef WLAN_FEATURE_LINK_LAYER_STATS
4500 {
4501 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4502 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
4503 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4504 WIPHY_VENDOR_CMD_NEED_NETDEV |
4505 WIPHY_VENDOR_CMD_NEED_RUNNING,
4506 .doit = wlan_hdd_cfg80211_ll_stats_clear
4507 },
4508
4509 {
4510 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4511 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
4512 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4513 WIPHY_VENDOR_CMD_NEED_NETDEV |
4514 WIPHY_VENDOR_CMD_NEED_RUNNING,
4515 .doit = wlan_hdd_cfg80211_ll_stats_set
4516 },
4517
4518 {
4519 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4520 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
4521 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4522 WIPHY_VENDOR_CMD_NEED_NETDEV |
4523 WIPHY_VENDOR_CMD_NEED_RUNNING,
4524 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05304525 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05304526#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05304527#ifdef WLAN_FEATURE_EXTSCAN
4528 {
4529 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4530 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
4531 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4532 WIPHY_VENDOR_CMD_NEED_NETDEV |
4533 WIPHY_VENDOR_CMD_NEED_RUNNING,
4534 .doit = wlan_hdd_cfg80211_extscan_start
4535 },
4536 {
4537 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4538 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
4539 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4540 WIPHY_VENDOR_CMD_NEED_NETDEV |
4541 WIPHY_VENDOR_CMD_NEED_RUNNING,
4542 .doit = wlan_hdd_cfg80211_extscan_stop
4543 },
4544 {
4545 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4546 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
4547 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4548 WIPHY_VENDOR_CMD_NEED_NETDEV,
4549 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
4550 },
4551 {
4552 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4553 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
4554 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4555 WIPHY_VENDOR_CMD_NEED_NETDEV |
4556 WIPHY_VENDOR_CMD_NEED_RUNNING,
4557 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
4558 },
4559 {
4560 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4561 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
4562 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4563 WIPHY_VENDOR_CMD_NEED_NETDEV |
4564 WIPHY_VENDOR_CMD_NEED_RUNNING,
4565 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
4566 },
4567 {
4568 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4569 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
4570 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4571 WIPHY_VENDOR_CMD_NEED_NETDEV |
4572 WIPHY_VENDOR_CMD_NEED_RUNNING,
4573 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
4574 },
4575 {
4576 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4577 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
4578 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4579 WIPHY_VENDOR_CMD_NEED_NETDEV |
4580 WIPHY_VENDOR_CMD_NEED_RUNNING,
4581 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
4582 },
4583 {
4584 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4585 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE,
4586 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4587 WIPHY_VENDOR_CMD_NEED_NETDEV |
4588 WIPHY_VENDOR_CMD_NEED_RUNNING,
4589 .doit = wlan_hdd_cfg80211_extscan_set_significant_change
4590 },
4591 {
4592 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4593 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE,
4594 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4595 WIPHY_VENDOR_CMD_NEED_NETDEV |
4596 WIPHY_VENDOR_CMD_NEED_RUNNING,
4597 .doit = wlan_hdd_cfg80211_extscan_reset_significant_change
4598 },
4599#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05304600/*EXT TDLS*/
4601 {
4602 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4603 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
4604 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4605 WIPHY_VENDOR_CMD_NEED_NETDEV |
4606 WIPHY_VENDOR_CMD_NEED_RUNNING,
4607 .doit = wlan_hdd_cfg80211_exttdls_enable
4608 },
4609 {
4610 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4611 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
4612 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4613 WIPHY_VENDOR_CMD_NEED_NETDEV |
4614 WIPHY_VENDOR_CMD_NEED_RUNNING,
4615 .doit = wlan_hdd_cfg80211_exttdls_disable
4616 },
4617 {
4618 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4619 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
4620 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4621 WIPHY_VENDOR_CMD_NEED_NETDEV,
4622 .doit = wlan_hdd_cfg80211_exttdls_get_status
4623 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05304624 {
4625 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4626 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
4627 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4628 WIPHY_VENDOR_CMD_NEED_NETDEV,
4629 .doit = wlan_hdd_cfg80211_get_supported_features
4630 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05304631 {
4632 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4633 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
4634 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4635 WIPHY_VENDOR_CMD_NEED_NETDEV,
4636 .doit = wlan_hdd_cfg80211_disable_dfs_channels
4637 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304638 {
4639 .info.vendor_id = QCA_NL80211_VENDOR_ID,
4640 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
4641 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
4642 WIPHY_VENDOR_CMD_NEED_NETDEV,
4643 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
4644 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05304645};
4646
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08004647/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05304648static const
4649struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08004650{
4651#ifdef FEATURE_WLAN_CH_AVOID
4652 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05304653 .vendor_id = QCA_NL80211_VENDOR_ID,
4654 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08004655 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05304656#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
4657#ifdef WLAN_FEATURE_LINK_LAYER_STATS
4658 {
4659 /* Index = 1*/
4660 .vendor_id = QCA_NL80211_VENDOR_ID,
4661 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
4662 },
4663 {
4664 /* Index = 2*/
4665 .vendor_id = QCA_NL80211_VENDOR_ID,
4666 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
4667 },
4668 {
4669 /* Index = 3*/
4670 .vendor_id = QCA_NL80211_VENDOR_ID,
4671 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
4672 },
4673 {
4674 /* Index = 4*/
4675 .vendor_id = QCA_NL80211_VENDOR_ID,
4676 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
4677 },
4678 {
4679 /* Index = 5*/
4680 .vendor_id = QCA_NL80211_VENDOR_ID,
4681 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
4682 },
4683 {
4684 /* Index = 6*/
4685 .vendor_id = QCA_NL80211_VENDOR_ID,
4686 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
4687 },
4688#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05304689#ifdef WLAN_FEATURE_EXTSCAN
4690 {
4691 .vendor_id = QCA_NL80211_VENDOR_ID,
4692 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
4693 },
4694 {
4695 .vendor_id = QCA_NL80211_VENDOR_ID,
4696 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
4697 },
4698 {
4699 .vendor_id = QCA_NL80211_VENDOR_ID,
4700 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
4701 },
4702 {
4703 .vendor_id = QCA_NL80211_VENDOR_ID,
4704 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
4705 },
4706 {
4707 .vendor_id = QCA_NL80211_VENDOR_ID,
4708 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
4709 },
4710 {
4711 .vendor_id = QCA_NL80211_VENDOR_ID,
4712 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
4713 },
4714 {
4715 .vendor_id = QCA_NL80211_VENDOR_ID,
4716 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
4717 },
4718 {
4719 .vendor_id = QCA_NL80211_VENDOR_ID,
4720 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
4721 },
4722 {
4723 .vendor_id = QCA_NL80211_VENDOR_ID,
4724 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
4725 },
4726 {
4727 .vendor_id = QCA_NL80211_VENDOR_ID,
4728 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
4729 },
4730 {
4731 .vendor_id = QCA_NL80211_VENDOR_ID,
4732 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE
4733 },
4734 {
4735 .vendor_id = QCA_NL80211_VENDOR_ID,
4736 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE
4737 },
4738 {
4739 .vendor_id = QCA_NL80211_VENDOR_ID,
4740 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE
4741 },
4742#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05304743/*EXT TDLS*/
4744 {
4745 .vendor_id = QCA_NL80211_VENDOR_ID,
4746 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
4747 },
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08004748};
4749
Jeff Johnson295189b2012-06-20 16:38:30 -07004750/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05304751 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304752 * This function is called by hdd_wlan_startup()
4753 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05304754 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07004755 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05304756struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07004757{
4758 struct wiphy *wiphy;
4759 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304760 /*
4761 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07004762 */
4763 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
4764
4765 if (!wiphy)
4766 {
4767 /* Print error and jump into err label and free the memory */
4768 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
4769 return NULL;
4770 }
4771
Sunil Duttc69bccb2014-05-26 21:30:20 +05304772
Jeff Johnson295189b2012-06-20 16:38:30 -07004773 return wiphy;
4774}
4775
4776/*
4777 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304778 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07004779 * private ioctl to change the band value
4780 */
4781int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
4782{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05304783 int i, j;
4784 eNVChannelEnabledType channelEnabledState;
4785
Jeff Johnsone7245742012-09-05 17:12:55 -07004786 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304787
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05304788 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07004789 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05304790
4791 if (NULL == wiphy->bands[i])
4792 {
4793 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
4794 __func__, i);
4795 continue;
4796 }
4797
4798 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
4799 {
4800 struct ieee80211_supported_band *band = wiphy->bands[i];
4801
4802 channelEnabledState = vos_nv_getChannelEnabledState(
4803 band->channels[j].hw_value);
4804
4805 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
4806 {
4807 // Enable Social channels for P2P
4808 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq) &&
4809 NV_CHANNEL_ENABLE == channelEnabledState)
4810 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
4811 else
4812 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
4813 continue;
4814 }
4815 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
4816 {
4817 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
4818 continue;
4819 }
4820
4821 if (NV_CHANNEL_DISABLE == channelEnabledState ||
4822 NV_CHANNEL_INVALID == channelEnabledState)
4823 {
4824 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
4825 }
4826 else if (NV_CHANNEL_DFS == channelEnabledState)
4827 {
4828 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
4829 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
4830 }
4831 else
4832 {
4833 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
4834 |IEEE80211_CHAN_RADAR);
4835 }
4836 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004837 }
4838 return 0;
4839}
4840/*
4841 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304842 * This function is called by hdd_wlan_startup()
4843 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07004844 * This function is used to initialize and register wiphy structure.
4845 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05304846int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004847 struct wiphy *wiphy,
4848 hdd_config_t *pCfg
4849 )
4850{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05304851 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05304852 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4853
Jeff Johnsone7245742012-09-05 17:12:55 -07004854 ENTER();
4855
Jeff Johnson295189b2012-06-20 16:38:30 -07004856 /* Now bind the underlying wlan device with wiphy */
4857 set_wiphy_dev(wiphy, dev);
4858
4859 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07004860
Kiet Lam6c583332013-10-14 05:37:09 +05304861#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07004862 /* the flag for the other case would be initialzed in
4863 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07004864 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05304865#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07004866
Amar Singhalfddc28c2013-09-05 13:03:40 -07004867 /* This will disable updating of NL channels from passive to
4868 * active if a beacon is received on passive channel. */
4869 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Amar Singhalf0073192013-09-20 12:34:56 -07004870
Amar Singhalfddc28c2013-09-05 13:03:40 -07004871
Amar Singhala49cbc52013-10-08 18:37:44 -07004872
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004873#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004874 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
4875 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
4876 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07004877 | WIPHY_FLAG_OFFCHAN_TX;
Kiet Lam6c583332013-10-14 05:37:09 +05304878 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004879#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07004880
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004881#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07004882 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08004883#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07004884 || pCfg->isFastRoamIniFeatureEnabled
4885#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004886#ifdef FEATURE_WLAN_ESE
4887 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07004888#endif
4889 )
4890 {
4891 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
4892 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08004893#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004894#ifdef FEATURE_WLAN_TDLS
4895 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
4896 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
4897#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05304898#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05304899 if (pCfg->configPNOScanSupport)
4900 {
4901 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
4902 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
4903 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
4904 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
4905 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05304906#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004907
Amar Singhalfddc28c2013-09-05 13:03:40 -07004908#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07004909 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
4910 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07004911 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07004912 driver need to determine what to do with both
4913 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07004914
4915 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07004916#else
4917 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07004918#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004919
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304920 wiphy->max_scan_ssids = MAX_SCAN_SSID;
4921
Madan Mohan Koyyalamudi6815b162013-07-19 17:17:46 +05304922 wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07004923
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05304924 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
4925
Jeff Johnson295189b2012-06-20 16:38:30 -07004926 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304927 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07004928 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -07004929 | BIT(NL80211_IFTYPE_P2P_CLIENT)
4930 | BIT(NL80211_IFTYPE_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07004931 | BIT(NL80211_IFTYPE_AP);
4932
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05304933 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08004934 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05304935#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
4936 if( pCfg->enableMCC )
4937 {
4938 /* Currently, supports up to two channels */
4939 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08004940
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05304941 if( !pCfg->allowMCCGODiffBI )
4942 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08004943
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05304944 }
4945 wiphy->iface_combinations = &wlan_hdd_iface_combination;
4946 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08004947#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05304948 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08004949
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 /* Before registering we need to update the ht capabilitied based
4951 * on ini values*/
4952 if( !pCfg->ShortGI20MhzEnable )
4953 {
4954 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
4955 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
4956 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
4957 }
4958
4959 if( !pCfg->ShortGI40MhzEnable )
4960 {
4961 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
4962 }
4963
4964 if( !pCfg->nChannelBondingMode5GHz )
4965 {
4966 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
4967 }
4968
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05304969 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05304970 if (true == hdd_is_5g_supported(pHddCtx))
4971 {
4972 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
4973 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05304974
4975 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
4976 {
4977
4978 if (NULL == wiphy->bands[i])
4979 {
4980 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
4981 __func__, i);
4982 continue;
4983 }
4984
4985 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
4986 {
4987 struct ieee80211_supported_band *band = wiphy->bands[i];
4988
4989 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
4990 {
4991 // Enable social channels for P2P
4992 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
4993 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
4994 else
4995 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
4996 continue;
4997 }
4998 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
4999 {
5000 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5001 continue;
5002 }
5003 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005004 }
5005 /*Initialise the supported cipher suite details*/
5006 wiphy->cipher_suites = hdd_cipher_suites;
5007 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
5008
5009 /*signal strength in mBm (100*dBm) */
5010 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
5011
5012#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05305013 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07005014#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005015
Sunil Duttc69bccb2014-05-26 21:30:20 +05305016 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
5017 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005018 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
5019 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
5020
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305021 EXIT();
5022 return 0;
5023}
5024
5025/* In this function we are registering wiphy. */
5026int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
5027{
5028 ENTER();
5029 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005030 if (0 > wiphy_register(wiphy))
5031 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305032 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07005033 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
5034 return -EIO;
5035 }
5036
5037 EXIT();
5038 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305039}
Jeff Johnson295189b2012-06-20 16:38:30 -07005040
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305041/* In this function we are updating channel list when,
5042 regulatory domain is FCC and country code is US.
5043 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
5044 As per FCC smart phone is not a indoor device.
5045 GO should not opeate on indoor channels */
5046void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
5047{
5048 int j;
5049 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5050 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
5051 //Default counrtycode from NV at the time of wiphy initialization.
5052 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
5053 &defaultCountryCode[0]))
5054 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005055 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305056 }
5057 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
5058 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305059 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
5060 {
5061 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
5062 return;
5063 }
5064 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
5065 {
5066 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
5067 // Mark UNII -1 band channel as passive
5068 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
5069 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
5070 }
5071 }
5072}
5073
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05305074/* This function registers for all frame which supplicant is interested in */
5075void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005076{
Jeff Johnson295189b2012-06-20 16:38:30 -07005077 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5078 /* Register for all P2P action, public action etc frames */
5079 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
5080
Jeff Johnsone7245742012-09-05 17:12:55 -07005081 ENTER();
5082
Jeff Johnson295189b2012-06-20 16:38:30 -07005083 /* Right now we are registering these frame when driver is getting
5084 initialized. Once we will move to 2.6.37 kernel, in which we have
5085 frame register ops, we will move this code as a part of that */
5086 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305087 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07005088 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
5089
5090 /* GAS Initial Response */
5091 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5092 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305093
Jeff Johnson295189b2012-06-20 16:38:30 -07005094 /* GAS Comeback Request */
5095 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5096 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
5097
5098 /* GAS Comeback Response */
5099 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5100 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
5101
5102 /* P2P Public Action */
5103 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305104 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07005105 P2P_PUBLIC_ACTION_FRAME_SIZE );
5106
5107 /* P2P Action */
5108 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5109 (v_U8_t*)P2P_ACTION_FRAME,
5110 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07005111
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05305112 /* WNM BSS Transition Request frame */
5113 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5114 (v_U8_t*)WNM_BSS_ACTION_FRAME,
5115 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07005116
5117 /* WNM-Notification */
5118 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5119 (v_U8_t*)WNM_NOTIFICATION_FRAME,
5120 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005121}
5122
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05305123void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005124{
Jeff Johnson295189b2012-06-20 16:38:30 -07005125 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5126 /* Register for all P2P action, public action etc frames */
5127 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
5128
Jeff Johnsone7245742012-09-05 17:12:55 -07005129 ENTER();
5130
Jeff Johnson295189b2012-06-20 16:38:30 -07005131 /* Right now we are registering these frame when driver is getting
5132 initialized. Once we will move to 2.6.37 kernel, in which we have
5133 frame register ops, we will move this code as a part of that */
5134 /* GAS Initial Request */
5135
5136 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5137 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
5138
5139 /* GAS Initial Response */
5140 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5141 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305142
Jeff Johnson295189b2012-06-20 16:38:30 -07005143 /* GAS Comeback Request */
5144 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5145 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
5146
5147 /* GAS Comeback Response */
5148 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5149 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
5150
5151 /* P2P Public Action */
5152 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305153 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07005154 P2P_PUBLIC_ACTION_FRAME_SIZE );
5155
5156 /* P2P Action */
5157 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5158 (v_U8_t*)P2P_ACTION_FRAME,
5159 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07005160 /* WNM-Notification */
5161 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5162 (v_U8_t*)WNM_NOTIFICATION_FRAME,
5163 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005164}
5165
5166#ifdef FEATURE_WLAN_WAPI
5167void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
5168 const u8 *mac_addr, u8 *key , int key_Len)
5169{
5170 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5171 tCsrRoamSetKey setKey;
5172 v_BOOL_t isConnected = TRUE;
5173 int status = 0;
5174 v_U32_t roamId= 0xFF;
5175 tANI_U8 *pKeyPtr = NULL;
5176 int n = 0;
5177
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305178 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
5179 __func__, hdd_device_modetoString(pAdapter->device_mode),
5180 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005181
Gopichand Nakkalae7480202013-02-11 15:24:22 +05305182 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07005183 setKey.keyId = key_index; // Store Key ID
5184 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
5185 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
5186 setKey.paeRole = 0 ; // the PAE role
5187 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
5188 {
5189 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
5190 }
5191 else
5192 {
5193 isConnected = hdd_connIsConnected(pHddStaCtx);
5194 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
5195 }
5196 setKey.keyLength = key_Len;
5197 pKeyPtr = setKey.Key;
5198 memcpy( pKeyPtr, key, key_Len);
5199
Arif Hussain6d2a3322013-11-17 19:50:10 -08005200 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07005201 __func__, key_Len);
5202 for (n = 0 ; n < key_Len; n++)
5203 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
5204 __func__,n,setKey.Key[n]);
5205
5206 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5207 if ( isConnected )
5208 {
5209 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
5210 pAdapter->sessionId, &setKey, &roamId );
5211 }
5212 if ( status != 0 )
5213 {
5214 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5215 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5216 __LINE__, status );
5217 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5218 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05305219 /* Need to clear any trace of key value in the memory.
5220 * Thus zero out the memory even though it is local
5221 * variable.
5222 */
5223 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07005224}
5225#endif /* FEATURE_WLAN_WAPI*/
5226
5227#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305228int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005229 beacon_data_t **ppBeacon,
5230 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005231#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305232int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005233 beacon_data_t **ppBeacon,
5234 struct cfg80211_beacon_data *params,
5235 int dtim_period)
5236#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305237{
Jeff Johnson295189b2012-06-20 16:38:30 -07005238 int size;
5239 beacon_data_t *beacon = NULL;
5240 beacon_data_t *old = NULL;
5241 int head_len,tail_len;
5242
Jeff Johnsone7245742012-09-05 17:12:55 -07005243 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07005244 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305245 {
5246 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5247 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005248 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305249 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005250
5251 old = pAdapter->sessionCtx.ap.beacon;
5252
5253 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305254 {
5255 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5256 FL("session(%d) old and new heads points to NULL"),
5257 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005258 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305259 }
5260
5261 if (params->tail && !params->tail_len)
5262 {
5263 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5264 FL("tail_len is zero but tail is not NULL"));
5265 return -EINVAL;
5266 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005267
Jeff Johnson295189b2012-06-20 16:38:30 -07005268#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
5269 /* Kernel 3.0 is not updating dtim_period for set beacon */
5270 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305271 {
5272 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5273 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005274 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305275 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005276#endif
5277
5278 if(params->head)
5279 head_len = params->head_len;
5280 else
5281 head_len = old->head_len;
5282
5283 if(params->tail || !old)
5284 tail_len = params->tail_len;
5285 else
5286 tail_len = old->tail_len;
5287
5288 size = sizeof(beacon_data_t) + head_len + tail_len;
5289
5290 beacon = kzalloc(size, GFP_KERNEL);
5291
5292 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305293 {
5294 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5295 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005296 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305297 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005298
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005299#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07005300 if(params->dtim_period || !old )
5301 beacon->dtim_period = params->dtim_period;
5302 else
5303 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005304#else
5305 if(dtim_period || !old )
5306 beacon->dtim_period = dtim_period;
5307 else
5308 beacon->dtim_period = old->dtim_period;
5309#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305310
Jeff Johnson295189b2012-06-20 16:38:30 -07005311 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
5312 beacon->tail = beacon->head + head_len;
5313 beacon->head_len = head_len;
5314 beacon->tail_len = tail_len;
5315
5316 if(params->head) {
5317 memcpy (beacon->head,params->head,beacon->head_len);
5318 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305319 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07005320 if(old)
5321 memcpy (beacon->head,old->head,beacon->head_len);
5322 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305323
Jeff Johnson295189b2012-06-20 16:38:30 -07005324 if(params->tail) {
5325 memcpy (beacon->tail,params->tail,beacon->tail_len);
5326 }
5327 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305328 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07005329 memcpy (beacon->tail,old->tail,beacon->tail_len);
5330 }
5331
5332 *ppBeacon = beacon;
5333
5334 kfree(old);
5335
5336 return 0;
5337
5338}
Jeff Johnson295189b2012-06-20 16:38:30 -07005339
5340v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
5341{
5342 int left = length;
5343 v_U8_t *ptr = pIes;
5344 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305345
Jeff Johnson295189b2012-06-20 16:38:30 -07005346 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305347 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005348 elem_id = ptr[0];
5349 elem_len = ptr[1];
5350 left -= 2;
5351 if(elem_len > left)
5352 {
5353 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07005354 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005355 eid,elem_len,left);
5356 return NULL;
5357 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305358 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07005359 {
5360 return ptr;
5361 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305362
Jeff Johnson295189b2012-06-20 16:38:30 -07005363 left -= elem_len;
5364 ptr += (elem_len + 2);
5365 }
5366 return NULL;
5367}
5368
Jeff Johnson295189b2012-06-20 16:38:30 -07005369/* Check if rate is 11g rate or not */
5370static int wlan_hdd_rate_is_11g(u8 rate)
5371{
Sanjay Devnani28322e22013-06-21 16:13:40 -07005372 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005373 u8 i;
5374 for (i = 0; i < 8; i++)
5375 {
5376 if(rate == gRateArray[i])
5377 return TRUE;
5378 }
5379 return FALSE;
5380}
5381
5382/* Check for 11g rate and set proper 11g only mode */
5383static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
5384 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
5385{
5386 u8 i, num_rates = pIe[0];
5387
5388 pIe += 1;
5389 for ( i = 0; i < num_rates; i++)
5390 {
5391 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
5392 {
5393 /* If rate set have 11g rate than change the mode to 11G */
5394 *pSapHw_mode = eSAP_DOT11_MODE_11g;
5395 if (pIe[i] & BASIC_RATE_MASK)
5396 {
5397 /* If we have 11g rate as basic rate, it means mode
5398 is 11g only mode.
5399 */
5400 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
5401 *pCheckRatesfor11g = FALSE;
5402 }
5403 }
5404 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
5405 {
5406 *require_ht = TRUE;
5407 }
5408 }
5409 return;
5410}
5411
5412static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
5413{
5414 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
5415 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
5416 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
5417 u8 checkRatesfor11g = TRUE;
5418 u8 require_ht = FALSE;
5419 u8 *pIe=NULL;
5420
5421 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
5422
5423 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
5424 pBeacon->head_len, WLAN_EID_SUPP_RATES);
5425 if (pIe != NULL)
5426 {
5427 pIe += 1;
5428 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
5429 &pConfig->SapHw_mode);
5430 }
5431
5432 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
5433 WLAN_EID_EXT_SUPP_RATES);
5434 if (pIe != NULL)
5435 {
5436
5437 pIe += 1;
5438 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
5439 &pConfig->SapHw_mode);
5440 }
5441
5442 if( pConfig->channel > 14 )
5443 {
5444 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
5445 }
5446
5447 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
5448 WLAN_EID_HT_CAPABILITY);
5449
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305450 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07005451 {
5452 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
5453 if(require_ht)
5454 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
5455 }
5456}
5457
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305458static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
5459 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
5460{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07005461 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305462 v_U8_t *pIe = NULL;
5463 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
5464
5465 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
5466 pBeacon->tail, pBeacon->tail_len);
5467
5468 if (pIe)
5469 {
5470 ielen = pIe[1] + 2;
5471 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
5472 {
5473 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
5474 }
5475 else
5476 {
5477 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
5478 return -EINVAL;
5479 }
5480 *total_ielen += ielen;
5481 }
5482 return 0;
5483}
5484
Arif Hussaine7f3ea52013-09-12 21:56:36 -07005485static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
5486 v_U8_t *genie, v_U8_t *total_ielen)
5487{
5488 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
5489 int left = pBeacon->tail_len;
5490 v_U8_t *ptr = pBeacon->tail;
5491 v_U8_t elem_id, elem_len;
5492 v_U16_t ielen = 0;
5493
5494 if ( NULL == ptr || 0 == left )
5495 return;
5496
5497 while (left >= 2)
5498 {
5499 elem_id = ptr[0];
5500 elem_len = ptr[1];
5501 left -= 2;
5502 if (elem_len > left)
5503 {
5504 hddLog( VOS_TRACE_LEVEL_ERROR,
5505 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
5506 elem_id, elem_len, left);
5507 return;
5508 }
5509 if (IE_EID_VENDOR == elem_id)
5510 {
5511 /* skipping the VSIE's which we don't want to include or
5512 * it will be included by existing code
5513 */
5514 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
5515#ifdef WLAN_FEATURE_WFD
5516 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
5517#endif
5518 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
5519 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
5520 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
5521 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
5522 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
5523 {
5524 ielen = ptr[1] + 2;
5525 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
5526 {
5527 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
5528 *total_ielen += ielen;
5529 }
5530 else
5531 {
5532 hddLog( VOS_TRACE_LEVEL_ERROR,
5533 "IE Length is too big "
5534 "IEs eid=%d elem_len=%d total_ie_lent=%d",
5535 elem_id, elem_len, *total_ielen);
5536 }
5537 }
5538 }
5539
5540 left -= elem_len;
5541 ptr += (elem_len + 2);
5542 }
5543 return;
5544}
5545
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005546#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07005547static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
5548 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005549#else
5550static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
5551 struct cfg80211_beacon_data *params)
5552#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005553{
5554 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305555 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005556 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07005557 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005558
5559 genie = vos_mem_malloc(MAX_GENIE_LEN);
5560
5561 if(genie == NULL) {
5562
5563 return -ENOMEM;
5564 }
5565
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305566 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
5567 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005568 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305569 hddLog(LOGE,
5570 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305571 ret = -EINVAL;
5572 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005573 }
5574
5575#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305576 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
5577 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
5578 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305579 hddLog(LOGE,
5580 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305581 ret = -EINVAL;
5582 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005583 }
5584#endif
5585
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305586 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
5587 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005588 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305589 hddLog(LOGE,
5590 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305591 ret = -EINVAL;
5592 goto done;
5593 }
5594
5595 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
5596 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07005597 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005598 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005599
5600 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5601 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
5602 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
5603 {
5604 hddLog(LOGE,
5605 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005606 ret = -EINVAL;
5607 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005608 }
5609
5610 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5611 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
5612 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
5613 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
5614 ==eHAL_STATUS_FAILURE)
5615 {
5616 hddLog(LOGE,
5617 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005618 ret = -EINVAL;
5619 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005620 }
5621
5622 // Added for ProResp IE
5623 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
5624 {
5625 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
5626 u8 probe_rsp_ie_len[3] = {0};
5627 u8 counter = 0;
5628 /* Check Probe Resp Length if it is greater then 255 then Store
5629 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
5630 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
5631 Store More then 255 bytes into One Variable.
5632 */
5633 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
5634 {
5635 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
5636 {
5637 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
5638 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
5639 }
5640 else
5641 {
5642 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
5643 rem_probe_resp_ie_len = 0;
5644 }
5645 }
5646
5647 rem_probe_resp_ie_len = 0;
5648
5649 if (probe_rsp_ie_len[0] > 0)
5650 {
5651 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5652 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
5653 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
5654 probe_rsp_ie_len[0], NULL,
5655 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5656 {
5657 hddLog(LOGE,
5658 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005659 ret = -EINVAL;
5660 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005661 }
5662 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
5663 }
5664
5665 if (probe_rsp_ie_len[1] > 0)
5666 {
5667 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5668 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
5669 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
5670 probe_rsp_ie_len[1], NULL,
5671 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5672 {
5673 hddLog(LOGE,
5674 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005675 ret = -EINVAL;
5676 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005677 }
5678 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
5679 }
5680
5681 if (probe_rsp_ie_len[2] > 0)
5682 {
5683 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5684 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
5685 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
5686 probe_rsp_ie_len[2], NULL,
5687 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5688 {
5689 hddLog(LOGE,
5690 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005691 ret = -EINVAL;
5692 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005693 }
5694 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
5695 }
5696
5697 if (probe_rsp_ie_len[1] == 0 )
5698 {
5699 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5700 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
5701 eANI_BOOLEAN_FALSE) )
5702 {
5703 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005704 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005705 }
5706 }
5707
5708 if (probe_rsp_ie_len[2] == 0 )
5709 {
5710 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5711 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
5712 eANI_BOOLEAN_FALSE) )
5713 {
5714 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005715 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005716 }
5717 }
5718
5719 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5720 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
5721 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
5722 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
5723 == eHAL_STATUS_FAILURE)
5724 {
5725 hddLog(LOGE,
5726 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005727 ret = -EINVAL;
5728 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005729 }
5730 }
5731 else
5732 {
5733 // Reset WNI_CFG_PROBE_RSP Flags
5734 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
5735
5736 hddLog(VOS_TRACE_LEVEL_INFO,
5737 "%s: No Probe Response IE received in set beacon",
5738 __func__);
5739 }
5740
5741 // Added for AssocResp IE
5742 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
5743 {
5744 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5745 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
5746 params->assocresp_ies_len, NULL,
5747 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5748 {
5749 hddLog(LOGE,
5750 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005751 ret = -EINVAL;
5752 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005753 }
5754
5755 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5756 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
5757 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
5758 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
5759 == eHAL_STATUS_FAILURE)
5760 {
5761 hddLog(LOGE,
5762 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005763 ret = -EINVAL;
5764 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005765 }
5766 }
5767 else
5768 {
5769 hddLog(VOS_TRACE_LEVEL_INFO,
5770 "%s: No Assoc Response IE received in set beacon",
5771 __func__);
5772
5773 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5774 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
5775 eANI_BOOLEAN_FALSE) )
5776 {
5777 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005778 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005779 }
5780 }
5781
Jeff Johnsone7245742012-09-05 17:12:55 -07005782done:
Jeff Johnson295189b2012-06-20 16:38:30 -07005783 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305784 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07005785}
Jeff Johnson295189b2012-06-20 16:38:30 -07005786
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305787/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005788 * FUNCTION: wlan_hdd_validate_operation_channel
5789 * called by wlan_hdd_cfg80211_start_bss() and
5790 * wlan_hdd_cfg80211_set_channel()
5791 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305792 * channel list.
5793 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07005794VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07005795{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305796
Jeff Johnson295189b2012-06-20 16:38:30 -07005797 v_U32_t num_ch = 0;
5798 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
5799 u32 indx = 0;
5800 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05305801 v_U8_t fValidChannel = FALSE, count = 0;
5802 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305803
Jeff Johnson295189b2012-06-20 16:38:30 -07005804 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
5805
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05305806 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07005807 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05305808 /* Validate the channel */
5809 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005810 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05305811 if ( channel == rfChannels[count].channelNum )
5812 {
5813 fValidChannel = TRUE;
5814 break;
5815 }
5816 }
5817 if (fValidChannel != TRUE)
5818 {
5819 hddLog(VOS_TRACE_LEVEL_ERROR,
5820 "%s: Invalid Channel [%d]", __func__, channel);
5821 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005822 }
5823 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05305824 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005825 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05305826 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
5827 valid_ch, &num_ch))
5828 {
5829 hddLog(VOS_TRACE_LEVEL_ERROR,
5830 "%s: failed to get valid channel list", __func__);
5831 return VOS_STATUS_E_FAILURE;
5832 }
5833 for (indx = 0; indx < num_ch; indx++)
5834 {
5835 if (channel == valid_ch[indx])
5836 {
5837 break;
5838 }
5839 }
5840
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05305841 if (indx >= num_ch)
5842 {
5843 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
5844 {
5845 eCsrBand band;
5846 unsigned int freq;
5847
5848 sme_GetFreqBand(hHal, &band);
5849
5850 if (eCSR_BAND_5G == band)
5851 {
5852#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
5853 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
5854 {
5855 freq = ieee80211_channel_to_frequency(channel,
5856 IEEE80211_BAND_2GHZ);
5857 }
5858 else
5859 {
5860 freq = ieee80211_channel_to_frequency(channel,
5861 IEEE80211_BAND_5GHZ);
5862 }
5863#else
5864 freq = ieee80211_channel_to_frequency(channel);
5865#endif
5866 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
5867 return VOS_STATUS_SUCCESS;
5868 }
5869 }
5870
5871 hddLog(VOS_TRACE_LEVEL_ERROR,
5872 "%s: Invalid Channel [%d]", __func__, channel);
5873 return VOS_STATUS_E_FAILURE;
5874 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005875 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05305876
Jeff Johnson295189b2012-06-20 16:38:30 -07005877 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305878
Jeff Johnson295189b2012-06-20 16:38:30 -07005879}
5880
Viral Modi3a32cc52013-02-08 11:14:52 -08005881/**
5882 * FUNCTION: wlan_hdd_cfg80211_set_channel
5883 * This function is used to set the channel number
5884 */
5885static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
5886 struct ieee80211_channel *chan,
5887 enum nl80211_channel_type channel_type
5888 )
5889{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305890 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08005891 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07005892 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08005893 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305894 hdd_context_t *pHddCtx;
5895 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08005896
5897 ENTER();
5898
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305899
Viral Modi3a32cc52013-02-08 11:14:52 -08005900 if( NULL == dev )
5901 {
5902 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005903 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08005904 return -ENODEV;
5905 }
5906 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05305907
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305908 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
5909 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
5910 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08005911 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305912 "%s: device_mode = %s (%d) freq = %d", __func__,
5913 hdd_device_modetoString(pAdapter->device_mode),
5914 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305915
5916 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5917 status = wlan_hdd_validate_context(pHddCtx);
5918
5919 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08005920 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305921 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5922 "%s: HDD context is not valid", __func__);
5923 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08005924 }
5925
5926 /*
5927 * Do freq to chan conversion
5928 * TODO: for 11a
5929 */
5930
5931 channel = ieee80211_frequency_to_channel(freq);
5932
5933 /* Check freq range */
5934 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
5935 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
5936 {
5937 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005938 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08005939 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
5940 WNI_CFG_CURRENT_CHANNEL_STAMAX);
5941 return -EINVAL;
5942 }
5943
5944 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
5945
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05305946 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
5947 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08005948 {
5949 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
5950 {
5951 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005952 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08005953 return -EINVAL;
5954 }
5955 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5956 "%s: set channel to [%d] for device mode =%d",
5957 __func__, channel,pAdapter->device_mode);
5958 }
5959 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08005960 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08005961 )
5962 {
5963 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5964 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
5965 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5966
5967 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
5968 {
5969 /* Link is up then return cant set channel*/
5970 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005971 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08005972 return -EINVAL;
5973 }
5974
5975 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
5976 pHddStaCtx->conn_info.operationChannel = channel;
5977 pRoamProfile->ChannelInfo.ChannelList =
5978 &pHddStaCtx->conn_info.operationChannel;
5979 }
5980 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08005981 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08005982 )
5983 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05305984 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
5985 {
5986 if(VOS_STATUS_SUCCESS !=
5987 wlan_hdd_validate_operation_channel(pAdapter,channel))
5988 {
5989 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005990 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05305991 return -EINVAL;
5992 }
5993 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
5994 }
5995 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08005996 {
5997 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
5998
5999 /* If auto channel selection is configured as enable/ 1 then ignore
6000 channel set by supplicant
6001 */
6002 if ( cfg_param->apAutoChannelSelection )
6003 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306004 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
6005 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08006006 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306007 "%s: set channel to auto channel (0) for device mode =%s (%d)",
6008 __func__, hdd_device_modetoString(pAdapter->device_mode),
6009 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08006010 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306011 else
6012 {
6013 if(VOS_STATUS_SUCCESS !=
6014 wlan_hdd_validate_operation_channel(pAdapter,channel))
6015 {
6016 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006017 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306018 return -EINVAL;
6019 }
6020 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
6021 }
Viral Modi3a32cc52013-02-08 11:14:52 -08006022 }
6023 }
6024 else
6025 {
6026 hddLog(VOS_TRACE_LEVEL_FATAL,
6027 "%s: Invalid device mode failed to set valid channel", __func__);
6028 return -EINVAL;
6029 }
6030 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306031 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006032}
6033
Jeff Johnson295189b2012-06-20 16:38:30 -07006034#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
6035static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6036 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006037#else
6038static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6039 struct cfg80211_beacon_data *params,
6040 const u8 *ssid, size_t ssid_len,
6041 enum nl80211_hidden_ssid hidden_ssid)
6042#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006043{
6044 tsap_Config_t *pConfig;
6045 beacon_data_t *pBeacon = NULL;
6046 struct ieee80211_mgmt *pMgmt_frame;
6047 v_U8_t *pIe=NULL;
6048 v_U16_t capab_info;
6049 eCsrAuthType RSNAuthType;
6050 eCsrEncryptionType RSNEncryptType;
6051 eCsrEncryptionType mcRSNEncryptType;
6052 int status = VOS_STATUS_SUCCESS;
6053 tpWLAN_SAPEventCB pSapEventCallback;
6054 hdd_hostapd_state_t *pHostapdState;
6055 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
6056 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306057 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006058 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306059 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006060 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08006061 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05306062 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07006063 v_BOOL_t MFPCapable = VOS_FALSE;
6064 v_BOOL_t MFPRequired = VOS_FALSE;
Abhishek Singhf0ac1752014-03-05 17:47:09 +05306065 eHddDot11Mode sapDot11Mode =
6066 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07006067
6068 ENTER();
6069
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306070 iniConfig = pHddCtx->cfg_ini;
6071
Jeff Johnson295189b2012-06-20 16:38:30 -07006072 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
6073
6074 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6075
6076 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6077
6078 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
6079
6080 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
6081
6082 //channel is already set in the set_channel Call back
6083 //pConfig->channel = pCommitConfig->channel;
6084
6085 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306086 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07006087 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
6088
6089 pConfig->dtim_period = pBeacon->dtim_period;
6090
Arif Hussain6d2a3322013-11-17 19:50:10 -08006091 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07006092 pConfig->dtim_period);
6093
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08006094 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07006095 {
6096 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006097 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05306098 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
6099 {
6100 tANI_BOOLEAN restartNeeded;
6101 pConfig->ieee80211d = 1;
6102 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
6103 sme_setRegInfo(hHal, pConfig->countryCode);
6104 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
6105 }
6106 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07006107 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07006108 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006109 pConfig->ieee80211d = 1;
6110 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
6111 sme_setRegInfo(hHal, pConfig->countryCode);
6112 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07006113 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07006114 else
6115 {
6116 pConfig->ieee80211d = 0;
6117 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306118 /*
6119 * If auto channel is configured i.e. channel is 0,
6120 * so skip channel validation.
6121 */
6122 if( AUTO_CHANNEL_SELECT != pConfig->channel )
6123 {
6124 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
6125 {
6126 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006127 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306128 return -EINVAL;
6129 }
6130 }
6131 else
6132 {
6133 if(1 != pHddCtx->is_dynamic_channel_range_set)
6134 {
6135 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
6136 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
6137 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
6138 }
6139 pHddCtx->is_dynamic_channel_range_set = 0;
6140 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006141 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07006142 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006143 {
6144 pConfig->ieee80211d = 0;
6145 }
6146 pConfig->authType = eSAP_AUTO_SWITCH;
6147
6148 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306149
6150 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07006151 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
6152
6153 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
6154
6155 /*Set wps station to configured*/
6156 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
6157
6158 if(pIe)
6159 {
6160 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
6161 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006162 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07006163 return -EINVAL;
6164 }
6165 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
6166 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07006167 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07006168 /* Check 15 bit of WPS IE as it contain information for wps state
6169 * WPS state
6170 */
6171 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
6172 {
6173 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
6174 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
6175 {
6176 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
6177 }
6178 }
6179 }
6180 else
6181 {
6182 pConfig->wps_state = SAP_WPS_DISABLED;
6183 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306184 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07006185
c_hpothufe599e92014-06-16 11:38:55 +05306186 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
6187 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
6188 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
6189 eCSR_ENCRYPT_TYPE_NONE;
6190
Jeff Johnson295189b2012-06-20 16:38:30 -07006191 pConfig->RSNWPAReqIELength = 0;
6192 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306193 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006194 WLAN_EID_RSN);
6195 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306196 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006197 pConfig->RSNWPAReqIELength = pIe[1] + 2;
6198 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
6199 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306200 /* The actual processing may eventually be more extensive than
6201 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07006202 * by the app.
6203 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306204 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07006205 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
6206 &RSNEncryptType,
6207 &mcRSNEncryptType,
6208 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08006209 &MFPCapable,
6210 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07006211 pConfig->pRSNWPAReqIE[1]+2,
6212 pConfig->pRSNWPAReqIE );
6213
6214 if( VOS_STATUS_SUCCESS == status )
6215 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306216 /* Now copy over all the security attributes you have
6217 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07006218 * */
6219 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
6220 pConfig->mcRSNEncryptType = mcRSNEncryptType;
6221 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
6222 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05306223 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08006224 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006225 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
6226 }
6227 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306228
Jeff Johnson295189b2012-06-20 16:38:30 -07006229 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
6230 pBeacon->tail, pBeacon->tail_len);
6231
6232 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
6233 {
6234 if (pConfig->pRSNWPAReqIE)
6235 {
6236 /*Mixed mode WPA/WPA2*/
6237 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
6238 pConfig->RSNWPAReqIELength += pIe[1] + 2;
6239 }
6240 else
6241 {
6242 pConfig->RSNWPAReqIELength = pIe[1] + 2;
6243 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
6244 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306245 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07006246 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
6247 &RSNEncryptType,
6248 &mcRSNEncryptType,
6249 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08006250 &MFPCapable,
6251 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07006252 pConfig->pRSNWPAReqIE[1]+2,
6253 pConfig->pRSNWPAReqIE );
6254
6255 if( VOS_STATUS_SUCCESS == status )
6256 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306257 /* Now copy over all the security attributes you have
6258 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07006259 * */
6260 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
6261 pConfig->mcRSNEncryptType = mcRSNEncryptType;
6262 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
6263 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05306264 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08006265 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
6267 }
6268 }
6269 }
6270
Jeff Johnson4416a782013-03-25 14:17:50 -07006271 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
6272 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
6273 return -EINVAL;
6274 }
6275
Jeff Johnson295189b2012-06-20 16:38:30 -07006276 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
6277
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006278#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006279 if (params->ssid != NULL)
6280 {
6281 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
6282 pConfig->SSIDinfo.ssid.length = params->ssid_len;
6283 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
6284 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
6285 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006286#else
6287 if (ssid != NULL)
6288 {
6289 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
6290 pConfig->SSIDinfo.ssid.length = ssid_len;
6291 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
6292 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
6293 }
6294#endif
6295
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306296 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07006297 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306298
Jeff Johnson295189b2012-06-20 16:38:30 -07006299 /* default value */
6300 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
6301 pConfig->num_accept_mac = 0;
6302 pConfig->num_deny_mac = 0;
6303
6304 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
6305 pBeacon->tail, pBeacon->tail_len);
6306
6307 /* pIe for black list is following form:
6308 type : 1 byte
6309 length : 1 byte
6310 OUI : 4 bytes
6311 acl type : 1 byte
6312 no of mac addr in black list: 1 byte
6313 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306314 */
6315 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006316 {
6317 pConfig->SapMacaddr_acl = pIe[6];
6318 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08006319 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006320 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05306321 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
6322 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006323 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
6324 for (i = 0; i < pConfig->num_deny_mac; i++)
6325 {
6326 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
6327 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306328 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006329 }
6330 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
6331 pBeacon->tail, pBeacon->tail_len);
6332
6333 /* pIe for white list is following form:
6334 type : 1 byte
6335 length : 1 byte
6336 OUI : 4 bytes
6337 acl type : 1 byte
6338 no of mac addr in white list: 1 byte
6339 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306340 */
6341 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006342 {
6343 pConfig->SapMacaddr_acl = pIe[6];
6344 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08006345 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006346 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05306347 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
6348 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006349 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
6350 for (i = 0; i < pConfig->num_accept_mac; i++)
6351 {
6352 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
6353 acl_entry++;
6354 }
6355 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05306356
Jeff Johnson295189b2012-06-20 16:38:30 -07006357 wlan_hdd_set_sapHwmode(pHostapdAdapter);
6358
Jeff Johnsone7245742012-09-05 17:12:55 -07006359#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08006360 /* Overwrite the hostapd setting for HW mode only for 11ac.
Kiet Lam0f320422013-11-21 19:29:17 +05306361 * This is valid only if mode is set to 11n in hostapd, either AUTO or
6362 * 11ac in .ini and 11ac is supported by both host and firmware.
6363 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
6364 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08006365 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
6366 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Abhishek Singhf0ac1752014-03-05 17:47:09 +05306367 (( sapDot11Mode == eHDD_DOT11_MODE_AUTO ) ||
6368 ( sapDot11Mode == eHDD_DOT11_MODE_11ac ) ||
6369 ( sapDot11Mode == eHDD_DOT11_MODE_11ac_ONLY ) ) &&
6370 (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
6371 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07006372 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05306373 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07006374 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05306375 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07006376
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306377 /* If ACS disable and selected channel <= 14
6378 * OR
6379 * ACS enabled and ACS operating band is choosen as 2.4
6380 * AND
6381 * VHT in 2.4G Disabled
6382 * THEN
6383 * Fallback to 11N mode
6384 */
6385 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
6386 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05306387 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306388 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07006389 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05306390 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
6391 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07006392 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
6393 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006394 }
6395#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306396
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07006397 if ( AUTO_CHANNEL_SELECT != pConfig->channel )
6398 {
6399 sme_SelectCBMode(hHal,
6400 sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode),
6401 pConfig->channel);
6402 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006403 // ht_capab is not what the name conveys,this is used for protection bitmap
6404 pConfig->ht_capab =
6405 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
6406
6407 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
6408 {
6409 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
6410 return -EINVAL;
6411 }
6412
6413 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306414 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07006415 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
6416 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306417 pConfig->obssProtEnabled =
6418 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07006419
Chet Lanctot8cecea22014-02-11 19:09:36 -08006420#ifdef WLAN_FEATURE_11W
6421 pConfig->mfpCapable = MFPCapable;
6422 pConfig->mfpRequired = MFPRequired;
6423 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
6424 pConfig->mfpCapable, pConfig->mfpRequired);
6425#endif
6426
Arif Hussain6d2a3322013-11-17 19:50:10 -08006427 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07006428 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08006429 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
6430 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
6431 (int)pConfig->channel);
6432 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
6433 pConfig->SapHw_mode, pConfig->privacy,
6434 pConfig->authType);
6435 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
6436 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
6437 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
6438 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07006439
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306440 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07006441 {
6442 //Bss already started. just return.
6443 //TODO Probably it should update some beacon params.
6444 hddLog( LOGE, "Bss Already started...Ignore the request");
6445 EXIT();
6446 return 0;
6447 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306448
Agarwal Ashish51325b52014-06-16 16:50:49 +05306449 if (vos_max_concurrent_connections_reached()) {
6450 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
6451 return -EINVAL;
6452 }
6453
Jeff Johnson295189b2012-06-20 16:38:30 -07006454 pConfig->persona = pHostapdAdapter->device_mode;
6455
Peng Xu2446a892014-09-05 17:21:18 +05306456 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
6457 if ( NULL != psmeConfig)
6458 {
6459 sme_GetConfigParam(hHal, psmeConfig);
6460 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
6461 vos_mem_free(psmeConfig);
6462 }
Peng Xuafc34e32014-09-25 13:23:55 +05306463 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05306464
Jeff Johnson295189b2012-06-20 16:38:30 -07006465 pSapEventCallback = hdd_hostapd_SAPEventCB;
6466 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
6467 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
6468 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006469 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006470 return -EINVAL;
6471 }
6472
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306473 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07006474 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
6475
6476 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306477
Jeff Johnson295189b2012-06-20 16:38:30 -07006478 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306479 {
6480 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006481 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07006482 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07006483 VOS_ASSERT(0);
6484 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306485
Jeff Johnson295189b2012-06-20 16:38:30 -07006486 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05306487 /* Initialize WMM configuation */
6488 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05306489 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006490
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07006491#ifdef WLAN_FEATURE_P2P_DEBUG
6492 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
6493 {
6494 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
6495 {
6496 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
6497 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08006498 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07006499 }
6500 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
6501 {
6502 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
6503 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08006504 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07006505 }
6506 }
6507#endif
6508
Jeff Johnson295189b2012-06-20 16:38:30 -07006509 pHostapdState->bCommit = TRUE;
6510 EXIT();
6511
6512 return 0;
6513}
6514
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006515#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306516static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
6517 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07006518 struct beacon_parameters *params)
6519{
6520 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306521 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306522 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006523
6524 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306525
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306526 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6527 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
6528 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306529 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
6530 hdd_device_modetoString(pAdapter->device_mode),
6531 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006532
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306533 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6534 status = wlan_hdd_validate_context(pHddCtx);
6535
6536 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006537 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306538 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6539 "%s: HDD context is not valid", __func__);
6540 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006541 }
6542
Agarwal Ashish51325b52014-06-16 16:50:49 +05306543 if (vos_max_concurrent_connections_reached()) {
6544 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
6545 return -EINVAL;
6546 }
6547
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306548 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07006549 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07006550 )
6551 {
6552 beacon_data_t *old,*new;
6553
6554 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306555
Jeff Johnson295189b2012-06-20 16:38:30 -07006556 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306557 {
6558 hddLog(VOS_TRACE_LEVEL_WARN,
6559 FL("already beacon info added to session(%d)"),
6560 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006561 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306562 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006563
6564 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
6565
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306566 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07006567 {
6568 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006569 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006570 return -EINVAL;
6571 }
6572
6573 pAdapter->sessionCtx.ap.beacon = new;
6574
6575 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
6576 }
6577
6578 EXIT();
6579 return status;
6580}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306581
6582static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006583 struct net_device *dev,
6584 struct beacon_parameters *params)
6585{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306586 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306587 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6588 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306589 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006590
6591 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306592 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6593 TRACE_CODE_HDD_CFG80211_SET_BEACON,
6594 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
6595 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
6596 __func__, hdd_device_modetoString(pAdapter->device_mode),
6597 pAdapter->device_mode);
6598
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306599 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6600 status = wlan_hdd_validate_context(pHddCtx);
6601
6602 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006603 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306604 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6605 "%s: HDD context is not valid", __func__);
6606 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006607 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306608
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306609 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07006610 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306611 )
Jeff Johnson295189b2012-06-20 16:38:30 -07006612 {
6613 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306614
Jeff Johnson295189b2012-06-20 16:38:30 -07006615 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306616
Jeff Johnson295189b2012-06-20 16:38:30 -07006617 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306618 {
6619 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6620 FL("session(%d) old and new heads points to NULL"),
6621 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006622 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306623 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006624
6625 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
6626
6627 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306628 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006629 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006630 return -EINVAL;
6631 }
6632
6633 pAdapter->sessionCtx.ap.beacon = new;
6634
6635 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
6636 }
6637
6638 EXIT();
6639 return status;
6640}
6641
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006642#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
6643
6644#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006645static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
6646 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006647#else
6648static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
6649 struct net_device *dev)
6650#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006651{
6652 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07006653 hdd_context_t *pHddCtx = NULL;
6654 hdd_scaninfo_t *pScanInfo = NULL;
6655 hdd_adapter_t *staAdapter = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306656 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306657 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006658
6659 ENTER();
6660
6661 if (NULL == pAdapter)
6662 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306663 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006664 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006665 return -ENODEV;
6666 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006667
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306668 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6669 TRACE_CODE_HDD_CFG80211_STOP_AP,
6670 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306671 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6672 status = wlan_hdd_validate_context(pHddCtx);
6673
6674 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006675 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306676 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6677 "%s: HDD context is not valid", __func__);
6678 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07006679 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006680
6681 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
6682 if (NULL == staAdapter)
6683 {
6684 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
6685 if (NULL == staAdapter)
6686 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07006687 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
6688 "%s: HDD adapter context for STA/P2P-CLI is Null",
6689 __func__);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006690 }
6691 }
6692
6693 pScanInfo = &pHddCtx->scan_info;
6694
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306695 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
6696 __func__, hdd_device_modetoString(pAdapter->device_mode),
6697 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006698
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306699 ret = wlan_hdd_scan_abort(pAdapter);
6700
Girish Gowli4bf7a632014-06-12 13:42:11 +05306701 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07006702 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306703 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6704 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306705
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306706 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07006707 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306708 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6709 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08006710
Jeff Johnsone7245742012-09-05 17:12:55 -07006711 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306712 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07006713 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05306714 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07006715 }
6716
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05306717 /* Delete all associated STAs before stopping AP/P2P GO */
6718 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05306719 hdd_hostapd_stop(dev);
6720
Jeff Johnson295189b2012-06-20 16:38:30 -07006721 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07006722 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07006723 )
6724 {
6725 beacon_data_t *old;
6726
6727 old = pAdapter->sessionCtx.ap.beacon;
6728
6729 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306730 {
6731 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6732 FL("session(%d) beacon data points to NULL"),
6733 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006734 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306735 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006736
Jeff Johnson295189b2012-06-20 16:38:30 -07006737 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006738
6739 mutex_lock(&pHddCtx->sap_lock);
6740 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
6741 {
Jeff Johnson4416a782013-03-25 14:17:50 -07006742 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006743 {
6744 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
6745
6746 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
6747
6748 if (!VOS_IS_STATUS_SUCCESS(status))
6749 {
6750 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006751 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006752 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306753 }
6754 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006755 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05306756 /* BSS stopped, clear the active sessions for this device mode */
6757 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006758 }
6759 mutex_unlock(&pHddCtx->sap_lock);
6760
6761 if(status != VOS_STATUS_SUCCESS)
6762 {
6763 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006764 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006765 return -EINVAL;
6766 }
6767
Jeff Johnson4416a782013-03-25 14:17:50 -07006768 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07006769 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
6770 ==eHAL_STATUS_FAILURE)
6771 {
6772 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006773 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006774 }
6775
Jeff Johnson4416a782013-03-25 14:17:50 -07006776 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07006777 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
6778 eANI_BOOLEAN_FALSE) )
6779 {
6780 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006781 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006782 }
6783
6784 // Reset WNI_CFG_PROBE_RSP Flags
6785 wlan_hdd_reset_prob_rspies(pAdapter);
6786
6787 pAdapter->sessionCtx.ap.beacon = NULL;
6788 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07006789#ifdef WLAN_FEATURE_P2P_DEBUG
6790 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
6791 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
6792 {
6793 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
6794 "GO got removed");
6795 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
6796 }
6797#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006798 }
6799 EXIT();
6800 return status;
6801}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006802
6803#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
6804
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306805static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
6806 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006807 struct cfg80211_ap_settings *params)
6808{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306809 hdd_adapter_t *pAdapter;
6810 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306811 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006812
6813 ENTER();
6814
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306815 if (NULL == dev)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07006816 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306817 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306818 "%s: Device is Null", __func__);
6819 return -ENODEV;
6820 }
6821
6822 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6823 if (NULL == pAdapter)
6824 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306825 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306826 "%s: HDD adapter is Null", __func__);
6827 return -ENODEV;
6828 }
6829
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306830 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6831 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
6832 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306833 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
6834 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306835 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306836 "%s: HDD adapter magic is invalid", __func__);
6837 return -ENODEV;
6838 }
6839
6840 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306841 status = wlan_hdd_validate_context(pHddCtx);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306842
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306843 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306844 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306845 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6846 "%s: HDD context is not valid", __func__);
6847 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306848 }
6849
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306850 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
6851 __func__, hdd_device_modetoString(pAdapter->device_mode),
6852 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306853
6854 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006855 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006856 )
6857 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306858 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006859
6860 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306861
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006862 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306863 {
6864 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6865 FL("already beacon info added to session(%d)"),
6866 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006867 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306868 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006869
6870 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, &params->beacon, params->dtim_period);
6871
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306872 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006873 {
6874 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306875 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006876 return -EINVAL;
6877 }
6878 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08006879#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07006880 wlan_hdd_cfg80211_set_channel(wiphy, dev,
6881#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
6882 params->channel, params->channel_type);
6883#else
6884 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
6885#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08006886#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006887 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
6888 params->ssid_len, params->hidden_ssid);
6889 }
6890
6891 EXIT();
6892 return status;
6893}
6894
6895
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306896static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006897 struct net_device *dev,
6898 struct cfg80211_beacon_data *params)
6899{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306900 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306901 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306902 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006903
6904 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306905
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306906 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6907 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
6908 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08006909 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006910 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306911
6912 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6913 status = wlan_hdd_validate_context(pHddCtx);
6914
6915 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07006916 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306917 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6918 "%s: HDD context is not valid", __func__);
6919 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07006920 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006921
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306922 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006923 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306924 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006925 {
6926 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306927
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006928 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306929
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006930 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306931 {
6932 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6933 FL("session(%d) beacon data points to NULL"),
6934 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006935 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306936 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006937
6938 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
6939
6940 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306941 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006942 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006943 return -EINVAL;
6944 }
6945
6946 pAdapter->sessionCtx.ap.beacon = new;
6947
6948 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
6949 }
6950
6951 EXIT();
6952 return status;
6953}
6954
6955#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
6956
Jeff Johnson295189b2012-06-20 16:38:30 -07006957
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05306958static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006959 struct net_device *dev,
6960 struct bss_parameters *params)
6961{
6962 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6963
6964 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306965
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306966 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6967 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
6968 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306969 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
6970 __func__, hdd_device_modetoString(pAdapter->device_mode),
6971 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006972
6973 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07006974 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306975 )
Jeff Johnson295189b2012-06-20 16:38:30 -07006976 {
6977 /* ap_isolate == -1 means that in change bss, upper layer doesn't
6978 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306979 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07006980 {
6981 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306982 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006983 }
6984
6985 EXIT();
6986 return 0;
6987}
6988
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05306989static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
6990 struct net_device *dev,
6991 struct bss_parameters *params)
6992{
6993 int ret;
6994
6995 vos_ssr_protect(__func__);
6996 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
6997 vos_ssr_unprotect(__func__);
6998
6999 return ret;
7000}
Kiet Lam10841362013-11-01 11:36:50 +05307001/* FUNCTION: wlan_hdd_change_country_code_cd
7002* to wait for contry code completion
7003*/
7004void* wlan_hdd_change_country_code_cb(void *pAdapter)
7005{
7006 hdd_adapter_t *call_back_pAdapter = pAdapter;
7007 complete(&call_back_pAdapter->change_country_code);
7008 return NULL;
7009}
7010
Jeff Johnson295189b2012-06-20 16:38:30 -07007011/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05307012 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07007013 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
7014 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05307015int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007016 struct net_device *ndev,
7017 enum nl80211_iftype type,
7018 u32 *flags,
7019 struct vif_params *params
7020 )
7021{
7022 struct wireless_dev *wdev;
7023 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08007024 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07007025 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007026 tCsrRoamProfile *pRoamProfile = NULL;
7027 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307028 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007029 eMib_dot11DesiredBssType connectedBssType;
7030 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307031 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007032
7033 ENTER();
7034
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307035 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08007036 {
7037 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7038 "%s: Adapter context is null", __func__);
7039 return VOS_STATUS_E_FAILURE;
7040 }
7041
7042 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7043 if (!pHddCtx)
7044 {
7045 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7046 "%s: HDD context is null", __func__);
7047 return VOS_STATUS_E_FAILURE;
7048 }
7049
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307050 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7051 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
7052 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307053 status = wlan_hdd_validate_context(pHddCtx);
7054
7055 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007056 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307057 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7058 "%s: HDD context is not valid", __func__);
7059 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007060 }
7061
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307062 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7063 __func__, hdd_device_modetoString(pAdapter->device_mode),
7064 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007065
Agarwal Ashish51325b52014-06-16 16:50:49 +05307066 if (vos_max_concurrent_connections_reached()) {
7067 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7068 return -EINVAL;
7069 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307070 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07007071 wdev = ndev->ieee80211_ptr;
7072
7073#ifdef WLAN_BTAMP_FEATURE
7074 if((NL80211_IFTYPE_P2P_CLIENT == type)||
7075 (NL80211_IFTYPE_ADHOC == type)||
7076 (NL80211_IFTYPE_AP == type)||
7077 (NL80211_IFTYPE_P2P_GO == type))
7078 {
7079 pHddCtx->isAmpAllowed = VOS_FALSE;
7080 // stop AMP traffic
7081 status = WLANBAP_StopAmp();
7082 if(VOS_STATUS_SUCCESS != status )
7083 {
7084 pHddCtx->isAmpAllowed = VOS_TRUE;
7085 hddLog(VOS_TRACE_LEVEL_FATAL,
7086 "%s: Failed to stop AMP", __func__);
7087 return -EINVAL;
7088 }
7089 }
7090#endif //WLAN_BTAMP_FEATURE
7091 /* Reset the current device mode bit mask*/
7092 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
7093
7094 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07007095 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07007096 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07007097 )
7098 {
7099 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08007100 if (!pWextState)
7101 {
7102 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7103 "%s: pWextState is null", __func__);
7104 return VOS_STATUS_E_FAILURE;
7105 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007106 pRoamProfile = &pWextState->roamProfile;
7107 LastBSSType = pRoamProfile->BSSType;
7108
7109 switch (type)
7110 {
7111 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07007112 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07007113 hddLog(VOS_TRACE_LEVEL_INFO,
7114 "%s: setting interface Type to INFRASTRUCTURE", __func__);
7115 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07007116#ifdef WLAN_FEATURE_11AC
7117 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
7118 {
7119 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
7120 }
7121#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307122 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07007123 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007124 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08007125 //Check for sub-string p2p to confirm its a p2p interface
7126 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307127 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08007128 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
7129 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
7130 }
7131 else
7132 {
7133 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07007134 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08007135 }
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05307136#ifdef FEATURE_WLAN_TDLS
7137 /* The open adapter for the p2p shall skip initializations in
7138 * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for
7139 * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke
7140 * tdls_init when the change_iface sets the device mode to
7141 * WLAN_HDD_P2P_CLIENT.
7142 */
7143
7144 if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
7145 {
Agarwal Ashish4b87f922014-06-18 03:03:21 +05307146 if (0 != wlan_hdd_sta_tdls_init (pAdapter))
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05307147 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307148 hddLog(VOS_TRACE_LEVEL_ERROR,
7149 "%s: tdls initialization failed", __func__);
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05307150 return -EINVAL;
7151 }
7152 }
7153#endif
7154
Jeff Johnson295189b2012-06-20 16:38:30 -07007155 break;
7156 case NL80211_IFTYPE_ADHOC:
7157 hddLog(VOS_TRACE_LEVEL_INFO,
7158 "%s: setting interface Type to ADHOC", __func__);
7159 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
7160 pRoamProfile->phyMode =
7161 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07007162 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007163 wdev->iftype = type;
7164 break;
7165
7166 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07007167 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07007168 {
7169 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
7170 "%s: setting interface Type to %s", __func__,
7171 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
7172
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08007173 //Cancel any remain on channel for GO mode
7174 if (NL80211_IFTYPE_P2P_GO == type)
7175 {
7176 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
7177 }
Mohit Khanna0f232092012-09-11 14:46:08 -07007178 if (NL80211_IFTYPE_AP == type)
7179 {
7180 /* As Loading WLAN Driver one interface being created for p2p device
7181 * address. This will take one HW STA and the max number of clients
7182 * that can connect to softAP will be reduced by one. so while changing
7183 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
7184 * interface as it is not required in SoftAP mode.
7185 */
7186
7187 // Get P2P Adapter
7188 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
7189
7190 if (pP2pAdapter)
7191 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307192 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -07007193 hdd_deinit_adapter(pHddCtx, pP2pAdapter);
7194 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
7195 }
7196 }
Swaroop Goltia2e32212014-04-09 23:37:33 +05307197 //Disable IMPS & BMPS for SAP/GO
7198 if(VOS_STATUS_E_FAILURE ==
7199 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
7200 {
7201 //Fail to Exit BMPS
7202 VOS_ASSERT(0);
7203 }
Deepthi Gowri500fc472014-08-11 19:53:10 +05307204
7205 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
7206
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307207#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07007208
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307209 /* A Mutex Lock is introduced while changing the mode to
7210 * protect the concurrent access for the Adapters by TDLS
7211 * module.
7212 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05307213 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307214#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007215 //De-init the adapter.
Jeff Johnson295189b2012-06-20 16:38:30 -07007216 hdd_deinit_adapter( pHddCtx, pAdapter );
7217 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07007218 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
7219 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307220#ifdef FEATURE_WLAN_TDLS
7221 mutex_unlock(&pHddCtx->tdls_lock);
7222#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07007223 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
7224 (pConfig->apRandomBssidEnabled))
7225 {
7226 /* To meet Android requirements create a randomized
7227 MAC address of the form 02:1A:11:Fx:xx:xx */
7228 get_random_bytes(&ndev->dev_addr[3], 3);
7229 ndev->dev_addr[0] = 0x02;
7230 ndev->dev_addr[1] = 0x1A;
7231 ndev->dev_addr[2] = 0x11;
7232 ndev->dev_addr[3] |= 0xF0;
7233 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
7234 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08007235 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
7236 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07007237 }
7238
Jeff Johnson295189b2012-06-20 16:38:30 -07007239 hdd_set_ap_ops( pAdapter->dev );
7240
Kiet Lam10841362013-11-01 11:36:50 +05307241 /* This is for only SAP mode where users can
7242 * control country through ini.
7243 * P2P GO follows station country code
7244 * acquired during the STA scanning. */
7245 if((NL80211_IFTYPE_AP == type) &&
7246 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
7247 {
7248 int status = 0;
7249 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
7250 "%s: setting country code from INI ", __func__);
7251 init_completion(&pAdapter->change_country_code);
7252 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
7253 (void *)(tSmeChangeCountryCallback)
7254 wlan_hdd_change_country_code_cb,
7255 pConfig->apCntryCode, pAdapter,
7256 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05307257 eSIR_FALSE,
7258 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05307259 if (eHAL_STATUS_SUCCESS == status)
7260 {
7261 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307262 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05307263 &pAdapter->change_country_code,
7264 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307265 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05307266 {
7267 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307268 FL("SME Timed out while setting country code %ld"),
7269 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08007270
7271 if (pHddCtx->isLogpInProgress)
7272 {
7273 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7274 "%s: LOGP in Progress. Ignore!!!", __func__);
7275 return -EAGAIN;
7276 }
Kiet Lam10841362013-11-01 11:36:50 +05307277 }
7278 }
7279 else
7280 {
7281 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007282 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05307283 return -EINVAL;
7284 }
7285 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007286 status = hdd_init_ap_mode(pAdapter);
7287 if(status != VOS_STATUS_SUCCESS)
7288 {
7289 hddLog(VOS_TRACE_LEVEL_FATAL,
7290 "%s: Error initializing the ap mode", __func__);
7291 return -EINVAL;
7292 }
7293 hdd_set_conparam(1);
7294
Jeff Johnson295189b2012-06-20 16:38:30 -07007295 /*interface type changed update in wiphy structure*/
7296 if(wdev)
7297 {
7298 wdev->iftype = type;
7299 pHddCtx->change_iface = type;
7300 }
7301 else
7302 {
7303 hddLog(VOS_TRACE_LEVEL_ERROR,
7304 "%s: ERROR !!!! Wireless dev is NULL", __func__);
7305 return -EINVAL;
7306 }
7307 goto done;
7308 }
7309
7310 default:
7311 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
7312 __func__);
7313 return -EOPNOTSUPP;
7314 }
7315 }
7316 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007317 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007318 )
7319 {
7320 switch(type)
7321 {
7322 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07007323 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07007324 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +05307325
7326 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307327#ifdef FEATURE_WLAN_TDLS
7328
7329 /* A Mutex Lock is introduced while changing the mode to
7330 * protect the concurrent access for the Adapters by TDLS
7331 * module.
7332 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05307333 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307334#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07007335 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07007336 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08007337 //Check for sub-string p2p to confirm its a p2p interface
7338 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08007339 {
7340 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
7341 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
7342 }
7343 else
7344 {
7345 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07007346 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08007347 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007348 hdd_set_conparam(0);
7349 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07007350 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
7351 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307352#ifdef FEATURE_WLAN_TDLS
7353 mutex_unlock(&pHddCtx->tdls_lock);
7354#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05307355 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07007356 if( VOS_STATUS_SUCCESS != status )
7357 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07007358 /* In case of JB, for P2P-GO, only change interface will be called,
7359 * This is the right place to enable back bmps_imps()
7360 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05307361 if (pHddCtx->hdd_wlan_suspended)
7362 {
7363 hdd_set_pwrparams(pHddCtx);
7364 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007365 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007366 goto done;
7367 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07007368 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07007369 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07007370 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
7371 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07007372 goto done;
7373 default:
7374 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
7375 __func__);
7376 return -EOPNOTSUPP;
7377
7378 }
7379
7380 }
7381 else
7382 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307383 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
7384 __func__, hdd_device_modetoString(pAdapter->device_mode),
7385 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007386 return -EOPNOTSUPP;
7387 }
7388
7389
7390 if(pRoamProfile)
7391 {
7392 if ( LastBSSType != pRoamProfile->BSSType )
7393 {
7394 /*interface type changed update in wiphy structure*/
7395 wdev->iftype = type;
7396
7397 /*the BSS mode changed, We need to issue disconnect
7398 if connected or in IBSS disconnect state*/
7399 if ( hdd_connGetConnectedBssType(
7400 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
7401 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
7402 {
7403 /*need to issue a disconnect to CSR.*/
7404 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7405 if( eHAL_STATUS_SUCCESS ==
7406 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
7407 pAdapter->sessionId,
7408 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
7409 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307410 ret = wait_for_completion_interruptible_timeout(
7411 &pAdapter->disconnect_comp_var,
7412 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7413 if (ret <= 0)
7414 {
7415 hddLog(VOS_TRACE_LEVEL_ERROR,
7416 FL("wait on disconnect_comp_var failed %ld"), ret);
7417 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007418 }
7419 }
7420 }
7421 }
7422
7423done:
7424 /*set bitmask based on updated value*/
7425 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07007426
7427 /* Only STA mode support TM now
7428 * all other mode, TM feature should be disabled */
7429 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
7430 (~VOS_STA & pHddCtx->concurrency_mode) )
7431 {
7432 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
7433 }
7434
Jeff Johnson295189b2012-06-20 16:38:30 -07007435#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307436 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05307437 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07007438 {
7439 //we are ok to do AMP
7440 pHddCtx->isAmpAllowed = VOS_TRUE;
7441 }
7442#endif //WLAN_BTAMP_FEATURE
7443 EXIT();
7444 return 0;
7445}
7446
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05307447/*
7448 * FUNCTION: wlan_hdd_cfg80211_change_iface
7449 * wrapper function to protect the actual implementation from SSR.
7450 */
7451int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
7452 struct net_device *ndev,
7453 enum nl80211_iftype type,
7454 u32 *flags,
7455 struct vif_params *params
7456 )
7457{
7458 int ret;
7459
7460 vos_ssr_protect(__func__);
7461 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
7462 vos_ssr_unprotect(__func__);
7463
7464 return ret;
7465}
7466
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007467#ifdef FEATURE_WLAN_TDLS
7468static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
7469 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
7470{
7471 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7472 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7473 VOS_STATUS status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007474 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307475 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05307476 tANI_U16 numCurrTdlsPeers;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007477
7478 ENTER();
7479
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05307480 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007481 {
7482 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7483 "Invalid arguments");
7484 return -EINVAL;
7485 }
Hoonki Lee27511902013-03-14 18:19:06 -07007486
7487 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
7488 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
7489 {
7490 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7491 "%s: TDLS mode is disabled OR not enabled in FW."
7492 MAC_ADDRESS_STR " Request declined.",
7493 __func__, MAC_ADDR_ARRAY(mac));
7494 return -ENOTSUPP;
7495 }
7496
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007497 if (pHddCtx->isLogpInProgress)
7498 {
7499 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7500 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +05307501 wlan_hdd_tdls_set_link_status(pAdapter,
7502 mac,
7503 eTDLS_LINK_IDLE,
7504 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007505 return -EBUSY;
7506 }
7507
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05307508 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007509
7510 if ( NULL == pTdlsPeer ) {
7511 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7512 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
7513 __func__, MAC_ADDR_ARRAY(mac), update);
7514 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007515 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007516
7517 /* in add station, we accept existing valid staId if there is */
7518 if ((0 == update) &&
7519 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
7520 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007521 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007522 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007523 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007524 " link_status %d. staId %d. add station ignored.",
7525 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
7526 return 0;
7527 }
7528 /* in change station, we accept only when staId is valid */
7529 if ((1 == update) &&
7530 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
7531 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
7532 {
7533 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7534 "%s: " MAC_ADDRESS_STR
7535 " link status %d. staId %d. change station %s.",
7536 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
7537 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
7538 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007539 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007540
7541 /* when others are on-going, we want to change link_status to idle */
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307542 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007543 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007544 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7545 "%s: " MAC_ADDRESS_STR
7546 " TDLS setup is ongoing. Request declined.",
7547 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07007548 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007549 }
7550
7551 /* first to check if we reached to maximum supported TDLS peer.
7552 TODO: for now, return -EPERM looks working fine,
7553 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05307554 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
7555 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007556 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007557 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7558 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05307559 " TDLS Max peer already connected. Request declined."
7560 " Num of peers (%d), Max allowed (%d).",
7561 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
7562 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007563 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007564 }
7565 else
7566 {
7567 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307568 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007569 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007570 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007571 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7572 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
7573 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007574 return -EPERM;
7575 }
7576 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007577 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +05307578 wlan_hdd_tdls_set_link_status(pAdapter,
7579 mac,
7580 eTDLS_LINK_CONNECTING,
7581 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007582
Jeff Johnsond75fe012013-04-06 10:53:06 -07007583 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05307584 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007585 {
7586 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7587 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07007588 if(StaParams->htcap_present)
7589 {
7590 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7591 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
7592 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7593 "ht_capa->extended_capabilities: %0x",
7594 StaParams->HTCap.extendedHtCapInfo);
7595 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007596 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7597 "params->capability: %0x",StaParams->capability);
7598 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007599 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07007600 if(StaParams->vhtcap_present)
7601 {
7602 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7603 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
7604 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
7605 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
7606 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007607 {
7608 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007609 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007610 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
7611 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7612 "[%d]: %x ", i, StaParams->supported_rates[i]);
7613 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07007614 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05307615 else if ((1 == update) && (NULL == StaParams))
7616 {
7617 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7618 "%s : update is true, but staParams is NULL. Error!", __func__);
7619 return -EPERM;
7620 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007621
7622 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
7623
7624 if (!update)
7625 {
7626 status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
7627 pAdapter->sessionId, mac);
7628 }
7629 else
7630 {
7631 status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
7632 pAdapter->sessionId, mac, StaParams);
7633 }
7634
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307635 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007636 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
7637
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307638 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007639 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007640 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307641 "%s: timeout waiting for tdls add station indication %ld",
7642 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007643 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007644 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307645
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007646 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
7647 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007648 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007649 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007650 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007651 }
7652
7653 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07007654
7655error:
Atul Mittal115287b2014-07-08 13:26:33 +05307656 wlan_hdd_tdls_set_link_status(pAdapter,
7657 mac,
7658 eTDLS_LINK_IDLE,
7659 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007660 return -EPERM;
7661
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007662}
7663#endif
7664
Jeff Johnson295189b2012-06-20 16:38:30 -07007665static int wlan_hdd_change_station(struct wiphy *wiphy,
7666 struct net_device *dev,
7667 u8 *mac,
7668 struct station_parameters *params)
7669{
7670 VOS_STATUS status = VOS_STATUS_SUCCESS;
7671 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkala29149562013-05-10 21:43:41 +05307672 hdd_context_t *pHddCtx;
7673 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007674 v_MACADDR_t STAMacAddress;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07007675#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007676 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007677 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05307678 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07007679#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07007680 ENTER();
7681
Gopichand Nakkala29149562013-05-10 21:43:41 +05307682 if ((NULL == pAdapter))
7683 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307684 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05307685 "invalid adapter ");
7686 return -EINVAL;
7687 }
7688
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307689 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7690 TRACE_CODE_HDD_CHANGE_STATION,
7691 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05307692 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7693 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7694
7695 if ((NULL == pHddCtx) || (NULL == pHddStaCtx))
7696 {
7697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7698 "invalid HDD state or HDD station context");
7699 return -EINVAL;
7700 }
7701
7702 if (pHddCtx->isLogpInProgress)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007703 {
7704 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7705 "%s:LOGP in Progress. Ignore!!!", __func__);
7706 return -EAGAIN;
7707 }
7708
Jeff Johnson295189b2012-06-20 16:38:30 -07007709 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
7710
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007711 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
7712 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07007713 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007714 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07007715 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307716 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07007717 WLANTL_STA_AUTHENTICATED);
7718
Gopichand Nakkala29149562013-05-10 21:43:41 +05307719 if (status != VOS_STATUS_SUCCESS)
7720 {
7721 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7722 "%s: Not able to change TL state to AUTHENTICATED", __func__);
7723 return -EINVAL;
7724 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007725 }
7726 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07007727 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
7728 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05307729#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007730 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
7731 StaParams.capability = params->capability;
7732 StaParams.uapsd_queues = params->uapsd_queues;
7733 StaParams.max_sp = params->max_sp;
7734
Naresh Jayaram3180aa42014-02-12 21:47:26 +05307735 /* Convert (first channel , number of channels) tuple to
7736 * the total list of channels. This goes with the assumption
7737 * that if the first channel is < 14, then the next channels
7738 * are an incremental of 1 else an incremental of 4 till the number
7739 * of channels.
7740 */
7741 if (0 != params->supported_channels_len) {
7742 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
7743 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
7744 {
7745 int wifi_chan_index;
7746 StaParams.supported_channels[j] = params->supported_channels[i];
7747 wifi_chan_index =
7748 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
7749 no_of_channels = params->supported_channels[i+1];
7750 for(k=1; k <= no_of_channels; k++)
7751 {
7752 StaParams.supported_channels[j+1] =
7753 StaParams.supported_channels[j] + wifi_chan_index;
7754 j+=1;
7755 }
7756 }
7757 StaParams.supported_channels_len = j;
7758 }
7759 vos_mem_copy(StaParams.supported_oper_classes,
7760 params->supported_oper_classes,
7761 params->supported_oper_classes_len);
7762 StaParams.supported_oper_classes_len =
7763 params->supported_oper_classes_len;
7764
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007765 if (0 != params->ext_capab_len)
7766 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
7767 sizeof(StaParams.extn_capability));
7768
7769 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07007770 {
7771 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007772 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07007773 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007774
7775 StaParams.supported_rates_len = params->supported_rates_len;
7776
7777 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
7778 * The supported_rates array , for all the structures propogating till Add Sta
7779 * to the firmware has to be modified , if the supplicant (ieee80211) is
7780 * modified to send more rates.
7781 */
7782
7783 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
7784 */
7785 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
7786 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
7787
7788 if (0 != StaParams.supported_rates_len) {
7789 int i = 0;
7790 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
7791 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007792 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007793 "Supported Rates with Length %d", StaParams.supported_rates_len);
7794 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007795 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007796 "[%d]: %0x", i, StaParams.supported_rates[i]);
7797 }
7798
7799 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07007800 {
7801 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007802 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07007803 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007804
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007805 if (0 != params->ext_capab_len ) {
7806 /*Define A Macro : TODO Sunil*/
7807 if ((1<<4) & StaParams.extn_capability[3]) {
7808 isBufSta = 1;
7809 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05307810 /* TDLS Channel Switching Support */
7811 if ((1<<6) & StaParams.extn_capability[3]) {
7812 isOffChannelSupported = 1;
7813 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007814 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05307815 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
7816 &StaParams, isBufSta,
7817 isOffChannelSupported);
7818
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307819 if (VOS_STATUS_SUCCESS != status) {
7820 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7821 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
7822 return -EINVAL;
7823 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007824 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
7825
7826 if (VOS_STATUS_SUCCESS != status) {
7827 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7828 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
7829 return -EINVAL;
7830 }
7831 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07007832#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05307833 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007834 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007835 return status;
7836}
7837
7838/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05307839 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -07007840 * This function is used to initialize the key information
7841 */
7842#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05307843static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007844 struct net_device *ndev,
7845 u8 key_index, bool pairwise,
7846 const u8 *mac_addr,
7847 struct key_params *params
7848 )
7849#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05307850static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007851 struct net_device *ndev,
7852 u8 key_index, const u8 *mac_addr,
7853 struct key_params *params
7854 )
7855#endif
7856{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007857 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07007858 tCsrRoamSetKey setKey;
7859 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307860 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007861 v_U32_t roamId= 0xFF;
7862 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07007863 hdd_hostapd_state_t *pHostapdState;
7864 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007865 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307866 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007867
7868 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307869
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307870 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7871 TRACE_CODE_HDD_CFG80211_ADD_KEY,
7872 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307873 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7874 status = wlan_hdd_validate_context(pHddCtx);
7875
7876 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007877 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307878 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7879 "%s: HDD context is not valid", __func__);
7880 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007881 }
7882
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307883 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7884 __func__, hdd_device_modetoString(pAdapter->device_mode),
7885 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007886
7887 if (CSR_MAX_NUM_KEY <= key_index)
7888 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007889 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007890 key_index);
7891
7892 return -EINVAL;
7893 }
7894
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007895 if (CSR_MAX_KEY_LEN < params->key_len)
7896 {
7897 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
7898 params->key_len);
7899
7900 return -EINVAL;
7901 }
7902
7903 hddLog(VOS_TRACE_LEVEL_INFO,
7904 "%s: called with key index = %d & key length %d",
7905 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07007906
7907 /*extract key idx, key len and key*/
7908 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
7909 setKey.keyId = key_index;
7910 setKey.keyLength = params->key_len;
7911 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
7912
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007913 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07007914 {
7915 case WLAN_CIPHER_SUITE_WEP40:
7916 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
7917 break;
7918
7919 case WLAN_CIPHER_SUITE_WEP104:
7920 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
7921 break;
7922
7923 case WLAN_CIPHER_SUITE_TKIP:
7924 {
7925 u8 *pKey = &setKey.Key[0];
7926 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
7927
7928 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
7929
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007930 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07007931
7932 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007933 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07007934 |--------------|----------|----------|
7935 <---16bytes---><--8bytes--><--8bytes-->
7936
7937 */
7938 /*Sme expects the 32 bytes key to be in the below order
7939
7940 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007941 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07007942 |--------------|----------|----------|
7943 <---16bytes---><--8bytes--><--8bytes-->
7944 */
7945 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007946 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07007947
7948 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007949 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07007950
7951 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007952 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07007953
7954
7955 break;
7956 }
7957
7958 case WLAN_CIPHER_SUITE_CCMP:
7959 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
7960 break;
7961
7962#ifdef FEATURE_WLAN_WAPI
7963 case WLAN_CIPHER_SUITE_SMS4:
7964 {
7965 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
7966 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
7967 params->key, params->key_len);
7968 return 0;
7969 }
7970#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007971
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007972#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07007973 case WLAN_CIPHER_SUITE_KRK:
7974 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
7975 break;
7976#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007977
7978#ifdef WLAN_FEATURE_11W
7979 case WLAN_CIPHER_SUITE_AES_CMAC:
7980 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07007981 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07007982#endif
7983
Jeff Johnson295189b2012-06-20 16:38:30 -07007984 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007985 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07007986 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05307987 status = -EOPNOTSUPP;
7988 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07007989 }
7990
7991 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
7992 __func__, setKey.encType);
7993
Shailender Karmuchi642e9812013-05-30 14:34:49 -07007994 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07007995#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7996 (!pairwise)
7997#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007998 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07007999#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008000 )
8001 {
8002 /* set group key*/
8003 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8004 "%s- %d: setting Broadcast key",
8005 __func__, __LINE__);
8006 setKey.keyDirection = eSIR_RX_ONLY;
8007 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
8008 }
8009 else
8010 {
8011 /* set pairwise key*/
8012 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8013 "%s- %d: setting pairwise key",
8014 __func__, __LINE__);
8015 setKey.keyDirection = eSIR_TX_RX;
8016 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
8017 }
8018 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
8019 {
8020 setKey.keyDirection = eSIR_TX_RX;
8021 /*Set the group key*/
8022 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
8023 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008024
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008025 if ( 0 != status )
8026 {
8027 hddLog(VOS_TRACE_LEVEL_ERROR,
8028 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308029 status = -EINVAL;
8030 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008031 }
8032 /*Save the keys here and call sme_RoamSetKey for setting
8033 the PTK after peer joins the IBSS network*/
8034 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
8035 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308036 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008037 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05308038 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
8039 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
8040 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008041 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008042 if( pHostapdState->bssState == BSS_START )
8043 {
c_hpothu7c55da62014-01-23 18:34:02 +05308044 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8045 vos_status = wlan_hdd_check_ula_done(pAdapter);
8046
8047 if ( vos_status != VOS_STATUS_SUCCESS )
8048 {
8049 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8050 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
8051 __LINE__, vos_status );
8052
8053 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
8054
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308055 status = -EINVAL;
8056 goto end;
c_hpothu7c55da62014-01-23 18:34:02 +05308057 }
8058
Jeff Johnson295189b2012-06-20 16:38:30 -07008059 status = WLANSAP_SetKeySta( pVosContext, &setKey);
8060
8061 if ( status != eHAL_STATUS_SUCCESS )
8062 {
8063 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8064 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
8065 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308066 status = -EINVAL;
8067 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07008068 }
8069 }
8070
8071 /* Saving WEP keys */
8072 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
8073 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
8074 {
8075 //Save the wep key in ap context. Issue setkey after the BSS is started.
8076 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
8077 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
8078 }
8079 else
8080 {
8081 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008082 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008083 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
8084 }
8085 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008086 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
8087 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008088 {
8089 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8090 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8091
Gopichand Nakkala3d295922013-05-07 16:19:14 +05308092#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8093 if (!pairwise)
8094#else
8095 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
8096#endif
8097 {
8098 /* set group key*/
8099 if (pHddStaCtx->roam_info.deferKeyComplete)
8100 {
8101 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8102 "%s- %d: Perform Set key Complete",
8103 __func__, __LINE__);
8104 hdd_PerformRoamSetKeyComplete(pAdapter);
8105 }
8106 }
8107
Jeff Johnson295189b2012-06-20 16:38:30 -07008108 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
8109
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08008110 pWextState->roamProfile.Keys.defaultIndex = key_index;
8111
8112
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008113 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07008114 params->key, params->key_len);
8115
Gopichand Nakkala3d295922013-05-07 16:19:14 +05308116
Jeff Johnson295189b2012-06-20 16:38:30 -07008117 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
8118
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308119 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07008120 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308121 __func__, setKey.peerMac[0], setKey.peerMac[1],
8122 setKey.peerMac[2], setKey.peerMac[3],
8123 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07008124 setKey.keyDirection);
8125
8126 vos_status = wlan_hdd_check_ula_done(pAdapter);
8127
8128 if ( vos_status != VOS_STATUS_SUCCESS )
8129 {
8130 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8131 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
8132 __LINE__, vos_status );
8133
8134 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
8135
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308136 status = -EINVAL;
8137 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07008138
8139 }
8140
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008141#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05308142 /* The supplicant may attempt to set the PTK once pre-authentication
8143 is done. Save the key in the UMAC and include it in the ADD BSS
8144 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008145 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05308146 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008147 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05308148 hddLog(VOS_TRACE_LEVEL_INFO_MED,
8149 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308150 status = 0;
8151 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +05308152 }
8153 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
8154 {
8155 hddLog(VOS_TRACE_LEVEL_ERROR,
8156 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308157 status = -EINVAL;
8158 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008159 }
8160#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07008161
8162 /* issue set key request to SME*/
8163 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
8164 pAdapter->sessionId, &setKey, &roamId );
8165
8166 if ( 0 != status )
8167 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308168 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07008169 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
8170 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308171 status = -EINVAL;
8172 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07008173 }
8174
8175
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308176 /* in case of IBSS as there was no information available about WEP keys during
8177 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07008178 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308179 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
8180 !( ( IW_AUTH_KEY_MGMT_802_1X
8181 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07008182 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
8183 )
8184 &&
8185 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
8186 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
8187 )
8188 )
8189 {
8190 setKey.keyDirection = eSIR_RX_ONLY;
8191 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
8192
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308193 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07008194 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308195 __func__, setKey.peerMac[0], setKey.peerMac[1],
8196 setKey.peerMac[2], setKey.peerMac[3],
8197 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07008198 setKey.keyDirection);
8199
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308200 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07008201 pAdapter->sessionId, &setKey, &roamId );
8202
8203 if ( 0 != status )
8204 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308205 hddLog(VOS_TRACE_LEVEL_ERROR,
8206 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008207 __func__, status);
8208 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308209 status = -EINVAL;
8210 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07008211 }
8212 }
8213 }
8214
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308215end:
8216 /* Need to clear any trace of key value in the memory.
8217 * Thus zero out the memory even though it is local
8218 * variable.
8219 */
8220 vos_mem_zero(&setKey, sizeof(setKey));
8221
8222 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008223}
8224
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308225#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8226static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
8227 struct net_device *ndev,
8228 u8 key_index, bool pairwise,
8229 const u8 *mac_addr,
8230 struct key_params *params
8231 )
8232#else
8233static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
8234 struct net_device *ndev,
8235 u8 key_index, const u8 *mac_addr,
8236 struct key_params *params
8237 )
8238#endif
8239{
8240 int ret;
8241 vos_ssr_protect(__func__);
8242#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8243 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
8244 mac_addr, params);
8245#else
8246 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
8247 params);
8248#endif
8249 vos_ssr_unprotect(__func__);
8250
8251 return ret;
8252}
8253
Jeff Johnson295189b2012-06-20 16:38:30 -07008254/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308255 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -07008256 * This function is used to get the key information
8257 */
8258#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308259static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308260 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008261 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308262 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07008263 const u8 *mac_addr, void *cookie,
8264 void (*callback)(void *cookie, struct key_params*)
8265 )
8266#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308267static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308268 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008269 struct net_device *ndev,
8270 u8 key_index, const u8 *mac_addr, void *cookie,
8271 void (*callback)(void *cookie, struct key_params*)
8272 )
8273#endif
8274{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308275 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308276 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8277 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008278 struct key_params params;
8279
8280 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308281
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308282 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8283 __func__, hdd_device_modetoString(pAdapter->device_mode),
8284 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308285
Jeff Johnson295189b2012-06-20 16:38:30 -07008286 memset(&params, 0, sizeof(params));
8287
8288 if (CSR_MAX_NUM_KEY <= key_index)
8289 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308290 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07008291 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308292 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008293
8294 switch(pRoamProfile->EncryptionType.encryptionType[0])
8295 {
8296 case eCSR_ENCRYPT_TYPE_NONE:
8297 params.cipher = IW_AUTH_CIPHER_NONE;
8298 break;
8299
8300 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
8301 case eCSR_ENCRYPT_TYPE_WEP40:
8302 params.cipher = WLAN_CIPHER_SUITE_WEP40;
8303 break;
8304
8305 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
8306 case eCSR_ENCRYPT_TYPE_WEP104:
8307 params.cipher = WLAN_CIPHER_SUITE_WEP104;
8308 break;
8309
8310 case eCSR_ENCRYPT_TYPE_TKIP:
8311 params.cipher = WLAN_CIPHER_SUITE_TKIP;
8312 break;
8313
8314 case eCSR_ENCRYPT_TYPE_AES:
8315 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
8316 break;
8317
8318 default:
8319 params.cipher = IW_AUTH_CIPHER_NONE;
8320 break;
8321 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308322
c_hpothuaaf19692014-05-17 17:01:48 +05308323 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8324 TRACE_CODE_HDD_CFG80211_GET_KEY,
8325 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308326
Jeff Johnson295189b2012-06-20 16:38:30 -07008327 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
8328 params.seq_len = 0;
8329 params.seq = NULL;
8330 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
8331 callback(cookie, &params);
8332 return 0;
8333}
8334
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308335#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8336static int wlan_hdd_cfg80211_get_key(
8337 struct wiphy *wiphy,
8338 struct net_device *ndev,
8339 u8 key_index, bool pairwise,
8340 const u8 *mac_addr, void *cookie,
8341 void (*callback)(void *cookie, struct key_params*)
8342 )
8343#else
8344static int wlan_hdd_cfg80211_get_key(
8345 struct wiphy *wiphy,
8346 struct net_device *ndev,
8347 u8 key_index, const u8 *mac_addr, void *cookie,
8348 void (*callback)(void *cookie, struct key_params*)
8349 )
8350#endif
8351{
8352 int ret;
8353
8354 vos_ssr_protect(__func__);
8355#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8356 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
8357 mac_addr, cookie, callback);
8358#else
8359 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
8360 callback);
8361#endif
8362 vos_ssr_unprotect(__func__);
8363
8364 return ret;
8365}
8366
Jeff Johnson295189b2012-06-20 16:38:30 -07008367/*
8368 * FUNCTION: wlan_hdd_cfg80211_del_key
8369 * This function is used to delete the key information
8370 */
8371#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308372static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008373 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308374 u8 key_index,
8375 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07008376 const u8 *mac_addr
8377 )
8378#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308379static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008380 struct net_device *ndev,
8381 u8 key_index,
8382 const u8 *mac_addr
8383 )
8384#endif
8385{
8386 int status = 0;
8387
8388 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308389 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07008390 //it is observed that this is invalidating peer
8391 //key index whenever re-key is done. This is affecting data link.
8392 //It should be ok to ignore del_key.
8393#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308394 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
8395 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008396 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
8397 tCsrRoamSetKey setKey;
8398 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308399
Jeff Johnson295189b2012-06-20 16:38:30 -07008400 ENTER();
8401
8402 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
8403 __func__,pAdapter->device_mode);
8404
8405 if (CSR_MAX_NUM_KEY <= key_index)
8406 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308407 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008408 key_index);
8409
8410 return -EINVAL;
8411 }
8412
8413 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8414 setKey.keyId = key_index;
8415
8416 if (mac_addr)
8417 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
8418 else
8419 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
8420
8421 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
8422
8423 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008424 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308425 )
8426 {
8427
8428 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07008429 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
8430 if( pHostapdState->bssState == BSS_START)
8431 {
8432 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308433
Jeff Johnson295189b2012-06-20 16:38:30 -07008434 if ( status != eHAL_STATUS_SUCCESS )
8435 {
8436 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8437 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
8438 __LINE__, status );
8439 }
8440 }
8441 }
8442 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308443 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07008444 )
8445 {
8446 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8447
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308448 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
8449
8450 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07008451 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308452 __func__, setKey.peerMac[0], setKey.peerMac[1],
8453 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07008454 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308455 if(pAdapter->sessionCtx.station.conn_info.connState ==
8456 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07008457 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308458 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07008459 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308460
Jeff Johnson295189b2012-06-20 16:38:30 -07008461 if ( 0 != status )
8462 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308463 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07008464 "%s: sme_RoamSetKey failure, returned %d",
8465 __func__, status);
8466 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
8467 return -EINVAL;
8468 }
8469 }
8470 }
8471#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008472 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008473 return status;
8474}
8475
8476/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308477 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -07008478 * This function is used to set the default tx key index
8479 */
8480#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308481static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008482 struct net_device *ndev,
8483 u8 key_index,
8484 bool unicast, bool multicast)
8485#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308486static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008487 struct net_device *ndev,
8488 u8 key_index)
8489#endif
8490{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308491 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308492 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308493 hdd_wext_state_t *pWextState;
8494 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308495 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008496
8497 ENTER();
8498
Gopichand Nakkala29149562013-05-10 21:43:41 +05308499 if ((NULL == pAdapter))
8500 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308501 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05308502 "invalid adapter");
8503 return -EINVAL;
8504 }
8505
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308506 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8507 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
8508 pAdapter->sessionId, key_index));
8509
Gopichand Nakkala29149562013-05-10 21:43:41 +05308510 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8511 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8512
8513 if ((NULL == pWextState) || (NULL == pHddStaCtx))
8514 {
8515 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8516 "invalid Wext state or HDD context");
8517 return -EINVAL;
8518 }
8519
Arif Hussain6d2a3322013-11-17 19:50:10 -08008520 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008521 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308522
Jeff Johnson295189b2012-06-20 16:38:30 -07008523 if (CSR_MAX_NUM_KEY <= key_index)
8524 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308525 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008526 key_index);
8527
8528 return -EINVAL;
8529 }
8530
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308531 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8532 status = wlan_hdd_validate_context(pHddCtx);
8533
8534 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008535 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308536 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8537 "%s: HDD context is not valid", __func__);
8538 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008539 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308540
Jeff Johnson295189b2012-06-20 16:38:30 -07008541 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07008542 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308543 )
Jeff Johnson295189b2012-06-20 16:38:30 -07008544 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05308545 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08008546 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308547 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08008548 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008549 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308550 {
8551 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07008552 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308553
Jeff Johnson295189b2012-06-20 16:38:30 -07008554 tCsrRoamSetKey setKey;
8555 v_U32_t roamId= 0xFF;
8556 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308557
8558 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008559 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308560
Jeff Johnson295189b2012-06-20 16:38:30 -07008561 Keys->defaultIndex = (u8)key_index;
8562 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8563 setKey.keyId = key_index;
8564 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308565
8566 vos_mem_copy(&setKey.Key[0],
8567 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07008568 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308569
Gopichand Nakkala29149562013-05-10 21:43:41 +05308570 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308571
8572 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07008573 &pHddStaCtx->conn_info.bssId[0],
8574 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308575
Gopichand Nakkala29149562013-05-10 21:43:41 +05308576 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
8577 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
8578 eCSR_ENCRYPT_TYPE_WEP104)
8579 {
8580 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
8581 even though ap is configured for WEP-40 encryption. In this canse the key length
8582 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
8583 type(104) and switching encryption type to 40*/
8584 pWextState->roamProfile.EncryptionType.encryptionType[0] =
8585 eCSR_ENCRYPT_TYPE_WEP40;
8586 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
8587 eCSR_ENCRYPT_TYPE_WEP40;
8588 }
8589
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308590 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07008591 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308592
Jeff Johnson295189b2012-06-20 16:38:30 -07008593 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308594 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07008595 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308596
Jeff Johnson295189b2012-06-20 16:38:30 -07008597 if ( 0 != status )
8598 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308599 hddLog(VOS_TRACE_LEVEL_ERROR,
8600 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008601 status);
8602 return -EINVAL;
8603 }
8604 }
8605 }
8606
8607 /* In SoftAp mode setting key direction for default mode */
8608 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
8609 {
8610 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
8611 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
8612 (eCSR_ENCRYPT_TYPE_AES !=
8613 pWextState->roamProfile.EncryptionType.encryptionType[0])
8614 )
8615 {
8616 /* Saving key direction for default key index to TX default */
8617 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
8618 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
8619 }
8620 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308621
Jeff Johnson295189b2012-06-20 16:38:30 -07008622 return status;
8623}
8624
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308625#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8626static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
8627 struct net_device *ndev,
8628 u8 key_index,
8629 bool unicast, bool multicast)
8630#else
8631static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
8632 struct net_device *ndev,
8633 u8 key_index)
8634#endif
8635{
8636 int ret;
8637 vos_ssr_protect(__func__);
8638#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8639 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
8640 multicast);
8641#else
8642 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
8643#endif
8644 vos_ssr_unprotect(__func__);
8645
8646 return ret;
8647}
8648
Jeff Johnson295189b2012-06-20 16:38:30 -07008649/*
8650 * FUNCTION: wlan_hdd_cfg80211_inform_bss
8651 * This function is used to inform the BSS details to nl80211 interface.
8652 */
8653static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
8654 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
8655{
8656 struct net_device *dev = pAdapter->dev;
8657 struct wireless_dev *wdev = dev->ieee80211_ptr;
8658 struct wiphy *wiphy = wdev->wiphy;
8659 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
8660 int chan_no;
8661 int ie_length;
8662 const char *ie;
8663 unsigned int freq;
8664 struct ieee80211_channel *chan;
8665 int rssi = 0;
8666 struct cfg80211_bss *bss = NULL;
8667
8668 ENTER();
8669
8670 if( NULL == pBssDesc )
8671 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008672 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008673 return bss;
8674 }
8675
8676 chan_no = pBssDesc->channelId;
8677 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
8678 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
8679
8680 if( NULL == ie )
8681 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008682 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008683 return bss;
8684 }
8685
8686#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
8687 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
8688 {
8689 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
8690 }
8691 else
8692 {
8693 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
8694 }
8695#else
8696 freq = ieee80211_channel_to_frequency(chan_no);
8697#endif
8698
8699 chan = __ieee80211_get_channel(wiphy, freq);
8700
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +05308701 if (!chan) {
8702 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
8703 return NULL;
8704 }
8705
Abhishek Singhaee43942014-06-16 18:55:47 +05308706 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -07008707
Abhishek Singhaee43942014-06-16 18:55:47 +05308708 return cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308709 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07008710 pBssDesc->capabilityInfo,
8711 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +05308712 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008713}
8714
8715
8716
8717/*
8718 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
8719 * This function is used to inform the BSS details to nl80211 interface.
8720 */
8721struct cfg80211_bss*
8722wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
8723 tSirBssDescription *bss_desc
8724 )
8725{
8726 /*
8727 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
8728 already exists in bss data base of cfg80211 for that particular BSS ID.
8729 Using cfg80211_inform_bss_frame to update the bss entry instead of
8730 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
8731 now there is no possibility to get the mgmt(probe response) frame from PE,
8732 converting bss_desc to ieee80211_mgmt(probe response) and passing to
8733 cfg80211_inform_bss_frame.
8734 */
8735 struct net_device *dev = pAdapter->dev;
8736 struct wireless_dev *wdev = dev->ieee80211_ptr;
8737 struct wiphy *wiphy = wdev->wiphy;
8738 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08008739#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
8740 qcom_ie_age *qie_age = NULL;
8741 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
8742#else
Jeff Johnson295189b2012-06-20 16:38:30 -07008743 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08008744#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008745 const char *ie =
8746 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
8747 unsigned int freq;
8748 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05308749 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008750 struct cfg80211_bss *bss_status = NULL;
8751 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
8752 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07008753 hdd_context_t *pHddCtx;
8754 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07008755#ifdef WLAN_OPEN_SOURCE
8756 struct timespec ts;
8757#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008758
Wilson Yangf80a0542013-10-07 13:02:37 -07008759 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8760 status = wlan_hdd_validate_context(pHddCtx);
8761
8762 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +05308763 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -07008764 {
8765 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8766 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
8767 return NULL;
8768 }
8769
8770
8771 if (0 != status)
8772 {
8773 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8774 "%s: HDD context is not valid", __func__);
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07008775 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07008776 }
8777
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05308778 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -07008779 if (!mgmt)
8780 {
8781 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8782 "%s: memory allocation failed ", __func__);
8783 return NULL;
8784 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07008785
Jeff Johnson295189b2012-06-20 16:38:30 -07008786 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07008787
8788#ifdef WLAN_OPEN_SOURCE
8789 /* Android does not want the timestamp from the frame.
8790 Instead it wants a monotonic increasing value */
8791 get_monotonic_boottime(&ts);
8792 mgmt->u.probe_resp.timestamp =
8793 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
8794#else
8795 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07008796 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
8797 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07008798
8799#endif
8800
Jeff Johnson295189b2012-06-20 16:38:30 -07008801 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
8802 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08008803
8804#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
8805 /* GPS Requirement: need age ie per entry. Using vendor specific. */
8806 /* Assuming this is the last IE, copy at the end */
8807 ie_length -=sizeof(qcom_ie_age);
8808 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
8809 qie_age->element_id = QCOM_VENDOR_IE_ID;
8810 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
8811 qie_age->oui_1 = QCOM_OUI1;
8812 qie_age->oui_2 = QCOM_OUI2;
8813 qie_age->oui_3 = QCOM_OUI3;
8814 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
8815 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
8816#endif
8817
Jeff Johnson295189b2012-06-20 16:38:30 -07008818 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05308819 if (bss_desc->fProbeRsp)
8820 {
8821 mgmt->frame_control |=
8822 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
8823 }
8824 else
8825 {
8826 mgmt->frame_control |=
8827 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
8828 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008829
8830#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308831 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07008832 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
8833 {
8834 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
8835 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308836 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07008837 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
8838
8839 {
8840 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
8841 }
8842 else
8843 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05308844 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
8845 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -07008846 kfree(mgmt);
8847 return NULL;
8848 }
8849#else
8850 freq = ieee80211_channel_to_frequency(chan_no);
8851#endif
8852 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08008853 /*when the band is changed on the fly using the GUI, three things are done
8854 * 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)
8855 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
8856 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
8857 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
8858 * and discards the channels correponding to previous band and calls back with zero bss results.
8859 * 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
8860 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
8861 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
8862 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
8863 * So drop the bss and continue to next bss.
8864 */
8865 if(chan == NULL)
8866 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05308867 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07008868 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08008869 return NULL;
8870 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008871 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308872 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07008873 * */
8874 if (( eConnectionState_Associated ==
8875 pAdapter->sessionCtx.station.conn_info.connState ) &&
8876 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
8877 pAdapter->sessionCtx.station.conn_info.bssId,
8878 WNI_CFG_BSSID_LEN)))
8879 {
8880 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
8881 rssi = (pAdapter->rssi * 100);
8882 }
8883 else
8884 {
8885 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
8886 }
8887
Nirav Shah20ac06f2013-12-12 18:14:06 +05308888 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
8889 "RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
8890 chan->center_freq, (int)(rssi/100));
8891
Jeff Johnson295189b2012-06-20 16:38:30 -07008892 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
8893 frame_len, rssi, GFP_KERNEL);
8894 kfree(mgmt);
8895 return bss_status;
8896}
8897
8898/*
8899 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
8900 * This function is used to update the BSS data base of CFG8011
8901 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308902struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07008903 tCsrRoamInfo *pRoamInfo
8904 )
8905{
8906 tCsrRoamConnectedProfile roamProfile;
8907 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8908 struct cfg80211_bss *bss = NULL;
8909
8910 ENTER();
8911
8912 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
8913 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
8914
8915 if (NULL != roamProfile.pBssDesc)
8916 {
Girish Gowlif4b68022014-08-28 23:18:57 +05308917 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
8918 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07008919
8920 if (NULL == bss)
8921 {
8922 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
8923 __func__);
8924 }
8925
8926 sme_RoamFreeConnectProfile(hHal, &roamProfile);
8927 }
8928 else
8929 {
8930 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
8931 __func__);
8932 }
8933 return bss;
8934}
8935
8936/*
8937 * FUNCTION: wlan_hdd_cfg80211_update_bss
8938 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308939static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
8940 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07008941 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308942{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308943 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008944 tCsrScanResultInfo *pScanResult;
8945 eHalStatus status = 0;
8946 tScanResultHandle pResult;
8947 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07008948 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008949
8950 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308951
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308952 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8953 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
8954 NO_SESSION, pAdapter->sessionId));
8955
Wilson Yangf80a0542013-10-07 13:02:37 -07008956 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8957
8958 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -07008959 {
Wilson Yangf80a0542013-10-07 13:02:37 -07008960 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8961 "%s:LOGP in Progress. Ignore!!!",__func__);
8962 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07008963 }
8964
Wilson Yangf80a0542013-10-07 13:02:37 -07008965
8966 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +05308967 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -07008968 {
8969 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8970 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
8971 return VOS_STATUS_E_PERM;
8972 }
8973
8974
Jeff Johnson295189b2012-06-20 16:38:30 -07008975 /*
8976 * start getting scan results and populate cgf80211 BSS database
8977 */
8978 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
8979
8980 /* no scan results */
8981 if (NULL == pResult)
8982 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05308983 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
8984 __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07008985 return status;
8986 }
8987
8988 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
8989
8990 while (pScanResult)
8991 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308992 /*
8993 * cfg80211_inform_bss() is not updating ie field of bss entry, if
8994 * entry already exists in bss data base of cfg80211 for that
8995 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
8996 * bss entry instead of cfg80211_inform_bss, But this call expects
8997 * mgmt packet as input. As of now there is no possibility to get
8998 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07008999 * ieee80211_mgmt(probe response) and passing to c
9000 * fg80211_inform_bss_frame.
9001 * */
9002
9003 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
9004 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309005
Jeff Johnson295189b2012-06-20 16:38:30 -07009006
9007 if (NULL == bss_status)
9008 {
9009 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009010 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009011 }
9012 else
9013 {
Yue Maf49ba872013-08-19 12:04:25 -07009014 cfg80211_put_bss(
9015#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9016 wiphy,
9017#endif
9018 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07009019 }
9020
9021 pScanResult = sme_ScanResultGetNext(hHal, pResult);
9022 }
9023
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309024 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07009025
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309026 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009027}
9028
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009029void
9030hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
9031{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309032 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -08009033 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009034} /****** end hddPrintMacAddr() ******/
9035
9036void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07009037hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009038{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309039 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009040 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07009041 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
9042 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
9043 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009044} /****** end hddPrintPmkId() ******/
9045
9046//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
9047//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
9048
9049//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
9050//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
9051
9052#define dump_bssid(bssid) \
9053 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07009054 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
9055 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009056 }
9057
9058#define dump_pmkid(pMac, pmkid) \
9059 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07009060 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
9061 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009062 }
9063
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07009064#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009065/*
9066 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
9067 * This function is used to notify the supplicant of a new PMKSA candidate.
9068 */
9069int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309070 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009071 int index, bool preauth )
9072{
Jeff Johnsone7245742012-09-05 17:12:55 -07009073#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009074 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07009075 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009076
9077 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07009078 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009079
9080 if( NULL == pRoamInfo )
9081 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009082 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009083 return -EINVAL;
9084 }
9085
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07009086 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
9087 {
9088 dump_bssid(pRoamInfo->bssid);
9089 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009090 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07009091 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009092#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309093 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009094}
9095#endif //FEATURE_WLAN_LFR
9096
Yue Maef608272013-04-08 23:09:17 -07009097#ifdef FEATURE_WLAN_LFR_METRICS
9098/*
9099 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
9100 * 802.11r/LFR metrics reporting function to report preauth initiation
9101 *
9102 */
9103#define MAX_LFR_METRICS_EVENT_LENGTH 100
9104VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
9105 tCsrRoamInfo *pRoamInfo)
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 wrqu.data.pointer = metrics_notification;
9123 wrqu.data.length = scnprintf(metrics_notification,
9124 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
9125 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
9126
9127 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
9128
9129 EXIT();
9130
9131 return VOS_STATUS_SUCCESS;
9132}
9133
9134/*
9135 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
9136 * 802.11r/LFR metrics reporting function to report preauth completion
9137 * or failure
9138 */
9139VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
9140 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
9141{
9142 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
9143 union iwreq_data wrqu;
9144
9145 ENTER();
9146
9147 if (NULL == pAdapter)
9148 {
9149 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
9150 return VOS_STATUS_E_FAILURE;
9151 }
9152
9153 /* create the event */
9154 memset(&wrqu, 0, sizeof(wrqu));
9155 memset(metrics_notification, 0, sizeof(metrics_notification));
9156
9157 scnprintf(metrics_notification, sizeof(metrics_notification),
9158 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
9159 MAC_ADDR_ARRAY(pRoamInfo->bssid));
9160
9161 if (1 == preauth_status)
9162 strncat(metrics_notification, " TRUE", 5);
9163 else
9164 strncat(metrics_notification, " FALSE", 6);
9165
9166 wrqu.data.pointer = metrics_notification;
9167 wrqu.data.length = strlen(metrics_notification);
9168
9169 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
9170
9171 EXIT();
9172
9173 return VOS_STATUS_SUCCESS;
9174}
9175
9176/*
9177 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
9178 * 802.11r/LFR metrics reporting function to report handover initiation
9179 *
9180 */
9181VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
9182 tCsrRoamInfo *pRoamInfo)
9183{
9184 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
9185 union iwreq_data wrqu;
9186
9187 ENTER();
9188
9189 if (NULL == pAdapter)
9190 {
9191 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
9192 return VOS_STATUS_E_FAILURE;
9193 }
9194
9195 /* create the event */
9196 memset(&wrqu, 0, sizeof(wrqu));
9197 memset(metrics_notification, 0, sizeof(metrics_notification));
9198
9199 wrqu.data.pointer = metrics_notification;
9200 wrqu.data.length = scnprintf(metrics_notification,
9201 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
9202 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
9203
9204 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
9205
9206 EXIT();
9207
9208 return VOS_STATUS_SUCCESS;
9209}
9210#endif
9211
Jeff Johnson295189b2012-06-20 16:38:30 -07009212/*
9213 * FUNCTION: hdd_cfg80211_scan_done_callback
9214 * scanning callback function, called after finishing scan
9215 *
9216 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309217static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -07009218 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
9219{
9220 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309221 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009222 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009223 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9224 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07009225 struct cfg80211_scan_request *req = NULL;
9226 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05309227 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309228 long waitRet = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009229
9230 ENTER();
9231
9232 hddLog(VOS_TRACE_LEVEL_INFO,
9233 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -08009234 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009235 __func__, halHandle, pContext, (int) scanId, (int) status);
9236
Kiet Lamac06e2c2013-10-23 16:25:07 +05309237 pScanInfo->mScanPendingCounter = 0;
9238
Jeff Johnson295189b2012-06-20 16:38:30 -07009239 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309240 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -07009241 &pScanInfo->scan_req_completion_event,
9242 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309243 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07009244 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309245 hddLog(VOS_TRACE_LEVEL_ERROR,
9246 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -07009247 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07009248 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07009249 }
9250
Yue Maef608272013-04-08 23:09:17 -07009251 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07009252 {
9253 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07009254 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07009255 }
9256
9257 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309258 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -07009259 {
9260 hddLog(VOS_TRACE_LEVEL_INFO,
9261 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -08009262 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -07009263 (int) scanId);
9264 }
9265
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309266 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009267 pAdapter);
9268
9269 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309270 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009271
9272
9273 /* If any client wait scan result through WEXT
9274 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009275 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07009276 {
9277 /* The other scan request waiting for current scan finish
9278 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009279 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07009280 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009281 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07009282 }
9283 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009284 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07009285 {
9286 struct net_device *dev = pAdapter->dev;
9287 union iwreq_data wrqu;
9288 int we_event;
9289 char *msg;
9290
9291 memset(&wrqu, '\0', sizeof(wrqu));
9292 we_event = SIOCGIWSCAN;
9293 msg = NULL;
9294 wireless_send_event(dev, we_event, &wrqu, msg);
9295 }
9296 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009297 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009298
9299 /* Get the Scan Req */
9300 req = pAdapter->request;
9301
9302 if (!req)
9303 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009304 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07009305 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07009306 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07009307 }
9308
9309 /*
9310 * setting up 0, just in case.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309311 */
Jeff Johnson295189b2012-06-20 16:38:30 -07009312 req->n_ssids = 0;
9313 req->n_channels = 0;
9314 req->ie = 0;
9315
Jeff Johnson295189b2012-06-20 16:38:30 -07009316 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07009317 /* Scan is no longer pending */
9318 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009319
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -07009320 /*
9321 * cfg80211_scan_done informing NL80211 about completion
9322 * of scanning
9323 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05309324 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
9325 {
9326 aborted = true;
9327 }
9328 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08009329 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07009330
Jeff Johnsone7245742012-09-05 17:12:55 -07009331allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07009332 /* release the wake lock at the end of the scan*/
9333 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07009334
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07009335 /* Acquire wakelock to handle the case where APP's tries to suspend
9336 * immediatly after the driver gets connect request(i.e after scan)
9337 * from supplicant, this result in app's is suspending and not able
9338 * to process the connect request to AP */
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05309339 hdd_prevent_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07009340
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07009341#ifdef FEATURE_WLAN_TDLS
c_hpothu3c8f8e82014-06-02 18:01:50 +05309342 if (!(eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode))
9343 {
9344 wlan_hdd_tdls_scan_done_callback(pAdapter);
9345 }
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07009346#endif
9347
Jeff Johnson295189b2012-06-20 16:38:30 -07009348 EXIT();
9349 return 0;
9350}
9351
9352/*
Rashmi Ramannab1429032014-04-26 14:59:09 +05309353 * FUNCTION: hdd_isConnectionInProgress
9354 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009355 *
9356 */
Ganesh Kondabattiniaeb7b772014-08-11 20:00:36 +05309357v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx, v_BOOL_t isRoC )
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009358{
9359 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
9360 hdd_station_ctx_t *pHddStaCtx = NULL;
9361 hdd_adapter_t *pAdapter = NULL;
9362 VOS_STATUS status = 0;
9363 v_U8_t staId = 0;
9364 v_U8_t *staMac = NULL;
9365
c_hpothu9b781ba2013-12-30 20:57:45 +05309366 if (TRUE == pHddCtx->btCoexModeSet)
9367 {
9368 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +05309369 FL("BTCoex Mode operation in progress"));
9370 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +05309371 }
9372
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009373 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
9374
9375 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
9376 {
9377 pAdapter = pAdapterNode->pAdapter;
9378
9379 if( pAdapter )
9380 {
9381 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309382 "%s: Adapter with device mode %s (%d) exists",
9383 __func__, hdd_device_modetoString(pAdapter->device_mode),
9384 pAdapter->device_mode);
Ganesh Kondabattiniaeb7b772014-08-11 20:00:36 +05309385 if ((((!isRoC) && (WLAN_HDD_INFRA_STATION == pAdapter->device_mode)) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +05309386 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
9387 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
9388 (eConnectionState_Connecting ==
9389 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
9390 {
9391 hddLog(VOS_TRACE_LEVEL_ERROR,
9392 "%s: %p(%d) Connection is in progress", __func__,
9393 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
9394 return VOS_TRUE;
9395 }
Ganesh Kondabattiniaeb7b772014-08-11 20:00:36 +05309396 if (((!isRoC) && (WLAN_HDD_INFRA_STATION == pAdapter->device_mode)) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309397 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
9398 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009399 {
9400 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9401 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309402 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009403 {
9404 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
9405 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08009406 "%s: client " MAC_ADDRESS_STR
9407 " is in the middle of WPS/EAPOL exchange.", __func__,
9408 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +05309409 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009410 }
9411 }
9412 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
9413 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
9414 {
9415 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
9416 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309417 if ((pAdapter->aStaInfo[staId].isUsed) &&
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009418 (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState))
9419 {
9420 staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
9421
9422 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08009423 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
9424 "middle of WPS/EAPOL exchange.", __func__,
9425 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +05309426 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009427 }
9428 }
9429 }
9430 }
9431 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
9432 pAdapterNode = pNext;
9433 }
Rashmi Ramannab1429032014-04-26 14:59:09 +05309434 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309435}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009436
9437/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05309438 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -07009439 * this scan respond to scan trigger and update cfg80211 scan database
9440 * later, scan dump command can be used to recieve scan results
9441 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05309442int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009443#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
9444 struct net_device *dev,
9445#endif
9446 struct cfg80211_scan_request *request)
9447{
Siddharth Bhal0c162d02014-05-06 19:50:42 +05309448 hdd_adapter_t *pAdapter = NULL;
9449 hdd_context_t *pHddCtx = NULL;
9450 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309451 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009452 tCsrScanRequest scanRequest;
9453 tANI_U8 *channelList = NULL, i;
9454 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309455 int status;
9456 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009457 v_U8_t* pP2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009458
Siddharth Bhal0c162d02014-05-06 19:50:42 +05309459#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
9460 struct net_device *dev = NULL;
9461 if (NULL == request)
9462 {
9463 hddLog(VOS_TRACE_LEVEL_ERROR,
9464 "%s: scan req param null", __func__);
9465 return -EINVAL;
9466 }
9467 dev = request->wdev->netdev;
9468#endif
9469
9470 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
9471 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
9472 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9473
Jeff Johnson295189b2012-06-20 16:38:30 -07009474 ENTER();
9475
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309476
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309477 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9478 __func__, hdd_device_modetoString(pAdapter->device_mode),
9479 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309480
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309481 status = wlan_hdd_validate_context(pHddCtx);
9482
9483 if (0 != status)
9484 {
9485 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9486 "%s: HDD context is not valid", __func__);
9487 return status;
9488 }
9489
Siddharth Bhal0c162d02014-05-06 19:50:42 +05309490 if (NULL == pwextBuf)
9491 {
9492 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
9493 __func__);
9494 return -EIO;
9495 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309496 cfg_param = pHddCtx->cfg_ini;
9497 pScanInfo = &pHddCtx->scan_info;
9498
Jeff Johnson295189b2012-06-20 16:38:30 -07009499#ifdef WLAN_BTAMP_FEATURE
9500 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009501 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -07009502 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08009503 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009504 "%s: No scanning when AMP is on", __func__);
9505 return -EOPNOTSUPP;
9506 }
9507#endif
9508 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009509 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009510 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009511 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309512 "%s: Not scanning on device_mode = %s (%d)",
9513 __func__, hdd_device_modetoString(pAdapter->device_mode),
9514 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009515 return -EOPNOTSUPP;
9516 }
9517
9518 if (TRUE == pScanInfo->mScanPending)
9519 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05309520 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
9521 {
9522 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
9523 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009524 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07009525 }
9526
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309527 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -07009528 //Channel and action frame is pending
9529 //Otherwise Cancel Remain On Channel and allow Scan
9530 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009531 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -07009532 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05309533 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009534 return -EBUSY;
9535 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009536#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07009537 /* if tdls disagree scan right now, return immediately.
9538 tdls will schedule the scan when scan is allowed. (return SUCCESS)
9539 or will reject the scan if any TDLS is in progress. (return -EBUSY)
9540 */
9541 status = wlan_hdd_tdls_scan_callback (pAdapter,
9542 wiphy,
9543#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
9544 dev,
Gopichand Nakkalac3c42b92013-03-20 19:42:34 -07009545#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07009546 request);
9547 if(status <= 0)
9548 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309549 if(!status)
9550 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
9551 "scan rejected %d", __func__, status);
9552 else
9553 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
9554 __func__, status);
9555
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07009556 return status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009557 }
9558#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07009559
Jeff Johnson295189b2012-06-20 16:38:30 -07009560 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
9561 {
9562 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -08009563 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009564 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309565 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009566 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
9567 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309568 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009569 "%s: MAX TM Level Scan not allowed", __func__);
9570 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309571 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07009572 }
9573 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
9574
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009575 /* Check if scan is allowed at this point of time.
9576 */
Ganesh Kondabattiniaeb7b772014-08-11 20:00:36 +05309577 if (hdd_isConnectionInProgress(pHddCtx, VOS_FALSE))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08009578 {
9579 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
9580 return -EBUSY;
9581 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309582
Jeff Johnson295189b2012-06-20 16:38:30 -07009583 vos_mem_zero( &scanRequest, sizeof(scanRequest));
9584
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309585 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
9586 (int)request->n_ssids);
9587
9588 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
9589 * Becasue of this, driver is assuming that this is not wildcard scan and so
9590 * is not aging out the scan results.
9591 */
9592 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07009593 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309594 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009595 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309596
9597 if ((request->ssids) && (0 < request->n_ssids))
9598 {
9599 tCsrSSIDInfo *SsidInfo;
9600 int j;
9601 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
9602 /* Allocate num_ssid tCsrSSIDInfo structure */
9603 SsidInfo = scanRequest.SSIDs.SSIDList =
9604 ( tCsrSSIDInfo *)vos_mem_malloc(
9605 request->n_ssids*sizeof(tCsrSSIDInfo));
9606
9607 if(NULL == scanRequest.SSIDs.SSIDList)
9608 {
9609 hddLog(VOS_TRACE_LEVEL_ERROR,
9610 "%s: memory alloc failed SSIDInfo buffer", __func__);
9611 return -ENOMEM;
9612 }
9613
9614 /* copy all the ssid's and their length */
9615 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
9616 {
9617 /* get the ssid length */
9618 SsidInfo->SSID.length = request->ssids[j].ssid_len;
9619 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
9620 SsidInfo->SSID.length);
9621 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
9622 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
9623 j, SsidInfo->SSID.ssId);
9624 }
9625 /* set the scan type to active */
9626 scanRequest.scanType = eSIR_ACTIVE_SCAN;
9627 }
9628 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07009629 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +05309630 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9631 TRACE_CODE_HDD_CFG80211_SCAN,
9632 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07009633 /* set the scan type to active */
9634 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07009635 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309636 else
9637 {
9638 /*Set the scan type to default type, in this case it is ACTIVE*/
9639 scanRequest.scanType = pScanInfo->scan_mode;
9640 }
9641 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
9642 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07009643
9644 /* set BSSType to default type */
9645 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
9646
9647 /*TODO: scan the requested channels only*/
9648
9649 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309650 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -07009651 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309652 hddLog(VOS_TRACE_LEVEL_WARN,
9653 "No of Scan Channels exceeded limit: %d", request->n_channels);
9654 request->n_channels = MAX_CHANNEL;
9655 }
9656
9657 hddLog(VOS_TRACE_LEVEL_INFO,
9658 "No of Scan Channels: %d", request->n_channels);
9659
9660
9661 if( request->n_channels )
9662 {
9663 char chList [(request->n_channels*5)+1];
9664 int len;
9665 channelList = vos_mem_malloc( request->n_channels );
9666 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +05309667 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309668 hddLog(VOS_TRACE_LEVEL_ERROR,
9669 "%s: memory alloc failed channelList", __func__);
9670 status = -ENOMEM;
9671 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +05309672 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309673
9674 for( i = 0, len = 0; i < request->n_channels ; i++ )
9675 {
9676 channelList[i] = request->channels[i]->hw_value;
9677 len += snprintf(chList+len, 5, "%d ", channelList[i]);
9678 }
9679
Nirav Shah20ac06f2013-12-12 18:14:06 +05309680 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309681 "Channel-List: %s ", chList);
9682 }
c_hpothu53512302014-04-15 18:49:53 +05309683
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309684 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
9685 scanRequest.ChannelInfo.ChannelList = channelList;
9686
9687 /* set requestType to full scan */
9688 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
9689
9690 /* Flush the scan results(only p2p beacons) for STA scan and P2P
9691 * search (Flush on both full scan and social scan but not on single
9692 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
9693 */
9694
9695 /* Supplicant does single channel scan after 8-way handshake
9696 * and in that case driver shoudnt flush scan results. If
9697 * driver flushes the scan results here and unfortunately if
9698 * the AP doesnt respond to our probe req then association
9699 * fails which is not desired
9700 */
9701
9702 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
9703 {
9704 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
9705 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
9706 pAdapter->sessionId );
9707 }
9708
9709 if( request->ie_len )
9710 {
9711 /* save this for future association (join requires this) */
9712 /*TODO: Array needs to be converted to dynamic allocation,
9713 * as multiple ie.s can be sent in cfg80211_scan_request structure
9714 * CR 597966
9715 */
9716 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
9717 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
9718 pScanInfo->scanAddIE.length = request->ie_len;
9719
9720 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
9721 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
9722 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07009723 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309724 if ( request->ie_len <= SIR_MAC_MAX_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -07009725 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309726 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
9727 memcpy( pwextBuf->roamProfile.addIEScan,
9728 request->ie, request->ie_len);
9729 }
9730 else
9731 {
9732 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
9733 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07009734 }
9735
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309736 }
9737 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
9738 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
9739
9740 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
9741 request->ie_len);
9742 if (pP2pIe != NULL)
9743 {
9744#ifdef WLAN_FEATURE_P2P_DEBUG
9745 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
9746 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
9747 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +05309748 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309749 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
9750 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
9751 "Go nego completed to Connection is started");
9752 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
9753 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +05309754 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309755 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
9756 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07009757 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309758 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
9759 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
9760 "Disconnected state to Connection is started");
9761 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
9762 "for 4way Handshake");
9763 }
9764#endif
9765
9766 /* no_cck will be set during p2p find to disable 11b rates */
9767 if(TRUE == request->no_cck)
9768 {
9769 hddLog(VOS_TRACE_LEVEL_INFO,
9770 "%s: This is a P2P Search", __func__);
9771 scanRequest.p2pSearch = 1;
9772
9773 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +05309774 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309775 /* set requestType to P2P Discovery */
9776 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
9777 }
9778
9779 /*
9780 Skip Dfs Channel in case of P2P Search
9781 if it is set in ini file
9782 */
9783 if(cfg_param->skipDfsChnlInP2pSearch)
9784 {
9785 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +05309786 }
9787 else
9788 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309789 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05309790 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009791
Agarwal Ashish4f616132013-12-30 23:32:50 +05309792 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009793 }
9794 }
9795
9796 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
9797
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07009798 /* acquire the wakelock to avoid the apps suspend during the scan. To
9799 * address the following issues.
9800 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
9801 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
9802 * for long time, this result in apps running at full power for long time.
9803 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
9804 * be stuck in full power because of resume BMPS
9805 */
9806 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07009807
Nirav Shah20ac06f2013-12-12 18:14:06 +05309808 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9809 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309810 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
9811 scanRequest.requestType, scanRequest.scanType,
9812 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +05309813 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
9814
Jeff Johnsone7245742012-09-05 17:12:55 -07009815 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009816 pAdapter->sessionId, &scanRequest, &scanId,
9817 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -07009818
Jeff Johnson295189b2012-06-20 16:38:30 -07009819 if (eHAL_STATUS_SUCCESS != status)
9820 {
9821 hddLog(VOS_TRACE_LEVEL_ERROR,
9822 "%s: sme_ScanRequest returned error %d", __func__, status);
9823 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07009824 if(eHAL_STATUS_RESOURCES == status)
9825 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309826 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
9827 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07009828 status = -EBUSY;
9829 } else {
9830 status = -EIO;
9831 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07009832 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07009833 goto free_mem;
9834 }
9835
9836 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309837 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009838 pAdapter->request = request;
9839 pScanInfo->scanId = scanId;
9840
9841 complete(&pScanInfo->scan_req_completion_event);
9842
9843free_mem:
9844 if( scanRequest.SSIDs.SSIDList )
9845 {
9846 vos_mem_free(scanRequest.SSIDs.SSIDList);
9847 }
9848
9849 if( channelList )
9850 vos_mem_free( channelList );
9851
9852 EXIT();
9853
9854 return status;
9855}
9856
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05309857int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
9858#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
9859 struct net_device *dev,
9860#endif
9861 struct cfg80211_scan_request *request)
9862{
9863 int ret;
9864
9865 vos_ssr_protect(__func__);
9866 ret = __wlan_hdd_cfg80211_scan(wiphy,
9867#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
9868 dev,
9869#endif
9870 request);
9871 vos_ssr_unprotect(__func__);
9872
9873 return ret;
9874}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07009875
9876void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
9877{
9878 v_U8_t iniDot11Mode =
9879 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
9880 eHddDot11Mode hddDot11Mode = iniDot11Mode;
9881
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05309882 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
9883 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07009884 switch ( iniDot11Mode )
9885 {
9886 case eHDD_DOT11_MODE_AUTO:
9887 case eHDD_DOT11_MODE_11ac:
9888 case eHDD_DOT11_MODE_11ac_ONLY:
9889#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +05309890 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
9891 sme_IsFeatureSupportedByFW(DOT11AC) )
9892 hddDot11Mode = eHDD_DOT11_MODE_11ac;
9893 else
9894 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07009895#else
9896 hddDot11Mode = eHDD_DOT11_MODE_11n;
9897#endif
9898 break;
9899 case eHDD_DOT11_MODE_11n:
9900 case eHDD_DOT11_MODE_11n_ONLY:
9901 hddDot11Mode = eHDD_DOT11_MODE_11n;
9902 break;
9903 default:
9904 hddDot11Mode = iniDot11Mode;
9905 break;
9906 }
9907 /* This call decides required channel bonding mode */
9908 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
9909 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
9910 operationChannel);
9911}
9912
Jeff Johnson295189b2012-06-20 16:38:30 -07009913/*
9914 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309915 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -07009916 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309917int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -07009918 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07009919{
9920 int status = 0;
9921 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -08009922 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009923 v_U32_t roamId;
9924 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07009925 eCsrAuthType RSNAuthType;
9926
9927 ENTER();
9928
9929 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -08009930 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9931
9932 status = wlan_hdd_validate_context(pHddCtx);
9933 if (status)
9934 {
9935 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9936 "%s: HDD context is not valid!", __func__);
9937 return status;
9938 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309939
Jeff Johnson295189b2012-06-20 16:38:30 -07009940 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
9941 {
9942 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
9943 return -EINVAL;
9944 }
9945
9946 pRoamProfile = &pWextState->roamProfile;
9947
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309948 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07009949 {
Jeff Johnsone7245742012-09-05 17:12:55 -07009950 hdd_station_ctx_t *pHddStaCtx;
9951 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009952
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309953 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07009954 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
9955 {
9956 /*QoS not enabled in cfg file*/
9957 pRoamProfile->uapsd_mask = 0;
9958 }
9959 else
9960 {
9961 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309962 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -07009963 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
9964 }
9965
9966 pRoamProfile->SSIDs.numOfSSIDs = 1;
9967 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
9968 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309969 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009970 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
9971 ssid, ssid_len);
9972
9973 if (bssid)
9974 {
9975 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
9976 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
9977 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309978 /* Save BSSID in seperate variable as well, as RoamProfile
9979 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -07009980 case of join failure we should send valid BSSID to supplicant
9981 */
9982 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
9983 WNI_CFG_BSSID_LEN);
9984 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07009985 else
9986 {
9987 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
9988 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009989
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05309990 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
9991 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07009992 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
9993 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309994 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009995 /*set gen ie*/
9996 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
9997 /*set auth*/
9998 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
9999 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010000#ifdef FEATURE_WLAN_WAPI
10001 if (pAdapter->wapi_info.nWapiMode)
10002 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010003 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010004 switch (pAdapter->wapi_info.wapiAuthMode)
10005 {
10006 case WAPI_AUTH_MODE_PSK:
10007 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010008 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070010009 pAdapter->wapi_info.wapiAuthMode);
10010 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
10011 break;
10012 }
10013 case WAPI_AUTH_MODE_CERT:
10014 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010015 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070010016 pAdapter->wapi_info.wapiAuthMode);
10017 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
10018 break;
10019 }
10020 } // End of switch
10021 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
10022 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
10023 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010024 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010025 pRoamProfile->AuthType.numEntries = 1;
10026 pRoamProfile->EncryptionType.numEntries = 1;
10027 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
10028 pRoamProfile->mcEncryptionType.numEntries = 1;
10029 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
10030 }
10031 }
10032#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010033#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053010034 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010035 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
10036 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
10037 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053010038 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
10039 sizeof (tSirGtkOffloadParams));
10040 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010041 }
10042#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010043 pRoamProfile->csrPersona = pAdapter->device_mode;
10044
Jeff Johnson32d95a32012-09-10 13:15:23 -070010045 if( operatingChannel )
10046 {
10047 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
10048 pRoamProfile->ChannelInfo.numOfChannels = 1;
10049 }
Chet Lanctot186b5732013-03-18 10:26:30 -070010050 else
10051 {
10052 pRoamProfile->ChannelInfo.ChannelList = NULL;
10053 pRoamProfile->ChannelInfo.numOfChannels = 0;
10054 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010055 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
10056 {
10057 hdd_select_cbmode(pAdapter,operatingChannel);
10058 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053010059
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080010060 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
10061 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010062 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080010063 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080010064 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
10065 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053010066 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
10067 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053010068 {
10069 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10070 "%s: Set HDD connState to eConnectionState_Connecting",
10071 __func__);
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080010072 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
10073 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053010074 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010075 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070010076 pAdapter->sessionId, pRoamProfile, &roamId);
10077
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053010078 if ((eHAL_STATUS_SUCCESS != status) &&
10079 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
10080 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053010081
10082 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080010083 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
10084 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
10085 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053010086 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080010087 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053010088 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080010089
10090 pRoamProfile->ChannelInfo.ChannelList = NULL;
10091 pRoamProfile->ChannelInfo.numOfChannels = 0;
10092
Jeff Johnson295189b2012-06-20 16:38:30 -070010093 }
10094 else
10095 {
10096 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
10097 return -EINVAL;
10098 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080010099 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010100 return status;
10101}
10102
10103/*
10104 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
10105 * This function is used to set the authentication type (OPEN/SHARED).
10106 *
10107 */
10108static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
10109 enum nl80211_auth_type auth_type)
10110{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010111 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010112 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10113
10114 ENTER();
10115
10116 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010117 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070010118 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010119 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053010120 hddLog(VOS_TRACE_LEVEL_INFO,
10121 "%s: set authentication type to AUTOSWITCH", __func__);
10122 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
10123 break;
10124
10125 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070010126#ifdef WLAN_FEATURE_VOWIFI_11R
10127 case NL80211_AUTHTYPE_FT:
10128#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010129 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070010130 "%s: set authentication type to OPEN", __func__);
10131 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
10132 break;
10133
10134 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010135 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070010136 "%s: set authentication type to SHARED", __func__);
10137 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
10138 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010139#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010140 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010141 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070010142 "%s: set authentication type to CCKM WPA", __func__);
10143 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
10144 break;
10145#endif
10146
10147
10148 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010149 hddLog(VOS_TRACE_LEVEL_ERROR,
10150 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070010151 auth_type);
10152 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
10153 return -EINVAL;
10154 }
10155
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010156 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070010157 pHddStaCtx->conn_info.authType;
10158 return 0;
10159}
10160
10161/*
10162 * FUNCTION: wlan_hdd_set_akm_suite
10163 * This function is used to set the key mgmt type(PSK/8021x).
10164 *
10165 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010166static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070010167 u32 key_mgmt
10168 )
10169{
10170 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10171 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053010172 /* Should be in ieee802_11_defs.h */
10173#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
10174#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070010175 /*set key mgmt type*/
10176 switch(key_mgmt)
10177 {
10178 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053010179 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053010180#ifdef WLAN_FEATURE_VOWIFI_11R
10181 case WLAN_AKM_SUITE_FT_PSK:
10182#endif
10183 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070010184 __func__);
10185 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
10186 break;
10187
10188 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053010189 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053010190#ifdef WLAN_FEATURE_VOWIFI_11R
10191 case WLAN_AKM_SUITE_FT_8021X:
10192#endif
10193 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070010194 __func__);
10195 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
10196 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010197#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010198#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
10199#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
10200 case WLAN_AKM_SUITE_CCKM:
10201 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
10202 __func__);
10203 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
10204 break;
10205#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070010206#ifndef WLAN_AKM_SUITE_OSEN
10207#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
10208 case WLAN_AKM_SUITE_OSEN:
10209 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
10210 __func__);
10211 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
10212 break;
10213#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010214
10215 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010216 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010217 __func__, key_mgmt);
10218 return -EINVAL;
10219
10220 }
10221 return 0;
10222}
10223
10224/*
10225 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010226 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070010227 * (NONE/WEP40/WEP104/TKIP/CCMP).
10228 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010229static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
10230 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070010231 bool ucast
10232 )
10233{
10234 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010235 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010236 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10237
10238 ENTER();
10239
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010240 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070010241 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010242 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070010243 __func__, cipher);
10244 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
10245 }
10246 else
10247 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010248
Jeff Johnson295189b2012-06-20 16:38:30 -070010249 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010250 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070010251 {
10252 case IW_AUTH_CIPHER_NONE:
10253 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
10254 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010255
Jeff Johnson295189b2012-06-20 16:38:30 -070010256 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053010257 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070010258 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010259
Jeff Johnson295189b2012-06-20 16:38:30 -070010260 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053010261 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070010262 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010263
Jeff Johnson295189b2012-06-20 16:38:30 -070010264 case WLAN_CIPHER_SUITE_TKIP:
10265 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
10266 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010267
Jeff Johnson295189b2012-06-20 16:38:30 -070010268 case WLAN_CIPHER_SUITE_CCMP:
10269 encryptionType = eCSR_ENCRYPT_TYPE_AES;
10270 break;
10271#ifdef FEATURE_WLAN_WAPI
10272 case WLAN_CIPHER_SUITE_SMS4:
10273 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
10274 break;
10275#endif
10276
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010277#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010278 case WLAN_CIPHER_SUITE_KRK:
10279 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
10280 break;
10281#endif
10282 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010283 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010284 __func__, cipher);
10285 return -EOPNOTSUPP;
10286 }
10287 }
10288
10289 if (ucast)
10290 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010291 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010292 __func__, encryptionType);
10293 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
10294 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010295 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070010296 encryptionType;
10297 }
10298 else
10299 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010300 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010301 __func__, encryptionType);
10302 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
10303 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
10304 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
10305 }
10306
10307 return 0;
10308}
10309
10310
10311/*
10312 * FUNCTION: wlan_hdd_cfg80211_set_ie
10313 * This function is used to parse WPA/RSN IE's.
10314 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010315int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
10316 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -070010317 size_t ie_len
10318 )
10319{
10320 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10321 u8 *genie = ie;
10322 v_U16_t remLen = ie_len;
10323#ifdef FEATURE_WLAN_WAPI
10324 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
10325 u16 *tmp;
10326 v_U16_t akmsuiteCount;
10327 int *akmlist;
10328#endif
10329 ENTER();
10330
10331 /* clear previous assocAddIE */
10332 pWextState->assocAddIE.length = 0;
10333 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070010334 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010335
10336 while (remLen >= 2)
10337 {
10338 v_U16_t eLen = 0;
10339 v_U8_t elementId;
10340 elementId = *genie++;
10341 eLen = *genie++;
10342 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010343
Arif Hussain6d2a3322013-11-17 19:50:10 -080010344 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070010345 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010346
10347 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070010348 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010349 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010350 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 -070010351 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010352 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010353 "%s: Invalid WPA IE", __func__);
10354 return -EINVAL;
10355 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010356 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070010357 {
10358 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010359 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070010360 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010361
Jeff Johnson295189b2012-06-20 16:38:30 -070010362 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
10363 {
Jeff Johnson902c9832012-12-10 14:28:09 -080010364 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
10365 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070010366 VOS_ASSERT(0);
10367 return -ENOMEM;
10368 }
10369 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
10370 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
10371 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010372
Jeff Johnson295189b2012-06-20 16:38:30 -070010373 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
10374 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
10375 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
10376 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010377 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
10378 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010379 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
10380 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
10381 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
10382 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
10383 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
10384 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010385 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053010386 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070010387 {
10388 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010389 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070010390 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010391
Jeff Johnson295189b2012-06-20 16:38:30 -070010392 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
10393 {
Jeff Johnson902c9832012-12-10 14:28:09 -080010394 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
10395 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070010396 VOS_ASSERT(0);
10397 return -ENOMEM;
10398 }
10399 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
10400 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
10401 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010402
Jeff Johnson295189b2012-06-20 16:38:30 -070010403 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
10404 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
10405 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010406#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010407 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
10408 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070010409 /*Consider WFD IE, only for P2P Client */
10410 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
10411 {
10412 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010413 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070010414 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010415
Jeff Johnson295189b2012-06-20 16:38:30 -070010416 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
10417 {
Jeff Johnson902c9832012-12-10 14:28:09 -080010418 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
10419 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070010420 VOS_ASSERT(0);
10421 return -ENOMEM;
10422 }
10423 // WFD IE is saved to Additional IE ; it should be accumulated to handle
10424 // WPS IE + P2P IE + WFD IE
10425 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
10426 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010427
Jeff Johnson295189b2012-06-20 16:38:30 -070010428 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
10429 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
10430 }
10431#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010432 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010433 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070010434 HS20_OUI_TYPE_SIZE)) )
10435 {
10436 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010437 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070010438 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010439
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070010440 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
10441 {
Jeff Johnson902c9832012-12-10 14:28:09 -080010442 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
10443 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070010444 VOS_ASSERT(0);
10445 return -ENOMEM;
10446 }
10447 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
10448 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010449
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070010450 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
10451 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
10452 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070010453 /* Appending OSEN Information Element in Assiciation Request */
10454 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
10455 OSEN_OUI_TYPE_SIZE)) )
10456 {
10457 v_U16_t curAddIELen = pWextState->assocAddIE.length;
10458 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
10459 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010460
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070010461 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
10462 {
10463 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
10464 "Need bigger buffer space");
10465 VOS_ASSERT(0);
10466 return -ENOMEM;
10467 }
10468 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
10469 pWextState->assocAddIE.length += eLen + 2;
10470
10471 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
10472 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
10473 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
10474 }
10475
10476 break;
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070010477 if (WLAN_HDD_IBSS == pAdapter->device_mode) {
10478
10479 /* populating as ADDIE in beacon frames */
10480 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
10481 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
10482 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
10483 {
10484 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
10485 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
10486 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
10487 {
10488 hddLog(LOGE,
10489 "Coldn't pass "
10490 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
10491 }
10492 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
10493 else
10494 hddLog(LOGE,
10495 "Could not pass on "
10496 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
10497
10498 /* IBSS mode doesn't contain params->proberesp_ies still
10499 beaconIE's need to be populated in probe response frames */
10500 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
10501 {
10502 u16 rem_probe_resp_ie_len = eLen + 2;
10503 u8 probe_rsp_ie_len[3] = {0};
10504 u8 counter = 0;
10505
10506 /* Check Probe Resp Length if it is greater then 255 then
10507 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
10508 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
10509 not able Store More then 255 bytes into One Variable */
10510
10511 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
10512 {
10513 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
10514 {
10515 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
10516 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
10517 }
10518 else
10519 {
10520 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
10521 rem_probe_resp_ie_len = 0;
10522 }
10523 }
10524
10525 rem_probe_resp_ie_len = 0;
10526
10527 if (probe_rsp_ie_len[0] > 0)
10528 {
10529 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
10530 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
10531 (tANI_U8*)(genie - 2),
10532 probe_rsp_ie_len[0], NULL,
10533 eANI_BOOLEAN_FALSE)
10534 == eHAL_STATUS_FAILURE)
10535 {
10536 hddLog(LOGE,
10537 "Could not pass"
10538 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
10539 }
10540 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
10541 }
10542
10543 if (probe_rsp_ie_len[1] > 0)
10544 {
10545 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
10546 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
10547 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
10548 probe_rsp_ie_len[1], NULL,
10549 eANI_BOOLEAN_FALSE)
10550 == eHAL_STATUS_FAILURE)
10551 {
10552 hddLog(LOGE,
10553 "Could not pass"
10554 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
10555 }
10556 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
10557 }
10558
10559 if (probe_rsp_ie_len[2] > 0)
10560 {
10561 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
10562 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
10563 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
10564 probe_rsp_ie_len[2], NULL,
10565 eANI_BOOLEAN_FALSE)
10566 == eHAL_STATUS_FAILURE)
10567 {
10568 hddLog(LOGE,
10569 "Could not pass"
10570 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
10571 }
10572 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
10573 }
10574
10575 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
10576 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
10577 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
10578 {
10579 hddLog(LOGE,
10580 "Could not pass"
10581 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
10582 }
10583 }
10584 else
10585 {
10586 // Reset WNI_CFG_PROBE_RSP Flags
10587 wlan_hdd_reset_prob_rspies(pAdapter);
10588
10589 hddLog(VOS_TRACE_LEVEL_INFO,
10590 "%s: No Probe Response IE received in set beacon",
10591 __func__);
10592 }
10593 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070010594 break;
10595 case DOT11F_EID_RSN:
10596 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
10597 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
10598 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
10599 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
10600 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
10601 break;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010602 /* Appending Extended Capabilities with Interworking bit set in Assoc Req */
10603 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010604 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010605 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010606 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010607 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010608
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010609 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
10610 {
Jeff Johnson902c9832012-12-10 14:28:09 -080010611 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
10612 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010613 VOS_ASSERT(0);
10614 return -ENOMEM;
10615 }
10616 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
10617 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010618
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010619 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
10620 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
10621 break;
10622 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010623#ifdef FEATURE_WLAN_WAPI
10624 case WLAN_EID_WAPI:
10625 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070010626 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070010627 pAdapter->wapi_info.nWapiMode);
10628 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010629 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070010630 akmsuiteCount = WPA_GET_LE16(tmp);
10631 tmp = tmp + 1;
10632 akmlist = (int *)(tmp);
10633 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
10634 {
10635 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
10636 }
10637 else
10638 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010639 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070010640 VOS_ASSERT(0);
10641 return -EINVAL;
10642 }
10643
10644 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
10645 {
10646 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010647 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010648 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010649 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010650 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010651 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010652 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010653 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010654 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
10655 }
10656 break;
10657#endif
10658 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010659 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010660 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070010661 /* when Unknown IE is received we should break and continue
10662 * to the next IE in the buffer instead we were returning
10663 * so changing this to break */
10664 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010665 }
10666 genie += eLen;
10667 remLen -= eLen;
10668 }
10669 EXIT();
10670 return 0;
10671}
10672
10673/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053010674 * FUNCTION: hdd_isWPAIEPresent
10675 * Parse the received IE to find the WPA IE
10676 *
10677 */
10678static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
10679{
10680 v_U8_t eLen = 0;
10681 v_U16_t remLen = ie_len;
10682 v_U8_t elementId = 0;
10683
10684 while (remLen >= 2)
10685 {
10686 elementId = *ie++;
10687 eLen = *ie++;
10688 remLen -= 2;
10689 if (eLen > remLen)
10690 {
10691 hddLog(VOS_TRACE_LEVEL_ERROR,
10692 "%s: IE length is wrong %d", __func__, eLen);
10693 return FALSE;
10694 }
10695 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
10696 {
10697 /* OUI - 0x00 0X50 0XF2
10698 WPA Information Element - 0x01
10699 WPA version - 0x01*/
10700 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
10701 return TRUE;
10702 }
10703 ie += eLen;
10704 remLen -= eLen;
10705 }
10706 return FALSE;
10707}
10708
10709/*
Jeff Johnson295189b2012-06-20 16:38:30 -070010710 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010711 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070010712 * parameters during connect operation.
10713 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010714int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070010715 struct cfg80211_connect_params *req
10716 )
10717{
10718 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010719 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010720 ENTER();
10721
10722 /*set wpa version*/
10723 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
10724
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010725 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070010726 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053010727 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070010728 {
10729 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
10730 }
10731 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
10732 {
10733 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
10734 }
10735 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010736
10737 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070010738 pWextState->wpaVersion);
10739
10740 /*set authentication type*/
10741 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
10742
10743 if (0 > status)
10744 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010745 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010746 "%s: failed to set authentication type ", __func__);
10747 return status;
10748 }
10749
10750 /*set key mgmt type*/
10751 if (req->crypto.n_akm_suites)
10752 {
10753 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
10754 if (0 > status)
10755 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010756 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070010757 __func__);
10758 return status;
10759 }
10760 }
10761
10762 /*set pairwise cipher type*/
10763 if (req->crypto.n_ciphers_pairwise)
10764 {
10765 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
10766 req->crypto.ciphers_pairwise[0], true);
10767 if (0 > status)
10768 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010769 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010770 "%s: failed to set unicast cipher type", __func__);
10771 return status;
10772 }
10773 }
10774 else
10775 {
10776 /*Reset previous cipher suite to none*/
10777 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
10778 if (0 > status)
10779 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010780 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010781 "%s: failed to set unicast cipher type", __func__);
10782 return status;
10783 }
10784 }
10785
10786 /*set group cipher type*/
10787 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
10788 false);
10789
10790 if (0 > status)
10791 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010792 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070010793 __func__);
10794 return status;
10795 }
10796
Chet Lanctot186b5732013-03-18 10:26:30 -070010797#ifdef WLAN_FEATURE_11W
10798 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
10799#endif
10800
Jeff Johnson295189b2012-06-20 16:38:30 -070010801 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
10802 if (req->ie_len)
10803 {
10804 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
10805 if ( 0 > status)
10806 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010807 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070010808 __func__);
10809 return status;
10810 }
10811 }
10812
10813 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010814 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070010815 {
10816 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
10817 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
10818 )
10819 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010820 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070010821 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
10822 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010823 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070010824 __func__);
10825 return -EOPNOTSUPP;
10826 }
10827 else
10828 {
10829 u8 key_len = req->key_len;
10830 u8 key_idx = req->key_idx;
10831
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010832 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070010833 && (CSR_MAX_NUM_KEY > key_idx)
10834 )
10835 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010836 hddLog(VOS_TRACE_LEVEL_INFO,
10837 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070010838 __func__, key_idx, key_len);
10839 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010840 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070010841 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010842 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070010843 (u8)key_len;
10844 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
10845 }
10846 }
10847 }
10848 }
10849
10850 return status;
10851}
10852
10853/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053010854 * FUNCTION: wlan_hdd_try_disconnect
10855 * This function is used to disconnect from previous
10856 * connection
10857 */
10858static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
10859{
10860 long ret = 0;
10861 hdd_station_ctx_t *pHddStaCtx;
10862 eMib_dot11DesiredBssType connectedBssType;
10863
10864 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10865
10866 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
10867
10868 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
10869 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
10870 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
10871 {
10872 /* Issue disconnect to CSR */
10873 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10874 if( eHAL_STATUS_SUCCESS ==
10875 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10876 pAdapter->sessionId,
10877 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
10878 {
10879 ret = wait_for_completion_interruptible_timeout(
10880 &pAdapter->disconnect_comp_var,
10881 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10882 if (0 >= ret)
10883 {
10884 hddLog(LOGE, FL("Failed to receive disconnect event"));
10885 return -EALREADY;
10886 }
10887 }
10888 }
10889 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
10890 {
10891 ret = wait_for_completion_interruptible_timeout(
10892 &pAdapter->disconnect_comp_var,
10893 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10894 if (0 >= ret)
10895 {
10896 hddLog(LOGE, FL("Failed to receive disconnect event"));
10897 return -EALREADY;
10898 }
10899 }
10900
10901 return 0;
10902}
10903
10904/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053010905 * FUNCTION: __wlan_hdd_cfg80211_connect
10906 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070010907 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010908static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010909 struct net_device *ndev,
10910 struct cfg80211_connect_params *req
10911 )
10912{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010913 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010914 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070010915 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053010916 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010917
10918 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010919
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010920 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10921 TRACE_CODE_HDD_CFG80211_CONNECT,
10922 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010923 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010924 "%s: device_mode = %s (%d)", __func__,
10925 hdd_device_modetoString(pAdapter->device_mode),
10926 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010927
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010928 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010929 if (!pHddCtx)
10930 {
10931 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10932 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053010933 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010934 }
10935
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010936 status = wlan_hdd_validate_context(pHddCtx);
10937
10938 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070010939 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010940 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10941 "%s: HDD context is not valid", __func__);
10942 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010943 }
10944
Agarwal Ashish51325b52014-06-16 16:50:49 +053010945 if (vos_max_concurrent_connections_reached()) {
10946 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
10947 return -ECONNREFUSED;
10948 }
10949
Jeff Johnson295189b2012-06-20 16:38:30 -070010950#ifdef WLAN_BTAMP_FEATURE
10951 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010952 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070010953 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010954 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010955 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080010956 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010957 }
10958#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053010959
10960 //If Device Mode is Station Concurrent Sessions Exit BMps
10961 //P2P Mode will be taken care in Open/close adapter
10962 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053010963 (vos_concurrent_open_sessions_running())) {
10964 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
10965 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053010966 }
10967
10968 /*Try disconnecting if already in connected state*/
10969 status = wlan_hdd_try_disconnect(pAdapter);
10970 if ( 0 > status)
10971 {
10972 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
10973 " connection"));
10974 return -EALREADY;
10975 }
10976
Jeff Johnson295189b2012-06-20 16:38:30 -070010977 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010978 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070010979
10980 if ( 0 > status)
10981 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010982 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070010983 __func__);
10984 return status;
10985 }
Mohit Khanna765234a2012-09-11 15:08:35 -070010986 if ( req->channel )
10987 {
10988 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
10989 req->ssid_len, req->bssid,
10990 req->channel->hw_value);
10991 }
10992 else
10993 {
10994 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010995 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -070010996 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010997
10998 if (0 > status)
10999 {
11000 //ReEnable BMPS if disabled
11001 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
11002 (NULL != pHddCtx))
11003 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053011004 if (pHddCtx->hdd_wlan_suspended)
11005 {
11006 hdd_set_pwrparams(pHddCtx);
11007 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011008 //ReEnable Bmps and Imps back
11009 hdd_enable_bmps_imps(pHddCtx);
11010 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053011011 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011012 return status;
11013 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011014 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011015 EXIT();
11016 return status;
11017}
11018
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011019static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
11020 struct net_device *ndev,
11021 struct cfg80211_connect_params *req)
11022{
11023 int ret;
11024 vos_ssr_protect(__func__);
11025 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
11026 vos_ssr_unprotect(__func__);
11027
11028 return ret;
11029}
Jeff Johnson295189b2012-06-20 16:38:30 -070011030
11031/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011032 * FUNCTION: wlan_hdd_disconnect
11033 * This function is used to issue a disconnect request to SME
11034 */
11035int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
11036{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011037 int status;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011038 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011039 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011040 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011041
11042 status = wlan_hdd_validate_context(pHddCtx);
11043
11044 if (0 != status)
11045 {
11046 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11047 "%s: HDD context is not valid", __func__);
11048 return status;
11049 }
11050
11051 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053011052
Agarwal Ashish47d18112014-08-04 19:55:07 +053011053 /* Need to apply spin lock before decreasing active sessions
11054 * as there can be chance for double decrement if context switch
11055 * Calls hdd_DisConnectHandler.
11056 */
11057
11058 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053011059 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
11060 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053011061 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
11062 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053011063 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
11064 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053011065
Abhishek Singhf4669da2014-05-26 15:07:49 +053011066 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053011067 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
11068
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011069 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011070
Mihir Shete182a0b22014-08-18 16:08:48 +053011071 /*
11072 * stop tx queues before deleting STA/BSS context from the firmware.
11073 * tx has to be disabled because the firmware can get busy dropping
11074 * the tx frames after BSS/STA has been deleted and will not send
11075 * back a response resulting in WDI timeout
11076 */
11077 netif_tx_disable(pAdapter->dev);
11078 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011079
Mihir Shete182a0b22014-08-18 16:08:48 +053011080 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011081 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
11082 pAdapter->sessionId, reason);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011083 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
11084 {
11085 hddLog(VOS_TRACE_LEVEL_INFO,
11086 FL("status = %d, already disconnected"),
11087 (int)status );
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011088
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011089 }
11090 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011091 {
11092 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011093 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011094 __func__, (int)status );
11095 return -EINVAL;
11096 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011097 ret = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011098 &pAdapter->disconnect_comp_var,
11099 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011100 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status ))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011101 {
11102 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053011103 "%s: Failed to disconnect, timed out", __func__);
11104 return -ETIMEDOUT;
11105 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011106 else if (ret == -ERESTARTSYS)
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053011107 {
11108 hddLog(VOS_TRACE_LEVEL_ERROR,
11109 "%s: Failed to disconnect, wait interrupted", __func__);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011110 return ret;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011111 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053011112 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11113 FL("Set HDD connState to eConnectionState_NotConnected"));
11114 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
11115
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053011116 return 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011117}
11118
11119
11120/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011121 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070011122 * This function is used to issue a disconnect request to SME
11123 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011124static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011125 struct net_device *dev,
11126 u16 reason
11127 )
11128{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011129 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011130 tCsrRoamProfile *pRoamProfile =
11131 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011132 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011133 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11134 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053011135#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080011136 tANI_U8 staIdx;
11137#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011138
Jeff Johnson295189b2012-06-20 16:38:30 -070011139 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011140
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011141 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11142 TRACE_CODE_HDD_CFG80211_DISCONNECT,
11143 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011144 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
11145 __func__, hdd_device_modetoString(pAdapter->device_mode),
11146 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011147
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011148 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
11149 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070011150
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011151 status = wlan_hdd_validate_context(pHddCtx);
11152
11153 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070011154 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011155 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11156 "%s: HDD context is not valid", __func__);
11157 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011158 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011159
Jeff Johnson295189b2012-06-20 16:38:30 -070011160 if (NULL != pRoamProfile)
11161 {
11162 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053011163 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
11164 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070011165 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011166 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070011167 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053011168 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070011169 switch(reason)
11170 {
11171 case WLAN_REASON_MIC_FAILURE:
11172 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
11173 break;
11174
11175 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
11176 case WLAN_REASON_DISASSOC_AP_BUSY:
11177 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
11178 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
11179 break;
11180
11181 case WLAN_REASON_PREV_AUTH_NOT_VALID:
11182 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053011183 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070011184 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
11185 break;
11186
Jeff Johnson295189b2012-06-20 16:38:30 -070011187 default:
11188 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
11189 break;
11190 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053011191 pScanInfo = &pHddCtx->scan_info;
11192 if (pScanInfo->mScanPending)
11193 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053011194 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053011195 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053011196 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053011197 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053011198 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011199
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080011200#ifdef FEATURE_WLAN_TDLS
11201 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080011202 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080011203 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080011204 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
11205 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080011206 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080011207 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080011208 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080011209 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011210 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080011211 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011212 MAC_ADDR_ARRAY(mac));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080011213 sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala4327a152013-03-04 23:22:42 -080011214 pAdapter->sessionId,
11215 mac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080011216 }
11217 }
11218#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011219 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011220 status = wlan_hdd_disconnect(pAdapter, reasonCode);
11221 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070011222 {
11223 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011224 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011225 __func__, (int)status );
11226 return -EINVAL;
11227 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011228 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053011229 else
11230 {
11231 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
11232 "called while in %d state", __func__,
11233 pHddStaCtx->conn_info.connState);
11234 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011235 }
11236 else
11237 {
11238 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
11239 }
11240
11241 return status;
11242}
11243
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011244static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
11245 struct net_device *dev,
11246 u16 reason
11247 )
11248{
11249 int ret;
11250 vos_ssr_protect(__func__);
11251 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
11252 vos_ssr_unprotect(__func__);
11253
11254 return ret;
11255}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053011256
Jeff Johnson295189b2012-06-20 16:38:30 -070011257/*
11258 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011259 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070011260 * settings in IBSS mode.
11261 */
11262static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011263 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011264 struct cfg80211_ibss_params *params
11265 )
11266{
11267 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011268 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011269 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11270 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011271
Jeff Johnson295189b2012-06-20 16:38:30 -070011272 ENTER();
11273
11274 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070011275 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070011276
11277 if (params->ie_len && ( NULL != params->ie) )
11278 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070011279 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
11280 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070011281 {
11282 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
11283 encryptionType = eCSR_ENCRYPT_TYPE_AES;
11284 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070011285 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070011286 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011287 tDot11fIEWPA dot11WPAIE;
11288 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070011289 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011290
Wilson Yang00256342013-10-10 23:13:38 -070011291 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070011292 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
11293 params->ie_len, DOT11F_EID_WPA);
11294 if ( NULL != ie )
11295 {
11296 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
11297 // Unpack the WPA IE
11298 //Skip past the EID byte and length byte - and four byte WiFi OUI
11299 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
11300 &ie[2+4],
11301 ie[1] - 4,
11302 &dot11WPAIE);
11303 /*Extract the multicast cipher, the encType for unicast
11304 cipher for wpa-none is none*/
11305 encryptionType =
11306 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
11307 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011308 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070011309
Jeff Johnson295189b2012-06-20 16:38:30 -070011310 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
11311
11312 if (0 > status)
11313 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011314 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070011315 __func__);
11316 return status;
11317 }
11318 }
11319
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011320 pWextState->roamProfile.AuthType.authType[0] =
11321 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070011322 eCSR_AUTH_TYPE_OPEN_SYSTEM;
11323
11324 if (params->privacy)
11325 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011326 /* Security enabled IBSS, At this time there is no information available
11327 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070011328 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011329 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070011330 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011331 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070011332 *enable privacy bit in beacons */
11333
11334 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
11335 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011336 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
11337 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011338 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
11339 pWextState->roamProfile.EncryptionType.numEntries = 1;
11340 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070011341 return status;
11342}
11343
11344/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011345 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011346 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070011347 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011348static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011349 struct net_device *dev,
11350 struct cfg80211_ibss_params *params
11351 )
11352{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011353 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070011354 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11355 tCsrRoamProfile *pRoamProfile;
11356 int status;
krunal sonie9002db2013-11-25 14:24:17 -080011357 bool alloc_bssid = VOS_FALSE;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011358 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11359 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011360
11361 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011362
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011363 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11364 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
11365 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011366 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011367 "%s: device_mode = %s (%d)", __func__,
11368 hdd_device_modetoString(pAdapter->device_mode),
11369 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011370
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011371 status = wlan_hdd_validate_context(pHddCtx);
11372
11373 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070011374 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011375 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11376 "%s: HDD context is not valid", __func__);
11377 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011378 }
11379
11380 if (NULL == pWextState)
11381 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011382 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070011383 __func__);
11384 return -EIO;
11385 }
11386
Agarwal Ashish51325b52014-06-16 16:50:49 +053011387 if (vos_max_concurrent_connections_reached()) {
11388 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
11389 return -ECONNREFUSED;
11390 }
11391
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053011392 /*Try disconnecting if already in connected state*/
11393 status = wlan_hdd_try_disconnect(pAdapter);
11394 if ( 0 > status)
11395 {
11396 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
11397 " IBSS connection"));
11398 return -EALREADY;
11399 }
11400
Jeff Johnson295189b2012-06-20 16:38:30 -070011401 pRoamProfile = &pWextState->roamProfile;
11402
11403 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
11404 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011405 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011406 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011407 return -EINVAL;
11408 }
11409
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070011410 /* BSSID is provided by upper layers hence no need to AUTO generate */
11411 if (NULL != params->bssid) {
11412 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
11413 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
11414 hddLog (VOS_TRACE_LEVEL_ERROR,
11415 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
11416 return -EIO;
11417 }
11418 }
krunal sonie9002db2013-11-25 14:24:17 -080011419 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
11420 {
11421 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
11422 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
11423 {
11424 hddLog (VOS_TRACE_LEVEL_ERROR,
11425 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
11426 return -EIO;
11427 }
11428 params->bssid = vos_mem_malloc(sizeof(VOS_MAC_ADDR_SIZE));
11429 if (!params->bssid)
11430 {
11431 hddLog (VOS_TRACE_LEVEL_ERROR,
11432 "%s:Failed memory allocation", __func__);
11433 return -EIO;
11434 }
11435 vos_mem_copy((v_U8_t *)params->bssid,
11436 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
11437 VOS_MAC_ADDR_SIZE);
11438 alloc_bssid = VOS_TRUE;
11439 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070011440
Jeff Johnson295189b2012-06-20 16:38:30 -070011441 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070011442 if (NULL !=
11443#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
11444 params->chandef.chan)
11445#else
11446 params->channel)
11447#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011448 {
11449 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011450 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
11451 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
11452 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11453 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011454
11455 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011456 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070011457 ieee80211_frequency_to_channel(
11458#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
11459 params->chandef.chan->center_freq);
11460#else
11461 params->channel->center_freq);
11462#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011463
11464 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
11465 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070011466 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011467 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
11468 __func__);
11469 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070011470 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011471
11472 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070011473 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011474 if (channelNum == validChan[indx])
11475 {
11476 break;
11477 }
11478 }
11479 if (indx >= numChans)
11480 {
11481 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011482 __func__, channelNum);
11483 return -EINVAL;
11484 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011485 /* Set the Operational Channel */
11486 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
11487 channelNum);
11488 pRoamProfile->ChannelInfo.numOfChannels = 1;
11489 pHddStaCtx->conn_info.operationChannel = channelNum;
11490 pRoamProfile->ChannelInfo.ChannelList =
11491 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070011492 }
11493
11494 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011495 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070011496 if (status < 0)
11497 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011498 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070011499 __func__);
11500 return status;
11501 }
11502
11503 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011504 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011505 params->ssid_len, params->bssid,
11506 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070011507
11508 if (0 > status)
11509 {
11510 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
11511 return status;
11512 }
11513
krunal sonie9002db2013-11-25 14:24:17 -080011514 if (NULL != params->bssid &&
11515 pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 &&
11516 alloc_bssid == VOS_TRUE)
11517 {
11518 vos_mem_free(params->bssid);
11519 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011520 return 0;
11521}
11522
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011523static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
11524 struct net_device *dev,
11525 struct cfg80211_ibss_params *params
11526 )
11527{
11528 int ret = 0;
11529
11530 vos_ssr_protect(__func__);
11531 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
11532 vos_ssr_unprotect(__func__);
11533
11534 return ret;
11535}
11536
Jeff Johnson295189b2012-06-20 16:38:30 -070011537/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011538 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011539 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070011540 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011541static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011542 struct net_device *dev
11543 )
11544{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011545 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011546 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11547 tCsrRoamProfile *pRoamProfile;
11548 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011549 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011550
11551 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011552
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011553 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11554 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
11555 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011556 status = wlan_hdd_validate_context(pHddCtx);
11557
11558 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011559 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011560 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11561 "%s: HDD context is not valid", __func__);
11562 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011563 }
11564
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011565 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
11566 hdd_device_modetoString(pAdapter->device_mode),
11567 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011568 if (NULL == pWextState)
11569 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011570 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070011571 __func__);
11572 return -EIO;
11573 }
11574
11575 pRoamProfile = &pWextState->roamProfile;
11576
11577 /* Issue disconnect only if interface type is set to IBSS */
11578 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
11579 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011580 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070011581 __func__);
11582 return -EINVAL;
11583 }
11584
11585 /* Issue Disconnect request */
11586 INIT_COMPLETION(pAdapter->disconnect_comp_var);
11587 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
11588 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
11589
11590 return 0;
11591}
11592
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011593static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
11594 struct net_device *dev
11595 )
11596{
11597 int ret = 0;
11598
11599 vos_ssr_protect(__func__);
11600 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
11601 vos_ssr_unprotect(__func__);
11602
11603 return ret;
11604}
11605
Jeff Johnson295189b2012-06-20 16:38:30 -070011606/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053011607 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070011608 * This function is used to set the phy parameters
11609 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
11610 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053011611static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011612 u32 changed)
11613{
11614 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
11615 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011616 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011617
11618 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011619 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11620 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
11621 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011622 status = wlan_hdd_validate_context(pHddCtx);
11623
11624 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011625 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011626 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11627 "%s: HDD context is not valid", __func__);
11628 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011629 }
11630
Jeff Johnson295189b2012-06-20 16:38:30 -070011631 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
11632 {
11633 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
11634 WNI_CFG_RTS_THRESHOLD_STAMAX :
11635 wiphy->rts_threshold;
11636
11637 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011638 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070011639 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011640 hddLog(VOS_TRACE_LEVEL_ERROR,
11641 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011642 __func__, rts_threshold);
11643 return -EINVAL;
11644 }
11645
11646 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
11647 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011648 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011649 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011650 hddLog(VOS_TRACE_LEVEL_ERROR,
11651 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011652 __func__, rts_threshold);
11653 return -EIO;
11654 }
11655
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011656 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011657 rts_threshold);
11658 }
11659
11660 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
11661 {
11662 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
11663 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
11664 wiphy->frag_threshold;
11665
11666 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011667 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011668 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011669 hddLog(VOS_TRACE_LEVEL_ERROR,
11670 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011671 frag_threshold);
11672 return -EINVAL;
11673 }
11674
11675 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
11676 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011677 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011678 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011679 hddLog(VOS_TRACE_LEVEL_ERROR,
11680 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011681 __func__, frag_threshold);
11682 return -EIO;
11683 }
11684
11685 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
11686 frag_threshold);
11687 }
11688
11689 if ((changed & WIPHY_PARAM_RETRY_SHORT)
11690 || (changed & WIPHY_PARAM_RETRY_LONG))
11691 {
11692 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
11693 wiphy->retry_short :
11694 wiphy->retry_long;
11695
11696 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
11697 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
11698 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011699 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011700 __func__, retry_value);
11701 return -EINVAL;
11702 }
11703
11704 if (changed & WIPHY_PARAM_RETRY_SHORT)
11705 {
11706 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
11707 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011708 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011709 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011710 hddLog(VOS_TRACE_LEVEL_ERROR,
11711 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011712 __func__, retry_value);
11713 return -EIO;
11714 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011715 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011716 __func__, retry_value);
11717 }
11718 else if (changed & WIPHY_PARAM_RETRY_SHORT)
11719 {
11720 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
11721 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011722 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011723 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011724 hddLog(VOS_TRACE_LEVEL_ERROR,
11725 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011726 __func__, retry_value);
11727 return -EIO;
11728 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011729 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011730 __func__, retry_value);
11731 }
11732 }
11733
11734 return 0;
11735}
11736
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053011737static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
11738 u32 changed)
11739{
11740 int ret;
11741
11742 vos_ssr_protect(__func__);
11743 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
11744 vos_ssr_unprotect(__func__);
11745
11746 return ret;
11747}
11748
Jeff Johnson295189b2012-06-20 16:38:30 -070011749/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053011750 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070011751 * This function is used to set the txpower
11752 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053011753static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070011754#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
11755 struct wireless_dev *wdev,
11756#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011757#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011758 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070011759#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011760 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070011761#endif
11762 int dbm)
11763{
11764 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011765 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011766 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
11767 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011768 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011769
11770 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011771 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11772 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
11773 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011774 status = wlan_hdd_validate_context(pHddCtx);
11775
11776 if (0 != status)
11777 {
11778 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11779 "%s: HDD context is not valid", __func__);
11780 return status;
11781 }
11782
11783 hHal = pHddCtx->hHal;
11784
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011785 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
11786 dbm, ccmCfgSetCallback,
11787 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011788 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011789 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011790 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
11791 return -EIO;
11792 }
11793
11794 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
11795 dbm);
11796
11797 switch(type)
11798 {
11799 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
11800 /* Fall through */
11801 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
11802 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
11803 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011804 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
11805 __func__);
11806 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070011807 }
11808 break;
11809 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011810 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070011811 __func__);
11812 return -EOPNOTSUPP;
11813 break;
11814 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011815 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
11816 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011817 return -EIO;
11818 }
11819
11820 return 0;
11821}
11822
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053011823static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
11824#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
11825 struct wireless_dev *wdev,
11826#endif
11827#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
11828 enum tx_power_setting type,
11829#else
11830 enum nl80211_tx_power_setting type,
11831#endif
11832 int dbm)
11833{
11834 int ret;
11835 vos_ssr_protect(__func__);
11836 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
11837#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
11838 wdev,
11839#endif
11840#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
11841 type,
11842#else
11843 type,
11844#endif
11845 dbm);
11846 vos_ssr_unprotect(__func__);
11847
11848 return ret;
11849}
11850
Jeff Johnson295189b2012-06-20 16:38:30 -070011851/*
11852 * FUNCTION: wlan_hdd_cfg80211_get_txpower
11853 * This function is used to read the txpower
11854 */
Yue Maf49ba872013-08-19 12:04:25 -070011855static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
11856#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
11857 struct wireless_dev *wdev,
11858#endif
11859 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070011860{
11861
11862 hdd_adapter_t *pAdapter;
11863 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011864 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011865
Jeff Johnsone7245742012-09-05 17:12:55 -070011866 ENTER();
11867
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011868 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070011869
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011870 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011871 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011872 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11873 "%s: HDD context is not valid", __func__);
11874 *dbm = 0;
11875 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011876 }
11877
Jeff Johnson295189b2012-06-20 16:38:30 -070011878 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
11879 if (NULL == pAdapter)
11880 {
11881 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
11882 return -ENOENT;
11883 }
11884
11885 wlan_hdd_get_classAstats(pAdapter);
11886 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
11887
Jeff Johnsone7245742012-09-05 17:12:55 -070011888 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011889 return 0;
11890}
11891
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011892static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070011893 u8* mac, struct station_info *sinfo)
11894{
11895 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
11896 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11897 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053011898 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070011899
11900 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
11901 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070011902
11903 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
11904 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
11905 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
11906 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
11907 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
11908 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
11909 tANI_U16 maxRate = 0;
11910 tANI_U16 myRate;
11911 tANI_U16 currentRate = 0;
11912 tANI_U8 maxSpeedMCS = 0;
11913 tANI_U8 maxMCSIdx = 0;
11914 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053011915 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070011916 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011917 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011918
Leo Chang6f8870f2013-03-26 18:11:36 -070011919#ifdef WLAN_FEATURE_11AC
11920 tANI_U32 vht_mcs_map;
11921 eDataRate11ACMaxMcs vhtMaxMcs;
11922#endif /* WLAN_FEATURE_11AC */
11923
Jeff Johnsone7245742012-09-05 17:12:55 -070011924 ENTER();
11925
Jeff Johnson295189b2012-06-20 16:38:30 -070011926 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
11927 (0 == ssidlen))
11928 {
11929 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
11930 " Invalid ssidlen, %d", __func__, ssidlen);
11931 /*To keep GUI happy*/
11932 return 0;
11933 }
11934
Mukul Sharma811205f2014-07-09 21:07:30 +053011935 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
11936 {
11937 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11938 "%s: Roaming in progress, so unable to proceed this request", __func__);
11939 return 0;
11940 }
11941
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011942 status = wlan_hdd_validate_context(pHddCtx);
11943
11944 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011945 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011946 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11947 "%s: HDD context is not valid", __func__);
11948 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011949 }
11950
Jeff Johnson295189b2012-06-20 16:38:30 -070011951
Kiet Lam3b17fc82013-09-27 05:24:08 +053011952 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
11953 sinfo->filled |= STATION_INFO_SIGNAL;
11954
c_hpothu09f19542014-05-30 21:53:31 +053011955 wlan_hdd_get_station_stats(pAdapter);
11956 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
11957
11958 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053011959 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
11960 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053011961 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053011962 {
11963 rate_flags = pAdapter->maxRateFlags;
11964 }
c_hpothu44ff4e02014-05-08 00:13:57 +053011965
Jeff Johnson295189b2012-06-20 16:38:30 -070011966 //convert to the UI units of 100kbps
11967 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
11968
11969#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070011970 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 -070011971 sinfo->signal,
11972 pCfg->reportMaxLinkSpeed,
11973 myRate,
11974 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070011975 (int) pCfg->linkSpeedRssiMid,
11976 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070011977 (int) rate_flags,
11978 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070011979#endif //LINKSPEED_DEBUG_ENABLED
11980
11981 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
11982 {
11983 // we do not want to necessarily report the current speed
11984 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
11985 {
11986 // report the max possible speed
11987 rssidx = 0;
11988 }
11989 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
11990 {
11991 // report the max possible speed with RSSI scaling
11992 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
11993 {
11994 // report the max possible speed
11995 rssidx = 0;
11996 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070011997 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070011998 {
11999 // report middle speed
12000 rssidx = 1;
12001 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070012002 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
12003 {
12004 // report middle speed
12005 rssidx = 2;
12006 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012007 else
12008 {
12009 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070012010 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070012011 }
12012 }
12013 else
12014 {
12015 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
12016 hddLog(VOS_TRACE_LEVEL_ERROR,
12017 "%s: Invalid value for reportMaxLinkSpeed: %u",
12018 __func__, pCfg->reportMaxLinkSpeed);
12019 rssidx = 0;
12020 }
12021
12022 maxRate = 0;
12023
12024 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053012025 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
12026 OperationalRates, &ORLeng))
12027 {
12028 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
12029 /*To keep GUI happy*/
12030 return 0;
12031 }
12032
Jeff Johnson295189b2012-06-20 16:38:30 -070012033 for (i = 0; i < ORLeng; i++)
12034 {
Jeff Johnsone7245742012-09-05 17:12:55 -070012035 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070012036 {
12037 /* Validate Rate Set */
12038 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
12039 {
12040 currentRate = supported_data_rate[j].supported_rate[rssidx];
12041 break;
12042 }
12043 }
12044 /* Update MAX rate */
12045 maxRate = (currentRate > maxRate)?currentRate:maxRate;
12046 }
12047
12048 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053012049 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
12050 ExtendedRates, &ERLeng))
12051 {
12052 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
12053 /*To keep GUI happy*/
12054 return 0;
12055 }
12056
Jeff Johnson295189b2012-06-20 16:38:30 -070012057 for (i = 0; i < ERLeng; i++)
12058 {
Jeff Johnsone7245742012-09-05 17:12:55 -070012059 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070012060 {
12061 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
12062 {
12063 currentRate = supported_data_rate[j].supported_rate[rssidx];
12064 break;
12065 }
12066 }
12067 /* Update MAX rate */
12068 maxRate = (currentRate > maxRate)?currentRate:maxRate;
12069 }
c_hpothu79aab322014-07-14 21:11:01 +053012070
Kiet Lamb69f8dc2013-11-15 15:34:27 +053012071 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053012072 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053012073 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053012074 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070012075 {
c_hpothu79aab322014-07-14 21:11:01 +053012076 if (rate_flags & eHAL_TX_RATE_VHT80)
12077 mode = 2;
12078 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
12079 mode = 1;
12080 else
12081 mode = 0;
12082
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053012083 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
12084 MCSRates, &MCSLeng))
12085 {
12086 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
12087 /*To keep GUI happy*/
12088 return 0;
12089 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012090 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070012091#ifdef WLAN_FEATURE_11AC
12092 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012093 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070012094 {
Leo Chang6f8870f2013-03-26 18:11:36 -070012095 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012096 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070012097 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070012098 {
Leo Chang6f8870f2013-03-26 18:11:36 -070012099 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070012100 }
Leo Chang6f8870f2013-03-26 18:11:36 -070012101 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070012102 {
Leo Chang6f8870f2013-03-26 18:11:36 -070012103 maxMCSIdx = 7;
12104 }
12105 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
12106 {
12107 maxMCSIdx = 8;
12108 }
12109 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
12110 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012111 //VHT20 is supporting 0~8
12112 if (rate_flags & eHAL_TX_RATE_VHT20)
12113 maxMCSIdx = 8;
12114 else
12115 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070012116 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012117
c_hpothu79aab322014-07-14 21:11:01 +053012118 if (0 != rssidx)/*check for scaled */
12119 {
12120 //get middle rate MCS index if rssi=1/2
12121 for (i=0; i <= maxMCSIdx; i++)
12122 {
12123 if (sinfo->signal <= rssiMcsTbl[mode][i])
12124 {
12125 maxMCSIdx = i;
12126 break;
12127 }
12128 }
12129 }
12130
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012131 if (rate_flags & eHAL_TX_RATE_VHT80)
12132 {
12133 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
12134 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
12135 }
12136 else if (rate_flags & eHAL_TX_RATE_VHT40)
12137 {
12138 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
12139 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
12140 }
12141 else if (rate_flags & eHAL_TX_RATE_VHT20)
12142 {
12143 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
12144 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
12145 }
12146
Leo Chang6f8870f2013-03-26 18:11:36 -070012147 maxSpeedMCS = 1;
12148 if (currentRate > maxRate)
12149 {
12150 maxRate = currentRate;
12151 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012152
Leo Chang6f8870f2013-03-26 18:11:36 -070012153 }
12154 else
12155#endif /* WLAN_FEATURE_11AC */
12156 {
12157 if (rate_flags & eHAL_TX_RATE_HT40)
12158 {
12159 rateFlag |= 1;
12160 }
12161 if (rate_flags & eHAL_TX_RATE_SGI)
12162 {
12163 rateFlag |= 2;
12164 }
12165
Girish Gowli01abcee2014-07-31 20:18:55 +053012166 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053012167 if (rssidx == 1 || rssidx == 2)
12168 {
12169 //get middle rate MCS index if rssi=1/2
12170 for (i=0; i <= 7; i++)
12171 {
12172 if (sinfo->signal <= rssiMcsTbl[mode][i])
12173 {
12174 temp = i+1;
12175 break;
12176 }
12177 }
12178 }
c_hpothu79aab322014-07-14 21:11:01 +053012179
12180 for (i = 0; i < MCSLeng; i++)
12181 {
Leo Chang6f8870f2013-03-26 18:11:36 -070012182 for (j = 0; j < temp; j++)
12183 {
12184 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
12185 {
12186 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
12187 break;
12188 }
12189 }
12190 if ((j < temp) && (currentRate > maxRate))
12191 {
12192 maxRate = currentRate;
12193 maxSpeedMCS = 1;
12194 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
12195 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012196 }
12197 }
12198 }
12199
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012200 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
12201 {
12202 maxRate = myRate;
12203 maxSpeedMCS = 1;
12204 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
12205 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012206 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053012207 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070012208 {
12209 maxRate = myRate;
12210 if (rate_flags & eHAL_TX_RATE_LEGACY)
12211 {
12212 maxSpeedMCS = 0;
12213 }
12214 else
12215 {
12216 maxSpeedMCS = 1;
12217 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
12218 }
12219 }
12220
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012221 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070012222 {
12223 sinfo->txrate.legacy = maxRate;
12224#ifdef LINKSPEED_DEBUG_ENABLED
12225 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
12226#endif //LINKSPEED_DEBUG_ENABLED
12227 }
12228 else
12229 {
12230 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070012231#ifdef WLAN_FEATURE_11AC
12232 sinfo->txrate.nss = 1;
12233 if (rate_flags & eHAL_TX_RATE_VHT80)
12234 {
12235 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012236 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070012237 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012238 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070012239 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012240 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
12241 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
12242 }
12243 else if (rate_flags & eHAL_TX_RATE_VHT20)
12244 {
12245 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
12246 }
12247#endif /* WLAN_FEATURE_11AC */
12248 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
12249 {
12250 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
12251 if (rate_flags & eHAL_TX_RATE_HT40)
12252 {
12253 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
12254 }
Leo Chang6f8870f2013-03-26 18:11:36 -070012255 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012256 if (rate_flags & eHAL_TX_RATE_SGI)
12257 {
12258 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
12259 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053012260
Jeff Johnson295189b2012-06-20 16:38:30 -070012261#ifdef LINKSPEED_DEBUG_ENABLED
12262 pr_info("Reporting MCS rate %d flags %x\n",
12263 sinfo->txrate.mcs,
12264 sinfo->txrate.flags );
12265#endif //LINKSPEED_DEBUG_ENABLED
12266 }
12267 }
12268 else
12269 {
12270 // report current rate instead of max rate
12271
12272 if (rate_flags & eHAL_TX_RATE_LEGACY)
12273 {
12274 //provide to the UI in units of 100kbps
12275 sinfo->txrate.legacy = myRate;
12276#ifdef LINKSPEED_DEBUG_ENABLED
12277 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
12278#endif //LINKSPEED_DEBUG_ENABLED
12279 }
12280 else
12281 {
12282 //must be MCS
12283 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070012284#ifdef WLAN_FEATURE_11AC
12285 sinfo->txrate.nss = 1;
12286 if (rate_flags & eHAL_TX_RATE_VHT80)
12287 {
12288 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
12289 }
12290 else
12291#endif /* WLAN_FEATURE_11AC */
12292 {
12293 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
12294 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012295 if (rate_flags & eHAL_TX_RATE_SGI)
12296 {
12297 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
12298 }
12299 if (rate_flags & eHAL_TX_RATE_HT40)
12300 {
12301 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
12302 }
Leo Chang6f8870f2013-03-26 18:11:36 -070012303#ifdef WLAN_FEATURE_11AC
12304 else if (rate_flags & eHAL_TX_RATE_VHT80)
12305 {
12306 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
12307 }
12308#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070012309#ifdef LINKSPEED_DEBUG_ENABLED
12310 pr_info("Reporting actual MCS rate %d flags %x\n",
12311 sinfo->txrate.mcs,
12312 sinfo->txrate.flags );
12313#endif //LINKSPEED_DEBUG_ENABLED
12314 }
12315 }
12316 sinfo->filled |= STATION_INFO_TX_BITRATE;
12317
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070012318 sinfo->tx_packets =
12319 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
12320 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
12321 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
12322 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
12323
12324 sinfo->tx_retries =
12325 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
12326 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
12327 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
12328 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
12329
12330 sinfo->tx_failed =
12331 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
12332 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
12333 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
12334 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
12335
12336 sinfo->filled |=
12337 STATION_INFO_TX_PACKETS |
12338 STATION_INFO_TX_RETRIES |
12339 STATION_INFO_TX_FAILED;
12340
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012341 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12342 TRACE_CODE_HDD_CFG80211_GET_STA,
12343 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070012344 EXIT();
12345 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012346}
12347
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012348static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
12349 u8* mac, struct station_info *sinfo)
12350{
12351 int ret;
12352
12353 vos_ssr_protect(__func__);
12354 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
12355 vos_ssr_unprotect(__func__);
12356
12357 return ret;
12358}
12359
12360static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070012361 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070012362{
12363 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053012364 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012365 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012366 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012367
Jeff Johnsone7245742012-09-05 17:12:55 -070012368 ENTER();
12369
Jeff Johnson295189b2012-06-20 16:38:30 -070012370 if (NULL == pAdapter)
12371 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012372 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012373 return -ENODEV;
12374 }
12375
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012376 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12377 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
12378 pAdapter->sessionId, timeout));
12379
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053012380 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012381 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053012382
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012383 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012384 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012385 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12386 "%s: HDD context is not valid", __func__);
12387 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012388 }
12389
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053012390 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
12391 (TRUE == pHddCtx->hdd_wlan_suspended) &&
12392 (pHddCtx->cfg_ini->fhostArpOffload) &&
12393 (eConnectionState_Associated ==
12394 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
12395 {
Amar Singhald53568e2013-09-26 11:03:45 -070012396
12397 hddLog(VOS_TRACE_LEVEL_INFO,
12398 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053012399 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053012400 if (!VOS_IS_STATUS_SUCCESS(vos_status))
12401 {
12402 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012403 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053012404 __func__, vos_status);
12405 }
12406 }
12407
Jeff Johnson295189b2012-06-20 16:38:30 -070012408 /**The get power cmd from the supplicant gets updated by the nl only
12409 *on successful execution of the function call
12410 *we are oppositely mapped w.r.t mode in the driver
12411 **/
12412 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
12413
Jeff Johnsone7245742012-09-05 17:12:55 -070012414 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012415 if (VOS_STATUS_E_FAILURE == vos_status)
12416 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012417 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12418 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012419 return -EINVAL;
12420 }
12421 return 0;
12422}
12423
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012424static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
12425 struct net_device *dev, bool mode, int timeout)
12426{
12427 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070012428
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012429 vos_ssr_protect(__func__);
12430 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
12431 vos_ssr_unprotect(__func__);
12432
12433 return ret;
12434}
Jeff Johnson295189b2012-06-20 16:38:30 -070012435#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12436static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
12437 struct net_device *netdev,
12438 u8 key_index)
12439{
Jeff Johnsone7245742012-09-05 17:12:55 -070012440 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070012441 return 0;
12442}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012443#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070012444
12445#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
12446static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
12447 struct net_device *dev,
12448 struct ieee80211_txq_params *params)
12449{
Jeff Johnsone7245742012-09-05 17:12:55 -070012450 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070012451 return 0;
12452}
12453#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12454static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
12455 struct ieee80211_txq_params *params)
12456{
Jeff Johnsone7245742012-09-05 17:12:55 -070012457 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070012458 return 0;
12459}
12460#endif //LINUX_VERSION_CODE
12461
Naresh Jayaram69e3f282014-10-14 12:29:12 +053012462#ifdef CFG80211_DEL_STA_V2
12463static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
12464 struct net_device *dev,
12465 struct station_del_parameters *param)
12466#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012467static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012468 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053012469#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012470{
12471 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012472 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012473 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012474 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012475 v_U8_t staId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012476
Jeff Johnsone7245742012-09-05 17:12:55 -070012477 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012478
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012479 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070012480 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012481 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012482 return -EINVAL;
12483 }
12484
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012485 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12486 TRACE_CODE_HDD_CFG80211_DEL_STA,
12487 pAdapter->sessionId, pAdapter->device_mode));
12488
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012489 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12490 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070012491
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012492 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012493 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012494 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12495 "%s: HDD context is not valid", __func__);
12496 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012497 }
12498
Jeff Johnson295189b2012-06-20 16:38:30 -070012499 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070012500 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070012501 )
12502 {
12503 if( NULL == mac )
12504 {
12505 v_U16_t i;
12506 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
12507 {
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070012508 if ((pAdapter->aStaInfo[i].isUsed) &&
12509 (!pAdapter->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070012510 {
12511 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
12512 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080012513 "%s: Delete STA with MAC::"
12514 MAC_ADDRESS_STR,
12515 __func__, MAC_ADDR_ARRAY(macAddr));
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070012516 vos_status = hdd_softap_sta_deauth(pAdapter, macAddr);
12517 if (VOS_IS_STATUS_SUCCESS(vos_status))
12518 pAdapter->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012519 }
12520 }
12521 }
12522 else
12523 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012524
12525 vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId);
12526 if (!VOS_IS_STATUS_SUCCESS(vos_status))
12527 {
12528 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080012529 "%s: Skip this DEL STA as this is not used::"
12530 MAC_ADDRESS_STR,
12531 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012532 return -ENOENT;
12533 }
12534
12535 if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE)
12536 {
12537 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080012538 "%s: Skip this DEL STA as deauth is in progress::"
12539 MAC_ADDRESS_STR,
12540 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012541 return -ENOENT;
12542 }
12543
12544 pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE;
12545
Jeff Johnson295189b2012-06-20 16:38:30 -070012546 hddLog(VOS_TRACE_LEVEL_INFO,
12547 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080012548 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012549 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -080012550 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012551
12552 vos_status = hdd_softap_sta_deauth(pAdapter, mac);
12553 if (!VOS_IS_STATUS_SUCCESS(vos_status))
12554 {
12555 pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE;
12556 hddLog(VOS_TRACE_LEVEL_INFO,
12557 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080012558 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012559 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -080012560 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080012561 return -ENOENT;
12562 }
12563
Jeff Johnson295189b2012-06-20 16:38:30 -070012564 }
12565 }
12566
12567 EXIT();
12568
12569 return 0;
12570}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053012571
12572#ifdef CFG80211_DEL_STA_V2
12573static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
12574 struct net_device *dev,
12575 struct station_del_parameters *param)
12576#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012577static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
12578 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053012579#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012580{
12581 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070012582
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012583 vos_ssr_protect(__func__);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053012584#ifdef CFG80211_DEL_STA_V2
12585 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, param);
12586#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012587 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, mac);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053012588#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012589 vos_ssr_unprotect(__func__);
12590
12591 return ret;
12592}
12593
12594static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012595 struct net_device *dev, u8 *mac, struct station_parameters *params)
12596{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012597 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalab977a972013-02-18 19:15:09 -080012598 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012599#ifdef FEATURE_WLAN_TDLS
12600 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012601 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012602
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012603 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12604 TRACE_CODE_HDD_CFG80211_ADD_STA,
12605 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012606 mask = params->sta_flags_mask;
12607
12608 set = params->sta_flags_set;
12609
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012610#ifdef WLAN_FEATURE_TDLS_DEBUG
12611 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12612 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
12613 __func__, mask, set, MAC_ADDR_ARRAY(mac));
12614#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012615
12616 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
12617 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012618 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012619 }
12620 }
12621#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -080012622 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012623}
12624
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012625static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
12626 struct net_device *dev, u8 *mac, struct station_parameters *params)
12627{
12628 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012629
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012630 vos_ssr_protect(__func__);
12631 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
12632 vos_ssr_unprotect(__func__);
12633
12634 return ret;
12635}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012636#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070012637
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053012638static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070012639 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012640{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012641 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12642 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012643 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012644 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012645 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012646 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070012647
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012648 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012649 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012650 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012651 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012652 return -EINVAL;
12653 }
12654
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012655 if (!pmksa) {
12656 hddLog(LOGE, FL("pmksa is NULL"));
12657 return -EINVAL;
12658 }
12659
12660 if (!pmksa->bssid || !pmksa->pmkid) {
12661 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
12662 pmksa->bssid, pmksa->pmkid);
12663 return -EINVAL;
12664 }
12665
12666 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
12667 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
12668
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012669 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12670 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012671
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012672 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012673 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012674 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12675 "%s: HDD context is not valid", __func__);
12676 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012677 }
12678
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012679 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012680 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
12681
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012682 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
12683 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012684
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012685 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012686 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012687 &pmk_id, 1, FALSE);
12688
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012689 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12690 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
12691 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012692
12693 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012694}
12695
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053012696static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
12697 struct cfg80211_pmksa *pmksa)
12698{
12699 int ret;
12700
12701 vos_ssr_protect(__func__);
12702 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
12703 vos_ssr_unprotect(__func__);
12704
12705 return ret;
12706}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012707
Wilson Yang6507c4e2013-10-01 20:11:19 -070012708
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053012709static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070012710 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012711{
Wilson Yang6507c4e2013-10-01 20:11:19 -070012712 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12713 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070012714 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080012715 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070012716
Jeff Johnson0299d0a2013-10-30 12:37:43 -070012717 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
12718 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -070012719
12720 /* Validate pAdapter */
12721 if (NULL == pAdapter)
12722 {
12723 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
12724 return -EINVAL;
12725 }
12726
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012727 if (!pmksa) {
12728 hddLog(LOGE, FL("pmksa is NULL"));
12729 return -EINVAL;
12730 }
12731
12732 if (!pmksa->bssid) {
12733 hddLog(LOGE, FL("pmksa->bssid is NULL"));
12734 return -EINVAL;
12735 }
12736
Wilson Yang6507c4e2013-10-01 20:11:19 -070012737 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12738 status = wlan_hdd_validate_context(pHddCtx);
12739
12740 if (0 != status)
12741 {
12742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12743 "%s: HDD context is not valid", __func__);
12744 return status;
12745 }
12746
12747 /*Retrieve halHandle*/
12748 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
12749
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012750 /* Delete the PMKID CSR cache */
12751 if (eHAL_STATUS_SUCCESS !=
12752 sme_RoamDelPMKIDfromCache(halHandle,
12753 pAdapter->sessionId, pmksa->bssid, FALSE)) {
12754 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
12755 MAC_ADDR_ARRAY(pmksa->bssid));
12756 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070012757 }
12758
Wilson Yangef657d32014-01-15 19:19:23 -080012759 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012760}
12761
Wilson Yang6507c4e2013-10-01 20:11:19 -070012762
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053012763static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
12764 struct cfg80211_pmksa *pmksa)
12765{
12766 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070012767
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053012768 vos_ssr_protect(__func__);
12769 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
12770 vos_ssr_unprotect(__func__);
12771
12772 return ret;
12773
12774}
12775
12776static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012777{
Wilson Yang6507c4e2013-10-01 20:11:19 -070012778 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12779 tHalHandle halHandle;
12780 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080012781 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070012782
12783 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__);
12784
12785 /* Validate pAdapter */
12786 if (NULL == pAdapter)
12787 {
12788 hddLog(VOS_TRACE_LEVEL_ERROR,
12789 "%s: Invalid Adapter" ,__func__);
12790 return -EINVAL;
12791 }
12792
12793 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12794 status = wlan_hdd_validate_context(pHddCtx);
12795
12796 if (0 != status)
12797 {
12798 hddLog(VOS_TRACE_LEVEL_ERROR,
12799 "%s: HDD context is not valid", __func__);
12800 return status;
12801 }
12802
12803 /*Retrieve halHandle*/
12804 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
12805
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012806 /* Flush the PMKID cache in CSR */
12807 if (eHAL_STATUS_SUCCESS !=
12808 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
12809 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
12810 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070012811 }
12812
Wilson Yangef657d32014-01-15 19:19:23 -080012813 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012814}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053012815
12816static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
12817{
12818 int ret;
12819
12820 vos_ssr_protect(__func__);
12821 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
12822 vos_ssr_unprotect(__func__);
12823
12824 return ret;
12825}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012826#endif
12827
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012828#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012829static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
12830 struct net_device *dev,
12831 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012832{
12833 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12834 hdd_station_ctx_t *pHddStaCtx;
12835
12836 if (NULL == pAdapter)
12837 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012838 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012839 return -ENODEV;
12840 }
12841
12842 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12843
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012844 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12845 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
12846 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012847 // Added for debug on reception of Re-assoc Req.
12848 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
12849 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012850 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012851 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080012852 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012853 }
12854
12855#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080012856 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012857 ftie->ie_len);
12858#endif
12859
12860 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053012861 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
12862 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012863 ftie->ie_len);
12864 return 0;
12865}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012866
12867static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
12868 struct net_device *dev,
12869 struct cfg80211_update_ft_ies_params *ftie)
12870{
12871 int ret;
12872
12873 vos_ssr_protect(__func__);
12874 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
12875 vos_ssr_unprotect(__func__);
12876
12877 return ret;
12878}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012879#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012880
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012881#ifdef FEATURE_WLAN_SCAN_PNO
12882
12883void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
12884 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
12885{
12886 int ret;
12887 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
12888 hdd_context_t *pHddCtx;
12889
Nirav Shah80830bf2013-12-31 16:35:12 +053012890 ENTER();
12891
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012892 if (NULL == pAdapter)
12893 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053012894 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012895 "%s: HDD adapter is Null", __func__);
12896 return ;
12897 }
12898
12899 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12900 if (NULL == pHddCtx)
12901 {
12902 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12903 "%s: HDD context is Null!!!", __func__);
12904 return ;
12905 }
12906
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053012907 spin_lock(&pHddCtx->schedScan_lock);
12908 if (TRUE == pHddCtx->isWiphySuspended)
12909 {
12910 pHddCtx->isSchedScanUpdatePending = TRUE;
12911 spin_unlock(&pHddCtx->schedScan_lock);
12912 hddLog(VOS_TRACE_LEVEL_INFO,
12913 "%s: Update cfg80211 scan database after it resume", __func__);
12914 return ;
12915 }
12916 spin_unlock(&pHddCtx->schedScan_lock);
12917
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012918 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
12919
12920 if (0 > ret)
12921 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
12922
12923 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053012924 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12925 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012926}
12927
12928/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012929 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053012930 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012931 */
12932static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
12933{
12934 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
12935 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053012936 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012937 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12938 int status = 0;
12939 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
12940
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053012941 /* The current firmware design does not allow PNO during any
12942 * active sessions. Hence, determine the active sessions
12943 * and return a failure.
12944 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012945 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
12946 {
12947 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053012948 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012949
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053012950 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
12951 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
12952 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
12953 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
12954 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
12955 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012956 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053012957 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012958 }
12959 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
12960 pAdapterNode = pNext;
12961 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053012962 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012963}
12964
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053012965void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
12966{
12967 hdd_adapter_t *pAdapter = callbackContext;
12968 hdd_context_t *pHddCtx;
12969
12970 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
12971 {
12972 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12973 FL("Invalid adapter or adapter has invalid magic"));
12974 return;
12975 }
12976
12977 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12978 if (0 != wlan_hdd_validate_context(pHddCtx))
12979 {
12980 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12981 FL("HDD context is not valid"));
12982 return;
12983 }
12984
c_hpothub53c45d2014-08-18 16:53:14 +053012985 if (VOS_STATUS_SUCCESS != status)
12986 {
12987 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053012988 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053012989 pHddCtx->isPnoEnable = FALSE;
12990 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053012991
12992 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
12993 complete(&pAdapter->pno_comp_var);
12994}
12995
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012996/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053012997 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
12998 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012999 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053013000static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013001 struct net_device *dev, struct cfg80211_sched_scan_request *request)
13002{
13003 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13004 tpSirPNOScanReq pPnoRequest = NULL;
13005 hdd_context_t *pHddCtx;
13006 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053013007 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053013008 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
13009 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013010 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
13011 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013012 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013013
13014 if (NULL == pAdapter)
13015 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013016 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013017 "%s: HDD adapter is Null", __func__);
13018 return -ENODEV;
13019 }
13020
13021 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013022 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013023
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013024 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013025 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053013026 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13027 "%s: HDD context is not valid", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013028 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013029 }
13030
13031 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
13032 if (NULL == hHal)
13033 {
13034 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13035 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013036 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013037 }
Sushant Kaushik2fe89932014-09-03 10:58:09 +053013038 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053013039 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053013040 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053013041 {
13042 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13043 "%s: aborting the existing scan is unsuccessfull", __func__);
13044 return -EBUSY;
13045 }
13046
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053013047 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013048 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053013049 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053013050 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053013051 return -EBUSY;
13052 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013053
c_hpothu37f21312014-04-09 21:49:54 +053013054 if (TRUE == pHddCtx->isPnoEnable)
13055 {
13056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
13057 FL("already PNO is enabled"));
13058 return -EBUSY;
13059 }
13060 pHddCtx->isPnoEnable = TRUE;
13061
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013062 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
13063 if (NULL == pPnoRequest)
13064 {
13065 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
13066 "%s: vos_mem_malloc failed", __func__);
c_hpothu37f21312014-04-09 21:49:54 +053013067 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013068 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013069 }
13070
Madan Mohan Koyyalamudic3f04352013-09-26 19:21:48 +053013071 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013072 pPnoRequest->enable = 1; /*Enable PNO */
13073 pPnoRequest->ucNetworksCount = request->n_match_sets;
13074
13075 if (( !pPnoRequest->ucNetworksCount ) ||
13076 ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
13077 {
13078 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053013079 "%s: Network input is not correct %d Max Network supported is %d",
13080 __func__, pPnoRequest->ucNetworksCount,
13081 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013082 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013083 goto error;
13084 }
13085
13086 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
13087 {
13088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053013089 "%s: Incorrect number of channels %d",
13090 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013091 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013092 goto error;
13093 }
13094
13095 /* Framework provides one set of channels(all)
13096 * common for all saved profile */
13097 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
13098 channels_allowed, &num_channels_allowed))
13099 {
13100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13101 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013102 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013103 goto error;
13104 }
13105 /* Checking each channel against allowed channel list */
13106 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053013107 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013108 {
Nirav Shah80830bf2013-12-31 16:35:12 +053013109 char chList [(request->n_channels*5)+1];
13110 int len;
13111 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013112 {
Nirav Shah80830bf2013-12-31 16:35:12 +053013113 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013114 {
Nirav Shah80830bf2013-12-31 16:35:12 +053013115 if (request->channels[i]->hw_value == channels_allowed[indx])
13116 {
13117 valid_ch[num_ch++] = request->channels[i]->hw_value;
13118 len += snprintf(chList+len, 5, "%d ",
13119 request->channels[i]->hw_value);
13120 break ;
13121 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013122 }
13123 }
Nirav Shah80830bf2013-12-31 16:35:12 +053013124 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
13125 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013126
13127 /* Filling per profile params */
13128 for (i = 0; i < pPnoRequest->ucNetworksCount; i++)
13129 {
13130 pPnoRequest->aNetworks[i].ssId.length =
13131 request->match_sets[i].ssid.ssid_len;
13132
13133 if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) ||
13134 ( pPnoRequest->aNetworks[i].ssId.length > 32 ) )
13135 {
13136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053013137 "%s: SSID Len %d is not correct for network %d",
13138 __func__, pPnoRequest->aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013139 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013140 goto error;
13141 }
13142
13143 memcpy(pPnoRequest->aNetworks[i].ssId.ssId,
13144 request->match_sets[i].ssid.ssid,
13145 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053013146 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13147 "%s: SSID of network %d is %s ", __func__,
13148 i, pPnoRequest->aNetworks[i].ssId.ssId);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013149 pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
13150 pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/
13151 pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
13152
13153 /*Copying list of valid channel into request */
13154 memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch);
13155 pPnoRequest->aNetworks[i].ucChannelCount = num_ch;
13156
13157 pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value
13158 }
13159
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053013160 for (i = 0; i < request->n_ssids; i++)
13161 {
13162 j = 0;
13163 while (j < pPnoRequest->ucNetworksCount)
13164 {
13165 if ((pPnoRequest->aNetworks[j].ssId.length ==
13166 request->ssids[i].ssid_len) &&
13167 (0 == memcmp(pPnoRequest->aNetworks[j].ssId.ssId,
13168 request->ssids[i].ssid,
13169 pPnoRequest->aNetworks[j].ssId.length)))
13170 {
13171 pPnoRequest->aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
13172 break;
13173 }
13174 j++;
13175 }
13176 }
13177 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13178 "Number of hidden networks being Configured = %d",
13179 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053013180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080013181 "request->ie_len = %zu", request->ie_len);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053013182 if ((0 < request->ie_len) && (NULL != request->ie))
13183 {
13184 pPnoRequest->us24GProbeTemplateLen = request->ie_len;
13185 memcpy(&pPnoRequest->p24GProbeTemplate, request->ie,
13186 pPnoRequest->us24GProbeTemplateLen);
13187
13188 pPnoRequest->us5GProbeTemplateLen = request->ie_len;
13189 memcpy(&pPnoRequest->p5GProbeTemplate, request->ie,
13190 pPnoRequest->us5GProbeTemplateLen);
13191 }
13192
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053013193 /* Driver gets only one time interval which is hardcoded in
13194 * supplicant for 10000ms. Taking power consumption into account 6 timers
13195 * will be used, Timervalue is increased exponentially i.e 10,20,40,
13196 * 80,160,320 secs. And number of scan cycle for each timer
13197 * is configurable through INI param gPNOScanTimerRepeatValue.
13198 * If it is set to 0 only one timer will be used and PNO scan cycle
13199 * will be repeated after each interval specified by supplicant
13200 * till PNO is disabled.
13201 */
13202 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
13203 pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
13204 else
13205 pPnoRequest->scanTimers.ucScanTimersCount =
13206 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
13207
13208 tempInterval = (request->interval)/1000;
13209 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13210 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
13211 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
13212 for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++)
13213 {
13214 pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat =
13215 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
13216 pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval;
13217 tempInterval *= 2;
13218 }
13219 //Repeat last timer until pno disabled.
13220 pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
13221
Madan Mohan Koyyalamudid206c7b2013-09-26 22:54:51 +053013222 pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013223
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013224 INIT_COMPLETION(pAdapter->pno_comp_var);
13225 pPnoRequest->statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
13226 pPnoRequest->callbackContext = pAdapter;
13227 pAdapter->pno_req_status = 0;
13228
Nirav Shah80830bf2013-12-31 16:35:12 +053013229 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13230 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
13231 pAdapter->sessionId, pPnoRequest->enable, pPnoRequest->modePNO,
13232 pPnoRequest->scanTimers.ucScanTimersCount);
13233
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013234 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
13235 pPnoRequest, pAdapter->sessionId,
13236 hdd_cfg80211_sched_scan_done_callback, pAdapter);
13237 if (eHAL_STATUS_SUCCESS != status)
13238 {
13239 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053013240 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013241 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013242 goto error;
13243 }
13244
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013245 ret = wait_for_completion_timeout(
13246 &pAdapter->pno_comp_var,
13247 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
13248 if (0 >= ret)
13249 {
13250 // Did not receive the response for PNO enable in time.
13251 // Assuming the PNO enable was success.
13252 // Returning error from here, because we timeout, results
13253 // in side effect of Wifi (Wifi Setting) not to work.
13254 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13255 FL("Timed out waiting for PNO to be Enabled"));
13256 ret = 0;
13257 goto error;
13258 }
13259
c_hpothu3c986b22014-07-09 14:45:09 +053013260 vos_mem_free(pPnoRequest);
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013261 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053013262 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013263
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013264error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13266 FL("PNO scanRequest offloaded ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013267 vos_mem_free(pPnoRequest);
c_hpothu37f21312014-04-09 21:49:54 +053013268 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013269 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013270}
13271
13272/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053013273 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
13274 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013275 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053013276static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
13277 struct net_device *dev, struct cfg80211_sched_scan_request *request)
13278{
13279 int ret;
13280
13281 vos_ssr_protect(__func__);
13282 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
13283 vos_ssr_unprotect(__func__);
13284
13285 return ret;
13286}
13287
13288/*
13289 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
13290 * Function to disable PNO
13291 */
13292static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013293 struct net_device *dev)
13294{
13295 eHalStatus status = eHAL_STATUS_FAILURE;
13296 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13297 hdd_context_t *pHddCtx;
13298 tHalHandle hHal;
13299 tpSirPNOScanReq pPnoRequest = NULL;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013300 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013301
13302 ENTER();
13303
13304 if (NULL == pAdapter)
13305 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013306 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013307 "%s: HDD adapter is Null", __func__);
13308 return -ENODEV;
13309 }
13310
13311 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013312
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013313 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013314 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053013315 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013316 "%s: HDD context is Null", __func__);
13317 return -ENODEV;
13318 }
13319
13320 /* The return 0 is intentional when isLogpInProgress and
13321 * isLoadUnloadInProgress. We did observe a crash due to a return of
13322 * failure in sched_scan_stop , especially for a case where the unload
13323 * of the happens at the same time. The function __cfg80211_stop_sched_scan
13324 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
13325 * success. If it returns a failure , then its next invocation due to the
13326 * clean up of the second interface will have the dev pointer corresponding
13327 * to the first one leading to a crash.
13328 */
13329 if (pHddCtx->isLogpInProgress)
13330 {
13331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13332 "%s: LOGP in Progress. Ignore!!!", __func__);
13333 return ret;
13334 }
13335
Mihir Shete18156292014-03-11 15:38:30 +053013336 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013337 {
13338 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13339 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
13340 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013341 }
13342
13343 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
13344 if (NULL == hHal)
13345 {
13346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13347 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013348 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013349 }
13350
13351 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
13352 if (NULL == pPnoRequest)
13353 {
13354 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
13355 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013356 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013357 }
13358
13359 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
13360 pPnoRequest->enable = 0; /* Disable PNO */
13361 pPnoRequest->ucNetworksCount = 0;
13362
13363 status = sme_SetPreferredNetworkList(hHal, pPnoRequest,
13364 pAdapter->sessionId,
13365 NULL, pAdapter);
13366 if (eHAL_STATUS_SUCCESS != status)
13367 {
13368 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13369 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013370 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013371 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013372 }
c_hpothu37f21312014-04-09 21:49:54 +053013373 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013374
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013375error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013376 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053013377 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013378 vos_mem_free(pPnoRequest);
13379
13380 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053013381 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013382}
13383
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053013384/*
13385 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
13386 * NL interface to disable PNO
13387 */
13388static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
13389 struct net_device *dev)
13390{
13391 int ret;
13392
13393 vos_ssr_protect(__func__);
13394 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
13395 vos_ssr_unprotect(__func__);
13396
13397 return ret;
13398}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053013399#endif /*FEATURE_WLAN_SCAN_PNO*/
13400
13401
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013402#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053013403#if TDLS_MGMT_VERSION2
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013404static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
13405 u8 *peer, u8 action_code, u8 dialog_token,
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053013406 u16 status_code, u32 peer_capability, const u8 *buf, size_t len)
13407#else
13408static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
13409 u8 *peer, u8 action_code, u8 dialog_token,
13410 u16 status_code, const u8 *buf, size_t len)
13411#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013412{
13413
13414 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13415 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013416 u8 peerMac[6];
13417 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070013418 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080013419 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070013420 long rc;
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053013421#if !(TDLS_MGMT_VERSION2)
13422 u32 peer_capability = 0;
13423#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053013424 tANI_U16 numCurrTdlsPeers;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013425
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013426 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13427 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
13428 pAdapter->sessionId, action_code));
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013429 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013430 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013431 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013432 "Invalid arguments");
13433 return -EINVAL;
13434 }
13435
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080013436 if (pHddCtx->isLogpInProgress)
13437 {
13438 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13439 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053013440 wlan_hdd_tdls_set_link_status(pAdapter,
13441 peer,
13442 eTDLS_LINK_IDLE,
13443 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080013444 return -EBUSY;
13445 }
13446
Hoonki Lee27511902013-03-14 18:19:06 -070013447 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013448 {
Hoonki Lee27511902013-03-14 18:19:06 -070013449 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
13450 "%s: TDLS mode is disabled OR not enabled in FW."
13451 MAC_ADDRESS_STR " action %d declined.",
13452 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013453 return -ENOTSUPP;
13454 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080013455
Hoonki Lee27511902013-03-14 18:19:06 -070013456 /* other than teardown frame, other mgmt frames are not sent if disabled */
13457 if (SIR_MAC_TDLS_TEARDOWN != action_code)
13458 {
13459 /* if tdls_mode is disabled to respond to peer's request */
13460 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
13461 {
13462 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
13463 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070013464 " TDLS mode is disabled. action %d declined.",
13465 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070013466
13467 return -ENOTSUPP;
13468 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053013469
13470 if (vos_max_concurrent_connections_reached())
13471 {
13472 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
13473 return -EINVAL;
13474 }
Hoonki Lee27511902013-03-14 18:19:06 -070013475 }
13476
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013477 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
13478 {
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053013479 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013480 {
13481 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013482 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070013483 " TDLS setup is ongoing. action %d declined.",
13484 __func__, MAC_ADDR_ARRAY(peer), action_code);
13485 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013486 }
13487 }
13488
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013489 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
13490 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080013491 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053013492 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
13493 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080013494 {
13495 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
13496 we return error code at 'add_station()'. Hence we have this
13497 check again in addtion to add_station().
13498 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013499 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080013500 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013501 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13502 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053013503 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
13504 __func__, MAC_ADDR_ARRAY(peer), action_code,
13505 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053013506 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080013507 }
13508 else
13509 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013510 /* maximum reached. tweak to send error code to peer and return
13511 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080013512 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013513 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13514 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053013515 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
13516 __func__, MAC_ADDR_ARRAY(peer), status_code,
13517 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070013518 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013519 /* fall through to send setup resp with failure status
13520 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080013521 }
13522 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013523 else
13524 {
13525 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053013526 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013527 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013528 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013529 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070013530 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
13531 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013532 return -EPERM;
13533 }
13534 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080013535 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013536 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013537
Hoonki Lee1090c6a2013-01-16 17:40:54 -080013538#ifdef WLAN_FEATURE_TDLS_DEBUG
13539 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053013540 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013541 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
13542 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -080013543#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013544
Hoonki Leea34dd892013-02-05 22:56:02 -080013545 /*Except teardown responder will not be used so just make 0*/
13546 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013547 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080013548 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070013549
13550 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053013551 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070013552
13553 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
13554 responder = pTdlsPeer->is_responder;
13555 else
Hoonki Leea34dd892013-02-05 22:56:02 -080013556 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070013557 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053013558 "%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 -070013559 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
13560 dialog_token, status_code, len);
13561 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080013562 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013563 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013564
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053013565 /* For explicit trigger of DIS_REQ come out of BMPS for
13566 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070013567 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053013568 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
13569 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070013570 {
13571 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
13572 {
13573 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053013574 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Hoonki Lee14621352013-04-16 17:51:19 -070013575 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
13576 }
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053013577 if (SIR_MAC_TDLS_DIS_REQ != action_code)
13578 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
Hoonki Lee14621352013-04-16 17:51:19 -070013579 }
13580
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013581 /* make sure doesn't call send_mgmt() while it is pending */
13582 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
13583 {
13584 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080013585 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013586 __func__, MAC_ADDR_ARRAY(peer), action_code);
13587 return -EBUSY;
13588 }
13589
13590 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013591 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
13592
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013593 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +053013594 peerMac, action_code, dialog_token, status_code, peer_capability, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013595
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013596 if (VOS_STATUS_SUCCESS != status)
13597 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013598 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13599 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013600 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -070013601 wlan_hdd_tdls_check_bmps(pAdapter);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053013602 return -EINVAL;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013603 }
13604
Hoonki Leed37cbb32013-04-20 00:31:14 -070013605 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
13606 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
13607
13608 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013609 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070013610 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070013611 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070013612 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013613 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080013614
13615 if (pHddCtx->isLogpInProgress)
13616 {
13617 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13618 "%s: LOGP in Progress. Ignore!!!", __func__);
13619 return -EAGAIN;
13620 }
13621
Hoonki Leed37cbb32013-04-20 00:31:14 -070013622 wlan_hdd_tdls_check_bmps(pAdapter);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053013623 return -EINVAL;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013624 }
13625
Gopichand Nakkala05922802013-03-14 12:23:19 -070013626 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070013627 {
13628 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -070013629 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070013630 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013631
Hoonki Leea34dd892013-02-05 22:56:02 -080013632 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
13633 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080013634 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -080013635 }
13636 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
13637 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080013638 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -080013639 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013640
13641 return 0;
13642}
13643
Atul Mittal115287b2014-07-08 13:26:33 +053013644
13645int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
13646 u8 *peer,
13647 cfg80211_exttdls_callback callback)
13648{
13649
13650 hddTdlsPeer_t *pTdlsPeer;
13651 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13652 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13653 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
13654 __func__, MAC_ADDR_ARRAY(peer));
13655
13656 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
13657 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
13658
13659 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13660 " %s TDLS External control and Implicit Trigger not enabled ",
13661 __func__);
13662 return -ENOTSUPP;
13663 }
13664
13665 /* To cater the requirement of establishing the TDLS link
13666 * irrespective of the data traffic , get an entry of TDLS peer.
13667 */
13668 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
13669 if (pTdlsPeer == NULL) {
13670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13671 "%s: peer " MAC_ADDRESS_STR " not existing",
13672 __func__, MAC_ADDR_ARRAY(peer));
13673 return -EINVAL;
13674 }
13675
13676 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
13677
13678 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13679 " %s TDLS Add Force Peer Failed",
13680 __func__);
13681 return -EINVAL;
13682 }
13683 /*EXT TDLS*/
13684
13685 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
13686 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13687 " %s TDLS set callback Failed",
13688 __func__);
13689 return -EINVAL;
13690 }
13691
13692 return(0);
13693
13694}
13695
13696int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter, u8 *peer)
13697{
13698
13699 hddTdlsPeer_t *pTdlsPeer;
13700 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13701 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13702 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
13703 __func__, MAC_ADDR_ARRAY(peer));
13704
13705 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
13706 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
13707
13708 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13709 " %s TDLS External control and Implicit Trigger not enabled ",
13710 __func__);
13711 return -ENOTSUPP;
13712 }
13713
13714
13715 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
13716
13717 if ( NULL == pTdlsPeer ) {
13718 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
13719 " peer not exsting",
13720 __func__, MAC_ADDR_ARRAY(peer));
13721 return -EINVAL;
13722 }
13723 else {
13724 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
13725 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
13726 }
13727
13728 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) )
13729 return -EINVAL;
13730
13731 /*EXT TDLS*/
13732
13733 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
13734
13735 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13736 " %s TDLS set callback Failed",
13737 __func__);
13738 return -EINVAL;
13739 }
13740 return(0);
13741
13742}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013743static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013744 u8 *peer, enum nl80211_tdls_operation oper)
13745{
13746 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13747 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013748 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013749 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013750
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013751 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13752 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
13753 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013754 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013755 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013756 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070013757 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013758 return -EINVAL;
13759 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080013760
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013761 status = wlan_hdd_validate_context(pHddCtx);
13762
13763 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080013764 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013765 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13766 "%s: HDD context is not valid", __func__);
13767 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080013768 }
13769
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013770
13771 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080013772 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013773 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080013774 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070013775 "TDLS Disabled in INI OR not enabled in FW. "
13776 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013777 return -ENOTSUPP;
13778 }
13779
13780 switch (oper) {
13781 case NL80211_TDLS_ENABLE_LINK:
13782 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013783 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013784 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053013785 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013786
Sunil Dutt41de4e22013-11-14 18:09:02 +053013787 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
13788
13789 if ( NULL == pTdlsPeer ) {
13790 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
13791 " (oper %d) not exsting. ignored",
13792 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
13793 return -EINVAL;
13794 }
13795
13796 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13797 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
13798 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
13799 "NL80211_TDLS_ENABLE_LINK");
13800
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070013801 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
13802 {
13803 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
13804 MAC_ADDRESS_STR " failed",
13805 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
13806 return -EINVAL;
13807 }
13808
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013809 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013810 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053013811 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053013812
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053013813 if (0 != wlan_hdd_tdls_get_link_establish_params(
13814 pAdapter, peer,&tdlsLinkEstablishParams)) {
13815 return -EINVAL;
13816 }
13817 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053013818
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053013819 sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter),
13820 pAdapter->sessionId, peer, &tdlsLinkEstablishParams);
13821 /* Send TDLS peer UAPSD capabilities to the firmware and
13822 * register with the TL on after the response for this operation
13823 * is received .
13824 */
13825 ret = wait_for_completion_interruptible_timeout(
13826 &pAdapter->tdls_link_establish_req_comp,
13827 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
13828 if (ret <= 0)
13829 {
13830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13831 "%s: Link Establish Request Faled Status %ld",
13832 __func__, ret);
13833 return -EINVAL;
13834 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053013835 }
Atul Mittal115287b2014-07-08 13:26:33 +053013836 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
13837 eTDLS_LINK_CONNECTED,
13838 eTDLS_LINK_SUCCESS);
Gopichand Nakkala471708b2013-06-04 20:03:01 +053013839 /* Mark TDLS client Authenticated .*/
13840 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
13841 pTdlsPeer->staId,
13842 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070013843 if (VOS_STATUS_SUCCESS == status)
13844 {
Hoonki Lee14621352013-04-16 17:51:19 -070013845 if (pTdlsPeer->is_responder == 0)
13846 {
13847 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
13848
13849 wlan_hdd_tdls_timer_restart(pAdapter,
13850 &pTdlsPeer->initiatorWaitTimeoutTimer,
13851 WAIT_TIME_TDLS_INITIATOR);
13852 /* suspend initiator TX until it receives direct packet from the
13853 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
13854 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
13855 &staId, NULL);
13856 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070013857 wlan_hdd_tdls_increment_peer_count(pAdapter);
13858 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013859 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053013860
13861 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053013862 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
13863 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053013864 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053013865 int ac;
13866 uint8 ucAc[4] = { WLANTL_AC_VO,
13867 WLANTL_AC_VI,
13868 WLANTL_AC_BK,
13869 WLANTL_AC_BE };
13870 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
13871 for(ac=0; ac < 4; ac++)
13872 {
13873 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
13874 pTdlsPeer->staId, ucAc[ac],
13875 tlTid[ac], tlTid[ac], 0, 0,
13876 WLANTL_BI_DIR );
13877 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053013878 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013879 }
13880
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013881 }
13882 break;
13883 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080013884 {
Sunil Dutt41de4e22013-11-14 18:09:02 +053013885 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
13886
13887 if ( NULL == pTdlsPeer ) {
13888 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
13889 " (oper %d) not exsting. ignored",
13890 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
13891 return -EINVAL;
13892 }
13893
13894 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13895 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
13896 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
13897 "NL80211_TDLS_DISABLE_LINK");
13898
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013899 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080013900 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013901 long status;
13902
Atul Mittal271a7652014-09-12 13:18:22 +053013903
13904 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
13905 eTDLS_LINK_TEARING,
13906 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
13907 eTDLS_LINK_UNSPECIFIED:
13908 eTDLS_LINK_DROPPED_BY_REMOTE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013909 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
13910
Lee Hoonkic1262f22013-01-24 21:59:00 -080013911 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
13912 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013913
13914 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
13915 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Atul Mittal271a7652014-09-12 13:18:22 +053013916 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053013917 eTDLS_LINK_IDLE,
13918 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013919 if (status <= 0)
13920 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13922 "%s: Del station failed status %ld",
13923 __func__, status);
13924 return -EPERM;
13925 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080013926 }
13927 else
13928 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013929 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13930 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080013931 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080013932 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013933 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013934 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053013935 {
Atul Mittal115287b2014-07-08 13:26:33 +053013936 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053013937
Atul Mittal115287b2014-07-08 13:26:33 +053013938 if (0 != status)
13939 {
13940 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13941 "%s: Error in TDLS Teardown", __func__);
13942 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053013943 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053013944 break;
13945 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013946 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053013947 {
Atul Mittal115287b2014-07-08 13:26:33 +053013948 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
13949 peer,
13950 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053013951
Atul Mittal115287b2014-07-08 13:26:33 +053013952 if (0 != status)
13953 {
13954 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13955 "%s: Error in TDLS Setup", __func__);
13956 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053013957 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053013958 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053013959 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013960 case NL80211_TDLS_DISCOVERY_REQ:
13961 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
13963 "%s: We don't support in-driver setup/teardown/discovery "
13964 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013965 return -ENOTSUPP;
13966 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13968 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013969 return -ENOTSUPP;
13970 }
13971 return 0;
13972}
Chilam NG571c65a2013-01-19 12:27:36 +053013973
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013974static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
13975 u8 *peer, enum nl80211_tdls_operation oper)
13976{
13977 int ret;
13978
13979 vos_ssr_protect(__func__);
13980 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
13981 vos_ssr_unprotect(__func__);
13982
13983 return ret;
13984}
13985
Chilam NG571c65a2013-01-19 12:27:36 +053013986int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
13987 struct net_device *dev, u8 *peer)
13988{
Arif Hussaina7c8e412013-11-20 11:06:42 -080013989 hddLog(VOS_TRACE_LEVEL_INFO,
13990 "tdls send discover req: "MAC_ADDRESS_STR,
13991 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053013992
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053013993#if TDLS_MGMT_VERSION2
13994 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
13995 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
13996#else
Chilam NG571c65a2013-01-19 12:27:36 +053013997 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
13998 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053013999#endif
Chilam NG571c65a2013-01-19 12:27:36 +053014000}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014001#endif
14002
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014003#ifdef WLAN_FEATURE_GTK_OFFLOAD
14004/*
14005 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
14006 * Callback rountine called upon receiving response for
14007 * get offload info
14008 */
14009void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
14010 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
14011{
14012
14013 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014014 tANI_U8 tempReplayCounter[8];
14015 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014016
14017 ENTER();
14018
14019 if (NULL == pAdapter)
14020 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053014021 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014022 "%s: HDD adapter is Null", __func__);
14023 return ;
14024 }
14025
14026 if (NULL == pGtkOffloadGetInfoRsp)
14027 {
14028 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14029 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
14030 return ;
14031 }
14032
14033 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
14034 {
14035 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14036 "%s: wlan Failed to get replay counter value",
14037 __func__);
14038 return ;
14039 }
14040
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014041 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14042 /* Update replay counter */
14043 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
14044 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
14045
14046 {
14047 /* changing from little to big endian since supplicant
14048 * works on big endian format
14049 */
14050 int i;
14051 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
14052
14053 for (i = 0; i < 8; i++)
14054 {
14055 tempReplayCounter[7-i] = (tANI_U8)p[i];
14056 }
14057 }
14058
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014059 /* Update replay counter to NL */
14060 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014061 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014062}
14063
14064/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014065 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014066 * This function is used to offload GTK rekeying job to the firmware.
14067 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014068int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014069 struct cfg80211_gtk_rekey_data *data)
14070{
14071 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14072 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
14073 hdd_station_ctx_t *pHddStaCtx;
14074 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014075 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014076 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014077 eHalStatus status = eHAL_STATUS_FAILURE;
14078
14079 ENTER();
14080
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014081
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014082 if (NULL == pAdapter)
14083 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014084 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014085 "%s: HDD adapter is Null", __func__);
14086 return -ENODEV;
14087 }
14088
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014089 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14090 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
14091 pAdapter->sessionId, pAdapter->device_mode));
14092
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014093 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014094
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014095 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014096 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014097 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14098 "%s: HDD context is not valid", __func__);
14099 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014100 }
14101
14102 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14103 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14104 if (NULL == hHal)
14105 {
14106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14107 "%s: HAL context is Null!!!", __func__);
14108 return -EAGAIN;
14109 }
14110
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014111 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
14112 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
14113 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
14114 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014115 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014116 {
14117 /* changing from big to little endian since driver
14118 * works on little endian format
14119 */
14120 tANI_U8 *p =
14121 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
14122 int i;
14123
14124 for (i = 0; i < 8; i++)
14125 {
14126 p[7-i] = data->replay_ctr[i];
14127 }
14128 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014129
14130 if (TRUE == pHddCtx->hdd_wlan_suspended)
14131 {
14132 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014133 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
14134 sizeof (tSirGtkOffloadParams));
14135 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014136 pAdapter->sessionId);
14137
14138 if (eHAL_STATUS_SUCCESS != status)
14139 {
14140 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14141 "%s: sme_SetGTKOffload failed, returned %d",
14142 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053014143
14144 /* Need to clear any trace of key value in the memory.
14145 * Thus zero out the memory even though it is local
14146 * variable.
14147 */
14148 vos_mem_zero(&hddGtkOffloadReqParams,
14149 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014150 return status;
14151 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14153 "%s: sme_SetGTKOffload successfull", __func__);
14154 }
14155 else
14156 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014157 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14158 "%s: wlan not suspended GTKOffload request is stored",
14159 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014160 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014161
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053014162 /* Need to clear any trace of key value in the memory.
14163 * Thus zero out the memory even though it is local
14164 * variable.
14165 */
14166 vos_mem_zero(&hddGtkOffloadReqParams,
14167 sizeof(hddGtkOffloadReqParams));
14168
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014169 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014170}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014171
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014172int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
14173 struct cfg80211_gtk_rekey_data *data)
14174{
14175 int ret;
14176
14177 vos_ssr_protect(__func__);
14178 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
14179 vos_ssr_unprotect(__func__);
14180
14181 return ret;
14182}
14183#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014184/*
14185 * FUNCTION: wlan_hdd_cfg80211_set_mac_acl
14186 * This function is used to set access control policy
14187 */
14188static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
14189 struct net_device *dev, const struct cfg80211_acl_data *params)
14190{
14191 int i;
14192 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14193 hdd_hostapd_state_t *pHostapdState;
14194 tsap_Config_t *pConfig;
14195 v_CONTEXT_t pVosContext = NULL;
14196 hdd_context_t *pHddCtx;
14197 int status;
14198
14199 ENTER();
14200
14201 if (NULL == pAdapter)
14202 {
14203 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14204 "%s: HDD adapter is Null", __func__);
14205 return -ENODEV;
14206 }
14207
14208 if (NULL == params)
14209 {
14210 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14211 "%s: params is Null", __func__);
14212 return -EINVAL;
14213 }
14214
14215 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14216 status = wlan_hdd_validate_context(pHddCtx);
14217
14218 if (0 != status)
14219 {
14220 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14221 "%s: HDD context is not valid", __func__);
14222 return status;
14223 }
14224
14225 pVosContext = pHddCtx->pvosContext;
14226 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
14227
14228 if (NULL == pHostapdState)
14229 {
14230 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14231 "%s: pHostapdState is Null", __func__);
14232 return -EINVAL;
14233 }
14234
14235 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
14236 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
14237
14238 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
14239 {
14240 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
14241
14242 /* default value */
14243 pConfig->num_accept_mac = 0;
14244 pConfig->num_deny_mac = 0;
14245
14246 /**
14247 * access control policy
14248 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
14249 * listed in hostapd.deny file.
14250 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
14251 * listed in hostapd.accept file.
14252 */
14253 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
14254 {
14255 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
14256 }
14257 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
14258 {
14259 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
14260 }
14261 else
14262 {
14263 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14264 "%s:Acl Policy : %d is not supported",
14265 __func__, params->acl_policy);
14266 return -ENOTSUPP;
14267 }
14268
14269 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
14270 {
14271 pConfig->num_accept_mac = params->n_acl_entries;
14272 for (i = 0; i < params->n_acl_entries; i++)
14273 {
14274 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14275 "** Add ACL MAC entry %i in WhiletList :"
14276 MAC_ADDRESS_STR, i,
14277 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
14278
14279 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
14280 sizeof(qcmacaddr));
14281 }
14282 }
14283 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
14284 {
14285 pConfig->num_deny_mac = params->n_acl_entries;
14286 for (i = 0; i < params->n_acl_entries; i++)
14287 {
14288 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14289 "** Add ACL MAC entry %i in BlackList :"
14290 MAC_ADDRESS_STR, i,
14291 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
14292
14293 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
14294 sizeof(qcmacaddr));
14295 }
14296 }
14297
14298 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
14299 {
14300 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14301 "%s: SAP Set Mac Acl fail", __func__);
14302 return -EINVAL;
14303 }
14304 }
14305 else
14306 {
14307 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053014308 "%s: Invalid device_mode = %s (%d)",
14309 __func__, hdd_device_modetoString(pAdapter->device_mode),
14310 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014311 return -EINVAL;
14312 }
14313
14314 return 0;
14315}
14316
Leo Chang9056f462013-08-01 19:21:11 -070014317#ifdef WLAN_NL80211_TESTMODE
14318#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070014319void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070014320(
14321 void *pAdapter,
14322 void *indCont
14323)
14324{
Leo Changd9df8aa2013-09-26 13:32:26 -070014325 tSirLPHBInd *lphbInd;
14326 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053014327 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070014328
14329 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070014330 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070014331
c_hpothu73f35e62014-04-18 13:40:08 +053014332 if (pAdapter == NULL)
14333 {
14334 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14335 "%s: pAdapter is NULL\n",__func__);
14336 return;
14337 }
14338
Leo Chang9056f462013-08-01 19:21:11 -070014339 if (NULL == indCont)
14340 {
14341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070014342 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070014343 return;
14344 }
14345
c_hpothu73f35e62014-04-18 13:40:08 +053014346 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070014347 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070014348 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053014349 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070014350 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070014351 GFP_ATOMIC);
14352 if (!skb)
14353 {
14354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14355 "LPHB timeout, NL buffer alloc fail");
14356 return;
14357 }
14358
Leo Changac3ba772013-10-07 09:47:04 -070014359 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070014360 {
14361 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14362 "WLAN_HDD_TM_ATTR_CMD put fail");
14363 goto nla_put_failure;
14364 }
Leo Changac3ba772013-10-07 09:47:04 -070014365 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070014366 {
14367 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14368 "WLAN_HDD_TM_ATTR_TYPE put fail");
14369 goto nla_put_failure;
14370 }
Leo Changac3ba772013-10-07 09:47:04 -070014371 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070014372 sizeof(tSirLPHBInd), lphbInd))
14373 {
14374 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14375 "WLAN_HDD_TM_ATTR_DATA put fail");
14376 goto nla_put_failure;
14377 }
Leo Chang9056f462013-08-01 19:21:11 -070014378 cfg80211_testmode_event(skb, GFP_ATOMIC);
14379 return;
14380
14381nla_put_failure:
14382 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14383 "NLA Put fail");
14384 kfree_skb(skb);
14385
14386 return;
14387}
14388#endif /* FEATURE_WLAN_LPHB */
14389
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014390static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070014391{
14392 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
14393 int err = 0;
14394#ifdef FEATURE_WLAN_LPHB
14395 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070014396 eHalStatus smeStatus;
Leo Chang9056f462013-08-01 19:21:11 -070014397#endif /* FEATURE_WLAN_LPHB */
14398
14399 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
14400 if (err)
14401 {
14402 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14403 "%s Testmode INV ATTR", __func__);
14404 return err;
14405 }
14406
14407 if (!tb[WLAN_HDD_TM_ATTR_CMD])
14408 {
14409 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14410 "%s Testmode INV CMD", __func__);
14411 return -EINVAL;
14412 }
14413
14414 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
14415 {
14416#ifdef FEATURE_WLAN_LPHB
14417 /* Low Power Heartbeat configuration request */
14418 case WLAN_HDD_TM_CMD_WLAN_HB:
14419 {
14420 int buf_len;
14421 void *buf;
14422 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080014423 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070014424
14425 if (!tb[WLAN_HDD_TM_ATTR_DATA])
14426 {
14427 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14428 "%s Testmode INV DATA", __func__);
14429 return -EINVAL;
14430 }
14431
14432 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
14433 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080014434
14435 hb_params_temp =(tSirLPHBReq *)buf;
14436 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
14437 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
14438 return -EINVAL;
14439
Leo Chang9056f462013-08-01 19:21:11 -070014440 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
14441 if (NULL == hb_params)
14442 {
14443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14444 "%s Request Buffer Alloc Fail", __func__);
14445 return -EINVAL;
14446 }
14447
14448 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070014449 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
14450 hb_params,
14451 wlan_hdd_cfg80211_lphb_ind_handler);
14452 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070014453 {
Leo Changd9df8aa2013-09-26 13:32:26 -070014454 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14455 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070014456 vos_mem_free(hb_params);
14457 }
Leo Chang9056f462013-08-01 19:21:11 -070014458 return 0;
14459 }
14460#endif /* FEATURE_WLAN_LPHB */
14461 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014462 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14463 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070014464 return -EOPNOTSUPP;
14465 }
14466
14467 return err;
14468}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014469
14470static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
14471{
14472 int ret;
14473
14474 vos_ssr_protect(__func__);
14475 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
14476 vos_ssr_unprotect(__func__);
14477
14478 return ret;
14479}
Leo Chang9056f462013-08-01 19:21:11 -070014480#endif /* CONFIG_NL80211_TESTMODE */
14481
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014482static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014483 struct net_device *dev,
14484 int idx, struct survey_info *survey)
14485{
14486 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14487 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053014488 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014489 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053014490 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014491 v_S7_t snr,rssi;
14492 int status, i, j, filled = 0;
14493
14494 ENTER();
14495
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014496 if (NULL == pAdapter)
14497 {
14498 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14499 "%s: HDD adapter is Null", __func__);
14500 return -ENODEV;
14501 }
14502
14503 if (NULL == wiphy)
14504 {
14505 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14506 "%s: wiphy is Null", __func__);
14507 return -ENODEV;
14508 }
14509
14510 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14511 status = wlan_hdd_validate_context(pHddCtx);
14512
14513 if (0 != status)
14514 {
14515 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14516 "%s: HDD context is not valid", __func__);
14517 return status;
14518 }
14519
Mihir Sheted9072e02013-08-21 17:02:29 +053014520 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14521
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014522 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053014523 0 != pAdapter->survey_idx ||
14524 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014525 {
14526 /* The survey dump ops when implemented completely is expected to
14527 * return a survey of all channels and the ops is called by the
14528 * kernel with incremental values of the argument 'idx' till it
14529 * returns -ENONET. But we can only support the survey for the
14530 * operating channel for now. survey_idx is used to track
14531 * that the ops is called only once and then return -ENONET for
14532 * the next iteration
14533 */
14534 pAdapter->survey_idx = 0;
14535 return -ENONET;
14536 }
14537
14538 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14539
14540 wlan_hdd_get_snr(pAdapter, &snr);
14541 wlan_hdd_get_rssi(pAdapter, &rssi);
14542
14543 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
14544 hdd_wlan_get_freq(channel, &freq);
14545
14546
14547 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
14548 {
14549 if (NULL == wiphy->bands[i])
14550 {
14551 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
14552 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
14553 continue;
14554 }
14555
14556 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
14557 {
14558 struct ieee80211_supported_band *band = wiphy->bands[i];
14559
14560 if (band->channels[j].center_freq == (v_U16_t)freq)
14561 {
14562 survey->channel = &band->channels[j];
14563 /* The Rx BDs contain SNR values in dB for the received frames
14564 * while the supplicant expects noise. So we calculate and
14565 * return the value of noise (dBm)
14566 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
14567 */
14568 survey->noise = rssi - snr;
14569 survey->filled = SURVEY_INFO_NOISE_DBM;
14570 filled = 1;
14571 }
14572 }
14573 }
14574
14575 if (filled)
14576 pAdapter->survey_idx = 1;
14577 else
14578 {
14579 pAdapter->survey_idx = 0;
14580 return -ENONET;
14581 }
14582
14583 return 0;
14584}
14585
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014586static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
14587 struct net_device *dev,
14588 int idx, struct survey_info *survey)
14589{
14590 int ret;
14591
14592 vos_ssr_protect(__func__);
14593 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
14594 vos_ssr_unprotect(__func__);
14595
14596 return ret;
14597}
14598
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014599/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053014600 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014601 * this is called when cfg80211 driver resume
14602 * driver updates latest sched_scan scan result(if any) to cfg80211 database
14603 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053014604int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014605{
14606 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
14607 hdd_adapter_t *pAdapter;
14608 hdd_adapter_list_node_t *pAdapterNode, *pNext;
14609 VOS_STATUS status = VOS_STATUS_SUCCESS;
14610
14611 ENTER();
14612
14613 if ( NULL == pHddCtx )
14614 {
14615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14616 "%s: HddCtx validation failed", __func__);
14617 return 0;
14618 }
14619
14620 if (pHddCtx->isLogpInProgress)
14621 {
14622 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14623 "%s: LOGP in Progress. Ignore!!!", __func__);
14624 return 0;
14625 }
14626
Mihir Shete18156292014-03-11 15:38:30 +053014627 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014628 {
14629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14630 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14631 return 0;
14632 }
14633
14634 spin_lock(&pHddCtx->schedScan_lock);
14635 pHddCtx->isWiphySuspended = FALSE;
14636 if (TRUE != pHddCtx->isSchedScanUpdatePending)
14637 {
14638 spin_unlock(&pHddCtx->schedScan_lock);
14639 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14640 "%s: Return resume is not due to PNO indication", __func__);
14641 return 0;
14642 }
14643 // Reset flag to avoid updatating cfg80211 data old results again
14644 pHddCtx->isSchedScanUpdatePending = FALSE;
14645 spin_unlock(&pHddCtx->schedScan_lock);
14646
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053014647
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014648 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
14649
14650 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
14651 {
14652 pAdapter = pAdapterNode->pAdapter;
14653 if ( (NULL != pAdapter) &&
14654 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
14655 {
14656 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053014657 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014658 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
14659 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053014660 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014661 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053014662 {
14663 /* Acquire wakelock to handle the case where APP's tries to
14664 * suspend immediately after updating the scan results. Whis
14665 * results in app's is in suspended state and not able to
14666 * process the connect request to AP
14667 */
14668 hdd_prevent_suspend_timeout(2000);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014669 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053014670 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014671
14672 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14673 "%s : cfg80211 scan result database updated", __func__);
14674
14675 return 0;
14676
14677 }
14678 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
14679 pAdapterNode = pNext;
14680 }
14681
14682 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14683 "%s: Failed to find Adapter", __func__);
14684 return 0;
14685}
14686
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053014687int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
14688{
14689 int ret;
14690
14691 vos_ssr_protect(__func__);
14692 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
14693 vos_ssr_unprotect(__func__);
14694
14695 return ret;
14696}
14697
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014698/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053014699 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014700 * this is called when cfg80211 driver suspends
14701 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053014702int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014703 struct cfg80211_wowlan *wow)
14704{
14705 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
14706
14707 ENTER();
14708 if (NULL == pHddCtx)
14709 {
14710 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
14711 "%s: HddCtx validation failed", __func__);
14712 return 0;
14713 }
14714
14715 pHddCtx->isWiphySuspended = TRUE;
14716
14717 EXIT();
14718
14719 return 0;
14720}
14721
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053014722int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
14723 struct cfg80211_wowlan *wow)
14724{
14725 int ret;
14726
14727 vos_ssr_protect(__func__);
14728 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
14729 vos_ssr_unprotect(__func__);
14730
14731 return ret;
14732}
Jeff Johnson295189b2012-06-20 16:38:30 -070014733/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014734static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070014735{
14736 .add_virtual_intf = wlan_hdd_add_virtual_intf,
14737 .del_virtual_intf = wlan_hdd_del_virtual_intf,
14738 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
14739 .change_station = wlan_hdd_change_station,
14740#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
14741 .add_beacon = wlan_hdd_cfg80211_add_beacon,
14742 .del_beacon = wlan_hdd_cfg80211_del_beacon,
14743 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014744#else
14745 .start_ap = wlan_hdd_cfg80211_start_ap,
14746 .change_beacon = wlan_hdd_cfg80211_change_beacon,
14747 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070014748#endif
14749 .change_bss = wlan_hdd_cfg80211_change_bss,
14750 .add_key = wlan_hdd_cfg80211_add_key,
14751 .get_key = wlan_hdd_cfg80211_get_key,
14752 .del_key = wlan_hdd_cfg80211_del_key,
14753 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080014754#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070014755 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080014756#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014757 .scan = wlan_hdd_cfg80211_scan,
14758 .connect = wlan_hdd_cfg80211_connect,
14759 .disconnect = wlan_hdd_cfg80211_disconnect,
14760 .join_ibss = wlan_hdd_cfg80211_join_ibss,
14761 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
14762 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
14763 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
14764 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070014765 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
14766 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053014767 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070014768#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
14769 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
14770 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
14771 .set_txq_params = wlan_hdd_set_txq_params,
14772#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014773 .get_station = wlan_hdd_cfg80211_get_station,
14774 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
14775 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014776 .add_station = wlan_hdd_cfg80211_add_station,
14777#ifdef FEATURE_WLAN_LFR
14778 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
14779 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
14780 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
14781#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014782#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
14783 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
14784#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014785#ifdef FEATURE_WLAN_TDLS
14786 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
14787 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
14788#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014789#ifdef WLAN_FEATURE_GTK_OFFLOAD
14790 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
14791#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014792#ifdef FEATURE_WLAN_SCAN_PNO
14793 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
14794 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
14795#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014796 .resume = wlan_hdd_cfg80211_resume_wlan,
14797 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014798 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070014799#ifdef WLAN_NL80211_TESTMODE
14800 .testmode_cmd = wlan_hdd_cfg80211_testmode,
14801#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014802 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070014803};
14804