blob: 47fbe38db8dcc45e2c5d9d21c8448d837f68fa40 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
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.
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +053026 *
Kiet Lamaa8e15a2014-02-11 23:30:06 -080027 */
Kiet Lam842dad02014-02-18 18:44:02 -080028
29
Kiet Lama7f454d2014-07-24 12:04:06 -070030
31
Jeff Johnson295189b2012-06-20 16:38:30 -070032/**========================================================================
33
34 \file wlan_hdd_cfg80211.c
35
36 \brief WLAN Host Device Driver implementation
37
Jeff Johnson295189b2012-06-20 16:38:30 -070038 ========================================================================*/
39
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070040/**=========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070041
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070042 EDIT HISTORY FOR FILE
Jeff Johnson295189b2012-06-20 16:38:30 -070043
44
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070045 This section contains comments describing changes made to the module.
46 Notice that changes are listed in reverse chronological order.
Jeff Johnson295189b2012-06-20 16:38:30 -070047
48
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070049 $Header:$ $DateTime: $ $Author: $
Jeff Johnson295189b2012-06-20 16:38:30 -070050
51
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070052 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070053 -------- --- --------------------------------------------------------
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070054 21/12/09 Ashwani Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070055
56 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070057 Ganesh K
Jeff Johnson295189b2012-06-20 16:38:30 -070058 ==========================================================================*/
59
Jeff Johnson295189b2012-06-20 16:38:30 -070060
61#include <linux/version.h>
62#include <linux/module.h>
63#include <linux/kernel.h>
64#include <linux/init.h>
65#include <linux/wireless.h>
66#include <wlan_hdd_includes.h>
67#include <net/arp.h>
68#include <net/cfg80211.h>
69#include <linux/wireless.h>
70#include <wlan_hdd_wowl.h>
71#include <aniGlobal.h>
72#include "ccmApi.h"
73#include "sirParams.h"
74#include "dot11f.h"
75#include "wlan_hdd_assoc.h"
76#include "wlan_hdd_wext.h"
77#include "sme_Api.h"
78#include "wlan_hdd_p2p.h"
79#include "wlan_hdd_cfg80211.h"
80#include "wlan_hdd_hostapd.h"
81#include "sapInternal.h"
82#include "wlan_hdd_softap_tx_rx.h"
83#include "wlan_hdd_main.h"
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053084#include "wlan_hdd_assoc.h"
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053085#include "wlan_hdd_power.h"
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053086#include "wlan_hdd_trace.h"
87#include "vos_types.h"
88#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070089#ifdef WLAN_BTAMP_FEATURE
90#include "bap_hdd_misc.h"
91#endif
92#include <qc_sap_ioctl.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080093#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"
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053096#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070097#include "wlan_hdd_dev_pwr.h"
Sushant Kaushik084f6592015-09-10 13:11:56 +053098#include "qwlan_version.h"
c_manjeecfd1efb2015-09-25 19:32:34 +053099#include "wlan_logging_sock_svc.h"
Sushant Kaushik084f6592015-09-10 13:11:56 +0530100
Jeff Johnson295189b2012-06-20 16:38:30 -0700101
102#define g_mode_rates_size (12)
103#define a_mode_rates_size (8)
104#define FREQ_BASE_80211G (2407)
105#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700106#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +0530107#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -0700108#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
krunal soni2a6a9062014-02-11 14:14:23 -0800109 ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700110
111#define HDD2GHZCHAN(freq, chan, flag) { \
112 .band = IEEE80211_BAND_2GHZ, \
113 .center_freq = (freq), \
114 .hw_value = (chan),\
115 .flags = (flag), \
116 .max_antenna_gain = 0 ,\
117 .max_power = 30, \
118}
119
120#define HDD5GHZCHAN(freq, chan, flag) { \
121 .band = IEEE80211_BAND_5GHZ, \
122 .center_freq = (freq), \
123 .hw_value = (chan),\
124 .flags = (flag), \
125 .max_antenna_gain = 0 ,\
126 .max_power = 30, \
127}
128
129#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
130{\
131 .bitrate = rate, \
132 .hw_value = rate_id, \
133 .flags = flag, \
134}
135
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530136#ifdef WLAN_FEATURE_VOWIFI_11R
137#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
138#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
139#endif
140
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530141#define HDD_CHANNEL_14 14
Dasari Srinivase18b2cf2014-10-28 17:09:42 +0530142#define WLAN_HDD_MAX_FEATURE_SET 8
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530143
Sunil Duttc69bccb2014-05-26 21:30:20 +0530144#ifdef WLAN_FEATURE_LINK_LAYER_STATS
145/*
146 * Used to allocate the size of 4096 for the link layer stats.
147 * The size of 4096 is considered assuming that all data per
148 * respective event fit with in the limit.Please take a call
149 * on the limit based on the data requirements on link layer
150 * statistics.
151 */
152#define LL_STATS_EVENT_BUF_SIZE 4096
153#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +0530154#ifdef WLAN_FEATURE_EXTSCAN
155/*
156 * Used to allocate the size of 4096 for the EXTScan NL data.
157 * The size of 4096 is considered assuming that all data per
158 * respective event fit with in the limit.Please take a call
159 * on the limit based on the data requirements.
160 */
161
162#define EXTSCAN_EVENT_BUF_SIZE 4096
163#define EXTSCAN_MAX_CACHED_RESULTS_PER_IND 32
164#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +0530165
Atul Mittal115287b2014-07-08 13:26:33 +0530166/*EXT TDLS*/
167/*
168 * Used to allocate the size of 4096 for the TDLS.
169 * The size of 4096 is considered assuming that all data per
170 * respective event fit with in the limit.Please take a call
171 * on the limit based on the data requirements on link layer
172 * statistics.
173 */
174#define EXTTDLS_EVENT_BUF_SIZE 4096
175
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530176static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700177{
178 WLAN_CIPHER_SUITE_WEP40,
179 WLAN_CIPHER_SUITE_WEP104,
180 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800181#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700182#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
183 WLAN_CIPHER_SUITE_KRK,
184 WLAN_CIPHER_SUITE_CCMP,
185#else
186 WLAN_CIPHER_SUITE_CCMP,
187#endif
188#ifdef FEATURE_WLAN_WAPI
189 WLAN_CIPHER_SUITE_SMS4,
190#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700191#ifdef WLAN_FEATURE_11W
192 WLAN_CIPHER_SUITE_AES_CMAC,
193#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700194};
195
196static inline int is_broadcast_ether_addr(const u8 *addr)
197{
198 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
199 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
200}
201
202static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530203{
Jeff Johnson295189b2012-06-20 16:38:30 -0700204 HDD2GHZCHAN(2412, 1, 0) ,
205 HDD2GHZCHAN(2417, 2, 0) ,
206 HDD2GHZCHAN(2422, 3, 0) ,
207 HDD2GHZCHAN(2427, 4, 0) ,
208 HDD2GHZCHAN(2432, 5, 0) ,
209 HDD2GHZCHAN(2437, 6, 0) ,
210 HDD2GHZCHAN(2442, 7, 0) ,
211 HDD2GHZCHAN(2447, 8, 0) ,
212 HDD2GHZCHAN(2452, 9, 0) ,
213 HDD2GHZCHAN(2457, 10, 0) ,
214 HDD2GHZCHAN(2462, 11, 0) ,
215 HDD2GHZCHAN(2467, 12, 0) ,
216 HDD2GHZCHAN(2472, 13, 0) ,
217 HDD2GHZCHAN(2484, 14, 0) ,
218};
219
Jeff Johnson295189b2012-06-20 16:38:30 -0700220static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
221{
222 HDD2GHZCHAN(2412, 1, 0) ,
223 HDD2GHZCHAN(2437, 6, 0) ,
224 HDD2GHZCHAN(2462, 11, 0) ,
225};
Jeff Johnson295189b2012-06-20 16:38:30 -0700226
227static struct ieee80211_channel hdd_channels_5_GHZ[] =
228{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700229 HDD5GHZCHAN(4920, 240, 0) ,
230 HDD5GHZCHAN(4940, 244, 0) ,
231 HDD5GHZCHAN(4960, 248, 0) ,
232 HDD5GHZCHAN(4980, 252, 0) ,
233 HDD5GHZCHAN(5040, 208, 0) ,
234 HDD5GHZCHAN(5060, 212, 0) ,
235 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700236 HDD5GHZCHAN(5180, 36, 0) ,
237 HDD5GHZCHAN(5200, 40, 0) ,
238 HDD5GHZCHAN(5220, 44, 0) ,
239 HDD5GHZCHAN(5240, 48, 0) ,
240 HDD5GHZCHAN(5260, 52, 0) ,
241 HDD5GHZCHAN(5280, 56, 0) ,
242 HDD5GHZCHAN(5300, 60, 0) ,
243 HDD5GHZCHAN(5320, 64, 0) ,
244 HDD5GHZCHAN(5500,100, 0) ,
245 HDD5GHZCHAN(5520,104, 0) ,
246 HDD5GHZCHAN(5540,108, 0) ,
247 HDD5GHZCHAN(5560,112, 0) ,
248 HDD5GHZCHAN(5580,116, 0) ,
249 HDD5GHZCHAN(5600,120, 0) ,
250 HDD5GHZCHAN(5620,124, 0) ,
251 HDD5GHZCHAN(5640,128, 0) ,
252 HDD5GHZCHAN(5660,132, 0) ,
253 HDD5GHZCHAN(5680,136, 0) ,
254 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800255#ifdef FEATURE_WLAN_CH144
256 HDD5GHZCHAN(5720,144, 0) ,
257#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700258 HDD5GHZCHAN(5745,149, 0) ,
259 HDD5GHZCHAN(5765,153, 0) ,
260 HDD5GHZCHAN(5785,157, 0) ,
261 HDD5GHZCHAN(5805,161, 0) ,
262 HDD5GHZCHAN(5825,165, 0) ,
263};
264
265static struct ieee80211_rate g_mode_rates[] =
266{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530267 HDD_G_MODE_RATETAB(10, 0x1, 0),
268 HDD_G_MODE_RATETAB(20, 0x2, 0),
269 HDD_G_MODE_RATETAB(55, 0x4, 0),
270 HDD_G_MODE_RATETAB(110, 0x8, 0),
271 HDD_G_MODE_RATETAB(60, 0x10, 0),
272 HDD_G_MODE_RATETAB(90, 0x20, 0),
273 HDD_G_MODE_RATETAB(120, 0x40, 0),
274 HDD_G_MODE_RATETAB(180, 0x80, 0),
275 HDD_G_MODE_RATETAB(240, 0x100, 0),
276 HDD_G_MODE_RATETAB(360, 0x200, 0),
277 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700278 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530279};
Jeff Johnson295189b2012-06-20 16:38:30 -0700280
281static struct ieee80211_rate a_mode_rates[] =
282{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530283 HDD_G_MODE_RATETAB(60, 0x10, 0),
284 HDD_G_MODE_RATETAB(90, 0x20, 0),
285 HDD_G_MODE_RATETAB(120, 0x40, 0),
286 HDD_G_MODE_RATETAB(180, 0x80, 0),
287 HDD_G_MODE_RATETAB(240, 0x100, 0),
288 HDD_G_MODE_RATETAB(360, 0x200, 0),
289 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700290 HDD_G_MODE_RATETAB(540, 0x800, 0),
291};
292
293static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
294{
295 .channels = hdd_channels_2_4_GHZ,
296 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
297 .band = IEEE80211_BAND_2GHZ,
298 .bitrates = g_mode_rates,
299 .n_bitrates = g_mode_rates_size,
300 .ht_cap.ht_supported = 1,
301 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
302 | IEEE80211_HT_CAP_GRN_FLD
303 | IEEE80211_HT_CAP_DSSSCCK40
304 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
305 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
306 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
307 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
308 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
309 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
310};
311
Jeff Johnson295189b2012-06-20 16:38:30 -0700312static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
313{
314 .channels = hdd_social_channels_2_4_GHZ,
315 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
316 .band = IEEE80211_BAND_2GHZ,
317 .bitrates = g_mode_rates,
318 .n_bitrates = g_mode_rates_size,
319 .ht_cap.ht_supported = 1,
320 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
321 | IEEE80211_HT_CAP_GRN_FLD
322 | IEEE80211_HT_CAP_DSSSCCK40
323 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
324 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
325 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
326 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
327 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
328 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
329};
Jeff Johnson295189b2012-06-20 16:38:30 -0700330
331static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
332{
333 .channels = hdd_channels_5_GHZ,
334 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
335 .band = IEEE80211_BAND_5GHZ,
336 .bitrates = a_mode_rates,
337 .n_bitrates = a_mode_rates_size,
338 .ht_cap.ht_supported = 1,
339 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
340 | IEEE80211_HT_CAP_GRN_FLD
341 | IEEE80211_HT_CAP_DSSSCCK40
342 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
343 | IEEE80211_HT_CAP_SGI_40
344 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
345 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
346 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
347 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
348 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
349 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
350};
351
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530352/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700353 TX/RX direction for each kind of interface */
354static const struct ieee80211_txrx_stypes
355wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
356 [NL80211_IFTYPE_STATION] = {
357 .tx = 0xffff,
358 .rx = BIT(SIR_MAC_MGMT_ACTION) |
359 BIT(SIR_MAC_MGMT_PROBE_REQ),
360 },
361 [NL80211_IFTYPE_AP] = {
362 .tx = 0xffff,
363 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
364 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
365 BIT(SIR_MAC_MGMT_PROBE_REQ) |
366 BIT(SIR_MAC_MGMT_DISASSOC) |
367 BIT(SIR_MAC_MGMT_AUTH) |
368 BIT(SIR_MAC_MGMT_DEAUTH) |
369 BIT(SIR_MAC_MGMT_ACTION),
370 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700371 [NL80211_IFTYPE_ADHOC] = {
372 .tx = 0xffff,
373 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
374 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
375 BIT(SIR_MAC_MGMT_PROBE_REQ) |
376 BIT(SIR_MAC_MGMT_DISASSOC) |
377 BIT(SIR_MAC_MGMT_AUTH) |
378 BIT(SIR_MAC_MGMT_DEAUTH) |
379 BIT(SIR_MAC_MGMT_ACTION),
380 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700381 [NL80211_IFTYPE_P2P_CLIENT] = {
382 .tx = 0xffff,
383 .rx = BIT(SIR_MAC_MGMT_ACTION) |
384 BIT(SIR_MAC_MGMT_PROBE_REQ),
385 },
386 [NL80211_IFTYPE_P2P_GO] = {
387 /* This is also same as for SoftAP */
388 .tx = 0xffff,
389 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
390 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
391 BIT(SIR_MAC_MGMT_PROBE_REQ) |
392 BIT(SIR_MAC_MGMT_DISASSOC) |
393 BIT(SIR_MAC_MGMT_AUTH) |
394 BIT(SIR_MAC_MGMT_DEAUTH) |
395 BIT(SIR_MAC_MGMT_ACTION),
396 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700397};
398
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800399#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800400static const struct ieee80211_iface_limit
401wlan_hdd_iface_limit[] = {
402 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800403 /* max = 3 ; Our driver create two interfaces during driver init
404 * wlan0 and p2p0 interfaces. p2p0 is considered as station
405 * interface until a group is formed. In JB architecture, once the
406 * group is formed, interface type of p2p0 is changed to P2P GO or
407 * Client.
408 * When supplicant remove the group, it first issue a set interface
409 * cmd to change the mode back to Station. In JB this works fine as
410 * we advertize two station type interface during driver init.
411 * Some vendors create separate interface for P2P GO/Client,
412 * after group formation(Third one). But while group remove
413 * supplicant first tries to change the mode(3rd interface) to STATION
414 * But as we advertized only two sta type interfaces nl80211 was
415 * returning error for the third one which was leading to failure in
416 * delete interface. Ideally while removing the group, supplicant
417 * should not try to change the 3rd interface mode to Station type.
418 * Till we get a fix in wpa_supplicant, we advertize max STA
419 * interface type to 3
420 */
421 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800422 .types = BIT(NL80211_IFTYPE_STATION),
423 },
424 {
425 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700426 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800427 },
428 {
429 .max = 1,
430 .types = BIT(NL80211_IFTYPE_P2P_GO) |
431 BIT(NL80211_IFTYPE_P2P_CLIENT),
432 },
433};
434
435/* By default, only single channel concurrency is allowed */
436static struct ieee80211_iface_combination
437wlan_hdd_iface_combination = {
438 .limits = wlan_hdd_iface_limit,
439 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800440 /*
441 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
442 * and p2p0 interfaces during driver init
443 * Some vendors create separate interface for P2P operations.
444 * wlan0: STA interface
445 * p2p0: P2P Device interface, action frames goes
446 * through this interface.
447 * p2p-xx: P2P interface, After GO negotiation this interface is
448 * created for p2p operations(GO/CLIENT interface).
449 */
450 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800451 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
452 .beacon_int_infra_match = false,
453};
454#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800455
Jeff Johnson295189b2012-06-20 16:38:30 -0700456static struct cfg80211_ops wlan_hdd_cfg80211_ops;
457
458/* Data rate 100KBPS based on IE Index */
459struct index_data_rate_type
460{
461 v_U8_t beacon_rate_index;
462 v_U16_t supported_rate[4];
463};
464
465/* 11B, 11G Rate table include Basic rate and Extended rate
466 The IDX field is the rate index
467 The HI field is the rate when RSSI is strong or being ignored
468 (in this case we report actual rate)
469 The MID field is the rate when RSSI is moderate
470 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
471 The LO field is the rate when RSSI is low
472 (in this case we don't report rates, actual current rate used)
473 */
474static const struct
475{
476 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700477 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700478} supported_data_rate[] =
479{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700480/* IDX HI HM LM LO (RSSI-based index */
481 {2, { 10, 10, 10, 0}},
482 {4, { 20, 20, 10, 0}},
483 {11, { 55, 20, 10, 0}},
484 {12, { 60, 55, 20, 0}},
485 {18, { 90, 55, 20, 0}},
486 {22, {110, 55, 20, 0}},
487 {24, {120, 90, 60, 0}},
488 {36, {180, 120, 60, 0}},
489 {44, {220, 180, 60, 0}},
490 {48, {240, 180, 90, 0}},
491 {66, {330, 180, 90, 0}},
492 {72, {360, 240, 90, 0}},
493 {96, {480, 240, 120, 0}},
494 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700495};
496
497/* MCS Based rate table */
498static struct index_data_rate_type supported_mcs_rate[] =
499{
500/* MCS L20 L40 S20 S40 */
501 {0, {65, 135, 72, 150}},
502 {1, {130, 270, 144, 300}},
503 {2, {195, 405, 217, 450}},
504 {3, {260, 540, 289, 600}},
505 {4, {390, 810, 433, 900}},
506 {5, {520, 1080, 578, 1200}},
507 {6, {585, 1215, 650, 1350}},
508 {7, {650, 1350, 722, 1500}}
509};
510
Leo Chang6f8870f2013-03-26 18:11:36 -0700511#ifdef WLAN_FEATURE_11AC
512
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530513#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700514
515struct index_vht_data_rate_type
516{
517 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530518 v_U16_t supported_VHT80_rate[2];
519 v_U16_t supported_VHT40_rate[2];
520 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700521};
522
523typedef enum
524{
525 DATA_RATE_11AC_MAX_MCS_7,
526 DATA_RATE_11AC_MAX_MCS_8,
527 DATA_RATE_11AC_MAX_MCS_9,
528 DATA_RATE_11AC_MAX_MCS_NA
529} eDataRate11ACMaxMcs;
530
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +0530531/* SSID broadcast type */
532typedef enum eSSIDBcastType
533{
534 eBCAST_UNKNOWN = 0,
535 eBCAST_NORMAL = 1,
536 eBCAST_HIDDEN = 2,
537} tSSIDBcastType;
538
Leo Chang6f8870f2013-03-26 18:11:36 -0700539/* MCS Based VHT rate table */
540static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
541{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530542/* MCS L80 S80 L40 S40 L20 S40*/
543 {0, {293, 325}, {135, 150}, {65, 72}},
544 {1, {585, 650}, {270, 300}, {130, 144}},
545 {2, {878, 975}, {405, 450}, {195, 217}},
546 {3, {1170, 1300}, {540, 600}, {260, 289}},
547 {4, {1755, 1950}, {810, 900}, {390, 433}},
548 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
549 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
550 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
551 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
552 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700553};
554#endif /* WLAN_FEATURE_11AC */
555
c_hpothu79aab322014-07-14 21:11:01 +0530556/*array index points to MCS and array value points respective rssi*/
557static int rssiMcsTbl[][10] =
558{
559/*MCS 0 1 2 3 4 5 6 7 8 9*/
560 {-82, -79, -77, -74, -70, -66, -65, -64, -59, -57}, //20
561 {-79, -76, -74, -71, -67, -63, -62, -61, -56, -54}, //40
562 {-76, -73, -71, -68, -64, -60, -59, -58, -53, -51} //80
563};
564
Jeff Johnson295189b2012-06-20 16:38:30 -0700565extern struct net_device_ops net_ops_struct;
Dasari Srinivas7875a302014-09-26 17:50:57 +0530566#ifdef FEATURE_WLAN_SCAN_PNO
567static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter);
568#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700569
Leo Chang9056f462013-08-01 19:21:11 -0700570#ifdef WLAN_NL80211_TESTMODE
571enum wlan_hdd_tm_attr
572{
573 WLAN_HDD_TM_ATTR_INVALID = 0,
574 WLAN_HDD_TM_ATTR_CMD = 1,
575 WLAN_HDD_TM_ATTR_DATA = 2,
576 WLAN_HDD_TM_ATTR_TYPE = 3,
577 /* keep last */
578 WLAN_HDD_TM_ATTR_AFTER_LAST,
579 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
580};
581
582enum wlan_hdd_tm_cmd
583{
584 WLAN_HDD_TM_CMD_WLAN_HB = 1,
585};
586
587#define WLAN_HDD_TM_DATA_MAX_LEN 5000
588
589static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
590{
591 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
592 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
593 .len = WLAN_HDD_TM_DATA_MAX_LEN },
594};
595#endif /* WLAN_NL80211_TESTMODE */
596
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800597#ifdef FEATURE_WLAN_CH_AVOID
598/*
599 * FUNCTION: wlan_hdd_send_avoid_freq_event
600 * This is called when wlan driver needs to send vendor specific
601 * avoid frequency range event to userspace
602 */
603int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
604 tHddAvoidFreqList *pAvoidFreqList)
605{
606 struct sk_buff *vendor_event;
607
608 ENTER();
609
610 if (!pHddCtx)
611 {
612 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
613 "%s: HDD context is null", __func__);
614 return -1;
615 }
616
617 if (!pAvoidFreqList)
618 {
619 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
620 "%s: pAvoidFreqList is null", __func__);
621 return -1;
622 }
623
624 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530625#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
626 NULL,
627#endif
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800628 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
Srinivas Dasari030bad32015-02-18 23:23:54 +0530648/*
649 * FUNCTION: __wlan_hdd_cfg80211_nan_request
650 * This is called when wlan driver needs to send vendor specific
651 * nan request event.
652 */
653static int __wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
654 struct wireless_dev *wdev,
655 const void *data, int data_len)
656{
657 tNanRequestReq nan_req;
658 VOS_STATUS status;
659 int ret_val = -1;
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530660 struct net_device *dev = wdev->netdev;
661 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
662 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530663 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
664
665 if (0 == data_len)
666 {
667 hddLog(VOS_TRACE_LEVEL_ERROR,
668 FL("NAN - Invalid Request, length = 0"));
669 return ret_val;
670 }
671
672 if (NULL == data)
673 {
674 hddLog(VOS_TRACE_LEVEL_ERROR,
675 FL("NAN - Invalid Request, data is NULL"));
676 return ret_val;
677 }
678
679 status = wlan_hdd_validate_context(pHddCtx);
680 if (0 != status)
681 {
682 hddLog(VOS_TRACE_LEVEL_ERROR,
683 FL("HDD context is not valid"));
684 return -EINVAL;
685 }
686
687 hddLog(LOG1, FL("Received NAN command"));
688 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
689 (tANI_U8 *)data, data_len);
690
691 /* check the NAN Capability */
692 if (TRUE != sme_IsFeatureSupportedByFW(NAN))
693 {
694 hddLog(VOS_TRACE_LEVEL_ERROR,
695 FL("NAN is not supported by Firmware"));
696 return -EINVAL;
697 }
698
699 nan_req.request_data_len = data_len;
700 nan_req.request_data = data;
701
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530702 status = sme_NanRequest(hHal, &nan_req, pAdapter->sessionId);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530703 if (VOS_STATUS_SUCCESS == status)
704 {
705 ret_val = 0;
706 }
707 return ret_val;
708}
709
710/*
711 * FUNCTION: wlan_hdd_cfg80211_nan_request
712 * Wrapper to protect the nan vendor command from ssr
713 */
714static int wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
715 struct wireless_dev *wdev,
716 const void *data, int data_len)
717{
718 int ret;
719
720 vos_ssr_protect(__func__);
721 ret = __wlan_hdd_cfg80211_nan_request(wiphy, wdev, data, data_len);
722 vos_ssr_unprotect(__func__);
723
724 return ret;
725}
726
727/*
728 * FUNCTION: wlan_hdd_cfg80211_nan_callback
729 * This is a callback function and it gets called
730 * when we need to report nan response event to
731 * upper layers.
732 */
733static void wlan_hdd_cfg80211_nan_callback(void* ctx, tSirNanEvent* msg)
734{
735 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
736 struct sk_buff *vendor_event;
737 int status;
738 tSirNanEvent *data;
739
740 ENTER();
741 if (NULL == msg)
742 {
743 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
744 FL(" msg received here is null"));
745 return;
746 }
747 data = msg;
748
749 status = wlan_hdd_validate_context(pHddCtx);
750
751 if (0 != status)
752 {
753 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
754 FL("HDD context is not valid"));
755 return;
756 }
757
758 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530759#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
760 NULL,
761#endif
Srinivas Dasari030bad32015-02-18 23:23:54 +0530762 data->event_data_len +
763 NLMSG_HDRLEN,
764 QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX,
765 GFP_KERNEL);
766
767 if (!vendor_event)
768 {
769 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
770 FL("cfg80211_vendor_event_alloc failed"));
771 return;
772 }
773 if (nla_put(vendor_event, QCA_WLAN_VENDOR_ATTR_NAN,
774 data->event_data_len, data->event_data))
775 {
776 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
777 FL("QCA_WLAN_VENDOR_ATTR_NAN put fail"));
778 kfree_skb(vendor_event);
779 return;
780 }
781 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
782 EXIT();
783}
784
785/*
786 * FUNCTION: wlan_hdd_cfg80211_nan_init
787 * This function is called to register the callback to sme layer
788 */
789inline void wlan_hdd_cfg80211_nan_init(hdd_context_t *pHddCtx)
790{
791 sme_NanRegisterCallback(pHddCtx->hHal, wlan_hdd_cfg80211_nan_callback);
792}
793
794
Sunil Duttc69bccb2014-05-26 21:30:20 +0530795#ifdef WLAN_FEATURE_LINK_LAYER_STATS
796
797static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
798 struct sk_buff *vendor_event)
799{
800 if (nla_put_u8(vendor_event,
801 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
802 stats->rate.preamble) ||
803 nla_put_u8(vendor_event,
804 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
805 stats->rate.nss) ||
806 nla_put_u8(vendor_event,
807 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
808 stats->rate.bw) ||
809 nla_put_u8(vendor_event,
810 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
811 stats->rate.rateMcsIdx) ||
812 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
813 stats->rate.bitrate ) ||
814 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
815 stats->txMpdu ) ||
816 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
817 stats->rxMpdu ) ||
818 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
819 stats->mpduLost ) ||
820 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
821 stats->retries) ||
822 nla_put_u32(vendor_event,
823 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
824 stats->retriesShort ) ||
825 nla_put_u32(vendor_event,
826 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
827 stats->retriesLong))
828 {
829 hddLog(VOS_TRACE_LEVEL_ERROR,
830 FL("QCA_WLAN_VENDOR_ATTR put fail"));
831 return FALSE;
832 }
833 return TRUE;
834}
835
836static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
837 struct sk_buff *vendor_event)
838{
839 u32 i = 0;
840 struct nlattr *rateInfo;
841 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
842 stats->type) ||
843 nla_put(vendor_event,
844 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
845 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
846 nla_put_u32(vendor_event,
847 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
848 stats->capabilities) ||
849 nla_put_u32(vendor_event,
850 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
851 stats->numRate))
852 {
853 hddLog(VOS_TRACE_LEVEL_ERROR,
854 FL("QCA_WLAN_VENDOR_ATTR put fail"));
855 goto error;
856 }
857
858 rateInfo = nla_nest_start(vendor_event,
859 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530860 if(!rateInfo)
861 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530862 for (i = 0; i < stats->numRate; i++)
863 {
864 struct nlattr *rates;
865 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
866 stats->rateStats +
867 (i * sizeof(tSirWifiRateStat)));
868 rates = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530869 if(!rates)
870 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530871
872 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
873 {
874 hddLog(VOS_TRACE_LEVEL_ERROR,
875 FL("QCA_WLAN_VENDOR_ATTR put fail"));
876 return FALSE;
877 }
878 nla_nest_end(vendor_event, rates);
879 }
880 nla_nest_end(vendor_event, rateInfo);
881
882 return TRUE;
883error:
884 return FALSE;
885}
886
887static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
888 struct sk_buff *vendor_event)
889{
890 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
891 stats->ac ) ||
892 nla_put_u32(vendor_event,
893 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
894 stats->txMpdu ) ||
895 nla_put_u32(vendor_event,
896 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
897 stats->rxMpdu ) ||
898 nla_put_u32(vendor_event,
899 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
900 stats->txMcast ) ||
901 nla_put_u32(vendor_event,
902 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
903 stats->rxMcast ) ||
904 nla_put_u32(vendor_event,
905 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
906 stats->rxAmpdu ) ||
907 nla_put_u32(vendor_event,
908 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
909 stats->txAmpdu ) ||
910 nla_put_u32(vendor_event,
911 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
912 stats->mpduLost )||
913 nla_put_u32(vendor_event,
914 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
915 stats->retries ) ||
916 nla_put_u32(vendor_event,
917 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
918 stats->retriesShort ) ||
919 nla_put_u32(vendor_event,
920 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
921 stats->retriesLong ) ||
922 nla_put_u32(vendor_event,
923 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
924 stats->contentionTimeMin ) ||
925 nla_put_u32(vendor_event,
926 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
927 stats->contentionTimeMax ) ||
928 nla_put_u32(vendor_event,
929 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
930 stats->contentionTimeAvg ) ||
931 nla_put_u32(vendor_event,
932 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
933 stats->contentionNumSamples ))
934 {
935 hddLog(VOS_TRACE_LEVEL_ERROR,
936 FL("QCA_WLAN_VENDOR_ATTR put fail") );
937 return FALSE;
938 }
939 return TRUE;
940}
941
942static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
943 struct sk_buff *vendor_event)
944{
Dino Myclec8f3f332014-07-21 16:48:27 +0530945 if (nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530946 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
947 nla_put(vendor_event,
948 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
949 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
950 nla_put_u32(vendor_event,
951 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
952 stats->state ) ||
953 nla_put_u32(vendor_event,
954 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
955 stats->roaming ) ||
956 nla_put_u32(vendor_event,
957 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
958 stats->capabilities ) ||
959 nla_put(vendor_event,
960 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
961 strlen(stats->ssid), stats->ssid) ||
962 nla_put(vendor_event,
963 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
964 WNI_CFG_BSSID_LEN, stats->bssid) ||
965 nla_put(vendor_event,
966 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
967 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
968 nla_put(vendor_event,
969 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
970 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
971 )
972 {
973 hddLog(VOS_TRACE_LEVEL_ERROR,
974 FL("QCA_WLAN_VENDOR_ATTR put fail") );
975 return FALSE;
976 }
977 return TRUE;
978}
979
Dino Mycle3b9536d2014-07-09 22:05:24 +0530980static v_BOOL_t put_wifi_iface_stats(hdd_adapter_t *pAdapter,
981 tpSirWifiIfaceStat pWifiIfaceStat,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530982 struct sk_buff *vendor_event)
983{
984 int i = 0;
985 struct nlattr *wmmInfo;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530986 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
987 WLANTL_InterfaceStatsType *pWifiIfaceStatTL = NULL;
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530988 tSirWifiWmmAcStat accessclassStats;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530989
Sunil Duttc69bccb2014-05-26 21:30:20 +0530990 if (FALSE == put_wifi_interface_info(
991 &pWifiIfaceStat->info,
992 vendor_event))
993 {
994 hddLog(VOS_TRACE_LEVEL_ERROR,
995 FL("QCA_WLAN_VENDOR_ATTR put fail") );
996 return FALSE;
997
998 }
Dino Mycle3b9536d2014-07-09 22:05:24 +0530999 pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *)
1000 vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType));
1001 if (NULL == pWifiIfaceStatTL)
1002 {
1003 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
1004 return FALSE;
1005 }
1006
Srinivas Dasaria8a304f2014-11-15 16:13:37 +05301007 accessclassStats = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK];
1008 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK] =
1009 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE];
1010 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE] = accessclassStats;
1011
1012 accessclassStats.ac = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac;
1013 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac =
1014 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac;
1015 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac = accessclassStats.ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301016
1017 if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED)
1018 {
1019 if (VOS_STATUS_SUCCESS ==
1020 WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1021 pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL))
1022 {
1023 /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are
1024 * obtained from TL structure
1025 */
1026
1027 pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx +
1028 pWifiIfaceStatTL->mgmtRx;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301029 pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData;
1030
Srinivas Dasari98947432014-11-07 19:41:24 +05301031 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMcast
1032 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMcast;
1033 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMcast
1034 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMcast;
1035 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMcast
1036 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMcast;
1037 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMcast
1038 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMcast;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301039
Srinivas Dasari98947432014-11-07 19:41:24 +05301040 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMpdu
1041 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMpdu;
1042 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMpdu
1043 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMpdu;
1044 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMpdu
1045 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMpdu;
1046 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMpdu
1047 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301048
Srinivas Dasari98947432014-11-07 19:41:24 +05301049 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxAmpdu
1050 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxAmpdu;
1051 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxAmpdu
1052 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxAmpdu;
1053 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxAmpdu
1054 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxAmpdu;
1055 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxAmpdu
1056 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxAmpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301057 }
1058 else
1059 {
1060 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL"));
1061 }
1062
Dino Mycle3b9536d2014-07-09 22:05:24 +05301063 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast =
1064 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO];
1065 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast =
1066 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI];
1067 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast =
1068 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE];
1069 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast =
1070 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK];
1071 }
1072 else
1073 {
1074 hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated"));
1075 }
1076
1077
Sunil Duttc69bccb2014-05-26 21:30:20 +05301078
1079 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301080 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1081 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_IFACE) ||
1082 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301083 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
1084 pWifiIfaceStat->beaconRx) ||
1085 nla_put_u32(vendor_event,
1086 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
1087 pWifiIfaceStat->mgmtRx) ||
1088 nla_put_u32(vendor_event,
1089 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
1090 pWifiIfaceStat->mgmtActionRx) ||
1091 nla_put_u32(vendor_event,
1092 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
1093 pWifiIfaceStat->mgmtActionTx) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301094 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301095 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
1096 pWifiIfaceStat->rssiMgmt) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301097 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301098 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
1099 pWifiIfaceStat->rssiData) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301100 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301101 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
1102 pWifiIfaceStat->rssiAck))
1103 {
1104 hddLog(VOS_TRACE_LEVEL_ERROR,
1105 FL("QCA_WLAN_VENDOR_ATTR put fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301106 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301107 return FALSE;
1108 }
1109
1110 wmmInfo = nla_nest_start(vendor_event,
1111 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301112 if(!wmmInfo)
1113 {
1114 vos_mem_free(pWifiIfaceStatTL);
1115 return FALSE;
1116 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301117 for (i = 0; i < WIFI_AC_MAX; i++)
1118 {
1119 struct nlattr *wmmStats;
1120 wmmStats = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301121 if(!wmmStats)
1122 {
1123 vos_mem_free(pWifiIfaceStatTL);
1124 return FALSE;
1125 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301126 if (FALSE == put_wifi_wmm_ac_stat(
1127 &pWifiIfaceStat->AccessclassStats[i],
1128 vendor_event))
1129 {
1130 hddLog(VOS_TRACE_LEVEL_ERROR,
1131 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301132 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301133 return FALSE;
1134 }
1135
1136 nla_nest_end(vendor_event, wmmStats);
1137 }
1138 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +05301139 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301140 return TRUE;
1141}
1142
1143static tSirWifiInterfaceMode
1144 hdd_map_device_to_ll_iface_mode ( int deviceMode )
1145{
1146 switch (deviceMode)
1147 {
1148 case WLAN_HDD_INFRA_STATION:
1149 return WIFI_INTERFACE_STA;
1150 case WLAN_HDD_SOFTAP:
1151 return WIFI_INTERFACE_SOFTAP;
1152 case WLAN_HDD_P2P_CLIENT:
1153 return WIFI_INTERFACE_P2P_CLIENT;
1154 case WLAN_HDD_P2P_GO:
1155 return WIFI_INTERFACE_P2P_GO;
1156 case WLAN_HDD_IBSS:
1157 return WIFI_INTERFACE_IBSS;
1158 default:
Dino Myclec8f3f332014-07-21 16:48:27 +05301159 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301160 }
1161}
1162
1163static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
1164 tpSirWifiInterfaceInfo pInfo)
1165{
1166 v_U8_t *staMac = NULL;
1167 hdd_station_ctx_t *pHddStaCtx;
1168 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1169 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1170
1171 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
1172
1173 vos_mem_copy(pInfo->macAddr,
1174 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1175
1176 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1177 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
1178 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
1179 {
1180 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1181 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
1182 {
1183 pInfo->state = WIFI_DISCONNECTED;
1184 }
1185 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
1186 {
1187 hddLog(VOS_TRACE_LEVEL_ERROR,
1188 "%s: Session ID %d, Connection is in progress", __func__,
1189 pAdapter->sessionId);
1190 pInfo->state = WIFI_ASSOCIATING;
1191 }
1192 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1193 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
1194 {
1195 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
1196 hddLog(VOS_TRACE_LEVEL_ERROR,
1197 "%s: client " MAC_ADDRESS_STR
1198 " is in the middle of WPS/EAPOL exchange.", __func__,
1199 MAC_ADDR_ARRAY(staMac));
1200 pInfo->state = WIFI_AUTHENTICATING;
1201 }
1202 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1203 {
1204 pInfo->state = WIFI_ASSOCIATED;
1205 vos_mem_copy(pInfo->bssid,
1206 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
1207 vos_mem_copy(pInfo->ssid,
1208 pHddStaCtx->conn_info.SSID.SSID.ssId,
1209 pHddStaCtx->conn_info.SSID.SSID.length);
1210 //NULL Terminate the string.
1211 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
1212 }
1213 }
1214 vos_mem_copy(pInfo->countryStr,
1215 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1216
1217 vos_mem_copy(pInfo->apCountryStr,
1218 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1219
1220 return TRUE;
1221}
1222
1223/*
1224 * hdd_link_layer_process_peer_stats () - This function is called after
1225 * receiving Link Layer Peer statistics from FW.This function converts
1226 * the firmware data to the NL data and sends the same to the kernel/upper
1227 * layers.
1228 */
1229static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
1230 v_VOID_t *pData)
1231{
1232 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301233 tpSirWifiPeerStat pWifiPeerStat;
1234 tpSirWifiPeerInfo pWifiPeerInfo;
1235 struct nlattr *peerInfo;
1236 struct sk_buff *vendor_event;
1237 int status, i;
1238
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301239 ENTER();
1240
Sunil Duttc69bccb2014-05-26 21:30:20 +05301241 status = wlan_hdd_validate_context(pHddCtx);
1242 if (0 != status)
1243 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301244 return;
1245 }
1246
1247 pWifiPeerStat = (tpSirWifiPeerStat) pData;
1248
1249 hddLog(VOS_TRACE_LEVEL_INFO,
1250 "LL_STATS_PEER_ALL : numPeers %u",
1251 pWifiPeerStat->numPeers);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301252 /*
1253 * Allocate a size of 4096 for the peer stats comprising
1254 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1255 * sizeof (tSirWifiRateStat).Each field is put with an
1256 * NL attribute.The size of 4096 is considered assuming
1257 * that number of rates shall not exceed beyond 50 with
1258 * the sizeof (tSirWifiRateStat) being 32.
1259 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301260 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1261 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301262 if (!vendor_event)
1263 {
1264 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301265 "%s: cfg80211_vendor_cmd_alloc_reply_skb failed",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301266 __func__);
1267 return;
1268 }
1269 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301270 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1271 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_PEER) ||
1272 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301273 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1274 pWifiPeerStat->numPeers))
1275 {
1276 hddLog(VOS_TRACE_LEVEL_ERROR,
1277 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1278 kfree_skb(vendor_event);
1279 return;
1280 }
1281
1282 peerInfo = nla_nest_start(vendor_event,
1283 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301284 if(!peerInfo)
1285 {
1286 hddLog(VOS_TRACE_LEVEL_ERROR,
1287 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO put fail",
1288 __func__);
1289 kfree_skb(vendor_event);
1290 return;
1291 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301292
1293 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1294 pWifiPeerStat->peerInfo);
1295
1296 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1297 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301298 int numRate = pWifiPeerInfo->numRate;
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301299 struct nlattr *peers = nla_nest_start(vendor_event, i);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301300
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301301 if(!peers)
1302 {
1303 hddLog(VOS_TRACE_LEVEL_ERROR,
1304 "%s: peer stats put fail",
1305 __func__);
1306 kfree_skb(vendor_event);
1307 return;
1308 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301309 if (FALSE == put_wifi_peer_info(
1310 pWifiPeerInfo, vendor_event))
1311 {
1312 hddLog(VOS_TRACE_LEVEL_ERROR,
1313 "%s: put_wifi_peer_info put fail", __func__);
1314 kfree_skb(vendor_event);
1315 return;
1316 }
1317
1318 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1319 pWifiPeerStat->peerInfo +
1320 (i * sizeof(tSirWifiPeerInfo)) +
1321 (numRate * sizeof (tSirWifiRateStat)));
1322 nla_nest_end(vendor_event, peers);
1323 }
1324 nla_nest_end(vendor_event, peerInfo);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301325 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301326 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301327}
1328
1329/*
1330 * hdd_link_layer_process_iface_stats () - This function is called after
1331 * receiving Link Layer Interface statistics from FW.This function converts
1332 * the firmware data to the NL data and sends the same to the kernel/upper
1333 * layers.
1334 */
1335static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1336 v_VOID_t *pData)
1337{
1338 tpSirWifiIfaceStat pWifiIfaceStat;
1339 struct sk_buff *vendor_event;
1340 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1341 int status;
1342
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301343 ENTER();
1344
Sunil Duttc69bccb2014-05-26 21:30:20 +05301345 status = wlan_hdd_validate_context(pHddCtx);
1346 if (0 != status)
1347 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301348 return;
1349 }
1350 /*
1351 * Allocate a size of 4096 for the interface stats comprising
1352 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1353 * assuming that all these fit with in the limit.Please take
1354 * a call on the limit based on the data requirements on
1355 * interface statistics.
1356 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301357 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1358 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301359 if (!vendor_event)
1360 {
1361 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301362 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05301363 return;
1364 }
1365
1366 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1367
Dino Mycle3b9536d2014-07-09 22:05:24 +05301368
1369 if (FALSE == hdd_get_interface_info( pAdapter,
1370 &pWifiIfaceStat->info))
1371 {
1372 hddLog(VOS_TRACE_LEVEL_ERROR,
1373 FL("hdd_get_interface_info get fail") );
1374 kfree_skb(vendor_event);
1375 return;
1376 }
1377
1378 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
1379 vendor_event))
1380 {
1381 hddLog(VOS_TRACE_LEVEL_ERROR,
1382 FL("put_wifi_iface_stats fail") );
1383 kfree_skb(vendor_event);
1384 return;
1385 }
1386
Sunil Duttc69bccb2014-05-26 21:30:20 +05301387 hddLog(VOS_TRACE_LEVEL_INFO,
1388 "WMI_LINK_STATS_IFACE Data");
1389
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301390 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301391
1392 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301393}
1394
1395/*
1396 * hdd_link_layer_process_radio_stats () - This function is called after
1397 * receiving Link Layer Radio statistics from FW.This function converts
1398 * the firmware data to the NL data and sends the same to the kernel/upper
1399 * layers.
1400 */
1401static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1402 v_VOID_t *pData)
1403{
1404 int status, i;
1405 tpSirWifiRadioStat pWifiRadioStat;
1406 tpSirWifiChannelStats pWifiChannelStats;
1407 struct sk_buff *vendor_event;
1408 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1409 struct nlattr *chList;
1410
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301411 ENTER();
1412
Sunil Duttc69bccb2014-05-26 21:30:20 +05301413 status = wlan_hdd_validate_context(pHddCtx);
1414 if (0 != status)
1415 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301416 return;
1417 }
1418 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1419
1420 hddLog(VOS_TRACE_LEVEL_INFO,
1421 "LL_STATS_RADIO"
1422 " radio is %d onTime is %u "
1423 " txTime is %u rxTime is %u "
1424 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05301425 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05301426 " onTimePnoScan is %u onTimeHs20 is %u "
1427 " numChannels is %u",
1428 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1429 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1430 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301431 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301432 pWifiRadioStat->onTimeRoamScan,
1433 pWifiRadioStat->onTimePnoScan,
1434 pWifiRadioStat->onTimeHs20,
1435 pWifiRadioStat->numChannels);
1436 /*
1437 * Allocate a size of 4096 for the Radio stats comprising
1438 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1439 * (tSirWifiChannelStats).Each channel data is put with an
1440 * NL attribute.The size of 4096 is considered assuming that
1441 * number of channels shall not exceed beyond 60 with the
1442 * sizeof (tSirWifiChannelStats) being 24 bytes.
1443 */
1444
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301445 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1446 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301447 if (!vendor_event)
1448 {
1449 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301450 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05301451 return;
1452 }
1453
1454 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301455 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1456 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_RADIO) ||
1457 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301458 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1459 pWifiRadioStat->radio) ||
1460 nla_put_u32(vendor_event,
1461 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1462 pWifiRadioStat->onTime) ||
1463 nla_put_u32(vendor_event,
1464 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1465 pWifiRadioStat->txTime) ||
1466 nla_put_u32(vendor_event,
1467 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1468 pWifiRadioStat->rxTime) ||
1469 nla_put_u32(vendor_event,
1470 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1471 pWifiRadioStat->onTimeScan) ||
1472 nla_put_u32(vendor_event,
1473 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1474 pWifiRadioStat->onTimeNbd) ||
1475 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301476 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
1477 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05301478 nla_put_u32(vendor_event,
1479 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1480 pWifiRadioStat->onTimeRoamScan) ||
1481 nla_put_u32(vendor_event,
1482 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1483 pWifiRadioStat->onTimePnoScan) ||
1484 nla_put_u32(vendor_event,
1485 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1486 pWifiRadioStat->onTimeHs20) ||
1487 nla_put_u32(vendor_event,
1488 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1489 pWifiRadioStat->numChannels))
1490 {
1491 hddLog(VOS_TRACE_LEVEL_ERROR,
1492 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1493 kfree_skb(vendor_event);
1494 return ;
1495 }
1496
1497 chList = nla_nest_start(vendor_event,
1498 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301499 if(!chList)
1500 {
1501 hddLog(VOS_TRACE_LEVEL_ERROR,
1502 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO put fail",
1503 __func__);
1504 kfree_skb(vendor_event);
1505 return;
1506 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301507 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1508 {
1509 struct nlattr *chInfo;
1510
1511 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1512 pWifiRadioStat->channels +
1513 (i * sizeof(tSirWifiChannelStats)));
1514
Sunil Duttc69bccb2014-05-26 21:30:20 +05301515 chInfo = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301516 if(!chInfo)
1517 {
1518 hddLog(VOS_TRACE_LEVEL_ERROR,
1519 "%s: failed to put chInfo",
1520 __func__);
1521 kfree_skb(vendor_event);
1522 return;
1523 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301524
1525 if (nla_put_u32(vendor_event,
1526 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1527 pWifiChannelStats->channel.width) ||
1528 nla_put_u32(vendor_event,
1529 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1530 pWifiChannelStats->channel.centerFreq) ||
1531 nla_put_u32(vendor_event,
1532 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1533 pWifiChannelStats->channel.centerFreq0) ||
1534 nla_put_u32(vendor_event,
1535 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1536 pWifiChannelStats->channel.centerFreq1) ||
1537 nla_put_u32(vendor_event,
1538 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1539 pWifiChannelStats->onTime) ||
1540 nla_put_u32(vendor_event,
1541 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1542 pWifiChannelStats->ccaBusyTime))
1543 {
1544 hddLog(VOS_TRACE_LEVEL_ERROR,
1545 FL("cfg80211_vendor_event_alloc failed") );
1546 kfree_skb(vendor_event);
1547 return ;
1548 }
1549 nla_nest_end(vendor_event, chInfo);
1550 }
1551 nla_nest_end(vendor_event, chList);
1552
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301553 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301554
1555 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301556 return;
1557}
1558
1559/*
1560 * hdd_link_layer_stats_ind_callback () - This function is called after
1561 * receiving Link Layer indications from FW.This callback converts the firmware
1562 * data to the NL data and send the same to the kernel/upper layers.
1563 */
1564static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1565 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05301566 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301567{
Dino Mycled3d50022014-07-07 12:58:25 +05301568 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
1569 hdd_adapter_t *pAdapter = NULL;
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301570 struct hdd_ll_stats_context *context;
Dino Mycled3d50022014-07-07 12:58:25 +05301571 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301572 int status;
1573
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301574 ENTER();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301575
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301576 status = wlan_hdd_validate_context(pHddCtx);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301577 if (0 != status)
1578 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301579 return;
1580 }
1581
Dino Mycled3d50022014-07-07 12:58:25 +05301582 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
1583 if (NULL == pAdapter)
1584 {
1585 hddLog(VOS_TRACE_LEVEL_ERROR,
1586 FL(" MAC address %pM does not exist with host"),
1587 macAddr);
1588 return;
1589 }
1590
Sunil Duttc69bccb2014-05-26 21:30:20 +05301591 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301592 "%s: Interface: %s LLStats indType: %d", __func__,
1593 pAdapter->dev->name, indType);
1594
Sunil Duttc69bccb2014-05-26 21:30:20 +05301595 switch (indType)
1596 {
1597 case SIR_HAL_LL_STATS_RESULTS_RSP:
1598 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301599 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05301600 "LL_STATS RESP paramID = 0x%x, ifaceId = %u MAC: %pM "
1601 "respId = %u, moreResultToFollow = %u",
1602 linkLayerStatsResults->paramId, linkLayerStatsResults->ifaceId,
1603 macAddr, linkLayerStatsResults->respId,
1604 linkLayerStatsResults->moreResultToFollow);
1605
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301606 spin_lock(&hdd_context_lock);
1607 context = &pHddCtx->ll_stats_context;
1608 /* validate response received from target */
1609 if ((context->request_id != linkLayerStatsResults->respId) ||
1610 !(context->request_bitmap & linkLayerStatsResults->paramId))
1611 {
1612 spin_unlock(&hdd_context_lock);
1613 hddLog(LOGE,
1614 FL("Error : Request id %d response id %d request bitmap 0x%x"
1615 "response bitmap 0x%x"),
1616 context->request_id, linkLayerStatsResults->respId,
1617 context->request_bitmap, linkLayerStatsResults->paramId);
1618 return;
1619 }
1620 spin_unlock(&hdd_context_lock);
1621
Sunil Duttc69bccb2014-05-26 21:30:20 +05301622 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1623 {
1624 hdd_link_layer_process_radio_stats(pAdapter,
1625 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301626 spin_lock(&hdd_context_lock);
1627 context->request_bitmap &= ~(WMI_LINK_STATS_RADIO);
1628 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301629 }
1630 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1631 {
1632 hdd_link_layer_process_iface_stats(pAdapter,
1633 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301634 spin_lock(&hdd_context_lock);
1635 context->request_bitmap &= ~(WMI_LINK_STATS_IFACE);
1636 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301637 }
1638 else if ( linkLayerStatsResults->paramId &
1639 WMI_LINK_STATS_ALL_PEER )
1640 {
1641 hdd_link_layer_process_peer_stats(pAdapter,
1642 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301643 spin_lock(&hdd_context_lock);
1644 context->request_bitmap &= ~(WMI_LINK_STATS_ALL_PEER);
1645 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301646 } /* WMI_LINK_STATS_ALL_PEER */
1647 else
1648 {
1649 hddLog(VOS_TRACE_LEVEL_ERROR,
1650 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1651 }
1652
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301653 spin_lock(&hdd_context_lock);
1654 /* complete response event if all requests are completed */
1655 if (0 == context->request_bitmap)
1656 complete(&context->response_event);
1657 spin_unlock(&hdd_context_lock);
1658
Sunil Duttc69bccb2014-05-26 21:30:20 +05301659 break;
1660 }
1661 default:
1662 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1663 break;
1664 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301665
1666 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301667 return;
1668}
1669
1670const struct
1671nla_policy
1672qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1673{
1674 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1675 { .type = NLA_U32 },
1676 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1677 { .type = NLA_U32 },
1678};
1679
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301680static int __wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1681 struct wireless_dev *wdev,
1682 const void *data,
1683 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301684{
1685 int status;
1686 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301687 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301688 struct net_device *dev = wdev->netdev;
1689 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1690 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1691
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301692 ENTER();
1693
Sunil Duttc69bccb2014-05-26 21:30:20 +05301694 status = wlan_hdd_validate_context(pHddCtx);
1695 if (0 != status)
1696 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301697 return -EINVAL;
1698 }
1699
1700 if (NULL == pAdapter)
1701 {
1702 hddLog(VOS_TRACE_LEVEL_ERROR,
1703 FL("HDD adapter is Null"));
1704 return -ENODEV;
1705 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301706 /* check the LLStats Capability */
1707 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1708 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1709 {
1710 hddLog(VOS_TRACE_LEVEL_ERROR,
1711 FL("Link Layer Statistics not supported by Firmware"));
1712 return -EINVAL;
1713 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301714
1715 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1716 (struct nlattr *)data,
1717 data_len, qca_wlan_vendor_ll_set_policy))
1718 {
1719 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1720 return -EINVAL;
1721 }
1722 if (!tb_vendor
1723 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1724 {
1725 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1726 return -EINVAL;
1727 }
1728 if (!tb_vendor[
1729 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1730 {
1731 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1732 return -EINVAL;
1733 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301734 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301735 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301736
Dino Mycledf0a5d92014-07-04 09:41:55 +05301737 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301738 nla_get_u32(
1739 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1740
Dino Mycledf0a5d92014-07-04 09:41:55 +05301741 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301742 nla_get_u32(
1743 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1744
Dino Mycled3d50022014-07-07 12:58:25 +05301745 vos_mem_copy(linkLayerStatsSetReq.macAddr,
1746 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301747
1748
1749 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05301750 "LL_STATS_SET reqId = %d, MAC = %pM, mpduSizeThreshold = %d "
1751 "Statistics Gathering = %d ",
1752 linkLayerStatsSetReq.reqId, linkLayerStatsSetReq.macAddr,
1753 linkLayerStatsSetReq.mpduSizeThreshold,
1754 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301755
1756 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1757 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05301758 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301759 {
1760 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1761 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301762 return -EINVAL;
1763
1764 }
Srinivas Dasari98947432014-11-07 19:41:24 +05301765
Sunil Duttc69bccb2014-05-26 21:30:20 +05301766 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301767 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301768 {
1769 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1770 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301771 return -EINVAL;
1772 }
1773
1774 pAdapter->isLinkLayerStatsSet = 1;
1775
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301776 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301777 return 0;
1778}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301779static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1780 struct wireless_dev *wdev,
1781 const void *data,
1782 int data_len)
1783{
1784 int ret = 0;
1785
1786 vos_ssr_protect(__func__);
1787 ret = __wlan_hdd_cfg80211_ll_stats_set(wiphy, wdev, data, data_len);
1788 vos_ssr_unprotect(__func__);
1789
1790 return ret;
1791}
Sunil Duttc69bccb2014-05-26 21:30:20 +05301792
1793const struct
1794nla_policy
1795qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1796{
1797 /* Unsigned 32bit value provided by the caller issuing the GET stats
1798 * command. When reporting
1799 * the stats results, the driver uses the same value to indicate
1800 * which GET request the results
1801 * correspond to.
1802 */
1803 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1804
1805 /* Unsigned 32bit value . bit mask to identify what statistics are
1806 requested for retrieval */
1807 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1808};
1809
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301810static int __wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1811 struct wireless_dev *wdev,
1812 const void *data,
1813 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301814{
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301815 unsigned long rc;
1816 struct hdd_ll_stats_context *context;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301817 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1818 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301819 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301820 struct net_device *dev = wdev->netdev;
1821 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mukul Sharma10313ba2015-07-29 19:14:39 +05301822 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301823 int status;
1824
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301825 ENTER();
1826
Sunil Duttc69bccb2014-05-26 21:30:20 +05301827 status = wlan_hdd_validate_context(pHddCtx);
1828 if (0 != status)
1829 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301830 return -EINVAL ;
1831 }
1832
1833 if (NULL == pAdapter)
1834 {
1835 hddLog(VOS_TRACE_LEVEL_FATAL,
1836 "%s: HDD adapter is Null", __func__);
1837 return -ENODEV;
1838 }
Mukul Sharma10313ba2015-07-29 19:14:39 +05301839
1840 if (pHddStaCtx == NULL)
1841 {
1842 hddLog(VOS_TRACE_LEVEL_FATAL,
1843 "%s: HddStaCtx is Null", __func__);
1844 return -ENODEV;
1845 }
1846
Dino Mycledf0a5d92014-07-04 09:41:55 +05301847 /* check the LLStats Capability */
1848 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1849 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1850 {
1851 hddLog(VOS_TRACE_LEVEL_ERROR,
1852 FL("Link Layer Statistics not supported by Firmware"));
1853 return -EINVAL;
1854 }
1855
Sunil Duttc69bccb2014-05-26 21:30:20 +05301856
1857 if (!pAdapter->isLinkLayerStatsSet)
1858 {
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05301859 hddLog(VOS_TRACE_LEVEL_ERROR,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301860 "%s: isLinkLayerStatsSet : %d",
1861 __func__, pAdapter->isLinkLayerStatsSet);
1862 return -EINVAL;
1863 }
1864
Mukul Sharma10313ba2015-07-29 19:14:39 +05301865 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1866 {
1867 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1868 "%s: Roaming in progress, so unable to proceed this request", __func__);
1869 return -EBUSY;
1870 }
1871
Sunil Duttc69bccb2014-05-26 21:30:20 +05301872 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
1873 (struct nlattr *)data,
1874 data_len, qca_wlan_vendor_ll_get_policy))
1875 {
1876 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1877 return -EINVAL;
1878 }
1879
1880 if (!tb_vendor
1881 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
1882 {
1883 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
1884 return -EINVAL;
1885 }
1886
1887 if (!tb_vendor
1888 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
1889 {
1890 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
1891 return -EINVAL;
1892 }
1893
Sunil Duttc69bccb2014-05-26 21:30:20 +05301894
Dino Mycledf0a5d92014-07-04 09:41:55 +05301895 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301896 nla_get_u32( tb_vendor[
1897 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05301898 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301899 nla_get_u32( tb_vendor[
1900 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
1901
Dino Mycled3d50022014-07-07 12:58:25 +05301902 vos_mem_copy(linkLayerStatsGetReq.macAddr,
1903 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301904
1905 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05301906 "LL_STATS_GET reqId = %d, MAC = %pM, paramIdMask = %d",
1907 linkLayerStatsGetReq.reqId, linkLayerStatsGetReq.macAddr,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301908 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301909
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301910 spin_lock(&hdd_context_lock);
1911 context = &pHddCtx->ll_stats_context;
1912 context->request_id = linkLayerStatsGetReq.reqId;
1913 context->request_bitmap = linkLayerStatsGetReq.paramIdMask;
1914 INIT_COMPLETION(context->response_event);
1915 spin_unlock(&hdd_context_lock);
1916
Sunil Duttc69bccb2014-05-26 21:30:20 +05301917 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301918 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301919 {
1920 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1921 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301922 return -EINVAL;
1923 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301924
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301925 rc = wait_for_completion_timeout(&context->response_event,
1926 msecs_to_jiffies(WLAN_WAIT_TIME_LL_STATS));
1927 if (!rc)
1928 {
1929 hddLog(LOGE,
1930 FL("Target response timed out request id %d request bitmap 0x%x"),
1931 context->request_id, context->request_bitmap);
1932 return -ETIMEDOUT;
1933 }
1934
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301935 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301936 return 0;
1937}
1938
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301939static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1940 struct wireless_dev *wdev,
1941 const void *data,
1942 int data_len)
1943{
1944 int ret = 0;
1945
1946 vos_ssr_protect(__func__);
1947 ret = __wlan_hdd_cfg80211_ll_stats_get(wiphy, wdev, data, data_len);
1948 vos_ssr_unprotect(__func__);
1949
1950 return ret;
1951}
1952
Sunil Duttc69bccb2014-05-26 21:30:20 +05301953const struct
1954nla_policy
1955qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
1956{
1957 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
1958 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
1959 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
1960 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
1961};
1962
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301963static int __wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
1964 struct wireless_dev *wdev,
1965 const void *data,
1966 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301967{
1968 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1969 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301970 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301971 struct net_device *dev = wdev->netdev;
1972 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1973 u32 statsClearReqMask;
1974 u8 stopReq;
1975 int status;
1976
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301977 ENTER();
1978
Sunil Duttc69bccb2014-05-26 21:30:20 +05301979 status = wlan_hdd_validate_context(pHddCtx);
1980 if (0 != status)
1981 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301982 return -EINVAL;
1983 }
1984
1985 if (NULL == pAdapter)
1986 {
1987 hddLog(VOS_TRACE_LEVEL_FATAL,
1988 "%s: HDD adapter is Null", __func__);
1989 return -ENODEV;
1990 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301991 /* check the LLStats Capability */
1992 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1993 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1994 {
1995 hddLog(VOS_TRACE_LEVEL_ERROR,
1996 FL("Enable LLStats Capability"));
1997 return -EINVAL;
1998 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301999
2000 if (!pAdapter->isLinkLayerStatsSet)
2001 {
2002 hddLog(VOS_TRACE_LEVEL_FATAL,
2003 "%s: isLinkLayerStatsSet : %d",
2004 __func__, pAdapter->isLinkLayerStatsSet);
2005 return -EINVAL;
2006 }
2007
2008 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
2009 (struct nlattr *)data,
2010 data_len, qca_wlan_vendor_ll_clr_policy))
2011 {
2012 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2013 return -EINVAL;
2014 }
2015
2016 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
2017
2018 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
2019 {
2020 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
2021 return -EINVAL;
2022
2023 }
2024
Sunil Duttc69bccb2014-05-26 21:30:20 +05302025
Dino Mycledf0a5d92014-07-04 09:41:55 +05302026 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302027 nla_get_u32(
2028 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
2029
Dino Mycledf0a5d92014-07-04 09:41:55 +05302030 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302031 nla_get_u8(
2032 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
2033
2034 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05302035 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302036
Dino Mycled3d50022014-07-07 12:58:25 +05302037 vos_mem_copy(linkLayerStatsClearReq.macAddr,
2038 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302039
2040 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05302041 "LL_STATS_CLEAR reqId = %d, MAC = %pM,"
2042 "statsClearReqMask = 0x%X, stopReq = %d",
2043 linkLayerStatsClearReq.reqId,
2044 linkLayerStatsClearReq.macAddr,
2045 linkLayerStatsClearReq.statsClearReqMask,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302046 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302047
2048 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302049 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302050 {
2051 struct sk_buff *temp_skbuff;
Srinivas Dasari98947432014-11-07 19:41:24 +05302052 hdd_station_ctx_t *pHddStaCtx;
2053
2054 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2055 if (VOS_STATUS_SUCCESS !=
2056 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2057 pHddStaCtx->conn_info.staId[0], statsClearReqMask))
2058 {
2059 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2060 "WLANTL_ClearInterfaceStats Failed", __func__);
2061 return -EINVAL;
2062 }
2063 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
2064 (statsClearReqMask & WIFI_STATS_IFACE)) {
2065 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
2066 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
2067 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
2068 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
2069 }
2070
Sunil Duttc69bccb2014-05-26 21:30:20 +05302071 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
2072 2 * sizeof(u32) +
2073 NLMSG_HDRLEN);
2074
2075 if (temp_skbuff != NULL)
2076 {
2077
2078 if (nla_put_u32(temp_skbuff,
2079 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
2080 statsClearReqMask) ||
2081 nla_put_u32(temp_skbuff,
2082 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
2083 stopReq))
2084 {
2085 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
2086 kfree_skb(temp_skbuff);
2087 return -EINVAL;
2088 }
2089 /* If the ask is to stop the stats collection as part of clear
2090 * (stopReq = 1) , ensure that no further requests of get
2091 * go to the firmware by having isLinkLayerStatsSet set to 0.
2092 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302093 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05302094 * case the firmware is just asked to clear the statistics.
2095 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05302096 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302097 pAdapter->isLinkLayerStatsSet = 0;
2098 return cfg80211_vendor_cmd_reply(temp_skbuff);
2099 }
2100 return -ENOMEM;
2101 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302102
2103 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302104 return -EINVAL;
2105}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302106static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2107 struct wireless_dev *wdev,
2108 const void *data,
2109 int data_len)
2110{
2111 int ret = 0;
2112
2113 vos_ssr_protect(__func__);
2114 ret = __wlan_hdd_cfg80211_ll_stats_clear(wiphy, wdev, data, data_len);
2115 vos_ssr_unprotect(__func__);
2116
2117 return ret;
2118
2119
2120}
Sunil Duttc69bccb2014-05-26 21:30:20 +05302121#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2122
Dino Mycle6fb96c12014-06-10 11:52:40 +05302123#ifdef WLAN_FEATURE_EXTSCAN
2124static const struct nla_policy
2125wlan_hdd_extscan_config_policy
2126 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
2127{
2128 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
2129 { .type = NLA_U32 },
2130 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
2131 { .type = NLA_U32 },
2132 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
2133 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
2134 { .type = NLA_U32 },
2135 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
2136 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
2137
2138 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
2139 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
2140 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
2141 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
2142 { .type = NLA_U8 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302143 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD] =
2144 { .type = NLA_U32 },
2145 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT] =
2146 { .type = NLA_U32 },
2147 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT] =
2148 { .type = NLA_U32 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05302149 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
2150 { .type = NLA_U32 },
2151 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
2152 { .type = NLA_U32 },
2153 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
2154 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302155 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT] =
2156 { .type = NLA_U8 },
2157 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS] =
Dino Mycle6fb96c12014-06-10 11:52:40 +05302158 { .type = NLA_U8 },
2159 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
2160 { .type = NLA_U8 },
2161 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
2162 { .type = NLA_U8 },
2163
2164 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
2165 { .type = NLA_U32 },
2166 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] =
2167 { .type = NLA_UNSPEC },
2168 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
2169 { .type = NLA_S32 },
2170 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
2171 { .type = NLA_S32 },
2172 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
2173 { .type = NLA_U32 },
2174 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
2175 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302176 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE] =
2177 { .type = NLA_U32 },
2178 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_SSID] =
2179 { .type = NLA_BINARY,
2180 .len = IEEE80211_MAX_SSID_LEN + 1 },
2181 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_LOST_SSID_SAMPLE_SIZE] =
Dino Mycle6fb96c12014-06-10 11:52:40 +05302182 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302183 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID] =
2184 { .type = NLA_U32 },
2185 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_BAND] =
2186 { .type = NLA_U8 },
2187 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_LOW] =
2188 { .type = NLA_S32 },
2189 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_HIGH] =
2190 { .type = NLA_S32 },
2191 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CONFIGURATION_FLAGS] =
2192 { .type = NLA_U32 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05302193};
2194
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302195/**
2196 * wlan_hdd_cfg80211_extscan_get_capabilities_rsp() - response from target
2197 * @ctx: hdd global context
2198 * @data: capabilities data
2199 *
2200 * Return: none
2201 */
2202static void
2203wlan_hdd_cfg80211_extscan_get_capabilities_rsp(void *ctx, void *pMsg)
Dino Mycle6fb96c12014-06-10 11:52:40 +05302204{
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302205 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302206 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302207 tSirEXTScanCapabilitiesEvent *data =
2208 (tSirEXTScanCapabilitiesEvent *) pMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302209
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302210 ENTER();
2211
2212 if (wlan_hdd_validate_context(pHddCtx))
2213 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302214 return;
2215 }
2216
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302217 if (!pMsg)
2218 {
2219 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2220 return;
2221 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302222
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302223 vos_spin_lock_acquire(&hdd_context_lock);
2224
2225 context = &pHddCtx->ext_scan_context;
2226 /* validate response received from target*/
2227 if (context->request_id != data->requestId)
2228 {
2229 vos_spin_lock_release(&hdd_context_lock);
2230 hddLog(LOGE,
2231 FL("Target response id did not match: request_id %d resposne_id %d"),
2232 context->request_id, data->requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302233 return;
2234 }
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302235 else
2236 {
2237 context->capability_response = *data;
2238 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302239 }
2240
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302241 vos_spin_lock_release(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302242
Dino Mycle6fb96c12014-06-10 11:52:40 +05302243 return;
2244}
2245
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302246/*
2247 * define short names for the global vendor params
2248 * used by wlan_hdd_send_ext_scan_capability()
2249 */
2250#define PARAM_REQUEST_ID \
2251 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
2252#define PARAM_STATUS \
2253 QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS
2254#define MAX_SCAN_CACHE_SIZE \
2255 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE
2256#define MAX_SCAN_BUCKETS \
2257 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS
2258#define MAX_AP_CACHE_PER_SCAN \
2259 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN
2260#define MAX_RSSI_SAMPLE_SIZE \
2261 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE
2262#define MAX_SCAN_RPT_THRHOLD \
2263 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD
2264#define MAX_HOTLIST_BSSIDS \
2265 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_BSSIDS
2266#define MAX_BSSID_HISTORY_ENTRIES \
2267 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES
2268#define MAX_HOTLIST_SSIDS \
2269 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_SSIDS
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302270#define MAX_SIGNIFICANT_WIFI_CHANGE_APS \
2271 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302272
2273static int wlan_hdd_send_ext_scan_capability(void *ctx)
2274{
2275 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2276 struct sk_buff *skb = NULL;
2277 int ret;
2278 tSirEXTScanCapabilitiesEvent *data;
2279 tANI_U32 nl_buf_len;
2280
2281 ret = wlan_hdd_validate_context(pHddCtx);
2282 if (0 != ret)
2283 {
2284 return ret;
2285 }
2286
2287 data = &(pHddCtx->ext_scan_context.capability_response);
2288
2289 nl_buf_len = NLMSG_HDRLEN;
2290 nl_buf_len += (sizeof(data->requestId) + NLA_HDRLEN) +
2291 (sizeof(data->status) + NLA_HDRLEN) +
2292 (sizeof(data->scanCacheSize) + NLA_HDRLEN) +
2293 (sizeof(data->scanBuckets) + NLA_HDRLEN) +
2294 (sizeof(data->maxApPerScan) + NLA_HDRLEN) +
2295 (sizeof(data->maxRssiSampleSize) + NLA_HDRLEN) +
2296 (sizeof(data->maxScanReportingThreshold) + NLA_HDRLEN) +
2297 (sizeof(data->maxHotlistAPs) + NLA_HDRLEN) +
2298 (sizeof(data->maxBsidHistoryEntries) + NLA_HDRLEN) +
2299 (sizeof(data->maxHotlistSSIDs) + NLA_HDRLEN);
2300
2301 skb = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy, nl_buf_len);
2302
2303 if (!skb)
2304 {
2305 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
2306 return -ENOMEM;
2307 }
2308
2309 hddLog(LOG1, "Req Id (%u) Status (%u)", data->requestId, data->status);
2310 hddLog(LOG1, "Scan cache size (%u) Scan buckets (%u) Max AP per scan (%u)",
2311 data->scanCacheSize, data->scanBuckets, data->maxApPerScan);
2312 hddLog(LOG1, "max_rssi_sample_size (%u) max_scan_reporting_threshold (%u)",
2313 data->maxRssiSampleSize, data->maxScanReportingThreshold);
2314 hddLog(LOG1, "max_hotlist_bssids (%u) max_bssid_history_entries (%u)"
2315 "max_hotlist_ssids (%u)", data->maxHotlistAPs,
2316 data->maxBsidHistoryEntries, data->maxHotlistSSIDs);
2317
2318 if (nla_put_u32(skb, PARAM_REQUEST_ID, data->requestId) ||
2319 nla_put_u32(skb, PARAM_STATUS, data->status) ||
2320 nla_put_u32(skb, MAX_SCAN_CACHE_SIZE, data->scanCacheSize) ||
2321 nla_put_u32(skb, MAX_SCAN_BUCKETS, data->scanBuckets) ||
2322 nla_put_u32(skb, MAX_AP_CACHE_PER_SCAN,
2323 data->maxApPerScan) ||
2324 nla_put_u32(skb, MAX_RSSI_SAMPLE_SIZE,
2325 data->maxRssiSampleSize) ||
2326 nla_put_u32(skb, MAX_SCAN_RPT_THRHOLD,
2327 data->maxScanReportingThreshold) ||
2328 nla_put_u32(skb, MAX_HOTLIST_BSSIDS, data->maxHotlistAPs) ||
2329 nla_put_u32(skb, MAX_BSSID_HISTORY_ENTRIES,
2330 data->maxBsidHistoryEntries) ||
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302331 nla_put_u32(skb, MAX_HOTLIST_SSIDS, data->maxHotlistSSIDs) ||
2332 nla_put_u32(skb, MAX_SIGNIFICANT_WIFI_CHANGE_APS, 0))
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302333 {
2334 hddLog(LOGE, FL("nla put fail"));
2335 goto nla_put_failure;
2336 }
2337
2338 cfg80211_vendor_cmd_reply(skb);
2339 return 0;
2340
2341nla_put_failure:
2342 kfree_skb(skb);
2343 return -EINVAL;;
2344}
2345
2346/*
2347 * done with short names for the global vendor params
2348 * used by wlan_hdd_send_ext_scan_capability()
2349 */
2350#undef PARAM_REQUEST_ID
2351#undef PARAM_STATUS
2352#undef MAX_SCAN_CACHE_SIZE
2353#undef MAX_SCAN_BUCKETS
2354#undef MAX_AP_CACHE_PER_SCAN
2355#undef MAX_RSSI_SAMPLE_SIZE
2356#undef MAX_SCAN_RPT_THRHOLD
2357#undef MAX_HOTLIST_BSSIDS
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302358#undef MAX_BSSID_HISTORY_ENTRIES
2359#undef MAX_HOTLIST_SSIDS
Dino Mycle6fb96c12014-06-10 11:52:40 +05302360
2361static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg)
2362{
2363 tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg;
2364 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302365 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302366 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302367
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302368 ENTER();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302369
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302370 if (wlan_hdd_validate_context(pHddCtx))
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302371 return;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302372
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302373 if (!pMsg)
2374 {
2375 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302376 return;
2377 }
2378
Dino Mycle6fb96c12014-06-10 11:52:40 +05302379 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2380 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2381
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302382 context = &pHddCtx->ext_scan_context;
2383 spin_lock(&hdd_context_lock);
2384 if (context->request_id == pData->requestId) {
2385 context->response_status = pData->status ? -EINVAL : 0;
2386 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302387 }
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302388 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302389
2390 /*
2391 * Store the Request ID for comparing with the requestID obtained
2392 * in other requests.HDD shall return a failure is the extscan_stop
2393 * request is issued with a different requestId as that of the
2394 * extscan_start request. Also, This requestId shall be used while
2395 * indicating the full scan results to the upper layers.
2396 * The requestId is stored with the assumption that the firmware
2397 * shall return the ext scan start request's requestId in ext scan
2398 * start response.
2399 */
2400 if (pData->status == 0)
2401 pMac->sme.extScanStartReqId = pData->requestId;
2402
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302403 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302404 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302405}
2406
2407
2408static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
2409{
2410 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
2411 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302412 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302413
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302414 ENTER();
2415
2416 if (wlan_hdd_validate_context(pHddCtx)){
2417 return;
2418 }
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302419
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302420 if (!pMsg)
2421 {
2422 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302423 return;
2424 }
2425
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302426 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2427 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302428
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302429 context = &pHddCtx->ext_scan_context;
2430 spin_lock(&hdd_context_lock);
2431 if (context->request_id == pData->requestId) {
2432 context->response_status = pData->status ? -EINVAL : 0;
2433 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302434 }
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302435 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302436
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302437 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302438 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302439}
2440
Dino Mycle6fb96c12014-06-10 11:52:40 +05302441static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
2442 void *pMsg)
2443{
2444 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302445 tpSirEXTScanSetBssidHotListRspParams pData =
2446 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302447 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302448
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302449 ENTER();
2450
2451 if (wlan_hdd_validate_context(pHddCtx)){
Dino Mycle6fb96c12014-06-10 11:52:40 +05302452 return;
2453 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302454
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302455 if (!pMsg)
2456 {
2457 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2458 return;
2459 }
2460
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302461 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2462 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302463
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302464 context = &pHddCtx->ext_scan_context;
2465 spin_lock(&hdd_context_lock);
2466 if (context->request_id == pData->requestId) {
2467 context->response_status = pData->status ? -EINVAL : 0;
2468 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302469 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302470 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302471
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302472 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302473 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302474}
2475
2476static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
2477 void *pMsg)
2478{
2479 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302480 tpSirEXTScanResetBssidHotlistRspParams pData =
2481 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05302482 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302483
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302484 ENTER();
2485
2486 if (wlan_hdd_validate_context(pHddCtx)) {
2487 return;
2488 }
2489 if (!pMsg)
2490 {
2491 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302492 return;
2493 }
2494
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05302495 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2496 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302497
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05302498 context = &pHddCtx->ext_scan_context;
2499 spin_lock(&hdd_context_lock);
2500 if (context->request_id == pData->requestId) {
2501 context->response_status = pData->status ? -EINVAL : 0;
2502 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302503 }
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05302504 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302505
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302506 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302507 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302508}
2509
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05302510static void wlan_hdd_cfg80211_extscan_set_ssid_hotlist_rsp(void *ctx,
2511 void *pMsg)
2512{
2513 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2514 tpSirEXTScanSetSsidHotListRspParams pData =
2515 (tpSirEXTScanSetSsidHotListRspParams) pMsg;
2516 struct hdd_ext_scan_context *context;
2517
2518 if (wlan_hdd_validate_context(pHddCtx)){
2519 return;
2520 }
2521
2522 if (!pMsg)
2523 {
2524 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2525 return;
2526 }
2527
2528 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2529 pData->status);
2530
2531 context = &pHddCtx->ext_scan_context;
2532 spin_lock(&hdd_context_lock);
2533 if (context->request_id == pData->requestId) {
2534 context->response_status = pData->status ? -EINVAL : 0;
2535 complete(&context->response_event);
2536 }
2537 spin_unlock(&hdd_context_lock);
2538
2539 return;
2540}
2541
2542static void wlan_hdd_cfg80211_extscan_reset_ssid_hotlist_rsp(void *ctx,
2543 void *pMsg)
2544{
2545 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2546 tpSirEXTScanResetSsidHotlistRspParams pData =
2547 (tpSirEXTScanResetSsidHotlistRspParams) pMsg;
2548 struct hdd_ext_scan_context *context;
2549
2550 if (wlan_hdd_validate_context(pHddCtx)) {
2551 return;
2552 }
2553 if (!pMsg)
2554 {
2555 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2556 return;
2557 }
2558
2559 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2560 pData->status);
2561
2562 context = &pHddCtx->ext_scan_context;
2563 spin_lock(&hdd_context_lock);
2564 if (context->request_id == pData->requestId) {
2565 context->response_status = pData->status ? -EINVAL : 0;
2566 complete(&context->response_event);
2567 }
2568 spin_unlock(&hdd_context_lock);
2569
2570 return;
2571}
2572
2573
Dino Mycle6fb96c12014-06-10 11:52:40 +05302574static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
2575 void *pMsg)
2576{
2577 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2578 struct sk_buff *skb = NULL;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302579 tANI_U32 i = 0, j, resultsPerEvent, scan_id_index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302580 tANI_S32 totalResults;
2581 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302582 tpSirWifiScanResult pSirWifiScanResult, head_ptr;
2583 struct hdd_ext_scan_context *context;
2584 bool ignore_cached_results = false;
2585 tExtscanCachedScanResult *result;
2586 struct nlattr *nla_results;
2587 tANI_U16 ieLength= 0;
2588 tANI_U8 *ie = NULL;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302589
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302590 ENTER();
2591
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302592 if (wlan_hdd_validate_context(pHddCtx))
Dino Mycle6fb96c12014-06-10 11:52:40 +05302593 return;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302594
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302595 if (!pMsg)
2596 {
2597 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2598 return;
2599 }
2600
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302601 spin_lock(&hdd_context_lock);
2602 context = &pHddCtx->ext_scan_context;
2603 ignore_cached_results = context->ignore_cached_results;
2604 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302605
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302606 if (ignore_cached_results) {
2607 hddLog(LOGE,
2608 FL("Ignore the cached results received after timeout"));
2609 return;
2610 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302611
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302612 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u More Data %u No of scan ids %u",
2613 pData->requestId, pData->moreData, pData->scanResultSize);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302614
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302615 result = (tExtscanCachedScanResult *)&(pData->result);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302616
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302617 for (scan_id_index = 0; scan_id_index < pData->scanResultSize;
2618 scan_id_index++) {
2619 result+= scan_id_index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302620
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302621 totalResults = result->num_results;
2622 hddLog(VOS_TRACE_LEVEL_INFO, "scan_id %u flags %u Num results %u",
2623 result->scan_id, result->flags, totalResults);
2624 i = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302625
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302626 do{
2627 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
2628 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
2629 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302630
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302631 skb = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
2632 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN);
2633
2634 if (!skb) {
2635 hddLog(VOS_TRACE_LEVEL_ERROR,
2636 FL("cfg80211_vendor_event_alloc failed"));
2637 return;
2638 }
2639
2640 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
2641
2642 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2643 pData->requestId) ||
2644 nla_put_u32(skb,
2645 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2646 resultsPerEvent)) {
2647 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2648 goto fail;
2649 }
2650 if (nla_put_u8(skb,
2651 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2652 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
Dino Mycle6fb96c12014-06-10 11:52:40 +05302653 {
2654 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2655 goto fail;
2656 }
2657
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302658 if (nla_put_u32(skb,
2659 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_SCAN_ID,
2660 result->scan_id)) {
2661 hddLog(LOGE, FL("put fail"));
2662 goto fail;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302663 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302664
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302665 nla_results = nla_nest_start(skb,
2666 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_LIST);
2667 if (!nla_results)
2668 goto fail;
2669
2670 if (resultsPerEvent) {
2671 struct nlattr *aps;
2672 struct nlattr *nla_result;
2673
2674 nla_result = nla_nest_start(skb, scan_id_index);
2675 if(!nla_result)
2676 goto fail;
2677
2678 if (nla_put_u32(skb,
2679 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_SCAN_ID,
2680 result->scan_id) ||
2681 nla_put_u32(skb,
2682 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_FLAGS,
2683 result->flags) ||
2684 nla_put_u32(skb,
2685 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2686 totalResults)) {
2687 hddLog(LOGE, FL("put fail"));
2688 goto fail;
2689 }
2690
2691 aps = nla_nest_start(skb,
2692 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2693 if (!aps)
2694 {
2695 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2696 goto fail;
2697 }
2698
2699 head_ptr = (tpSirWifiScanResult) &(result->ap);
2700
2701 for (j = 0; j < resultsPerEvent; j++, i++) {
2702 struct nlattr *ap;
2703 pSirWifiScanResult = head_ptr + i;
2704
2705 /*
2706 * Firmware returns timestamp from WiFi turn ON till
2707 * BSSID was cached (in seconds). Add this with
2708 * time gap between system boot up to WiFi turn ON
2709 * to derive the time since boot when the
2710 * BSSID was cached.
2711 */
2712 pSirWifiScanResult->ts += pHddCtx->wifi_turn_on_time_since_boot;
2713 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
2714 "Ssid (%s)"
2715 "Bssid: %pM "
2716 "Channel (%u)"
2717 "Rssi (%d)"
2718 "RTT (%u)"
2719 "RTT_SD (%u)"
2720 "Beacon Period %u"
2721 "Capability 0x%x "
2722 "Ie length %d",
2723 i,
2724 pSirWifiScanResult->ts,
2725 pSirWifiScanResult->ssid,
2726 pSirWifiScanResult->bssid,
2727 pSirWifiScanResult->channel,
2728 pSirWifiScanResult->rssi,
2729 pSirWifiScanResult->rtt,
2730 pSirWifiScanResult->rtt_sd,
2731 pSirWifiScanResult->beaconPeriod,
2732 pSirWifiScanResult->capability,
2733 ieLength);
2734
2735 ap = nla_nest_start(skb, j + 1);
2736 if (!ap)
2737 {
2738 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2739 goto fail;
2740 }
2741
2742 if (nla_put_u64(skb,
2743 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2744 pSirWifiScanResult->ts) )
2745 {
2746 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2747 goto fail;
2748 }
2749 if (nla_put(skb,
2750 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2751 sizeof(pSirWifiScanResult->ssid),
2752 pSirWifiScanResult->ssid) )
2753 {
2754 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2755 goto fail;
2756 }
2757 if (nla_put(skb,
2758 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2759 sizeof(pSirWifiScanResult->bssid),
2760 pSirWifiScanResult->bssid) )
2761 {
2762 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2763 goto fail;
2764 }
2765 if (nla_put_u32(skb,
2766 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2767 pSirWifiScanResult->channel) )
2768 {
2769 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2770 goto fail;
2771 }
2772 if (nla_put_s32(skb,
2773 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2774 pSirWifiScanResult->rssi) )
2775 {
2776 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2777 goto fail;
2778 }
2779 if (nla_put_u32(skb,
2780 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2781 pSirWifiScanResult->rtt) )
2782 {
2783 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2784 goto fail;
2785 }
2786 if (nla_put_u32(skb,
2787 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2788 pSirWifiScanResult->rtt_sd))
2789 {
2790 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2791 goto fail;
2792 }
2793 if (nla_put_u32(skb,
2794 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
2795 pSirWifiScanResult->beaconPeriod))
2796 {
2797 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2798 goto fail;
2799 }
2800 if (nla_put_u32(skb,
2801 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
2802 pSirWifiScanResult->capability))
2803 {
2804 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2805 goto fail;
2806 }
2807 if (nla_put_u32(skb,
2808 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
2809 ieLength))
2810 {
2811 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2812 goto fail;
2813 }
2814
2815 if (ieLength)
2816 if (nla_put(skb,
2817 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
2818 ieLength, ie)) {
2819 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2820 goto fail;
2821 }
2822
2823 nla_nest_end(skb, ap);
2824 }
2825 nla_nest_end(skb, aps);
2826 nla_nest_end(skb, nla_result);
2827 }
2828
2829 nla_nest_end(skb, nla_results);
2830
2831 cfg80211_vendor_cmd_reply(skb);
2832
2833 } while (totalResults > 0);
2834 }
2835
2836 if (!pData->moreData) {
2837 spin_lock(&hdd_context_lock);
2838 context->response_status = 0;
2839 complete(&context->response_event);
2840 spin_unlock(&hdd_context_lock);
2841 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302842
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302843 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302844 return;
2845fail:
2846 kfree_skb(skb);
2847 return;
2848}
2849
2850static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
2851 void *pMsg)
2852{
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302853 tpSirEXTScanHotlistMatch pData = (tpSirEXTScanHotlistMatch) pMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302854 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2855 struct sk_buff *skb = NULL;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302856 tANI_U32 i, index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302857
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302858 ENTER();
2859
2860 if (wlan_hdd_validate_context(pHddCtx)) {
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302861 hddLog(LOGE,
2862 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302863 return;
2864 }
2865 if (!pMsg)
2866 {
2867 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302868 return;
2869 }
2870
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302871 if (pData->bss_found)
2872 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX;
2873 else
2874 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX;
2875
Dino Mycle6fb96c12014-06-10 11:52:40 +05302876 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302877#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2878 NULL,
2879#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302880 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302881 index, GFP_KERNEL);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302882
2883 if (!skb) {
2884 hddLog(VOS_TRACE_LEVEL_ERROR,
2885 FL("cfg80211_vendor_event_alloc failed"));
2886 return;
2887 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302888
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302889 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2890 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numHotlistBss);
2891 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2892 hddLog(VOS_TRACE_LEVEL_INFO, "ap_found %u", pData->bss_found);
2893
2894 for (i = 0; i < pData->numHotlistBss; i++) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302895 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
2896 "Ssid (%s) "
2897 "Bssid (" MAC_ADDRESS_STR ") "
2898 "Channel (%u) "
2899 "Rssi (%d) "
2900 "RTT (%u) "
2901 "RTT_SD (%u) ",
2902 i,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302903 pData->bssHotlist[i].ts,
2904 pData->bssHotlist[i].ssid,
2905 MAC_ADDR_ARRAY(pData->bssHotlist[i].bssid),
2906 pData->bssHotlist[i].channel,
2907 pData->bssHotlist[i].rssi,
2908 pData->bssHotlist[i].rtt,
2909 pData->bssHotlist[i].rtt_sd);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302910 }
2911
2912 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2913 pData->requestId) ||
2914 nla_put_u32(skb,
2915 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302916 pData->numHotlistBss)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302917 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2918 goto fail;
2919 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302920 if (pData->numHotlistBss) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302921 struct nlattr *aps;
2922
2923 aps = nla_nest_start(skb,
2924 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2925 if (!aps)
2926 goto fail;
2927
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302928 for (i = 0; i < pData->numHotlistBss; i++) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302929 struct nlattr *ap;
2930
2931 ap = nla_nest_start(skb, i + 1);
2932 if (!ap)
2933 goto fail;
2934
2935 if (nla_put_u64(skb,
2936 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302937 pData->bssHotlist[i].ts) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302938 nla_put(skb,
2939 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302940 sizeof(pData->bssHotlist[i].ssid),
2941 pData->bssHotlist[i].ssid) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302942 nla_put(skb,
2943 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302944 sizeof(pData->bssHotlist[i].bssid),
2945 pData->bssHotlist[i].bssid) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302946 nla_put_u32(skb,
2947 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302948 pData->bssHotlist[i].channel) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302949 nla_put_s32(skb,
2950 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302951 pData->bssHotlist[i].rssi) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302952 nla_put_u32(skb,
2953 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302954 pData->bssHotlist[i].rtt) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302955 nla_put_u32(skb,
2956 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302957 pData->bssHotlist[i].rtt_sd))
Dino Mycle6fb96c12014-06-10 11:52:40 +05302958 goto fail;
2959
2960 nla_nest_end(skb, ap);
2961 }
2962 nla_nest_end(skb, aps);
2963
2964 if (nla_put_u8(skb,
2965 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2966 pData->moreData))
2967 goto fail;
2968 }
2969
2970 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302971 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302972 return;
2973
2974fail:
2975 kfree_skb(skb);
2976 return;
2977
2978}
Dino Mycle6fb96c12014-06-10 11:52:40 +05302979
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05302980/**
2981 * wlan_hdd_cfg80211_extscan_hotlist_ssid_match_ind() -
2982 * Handle an SSID hotlist match event
2983 * @ctx: HDD context registered with SME
2984 * @event: The SSID hotlist match event
2985 *
2986 * This function will take an SSID match event that was generated by
2987 * firmware and will convert it into a cfg80211 vendor event which is
2988 * sent to userspace.
2989 *
2990 * Return: none
2991 */
2992static void
2993wlan_hdd_cfg80211_extscan_hotlist_ssid_match_ind(void *ctx,
2994 void *pMsg)
2995{
2996 hdd_context_t *hdd_ctx = ctx;
2997 struct sk_buff *skb;
2998 tANI_U32 i, index;
2999 tpSirEXTScanSsidHotlistMatch pData = (tpSirEXTScanSsidHotlistMatch) pMsg;
3000
3001 ENTER();
3002
3003 if (wlan_hdd_validate_context(hdd_ctx)) {
3004 hddLog(LOGE,
3005 FL("HDD context is not valid or response"));
3006 return;
3007 }
3008 if (!pMsg)
3009 {
3010 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
3011 return;
3012 }
3013
3014 if (pData->ssid_found) {
3015 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND_INDEX;
3016 hddLog(LOG1, "SSID hotlist found");
3017 } else {
3018 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST_INDEX;
3019 hddLog(LOG1, "SSID hotlist lost");
3020 }
3021
3022 skb = cfg80211_vendor_event_alloc(hdd_ctx->wiphy,
3023#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3024 NULL,
3025#endif
3026 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3027 index, GFP_KERNEL);
3028
3029 if (!skb) {
3030 hddLog(LOGE, FL("cfg80211_vendor_event_alloc failed"));
3031 return;
3032 }
3033 hddLog(LOG1, "Req Id %u, Num of SSIDs %u, More Data (%u)",
3034 pData->requestId, pData->numHotlistSsid, pData->moreData);
3035
3036 for (i = 0; i < pData->numHotlistSsid; i++) {
3037 hddLog(LOG1, "[i=%d] Timestamp %llu "
3038 "Ssid: %s "
3039 "Bssid (" MAC_ADDRESS_STR ") "
3040 "Channel %u "
3041 "Rssi %d "
3042 "RTT %u "
3043 "RTT_SD %u",
3044 i,
3045 pData->ssidHotlist[i].ts,
3046 pData->ssidHotlist[i].ssid,
3047 MAC_ADDR_ARRAY(pData->ssidHotlist[i].bssid),
3048 pData->ssidHotlist[i].channel,
3049 pData->ssidHotlist[i].rssi,
3050 pData->ssidHotlist[i].rtt,
3051 pData->ssidHotlist[i].rtt_sd);
3052 }
3053
3054 if (nla_put_u32(skb,
3055 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3056 pData->requestId) ||
3057 nla_put_u32(skb,
3058 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3059 pData->numHotlistSsid)) {
3060 hddLog(LOGE, FL("put fail"));
3061 goto fail;
3062 }
3063
3064 if (pData->numHotlistSsid) {
3065 struct nlattr *aps;
3066 aps = nla_nest_start(skb,
3067 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3068 if (!aps) {
3069 hddLog(LOGE, FL("nest fail"));
3070 goto fail;
3071 }
3072
3073 for (i = 0; i < pData->numHotlistSsid; i++) {
3074 struct nlattr *ap;
3075
3076 ap = nla_nest_start(skb, i);
3077 if (!ap) {
3078 hddLog(LOGE, FL("nest fail"));
3079 goto fail;
3080 }
3081
3082 if (nla_put_u64(skb,
3083 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3084 pData->ssidHotlist[i].ts) ||
3085 nla_put(skb,
3086 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3087 sizeof(pData->ssidHotlist[i].ssid),
3088 pData->ssidHotlist[i].ssid) ||
3089 nla_put(skb,
3090 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3091 sizeof(pData->ssidHotlist[i].bssid),
3092 pData->ssidHotlist[i].bssid) ||
3093 nla_put_u32(skb,
3094 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3095 pData->ssidHotlist[i].channel) ||
3096 nla_put_s32(skb,
3097 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
3098 pData->ssidHotlist[i].rssi) ||
3099 nla_put_u32(skb,
3100 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3101 pData->ssidHotlist[i].rtt) ||
3102 nla_put_u32(skb,
3103 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3104 pData->ssidHotlist[i].rtt_sd)) {
3105 hddLog(LOGE, FL("put fail"));
3106 goto fail;
3107 }
3108 nla_nest_end(skb, ap);
3109 }
3110 nla_nest_end(skb, aps);
3111
3112 if (nla_put_u8(skb,
3113 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3114 pData->moreData)) {
3115 hddLog(LOGE, FL("put fail"));
3116 goto fail;
3117 }
3118 }
3119
3120 cfg80211_vendor_event(skb, GFP_KERNEL);
3121 return;
3122
3123fail:
3124 kfree_skb(skb);
3125 return;
3126
3127}
3128
3129
Dino Mycle6fb96c12014-06-10 11:52:40 +05303130static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
3131 void *pMsg)
3132{
3133 struct sk_buff *skb;
3134 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3135 tpSirWifiFullScanResultEvent pData =
3136 (tpSirWifiFullScanResultEvent) (pMsg);
3137
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303138 ENTER();
3139
3140 if (wlan_hdd_validate_context(pHddCtx)) {
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303141 hddLog(LOGE,
3142 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303143 return;
3144 }
3145 if (!pMsg)
3146 {
3147 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303148 return;
3149 }
3150
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303151 /*
3152 * If the full scan result including IE data exceeds NL 4K size
3153 * limitation, drop that beacon/probe rsp frame.
3154 */
3155 if ((sizeof(*pData) + pData->ieLength) >= EXTSCAN_EVENT_BUF_SIZE) {
3156 hddLog(LOGE, FL("Frame exceeded NL size limilation, drop it!"));
3157 return;
3158 }
3159
Dino Mycle6fb96c12014-06-10 11:52:40 +05303160 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303161#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3162 NULL,
3163#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303164 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3165 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
3166 GFP_KERNEL);
3167
3168 if (!skb) {
3169 hddLog(VOS_TRACE_LEVEL_ERROR,
3170 FL("cfg80211_vendor_event_alloc failed"));
3171 return;
3172 }
3173
Dino Mycle6fb96c12014-06-10 11:52:40 +05303174 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
3175 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
3176 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
3177 "Ssid (%s)"
3178 "Bssid (" MAC_ADDRESS_STR ")"
3179 "Channel (%u)"
3180 "Rssi (%d)"
3181 "RTT (%u)"
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303182 "RTT_SD (%u)"
3183 "Bcn Period %d"
3184 "Capability 0x%X "),
Dino Mycle6fb96c12014-06-10 11:52:40 +05303185 pData->ap.ts,
3186 pData->ap.ssid,
3187 MAC_ADDR_ARRAY(pData->ap.bssid),
3188 pData->ap.channel,
3189 pData->ap.rssi,
3190 pData->ap.rtt,
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303191 pData->ap.rtt_sd,
3192 pData->ap.beaconPeriod,
3193 pData->ap.capability);
3194
Dino Mycle6fb96c12014-06-10 11:52:40 +05303195 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
3196 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3197 pData->requestId) ||
3198 nla_put_u64(skb,
3199 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3200 pData->ap.ts) ||
3201 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3202 sizeof(pData->ap.ssid),
3203 pData->ap.ssid) ||
3204 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3205 WNI_CFG_BSSID_LEN,
3206 pData->ap.bssid) ||
3207 nla_put_u32(skb,
3208 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3209 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05303210 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303211 pData->ap.rssi) ||
3212 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3213 pData->ap.rtt) ||
3214 nla_put_u32(skb,
3215 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3216 pData->ap.rtt_sd) ||
3217 nla_put_u16(skb,
3218 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
3219 pData->ap.beaconPeriod) ||
3220 nla_put_u16(skb,
3221 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
3222 pData->ap.capability) ||
3223 nla_put_u32(skb,
3224 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303225 pData->ieLength) ||
3226 nla_put_u8(skb,
3227 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3228 pData->moreData))
Dino Mycle6fb96c12014-06-10 11:52:40 +05303229 {
3230 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3231 goto nla_put_failure;
3232 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303233
3234 if (pData->ieLength) {
3235 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
3236 pData->ieLength,
3237 pData->ie))
3238 {
3239 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3240 goto nla_put_failure;
3241 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303242 }
3243
3244 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303245 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303246 return;
3247
3248nla_put_failure:
3249 kfree_skb(skb);
3250 return;
3251}
3252
3253static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
3254 void *pMsg)
3255{
3256 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3257 struct sk_buff *skb = NULL;
3258 tpSirEXTScanResultsAvailableIndParams pData =
3259 (tpSirEXTScanResultsAvailableIndParams) pMsg;
3260
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303261 ENTER();
3262
3263 if (wlan_hdd_validate_context(pHddCtx)){
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303264 hddLog(LOGE,
3265 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303266 return;
3267 }
3268 if (!pMsg)
3269 {
3270 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303271 return;
3272 }
3273
3274 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303275#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3276 NULL,
3277#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303278 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3279 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
3280 GFP_KERNEL);
3281
3282 if (!skb) {
3283 hddLog(VOS_TRACE_LEVEL_ERROR,
3284 FL("cfg80211_vendor_event_alloc failed"));
3285 return;
3286 }
3287
Dino Mycle6fb96c12014-06-10 11:52:40 +05303288 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3289 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
3290 pData->numResultsAvailable);
3291 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3292 pData->requestId) ||
3293 nla_put_u32(skb,
3294 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3295 pData->numResultsAvailable)) {
3296 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3297 goto nla_put_failure;
3298 }
3299
3300 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303301 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303302 return;
3303
3304nla_put_failure:
3305 kfree_skb(skb);
3306 return;
3307}
3308
3309static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
3310{
3311 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3312 struct sk_buff *skb = NULL;
3313 tpSirEXTScanProgressIndParams pData =
3314 (tpSirEXTScanProgressIndParams) pMsg;
3315
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303316 ENTER();
3317
3318 if (wlan_hdd_validate_context(pHddCtx)){
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303319 hddLog(LOGE,
3320 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303321 return;
3322 }
3323 if (!pMsg)
3324 {
3325 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303326 return;
3327 }
3328
3329 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303330#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3331 NULL,
3332#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303333 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3334 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
3335 GFP_KERNEL);
3336
3337 if (!skb) {
3338 hddLog(VOS_TRACE_LEVEL_ERROR,
3339 FL("cfg80211_vendor_event_alloc failed"));
3340 return;
3341 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303342 hddLog(VOS_TRACE_LEVEL_INFO, FL("Request Id (%u) "), pData->requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303343 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
3344 pData->extScanEventType);
3345 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
3346 pData->status);
3347
3348 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
3349 pData->extScanEventType) ||
3350 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05303351 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3352 pData->requestId) ||
3353 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303354 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
3355 pData->status)) {
3356 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3357 goto nla_put_failure;
3358 }
3359
3360 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303361 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303362 return;
3363
3364nla_put_failure:
3365 kfree_skb(skb);
3366 return;
3367}
3368
3369void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
3370 void *pMsg)
3371{
3372 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3373
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303374 ENTER();
3375
Dino Mycle6fb96c12014-06-10 11:52:40 +05303376 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303377 return;
3378 }
3379
3380 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
3381
3382
3383 switch(evType) {
3384 case SIR_HAL_EXTSCAN_START_RSP:
3385 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
3386 break;
3387
3388 case SIR_HAL_EXTSCAN_STOP_RSP:
3389 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
3390 break;
3391 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
3392 /* There is no need to send this response to upper layer
3393 Just log the message */
3394 hddLog(VOS_TRACE_LEVEL_INFO,
3395 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
3396 break;
3397 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
3398 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
3399 break;
3400
3401 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
3402 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
3403 break;
3404
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303405 case SIR_HAL_EXTSCAN_SET_SSID_HOTLIST_RSP:
3406 wlan_hdd_cfg80211_extscan_set_ssid_hotlist_rsp(ctx, pMsg);
3407 break;
3408
3409 case SIR_HAL_EXTSCAN_RESET_SSID_HOTLIST_RSP:
3410 wlan_hdd_cfg80211_extscan_reset_ssid_hotlist_rsp(ctx, pMsg);
3411 break;
3412
Dino Mycle6fb96c12014-06-10 11:52:40 +05303413 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303414 wlan_hdd_cfg80211_extscan_get_capabilities_rsp(ctx, pMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303415 break;
3416 case SIR_HAL_EXTSCAN_PROGRESS_IND:
3417 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
3418 break;
3419 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
3420 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
3421 break;
3422 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
3423 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
3424 break;
3425 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
3426 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
3427 break;
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303428 case SIR_HAL_EXTSCAN_SSID_HOTLIST_MATCH_IND:
3429 wlan_hdd_cfg80211_extscan_hotlist_ssid_match_ind(ctx, pMsg);
3430 break;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303431 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
3432 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
3433 break;
3434 default:
3435 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
3436 break;
3437 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303438 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303439}
3440
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303441static int __wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3442 struct wireless_dev *wdev,
3443 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303444{
Dino Myclee8843b32014-07-04 14:21:45 +05303445 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303446 struct net_device *dev = wdev->netdev;
3447 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3448 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3449 struct nlattr
3450 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3451 eHalStatus status;
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303452 struct hdd_ext_scan_context *context;
3453 unsigned long rc;
3454 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303455
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303456 ENTER();
3457
Dino Mycle6fb96c12014-06-10 11:52:40 +05303458 status = wlan_hdd_validate_context(pHddCtx);
3459 if (0 != status)
3460 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303461 return -EINVAL;
3462 }
Dino Myclee8843b32014-07-04 14:21:45 +05303463 /* check the EXTScan Capability */
3464 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303465 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3466 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05303467 {
3468 hddLog(VOS_TRACE_LEVEL_ERROR,
3469 FL("EXTScan not enabled/supported by Firmware"));
3470 return -EINVAL;
3471 }
3472
Dino Mycle6fb96c12014-06-10 11:52:40 +05303473 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3474 data, dataLen,
3475 wlan_hdd_extscan_config_policy)) {
3476 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3477 return -EINVAL;
3478 }
3479
3480 /* Parse and fetch request Id */
3481 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3482 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3483 return -EINVAL;
3484 }
3485
Dino Myclee8843b32014-07-04 14:21:45 +05303486 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303487 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303488 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303489
Dino Myclee8843b32014-07-04 14:21:45 +05303490 reqMsg.sessionId = pAdapter->sessionId;
3491 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303492
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303493 vos_spin_lock_acquire(&hdd_context_lock);
3494 context = &pHddCtx->ext_scan_context;
3495 context->request_id = reqMsg.requestId;
3496 INIT_COMPLETION(context->response_event);
3497 vos_spin_lock_release(&hdd_context_lock);
3498
Dino Myclee8843b32014-07-04 14:21:45 +05303499 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303500 if (!HAL_STATUS_SUCCESS(status)) {
3501 hddLog(VOS_TRACE_LEVEL_ERROR,
3502 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303503 return -EINVAL;
3504 }
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303505
3506 rc = wait_for_completion_timeout(&context->response_event,
3507 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3508 if (!rc) {
3509 hddLog(LOGE, FL("Target response timed out"));
3510 return -ETIMEDOUT;
3511 }
3512
3513 ret = wlan_hdd_send_ext_scan_capability(pHddCtx);
3514 if (ret)
3515 hddLog(LOGE, FL("Failed to send ext scan capability to user space"));
3516
3517 return ret;
3518
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303519 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303520 return 0;
3521}
3522
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303523static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3524 struct wireless_dev *wdev,
3525 const void *data, int dataLen)
3526{
3527 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303528
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303529 vos_ssr_protect(__func__);
3530 ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen);
3531 vos_ssr_unprotect(__func__);
3532
3533 return ret;
3534}
3535
3536static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3537 struct wireless_dev *wdev,
3538 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303539{
Dino Myclee8843b32014-07-04 14:21:45 +05303540 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303541 struct net_device *dev = wdev->netdev;
3542 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3543 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3544 struct nlattr
3545 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3546 eHalStatus status;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303547 struct hdd_ext_scan_context *context;
3548 unsigned long rc;
3549 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303550
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303551 ENTER();
3552
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303553 if (VOS_FTM_MODE == hdd_get_conparam()) {
3554 hddLog(LOGE, FL("Command not allowed in FTM mode"));
3555 return -EINVAL;
3556 }
3557
Dino Mycle6fb96c12014-06-10 11:52:40 +05303558 status = wlan_hdd_validate_context(pHddCtx);
3559 if (0 != status)
3560 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303561 return -EINVAL;
3562 }
Dino Myclee8843b32014-07-04 14:21:45 +05303563 /* check the EXTScan Capability */
3564 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303565 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3566 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05303567 {
3568 hddLog(VOS_TRACE_LEVEL_ERROR,
3569 FL("EXTScan not enabled/supported by Firmware"));
3570 return -EINVAL;
3571 }
3572
Dino Mycle6fb96c12014-06-10 11:52:40 +05303573 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3574 data, dataLen,
3575 wlan_hdd_extscan_config_policy)) {
3576 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3577 return -EINVAL;
3578 }
3579 /* Parse and fetch request Id */
3580 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3581 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3582 return -EINVAL;
3583 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303584
Dino Myclee8843b32014-07-04 14:21:45 +05303585 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303586 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3587
Dino Myclee8843b32014-07-04 14:21:45 +05303588 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303589
Dino Myclee8843b32014-07-04 14:21:45 +05303590 reqMsg.sessionId = pAdapter->sessionId;
3591 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303592
3593 /* Parse and fetch flush parameter */
3594 if (!tb
3595 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3596 {
3597 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3598 goto failed;
3599 }
Dino Myclee8843b32014-07-04 14:21:45 +05303600 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303601 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3602
Dino Myclee8843b32014-07-04 14:21:45 +05303603 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303604
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303605 spin_lock(&hdd_context_lock);
3606 context = &pHddCtx->ext_scan_context;
3607 context->request_id = reqMsg.requestId;
3608 context->ignore_cached_results = false;
3609 INIT_COMPLETION(context->response_event);
3610 spin_unlock(&hdd_context_lock);
3611
Dino Myclee8843b32014-07-04 14:21:45 +05303612 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303613 if (!HAL_STATUS_SUCCESS(status)) {
3614 hddLog(VOS_TRACE_LEVEL_ERROR,
3615 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303616 return -EINVAL;
3617 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303618
3619 rc = wait_for_completion_timeout(&context->response_event,
3620 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3621 if (!rc) {
3622 hddLog(LOGE, FL("Target response timed out"));
3623 retval = -ETIMEDOUT;
3624 spin_lock(&hdd_context_lock);
3625 context->ignore_cached_results = true;
3626 spin_unlock(&hdd_context_lock);
3627 } else {
3628 spin_lock(&hdd_context_lock);
3629 retval = context->response_status;
3630 spin_unlock(&hdd_context_lock);
3631 }
3632
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303633 EXIT();
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303634 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303635
3636failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303637 return -EINVAL;
3638}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303639static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3640 struct wireless_dev *wdev,
3641 const void *data, int dataLen)
3642{
3643 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303644
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303645 vos_ssr_protect(__func__);
3646 ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen);
3647 vos_ssr_unprotect(__func__);
3648
3649 return ret;
3650}
3651
3652static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303653 struct wireless_dev *wdev,
Edhar, Mahesh Kumared8631f2015-01-20 14:31:47 +05303654 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303655{
3656 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3657 struct net_device *dev = wdev->netdev;
3658 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3659 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3660 struct nlattr
3661 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3662 struct nlattr
3663 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3664 struct nlattr *apTh;
3665 eHalStatus status;
3666 tANI_U8 i = 0;
3667 int rem;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303668 struct hdd_ext_scan_context *context;
3669 tANI_U32 request_id;
3670 unsigned long rc;
3671 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303672
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303673 ENTER();
3674
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303675 if (VOS_FTM_MODE == hdd_get_conparam()) {
3676 hddLog(LOGE, FL("Command not allowed in FTM mode"));
3677 return -EINVAL;
3678 }
3679
Dino Mycle6fb96c12014-06-10 11:52:40 +05303680 status = wlan_hdd_validate_context(pHddCtx);
3681 if (0 != status)
3682 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303683 return -EINVAL;
3684 }
Dino Myclee8843b32014-07-04 14:21:45 +05303685 /* check the EXTScan Capability */
3686 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303687 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3688 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05303689 {
3690 hddLog(VOS_TRACE_LEVEL_ERROR,
3691 FL("EXTScan not enabled/supported by Firmware"));
3692 return -EINVAL;
3693 }
3694
Dino Mycle6fb96c12014-06-10 11:52:40 +05303695 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3696 data, dataLen,
3697 wlan_hdd_extscan_config_policy)) {
3698 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3699 return -EINVAL;
3700 }
3701
3702 /* Parse and fetch request Id */
3703 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3704 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3705 return -EINVAL;
3706 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303707 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3708 vos_mem_malloc(sizeof(*pReqMsg));
3709 if (!pReqMsg) {
3710 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3711 return -ENOMEM;
3712 }
3713
Dino Myclee8843b32014-07-04 14:21:45 +05303714
Dino Mycle6fb96c12014-06-10 11:52:40 +05303715 pReqMsg->requestId = nla_get_u32(
3716 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3717 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3718
3719 /* Parse and fetch number of APs */
3720 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3721 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3722 goto fail;
3723 }
3724
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303725 /* Parse and fetch lost ap sample size */
3726 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE]) {
3727 hddLog(LOGE, FL("attr lost ap sample size failed"));
3728 goto fail;
3729 }
3730
3731 pReqMsg->lostBssidSampleSize = nla_get_u32(
3732 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE]);
3733 hddLog(LOG1, FL("Lost ap sample size %d"), pReqMsg->lostBssidSampleSize);
3734
Dino Mycle6fb96c12014-06-10 11:52:40 +05303735 pReqMsg->sessionId = pAdapter->sessionId;
3736 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3737
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303738 pReqMsg->numBssid = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303739 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303740 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numBssid);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303741
3742 nla_for_each_nested(apTh,
3743 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3744 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3745 nla_data(apTh), nla_len(apTh),
3746 NULL)) {
3747 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3748 goto fail;
3749 }
3750
3751 /* Parse and fetch MAC address */
3752 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3753 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3754 goto fail;
3755 }
3756 memcpy(pReqMsg->ap[i].bssid, nla_data(
3757 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3758 sizeof(tSirMacAddr));
3759 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3760
3761 /* Parse and fetch low RSSI */
3762 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3763 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3764 goto fail;
3765 }
3766 pReqMsg->ap[i].low = nla_get_s32(
3767 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3768 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3769
3770 /* Parse and fetch high RSSI */
3771 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3772 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3773 goto fail;
3774 }
3775 pReqMsg->ap[i].high = nla_get_s32(
3776 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3777 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3778 pReqMsg->ap[i].high);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303779 i++;
3780 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303781
3782 context = &pHddCtx->ext_scan_context;
3783 spin_lock(&hdd_context_lock);
3784 INIT_COMPLETION(context->response_event);
3785 context->request_id = request_id = pReqMsg->requestId;
3786 spin_unlock(&hdd_context_lock);
3787
Dino Mycle6fb96c12014-06-10 11:52:40 +05303788 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3789 if (!HAL_STATUS_SUCCESS(status)) {
3790 hddLog(VOS_TRACE_LEVEL_ERROR,
3791 FL("sme_SetBssHotlist failed(err=%d)"), status);
3792 vos_mem_free(pReqMsg);
3793 return -EINVAL;
3794 }
3795
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303796 /* request was sent -- wait for the response */
3797 rc = wait_for_completion_timeout(&context->response_event,
3798 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3799
3800 if (!rc) {
3801 hddLog(LOGE, FL("sme_SetBssHotlist timed out"));
3802 retval = -ETIMEDOUT;
3803 } else {
3804 spin_lock(&hdd_context_lock);
3805 if (context->request_id == request_id)
3806 retval = context->response_status;
3807 else
3808 retval = -EINVAL;
3809 spin_unlock(&hdd_context_lock);
3810 }
3811
Dino Myclee8843b32014-07-04 14:21:45 +05303812 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303813 EXIT();
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303814 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303815
3816fail:
3817 vos_mem_free(pReqMsg);
3818 return -EINVAL;
3819}
3820
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303821static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3822 struct wireless_dev *wdev,
3823 const void *data, int dataLen)
3824{
3825 int ret = 0;
3826
3827 vos_ssr_protect(__func__);
3828 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
3829 dataLen);
3830 vos_ssr_unprotect(__func__);
3831
3832 return ret;
3833}
3834
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303835/*
3836 * define short names for the global vendor params
3837 * used by wlan_hdd_cfg80211_extscan_set_ssid_hotlist()
3838 */
3839#define PARAM_MAX \
3840QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
3841#define PARAM_REQUEST_ID \
3842QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
3843#define PARAMS_LOST_SSID_SAMPLE_SIZE \
3844QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_LOST_SSID_SAMPLE_SIZE
3845#define PARAMS_NUM_SSID \
3846QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID
3847#define THRESHOLD_PARAM \
3848QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM
3849#define PARAM_SSID \
3850QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_SSID
3851#define PARAM_BAND \
3852QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_BAND
3853#define PARAM_RSSI_LOW \
3854QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_LOW
3855#define PARAM_RSSI_HIGH \
3856QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_HIGH
3857
3858/**
3859 * __wlan_hdd_cfg80211_extscan_set_ssid_hotlist() - set ssid hot list
3860 * @wiphy: Pointer to wireless phy
3861 * @wdev: Pointer to wireless device
3862 * @data: Pointer to data
3863 * @data_len: Data length
3864 *
3865 * Return: 0 on success, negative errno on failure
3866 */
3867static int
3868__wlan_hdd_cfg80211_extscan_set_ssid_hotlist(struct wiphy *wiphy,
3869 struct wireless_dev *wdev,
3870 const void *data,
3871 int data_len)
3872{
3873 tSirEXTScanSetSsidHotListReqParams *request;
3874 struct net_device *dev = wdev->netdev;
3875 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3876 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
3877 struct nlattr *tb[PARAM_MAX + 1];
3878 struct nlattr *tb2[PARAM_MAX + 1];
3879 struct nlattr *ssids;
3880 struct hdd_ext_scan_context *context;
3881 uint32_t request_id;
3882 char ssid_string[SIR_MAC_MAX_SSID_LENGTH + 1] = {'\0'};
3883 int ssid_len;
3884 eHalStatus status;
3885 int i, rem, retval;
3886 unsigned long rc;
3887
3888 ENTER();
3889
3890 if (VOS_FTM_MODE == hdd_get_conparam()) {
3891 hddLog(LOGE, FL("Command not allowed in FTM mode"));
3892 return -EINVAL;
3893 }
3894
3895 retval = wlan_hdd_validate_context(hdd_ctx);
3896 if (0 != retval) {
3897 hddLog(LOGE, FL("HDD context is not valid"));
3898 return -EINVAL;
3899 }
3900
3901 /* check the EXTScan Capability */
3902 if ( (TRUE != hdd_ctx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303903 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3904 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303905 {
3906 hddLog(VOS_TRACE_LEVEL_ERROR,
3907 FL("EXTScan not enabled/supported by Firmware"));
3908 return -EINVAL;
3909 }
3910
3911 if (nla_parse(tb, PARAM_MAX,
3912 data, data_len,
3913 wlan_hdd_extscan_config_policy)) {
3914 hddLog(LOGE, FL("Invalid ATTR"));
3915 return -EINVAL;
3916 }
3917
3918 request = vos_mem_malloc(sizeof(*request));
3919 if (!request) {
3920 hddLog(LOGE, FL("vos_mem_malloc failed"));
3921 return -ENOMEM;
3922 }
3923
3924 /* Parse and fetch request Id */
3925 if (!tb[PARAM_REQUEST_ID]) {
3926 hddLog(LOGE, FL("attr request id failed"));
3927 goto fail;
3928 }
3929
3930 request->request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
3931 hddLog(LOG1, FL("Request Id %d"), request->request_id);
3932
3933 /* Parse and fetch lost SSID sample size */
3934 if (!tb[PARAMS_LOST_SSID_SAMPLE_SIZE]) {
3935 hddLog(LOGE, FL("attr number of Ssid failed"));
3936 goto fail;
3937 }
3938 request->lost_ssid_sample_size =
3939 nla_get_u32(tb[PARAMS_LOST_SSID_SAMPLE_SIZE]);
3940 hddLog(LOG1, FL("Lost SSID Sample Size %d"),
3941 request->lost_ssid_sample_size);
3942
3943 /* Parse and fetch number of hotlist SSID */
3944 if (!tb[PARAMS_NUM_SSID]) {
3945 hddLog(LOGE, FL("attr number of Ssid failed"));
3946 goto fail;
3947 }
3948 request->ssid_count = nla_get_u32(tb[PARAMS_NUM_SSID]);
3949 hddLog(LOG1, FL("Number of SSID %d"), request->ssid_count);
3950
3951 request->session_id = adapter->sessionId;
3952 hddLog(LOG1, FL("Session Id (%d)"), request->session_id);
3953
3954 i = 0;
3955 nla_for_each_nested(ssids, tb[THRESHOLD_PARAM], rem) {
3956 if (i >= WLAN_EXTSCAN_MAX_HOTLIST_SSIDS) {
3957 hddLog(LOGE,
3958 FL("Too Many SSIDs, %d exceeds %d"),
3959 i, WLAN_EXTSCAN_MAX_HOTLIST_SSIDS);
3960 break;
3961 }
3962 if (nla_parse(tb2, PARAM_MAX,
3963 nla_data(ssids), nla_len(ssids),
3964 wlan_hdd_extscan_config_policy)) {
3965 hddLog(LOGE, FL("nla_parse failed"));
3966 goto fail;
3967 }
3968
3969 /* Parse and fetch SSID */
3970 if (!tb2[PARAM_SSID]) {
3971 hddLog(LOGE, FL("attr ssid failed"));
3972 goto fail;
3973 }
3974 nla_memcpy(ssid_string,
3975 tb2[PARAM_SSID],
3976 sizeof(ssid_string));
3977 hddLog(LOG1, FL("SSID %s"),
3978 ssid_string);
3979 ssid_len = strlen(ssid_string);
3980 memcpy(request->ssid[i].ssid.ssId, ssid_string, ssid_len);
3981 request->ssid[i].ssid.length = ssid_len;
3982 request->ssid[i].ssid.ssId[ssid_len] = '\0';
3983 hddLog(LOG1, FL("After copying SSID %s"),
3984 request->ssid[i].ssid.ssId);
3985 hddLog(LOG1, FL("After copying length: %d"),
3986 ssid_len);
3987
3988 /* Parse and fetch low RSSI */
3989 if (!tb2[PARAM_BAND]) {
3990 hddLog(LOGE, FL("attr band failed"));
3991 goto fail;
3992 }
3993 request->ssid[i].band = nla_get_u8(tb2[PARAM_BAND]);
3994 hddLog(LOG1, FL("band %d"), request->ssid[i].band);
3995
3996 /* Parse and fetch low RSSI */
3997 if (!tb2[PARAM_RSSI_LOW]) {
3998 hddLog(LOGE, FL("attr low RSSI failed"));
3999 goto fail;
4000 }
4001 request->ssid[i].rssi_low = nla_get_s32(tb2[PARAM_RSSI_LOW]);
4002 hddLog(LOG1, FL("RSSI low %d"), request->ssid[i].rssi_low);
4003
4004 /* Parse and fetch high RSSI */
4005 if (!tb2[PARAM_RSSI_HIGH]) {
4006 hddLog(LOGE, FL("attr high RSSI failed"));
4007 goto fail;
4008 }
4009 request->ssid[i].rssi_high = nla_get_u32(tb2[PARAM_RSSI_HIGH]);
4010 hddLog(LOG1, FL("RSSI high %d"), request->ssid[i].rssi_high);
4011 i++;
4012 }
4013
4014 context = &hdd_ctx->ext_scan_context;
4015 spin_lock(&hdd_context_lock);
4016 INIT_COMPLETION(context->response_event);
4017 context->request_id = request_id = request->request_id;
4018 spin_unlock(&hdd_context_lock);
4019
4020 status = sme_set_ssid_hotlist(hdd_ctx->hHal, request);
4021 if (!HAL_STATUS_SUCCESS(status)) {
4022 hddLog(LOGE,
4023 FL("sme_set_ssid_hotlist failed(err=%d)"), status);
4024 goto fail;
4025 }
4026
4027 vos_mem_free(request);
4028
4029 /* request was sent -- wait for the response */
4030 rc = wait_for_completion_timeout(&context->response_event,
4031 msecs_to_jiffies
4032 (WLAN_WAIT_TIME_EXTSCAN));
4033 if (!rc) {
4034 hddLog(LOGE, FL("sme_set_ssid_hotlist timed out"));
4035 retval = -ETIMEDOUT;
4036 } else {
4037 spin_lock(&hdd_context_lock);
4038 if (context->request_id == request_id)
4039 retval = context->response_status;
4040 else
4041 retval = -EINVAL;
4042 spin_unlock(&hdd_context_lock);
4043 }
4044
4045 return retval;
4046
4047fail:
4048 vos_mem_free(request);
4049 return -EINVAL;
4050}
4051
4052/*
4053 * done with short names for the global vendor params
4054 * used by wlan_hdd_cfg80211_extscan_set_ssid_hotlist()
4055 */
4056#undef PARAM_MAX
4057#undef PARAM_REQUEST_ID
4058#undef PARAMS_NUM_SSID
4059#undef THRESHOLD_PARAM
4060#undef PARAM_SSID
4061#undef PARAM_BAND
4062#undef PARAM_RSSI_LOW
4063#undef PARAM_RSSI_HIGH
4064
4065static int wlan_hdd_cfg80211_extscan_set_ssid_hotlist(struct wiphy *wiphy,
4066 struct wireless_dev *wdev,
4067 const void *data, int dataLen)
4068{
4069 int ret = 0;
4070
4071 vos_ssr_protect(__func__);
4072 ret = __wlan_hdd_cfg80211_extscan_set_ssid_hotlist(wiphy, wdev, data,
4073 dataLen);
4074 vos_ssr_unprotect(__func__);
4075
4076 return ret;
4077}
4078
4079static int
4080__wlan_hdd_cfg80211_extscan_reset_ssid_hotlist(struct wiphy *wiphy,
4081 struct wireless_dev *wdev,
4082 const void *data,
4083 int data_len)
4084{
4085 tSirEXTScanResetSsidHotlistReqParams request;
4086 struct net_device *dev = wdev->netdev;
4087 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4088 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
4089 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4090 struct hdd_ext_scan_context *context;
4091 uint32_t request_id;
4092 eHalStatus status;
4093 int retval;
4094 unsigned long rc;
4095
4096 ENTER();
4097
4098 if (VOS_FTM_MODE == hdd_get_conparam()) {
4099 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4100 return -EINVAL;
4101 }
4102
4103 retval = wlan_hdd_validate_context(hdd_ctx);
4104 if (0 != retval) {
4105 hddLog(LOGE, FL("HDD context is not valid"));
4106 return -EINVAL;
4107 }
4108
4109 /* check the EXTScan Capability */
4110 if ( (TRUE != hdd_ctx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304111 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4112 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05304113 {
4114 hddLog(LOGE,
4115 FL("EXTScan not enabled/supported by Firmware"));
4116 return -EINVAL;
4117 }
4118
4119 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4120 data, data_len,
4121 wlan_hdd_extscan_config_policy)) {
4122 hddLog(LOGE, FL("Invalid ATTR"));
4123 return -EINVAL;
4124 }
4125
4126 /* Parse and fetch request Id */
4127 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4128 hddLog(LOGE, FL("attr request id failed"));
4129 return -EINVAL;
4130 }
4131
4132 request.requestId = nla_get_u32(
4133 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4134 request.sessionId = adapter->sessionId;
4135 hddLog(LOG1, FL("Request Id %d Session Id %d"), request.requestId,
4136 request.sessionId);
4137
4138 context = &hdd_ctx->ext_scan_context;
4139 spin_lock(&hdd_context_lock);
4140 INIT_COMPLETION(context->response_event);
4141 context->request_id = request_id = request.requestId;
4142 spin_unlock(&hdd_context_lock);
4143
4144 status = sme_reset_ssid_hotlist(hdd_ctx->hHal, &request);
4145 if (!HAL_STATUS_SUCCESS(status)) {
4146 hddLog(LOGE,
4147 FL("sme_reset_ssid_hotlist failed(err=%d)"), status);
4148 return -EINVAL;
4149 }
4150
4151 /* request was sent -- wait for the response */
4152 rc = wait_for_completion_timeout(&context->response_event,
4153 msecs_to_jiffies
4154 (WLAN_WAIT_TIME_EXTSCAN));
4155 if (!rc) {
4156 hddLog(LOGE, FL("sme_reset_ssid_hotlist timed out"));
4157 retval = -ETIMEDOUT;
4158 } else {
4159 spin_lock(&hdd_context_lock);
4160 if (context->request_id == request_id)
4161 retval = context->response_status;
4162 else
4163 retval = -EINVAL;
4164 spin_unlock(&hdd_context_lock);
4165 }
4166
4167 return retval;
4168}
4169
4170static int
4171wlan_hdd_cfg80211_extscan_reset_ssid_hotlist(struct wiphy *wiphy,
4172 struct wireless_dev *wdev,
4173 const void *data,
4174 int data_len)
4175{
4176 int ret;
4177
4178 vos_ssr_protect(__func__);
4179 ret = __wlan_hdd_cfg80211_extscan_reset_ssid_hotlist(wiphy, wdev,
4180 data, data_len);
4181 vos_ssr_unprotect(__func__);
4182
4183 return ret;
4184}
4185
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304186static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304187 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304188 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304189{
4190 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4191 tANI_U32 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
4192 tANI_U8 numChannels = 0;
4193 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304194 tANI_U32 requestId, maxChannels;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304195 tWifiBand wifiBand;
4196 eHalStatus status;
4197 struct sk_buff *replySkb;
4198 tANI_U8 i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304199 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304200
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304201 ENTER();
4202
Dino Mycle6fb96c12014-06-10 11:52:40 +05304203 status = wlan_hdd_validate_context(pHddCtx);
4204 if (0 != status)
4205 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304206 return -EINVAL;
4207 }
Dino Myclee8843b32014-07-04 14:21:45 +05304208
Dino Mycle6fb96c12014-06-10 11:52:40 +05304209 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4210 data, dataLen,
4211 wlan_hdd_extscan_config_policy)) {
4212 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4213 return -EINVAL;
4214 }
4215
4216 /* Parse and fetch request Id */
4217 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4218 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4219 return -EINVAL;
4220 }
4221 requestId = nla_get_u32(
4222 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4223 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
4224
4225 /* Parse and fetch wifi band */
4226 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
4227 {
4228 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
4229 return -EINVAL;
4230 }
4231 wifiBand = nla_get_u32(
4232 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
4233 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
4234
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304235 /* Parse and fetch max channels */
4236 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS])
4237 {
4238 hddLog(LOGE, FL("attr max channels failed"));
4239 return -EINVAL;
4240 }
4241 maxChannels = nla_get_u32(
4242 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS]);
4243 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max channels %d"), maxChannels);
4244
Dino Mycle6fb96c12014-06-10 11:52:40 +05304245 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
4246 wifiBand, ChannelList,
4247 &numChannels);
4248 if (eHAL_STATUS_SUCCESS != status) {
4249 hddLog(VOS_TRACE_LEVEL_ERROR,
4250 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
4251 return -EINVAL;
4252 }
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304253
4254 numChannels = VOS_MIN(numChannels, maxChannels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304255 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of channels (%d)"), numChannels);
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304256
Dino Mycle6fb96c12014-06-10 11:52:40 +05304257 for (i = 0; i < numChannels; i++)
4258 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %u ", ChannelList[i]);
4259
4260 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
4261 sizeof(u32) * numChannels +
4262 NLMSG_HDRLEN);
4263
4264 if (!replySkb) {
4265 hddLog(VOS_TRACE_LEVEL_ERROR,
4266 FL("valid channels: buffer alloc fail"));
4267 return -EINVAL;
4268 }
4269 if (nla_put_u32(replySkb,
4270 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
4271 numChannels) ||
4272 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
4273 sizeof(u32) * numChannels, ChannelList)) {
4274
4275 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4276 kfree_skb(replySkb);
4277 return -EINVAL;
4278 }
4279
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304280 ret = cfg80211_vendor_cmd_reply(replySkb);
4281
4282 EXIT();
4283 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304284}
4285
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304286static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
4287 struct wireless_dev *wdev,
4288 const void *data, int dataLen)
4289{
4290 int ret = 0;
4291
4292 vos_ssr_protect(__func__);
4293 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
4294 dataLen);
4295 vos_ssr_unprotect(__func__);
4296
4297 return ret;
4298}
4299
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304300static int hdd_extscan_start_fill_bucket_channel_spec(
4301 hdd_context_t *pHddCtx,
4302 tpSirEXTScanStartReqParams pReqMsg,
4303 struct nlattr **tb)
4304{
4305 struct nlattr *bucket[
4306 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4307 struct nlattr *channel[
4308 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4309 struct nlattr *buckets;
4310 struct nlattr *channels;
4311 int rem1, rem2;
4312 eHalStatus status;
4313 tANI_U8 bktIndex, j, numChannels;
4314 tANI_U32 chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
4315 tANI_U32 passive_max_chn_time, active_max_chn_time;
4316
4317 bktIndex = 0;
4318
4319 nla_for_each_nested(buckets,
4320 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
4321 if (nla_parse(bucket,
4322 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4323 nla_data(buckets), nla_len(buckets), NULL)) {
4324 hddLog(LOGE, FL("nla_parse failed"));
4325 return -EINVAL;
4326 }
4327
4328 /* Parse and fetch bucket spec */
4329 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
4330 hddLog(LOGE, FL("attr bucket index failed"));
4331 return -EINVAL;
4332 }
4333 pReqMsg->buckets[bktIndex].bucket = nla_get_u8(
4334 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
4335 hddLog(LOG1, FL("Bucket spec Index %d"),
4336 pReqMsg->buckets[bktIndex].bucket);
4337
4338 /* Parse and fetch wifi band */
4339 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
4340 hddLog(LOGE, FL("attr wifi band failed"));
4341 return -EINVAL;
4342 }
4343 pReqMsg->buckets[bktIndex].band = nla_get_u8(
4344 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
4345 hddLog(LOG1, FL("Wifi band %d"),
4346 pReqMsg->buckets[bktIndex].band);
4347
4348 /* Parse and fetch period */
4349 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
4350 hddLog(LOGE, FL("attr period failed"));
4351 return -EINVAL;
4352 }
4353 pReqMsg->buckets[bktIndex].period = nla_get_u32(
4354 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
4355 hddLog(LOG1, FL("period %d"),
4356 pReqMsg->buckets[bktIndex].period);
4357
4358 /* Parse and fetch report events */
4359 if (!bucket[
4360 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
4361 hddLog(LOGE, FL("attr report events failed"));
4362 return -EINVAL;
4363 }
4364 pReqMsg->buckets[bktIndex].reportEvents = nla_get_u8(
4365 bucket[
4366 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
4367 hddLog(LOG1, FL("report events %d"),
4368 pReqMsg->buckets[bktIndex].reportEvents);
4369
4370 /* Parse and fetch max period */
4371 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]) {
4372 hddLog(LOGE, FL("attr max period failed"));
4373 return -EINVAL;
4374 }
4375 pReqMsg->buckets[bktIndex].max_period = nla_get_u32(
4376 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]);
4377 hddLog(LOG1, FL("max period %u"),
4378 pReqMsg->buckets[bktIndex].max_period);
4379
4380 /* Parse and fetch exponent */
4381 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]) {
4382 hddLog(LOGE, FL("attr exponent failed"));
4383 return -EINVAL;
4384 }
4385 pReqMsg->buckets[bktIndex].exponent = nla_get_u32(
4386 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]);
4387 hddLog(LOG1, FL("exponent %u"),
4388 pReqMsg->buckets[bktIndex].exponent);
4389
4390 /* Parse and fetch step count */
4391 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]) {
4392 hddLog(LOGE, FL("attr step count failed"));
4393 return -EINVAL;
4394 }
4395 pReqMsg->buckets[bktIndex].step_count = nla_get_u32(
4396 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]);
4397 hddLog(LOG1, FL("Step count %u"),
4398 pReqMsg->buckets[bktIndex].step_count);
4399
4400 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &passive_max_chn_time);
4401 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &active_max_chn_time);
4402
4403 /* Framework shall pass the channel list if the input WiFi band is
4404 * WIFI_BAND_UNSPECIFIED.
4405 * If the input WiFi band is specified (any value other than
4406 * WIFI_BAND_UNSPECIFIED) then driver populates the channel list
4407 */
4408 if (pReqMsg->buckets[bktIndex].band != WIFI_BAND_UNSPECIFIED) {
4409 numChannels = 0;
4410 hddLog(LOG1, "WiFi band is specified, driver to fill channel list");
4411 status = sme_GetValidChannelsByBand(pHddCtx->hHal,
4412 pReqMsg->buckets[bktIndex].band,
4413 chanList, &numChannels);
4414 if (!HAL_STATUS_SUCCESS(status)) {
4415 hddLog(LOGE,
4416 FL("sme_GetValidChannelsByBand failed (err=%d)"),
4417 status);
4418 return -EINVAL;
4419 }
4420
4421 pReqMsg->buckets[bktIndex].numChannels =
4422 VOS_MIN(numChannels, WLAN_EXTSCAN_MAX_CHANNELS);
4423 hddLog(LOG1, FL("Num channels %d"),
4424 pReqMsg->buckets[bktIndex].numChannels);
4425
4426 for (j = 0; j < pReqMsg->buckets[bktIndex].numChannels;
4427 j++) {
4428 pReqMsg->buckets[bktIndex].channels[j].channel =
4429 chanList[j];
4430 pReqMsg->buckets[bktIndex].channels[j].
4431 chnlClass = 0;
4432 if (CSR_IS_CHANNEL_DFS(
4433 vos_freq_to_chan(chanList[j]))) {
4434 pReqMsg->buckets[bktIndex].channels[j].
4435 passive = 1;
4436 pReqMsg->buckets[bktIndex].channels[j].
4437 dwellTimeMs = passive_max_chn_time;
4438 } else {
4439 pReqMsg->buckets[bktIndex].channels[j].
4440 passive = 0;
4441 pReqMsg->buckets[bktIndex].channels[j].
4442 dwellTimeMs = active_max_chn_time;
4443 }
4444
4445 hddLog(LOG1,
4446 "Channel %u Passive %u Dwell time %u ms",
4447 pReqMsg->buckets[bktIndex].channels[j].channel,
4448 pReqMsg->buckets[bktIndex].channels[j].passive,
4449 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
4450 }
4451
4452 bktIndex++;
4453 continue;
4454 }
4455
4456 /* Parse and fetch number of channels */
4457 if (!bucket[
4458 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]) {
4459 hddLog(LOGE, FL("attr num channels failed"));
4460 return -EINVAL;
4461 }
4462
4463 pReqMsg->buckets[bktIndex].numChannels =
4464 nla_get_u32(bucket[
4465 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
4466 hddLog(LOG1, FL("num channels %d"),
4467 pReqMsg->buckets[bktIndex].numChannels);
4468
4469 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
4470 hddLog(LOGE, FL("attr channel spec failed"));
4471 return -EINVAL;
4472 }
4473
4474 j = 0;
4475 nla_for_each_nested(channels,
4476 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
4477 if (nla_parse(channel,
4478 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4479 nla_data(channels), nla_len(channels),
4480 wlan_hdd_extscan_config_policy)) {
4481 hddLog(LOGE, FL("nla_parse failed"));
4482 return -EINVAL;
4483 }
4484
4485 /* Parse and fetch channel */
4486 if (!channel[
4487 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
4488 hddLog(LOGE, FL("attr channel failed"));
4489 return -EINVAL;
4490 }
4491 pReqMsg->buckets[bktIndex].channels[j].channel =
4492 nla_get_u32(channel[
4493 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
4494 hddLog(LOG1, FL("channel %u"),
4495 pReqMsg->buckets[bktIndex].channels[j].channel);
4496
4497 /* Parse and fetch dwell time */
4498 if (!channel[
4499 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
4500 hddLog(LOGE, FL("attr dwelltime failed"));
4501 return -EINVAL;
4502 }
4503 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs =
4504 nla_get_u32(channel[
4505 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
4506
4507 hddLog(LOG1, FL("Dwell time (%u ms)"),
4508 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
4509
4510
4511 /* Parse and fetch channel spec passive */
4512 if (!channel[
4513 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
4514 hddLog(LOGE,
4515 FL("attr channel spec passive failed"));
4516 return -EINVAL;
4517 }
4518 pReqMsg->buckets[bktIndex].channels[j].passive =
4519 nla_get_u8(channel[
4520 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
4521 hddLog(LOG1, FL("Chnl spec passive %u"),
4522 pReqMsg->buckets[bktIndex].channels[j].passive);
4523
4524 j++;
4525 }
4526
4527 bktIndex++;
4528 }
4529
4530 return 0;
4531}
4532
4533
4534/*
4535 * define short names for the global vendor params
4536 * used by wlan_hdd_cfg80211_extscan_start()
4537 */
4538#define PARAM_MAX \
4539QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
4540#define PARAM_REQUEST_ID \
4541QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
4542#define PARAM_BASE_PERIOD \
4543QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD
4544#define PARAM_MAX_AP_PER_SCAN \
4545QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN
4546#define PARAM_RPT_THRHLD_PERCENT \
4547QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT
4548#define PARAM_RPT_THRHLD_NUM_SCANS \
4549QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS
4550#define PARAM_NUM_BUCKETS \
4551QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS
4552
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304553static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304554 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304555 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304556{
Dino Myclee8843b32014-07-04 14:21:45 +05304557 tpSirEXTScanStartReqParams pReqMsg = NULL;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304558 struct net_device *dev = wdev->netdev;
4559 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4560 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4561 struct nlattr *tb[PARAM_MAX + 1];
4562 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304563 eHalStatus status;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304564 tANI_U32 request_id;
4565 struct hdd_ext_scan_context *context;
4566 unsigned long rc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304567
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304568 ENTER();
4569
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304570 if (VOS_FTM_MODE == hdd_get_conparam()) {
4571 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4572 return -EINVAL;
4573 }
4574
Dino Mycle6fb96c12014-06-10 11:52:40 +05304575 status = wlan_hdd_validate_context(pHddCtx);
4576 if (0 != status)
4577 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304578 return -EINVAL;
4579 }
Dino Myclee8843b32014-07-04 14:21:45 +05304580 /* check the EXTScan Capability */
4581 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304582 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4583 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304584 {
4585 hddLog(VOS_TRACE_LEVEL_ERROR,
4586 FL("EXTScan not enabled/supported by Firmware"));
4587 return -EINVAL;
4588 }
4589
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304590 if (nla_parse(tb, PARAM_MAX,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304591 data, dataLen,
4592 wlan_hdd_extscan_config_policy)) {
4593 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4594 return -EINVAL;
4595 }
4596
4597 /* Parse and fetch request Id */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304598 if (!tb[PARAM_REQUEST_ID]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304599 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4600 return -EINVAL;
4601 }
4602
Dino Myclee8843b32014-07-04 14:21:45 +05304603 pReqMsg = (tpSirEXTScanStartReqParams)
4604 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304605 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05304606 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
4607 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304608 }
4609
4610 pReqMsg->requestId = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304611 tb[PARAM_REQUEST_ID]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304612 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4613
4614 pReqMsg->sessionId = pAdapter->sessionId;
4615 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4616
4617 /* Parse and fetch base period */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304618 if (!tb[PARAM_BASE_PERIOD]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304619 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
4620 goto fail;
4621 }
4622 pReqMsg->basePeriod = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304623 tb[PARAM_BASE_PERIOD]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304624 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
4625 pReqMsg->basePeriod);
4626
4627 /* Parse and fetch max AP per scan */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304628 if (!tb[PARAM_MAX_AP_PER_SCAN]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304629 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
4630 goto fail;
4631 }
4632 pReqMsg->maxAPperScan = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304633 tb[PARAM_MAX_AP_PER_SCAN]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304634 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
4635 pReqMsg->maxAPperScan);
4636
4637 /* Parse and fetch report threshold */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304638 if (!tb[PARAM_RPT_THRHLD_PERCENT]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304639 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
4640 goto fail;
4641 }
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304642 pReqMsg->reportThresholdPercent = nla_get_u8(
4643 tb[PARAM_RPT_THRHLD_PERCENT]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304644 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304645 pReqMsg->reportThresholdPercent);
4646
4647 /* Parse and fetch report threshold num scans */
4648 if (!tb[PARAM_RPT_THRHLD_NUM_SCANS]) {
4649 hddLog(LOGE, FL("attr report_threshold num scans failed"));
4650 goto fail;
4651 }
4652 pReqMsg->reportThresholdNumScans = nla_get_u8(
4653 tb[PARAM_RPT_THRHLD_NUM_SCANS]);
4654 hddLog(LOG1, FL("Report Threshold num scans %d"),
4655 pReqMsg->reportThresholdNumScans);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304656
4657 /* Parse and fetch number of buckets */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304658 if (!tb[PARAM_NUM_BUCKETS]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304659 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
4660 goto fail;
4661 }
4662 pReqMsg->numBuckets = nla_get_u8(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304663 tb[PARAM_NUM_BUCKETS]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304664 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
4665 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
4666 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
4667 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
4668 }
4669 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
4670 pReqMsg->numBuckets);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304671
Dino Mycle6fb96c12014-06-10 11:52:40 +05304672 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
4673 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
4674 goto fail;
4675 }
4676
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304677 pReqMsg->homeAwayTime = pHddCtx->cfg_ini->nRestTimeConc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304678
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304679 if (hdd_extscan_start_fill_bucket_channel_spec(pHddCtx, pReqMsg, tb))
4680 goto fail;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304681
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304682 context = &pHddCtx->ext_scan_context;
4683 spin_lock(&hdd_context_lock);
4684 INIT_COMPLETION(context->response_event);
4685 context->request_id = request_id = pReqMsg->requestId;
4686 spin_unlock(&hdd_context_lock);
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304687
Dino Mycle6fb96c12014-06-10 11:52:40 +05304688 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
4689 if (!HAL_STATUS_SUCCESS(status)) {
4690 hddLog(VOS_TRACE_LEVEL_ERROR,
4691 FL("sme_EXTScanStart failed(err=%d)"), status);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304692 goto fail;
4693 }
4694
4695 /* request was sent -- wait for the response */
4696 rc = wait_for_completion_timeout(&context->response_event,
4697 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4698
4699 if (!rc) {
4700 hddLog(LOGE, FL("sme_ExtScanStart timed out"));
4701 retval = -ETIMEDOUT;
4702 } else {
4703 spin_lock(&hdd_context_lock);
4704 if (context->request_id == request_id)
4705 retval = context->response_status;
4706 else
4707 retval = -EINVAL;
4708 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304709 }
4710
Dino Myclee8843b32014-07-04 14:21:45 +05304711 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304712 EXIT();
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304713 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304714
4715fail:
4716 vos_mem_free(pReqMsg);
4717 return -EINVAL;
4718}
4719
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304720/*
4721 * done with short names for the global vendor params
4722 * used by wlan_hdd_cfg80211_extscan_start()
4723 */
4724#undef PARAM_MAX
4725#undef PARAM_REQUEST_ID
4726#undef PARAM_BASE_PERIOD
4727#undef PARAMS_MAX_AP_PER_SCAN
4728#undef PARAMS_RPT_THRHLD_PERCENT
4729#undef PARAMS_RPT_THRHLD_NUM_SCANS
4730#undef PARAMS_NUM_BUCKETS
4731
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304732static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
4733 struct wireless_dev *wdev,
4734 const void *data, int dataLen)
4735{
4736 int ret = 0;
4737
4738 vos_ssr_protect(__func__);
4739 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
4740 vos_ssr_unprotect(__func__);
4741
4742 return ret;
4743}
4744
4745static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304746 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304747 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304748{
Dino Myclee8843b32014-07-04 14:21:45 +05304749 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304750 struct net_device *dev = wdev->netdev;
4751 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4752 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4753 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4754 eHalStatus status;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304755 int retval;
4756 unsigned long rc;
4757 struct hdd_ext_scan_context *context;
4758 tANI_U32 request_id;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304759
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304760 ENTER();
4761
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304762 if (VOS_FTM_MODE == hdd_get_conparam()) {
4763 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4764 return -EINVAL;
4765 }
4766
Dino Mycle6fb96c12014-06-10 11:52:40 +05304767 status = wlan_hdd_validate_context(pHddCtx);
4768 if (0 != status)
4769 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304770 return -EINVAL;
4771 }
Dino Myclee8843b32014-07-04 14:21:45 +05304772 /* check the EXTScan Capability */
4773 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304774 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4775 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304776 {
4777 hddLog(VOS_TRACE_LEVEL_ERROR,
4778 FL("EXTScan not enabled/supported by Firmware"));
4779 return -EINVAL;
4780 }
4781
Dino Mycle6fb96c12014-06-10 11:52:40 +05304782 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4783 data, dataLen,
4784 wlan_hdd_extscan_config_policy)) {
4785 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4786 return -EINVAL;
4787 }
4788
4789 /* Parse and fetch request Id */
4790 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4791 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4792 return -EINVAL;
4793 }
4794
Dino Myclee8843b32014-07-04 14:21:45 +05304795 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304796 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304797 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304798
Dino Myclee8843b32014-07-04 14:21:45 +05304799 reqMsg.sessionId = pAdapter->sessionId;
4800 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304801
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304802 context = &pHddCtx->ext_scan_context;
4803 spin_lock(&hdd_context_lock);
4804 INIT_COMPLETION(context->response_event);
4805 context->request_id = request_id = reqMsg.sessionId;
4806 spin_unlock(&hdd_context_lock);
4807
Dino Myclee8843b32014-07-04 14:21:45 +05304808 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304809 if (!HAL_STATUS_SUCCESS(status)) {
4810 hddLog(VOS_TRACE_LEVEL_ERROR,
4811 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304812 return -EINVAL;
4813 }
4814
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304815 /* request was sent -- wait for the response */
4816 rc = wait_for_completion_timeout(&context->response_event,
4817 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4818
4819 if (!rc) {
4820 hddLog(LOGE, FL("sme_ExtScanStop timed out"));
4821 retval = -ETIMEDOUT;
4822 } else {
4823 spin_lock(&hdd_context_lock);
4824 if (context->request_id == request_id)
4825 retval = context->response_status;
4826 else
4827 retval = -EINVAL;
4828 spin_unlock(&hdd_context_lock);
4829 }
4830
4831 return retval;
4832
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304833 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304834 return 0;
4835}
4836
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304837static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
4838 struct wireless_dev *wdev,
4839 const void *data, int dataLen)
4840{
4841 int ret = 0;
4842
4843 vos_ssr_protect(__func__);
4844 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
4845 vos_ssr_unprotect(__func__);
4846
4847 return ret;
4848}
4849
4850static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304851 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304852 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304853{
Dino Myclee8843b32014-07-04 14:21:45 +05304854 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304855 struct net_device *dev = wdev->netdev;
4856 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4857 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4858 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4859 eHalStatus status;
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304860 struct hdd_ext_scan_context *context;
4861 tANI_U32 request_id;
4862 unsigned long rc;
4863 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304864
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304865 ENTER();
4866
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304867 if (VOS_FTM_MODE == hdd_get_conparam()) {
4868 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4869 return -EINVAL;
4870 }
4871
Dino Mycle6fb96c12014-06-10 11:52:40 +05304872 status = wlan_hdd_validate_context(pHddCtx);
4873 if (0 != status)
4874 {
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304875 hddLog(LOGE, FL("HDD context is not valid"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304876 return -EINVAL;
4877 }
Dino Myclee8843b32014-07-04 14:21:45 +05304878 /* check the EXTScan Capability */
4879 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304880 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4881 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304882 {
4883 hddLog(VOS_TRACE_LEVEL_ERROR,
4884 FL("EXTScan not enabled/supported by Firmware"));
4885 return -EINVAL;
4886 }
4887
Dino Mycle6fb96c12014-06-10 11:52:40 +05304888 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4889 data, dataLen,
4890 wlan_hdd_extscan_config_policy)) {
4891 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4892 return -EINVAL;
4893 }
4894
4895 /* Parse and fetch request Id */
4896 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4897 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4898 return -EINVAL;
4899 }
4900
Dino Myclee8843b32014-07-04 14:21:45 +05304901 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304902 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304903 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304904
Dino Myclee8843b32014-07-04 14:21:45 +05304905 reqMsg.sessionId = pAdapter->sessionId;
4906 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304907
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304908 context = &pHddCtx->ext_scan_context;
4909 spin_lock(&hdd_context_lock);
4910 INIT_COMPLETION(context->response_event);
4911 context->request_id = request_id = reqMsg.requestId;
4912 spin_unlock(&hdd_context_lock);
4913
Dino Myclee8843b32014-07-04 14:21:45 +05304914 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304915 if (!HAL_STATUS_SUCCESS(status)) {
4916 hddLog(VOS_TRACE_LEVEL_ERROR,
4917 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304918 return -EINVAL;
4919 }
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304920
4921 /* request was sent -- wait for the response */
4922 rc = wait_for_completion_timeout(&context->response_event,
4923 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4924 if (!rc) {
4925 hddLog(LOGE, FL("sme_ResetBssHotlist timed out"));
4926 retval = -ETIMEDOUT;
4927 } else {
4928 spin_lock(&hdd_context_lock);
4929 if (context->request_id == request_id)
4930 retval = context->response_status;
4931 else
4932 retval = -EINVAL;
4933 spin_unlock(&hdd_context_lock);
4934 }
4935
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304936 EXIT();
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304937 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304938}
4939
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304940static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
4941 struct wireless_dev *wdev,
4942 const void *data, int dataLen)
4943{
4944 int ret = 0;
4945
4946 vos_ssr_protect(__func__);
4947 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
4948 vos_ssr_unprotect(__func__);
4949
4950 return ret;
4951}
Dino Mycle6fb96c12014-06-10 11:52:40 +05304952#endif /* WLAN_FEATURE_EXTSCAN */
4953
Atul Mittal115287b2014-07-08 13:26:33 +05304954/*EXT TDLS*/
4955static const struct nla_policy
4956wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
4957{
4958 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4959 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
4960 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
4961 {.type = NLA_S32 },
4962 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
4963 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
4964
4965};
4966
4967static const struct nla_policy
4968wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
4969{
4970 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4971
4972};
4973
4974static const struct nla_policy
4975wlan_hdd_tdls_config_state_change_policy[
4976 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
4977{
4978 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
4979 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
4980 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304981 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
4982 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
4983 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304984
4985};
4986
4987static const struct nla_policy
4988wlan_hdd_tdls_config_get_status_policy[
4989 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
4990{
4991 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
4992 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
4993 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304994 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
4995 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
4996 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304997
4998};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304999
5000static const struct nla_policy
5001wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
5002{
5003 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
5004};
5005
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305006static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305007 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305008 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305009 int data_len)
5010{
5011
5012 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5013 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
5014
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305015 ENTER();
5016
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305017 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305018 return -EINVAL;
5019 }
5020 if (FALSE == pHddCtx->cfg_ini->enableMacSpoofing) {
Ratheesh S P36dbc932015-08-07 14:28:57 +05305021 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN disabled in ini"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305022 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05305023 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305024 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
Ratheesh S P36dbc932015-08-07 14:28:57 +05305025 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN not supported by FW"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305026 return -ENOTSUPP;
5027 }
5028
5029 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
5030 data, data_len, wlan_hdd_mac_config)) {
5031 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5032 return -EINVAL;
5033 }
5034
5035 /* Parse and fetch mac address */
5036 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
5037 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5038 return -EINVAL;
5039 }
5040
5041 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
5042 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
5043 VOS_MAC_ADDR_LAST_3_BYTES);
5044
Siddharth Bhal76972212014-10-15 16:22:51 +05305045 pHddCtx->spoofMacAddr.isEnabled = TRUE;
5046
5047 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305048 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
5049 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05305050 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
5051 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
5052 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
5053 {
5054 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
5055 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
5056 VOS_MAC_ADDRESS_LEN);
5057 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305058 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305059
Siddharth Bhal76972212014-10-15 16:22:51 +05305060 if (VOS_STATUS_SUCCESS != hdd_processSpoofMacAddrRequest(pHddCtx))
5061 {
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305062 hddLog(LOGE, FL("Failed to send Spoof Mac Addr to FW"));
5063 }
5064
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305065 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305066 return 0;
5067}
5068
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305069static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
5070 struct wireless_dev *wdev,
5071 const void *data,
5072 int data_len)
5073{
5074 int ret = 0;
5075
5076 vos_ssr_protect(__func__);
5077 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
5078 vos_ssr_unprotect(__func__);
5079
5080 return ret;
5081}
5082
5083static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305084 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305085 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305086 int data_len)
5087{
5088 u8 peer[6] = {0};
5089 struct net_device *dev = wdev->netdev;
5090 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5091 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5092 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
5093 eHalStatus ret;
5094 tANI_S32 state;
5095 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305096 tANI_S32 global_operating_class = 0;
5097 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05305098 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305099 int retVal;
5100
5101 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305102
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305103 if (!pAdapter) {
5104 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5105 return -EINVAL;
5106 }
5107
Atul Mittal115287b2014-07-08 13:26:33 +05305108 ret = wlan_hdd_validate_context(pHddCtx);
5109 if (0 != ret) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305110 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305111 return -EINVAL;
5112 }
5113 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305114 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305115 return -ENOTSUPP;
5116 }
5117 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
5118 data, data_len,
5119 wlan_hdd_tdls_config_get_status_policy)) {
5120 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5121 return -EINVAL;
5122 }
5123
5124 /* Parse and fetch mac address */
5125 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
5126 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5127 return -EINVAL;
5128 }
5129
5130 memcpy(peer, nla_data(
5131 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
5132 sizeof(peer));
5133 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5134
Konamki, Sreelakshmiabb59ed2015-06-12 12:13:23 +05305135 wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
Atul Mittal115287b2014-07-08 13:26:33 +05305136
Atul Mittal115287b2014-07-08 13:26:33 +05305137 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305138 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05305139 NLMSG_HDRLEN);
5140
5141 if (!skb) {
5142 hddLog(VOS_TRACE_LEVEL_ERROR,
5143 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5144 return -EINVAL;
5145 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305146 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 +05305147 reason,
5148 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305149 global_operating_class,
5150 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05305151 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305152 if (nla_put_s32(skb,
5153 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
5154 state) ||
5155 nla_put_s32(skb,
5156 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
5157 reason) ||
5158 nla_put_s32(skb,
5159 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
5160 global_operating_class) ||
5161 nla_put_s32(skb,
5162 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
5163 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05305164
5165 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
5166 goto nla_put_failure;
5167 }
5168
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305169 retVal = cfg80211_vendor_cmd_reply(skb);
5170 EXIT();
5171 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05305172
5173nla_put_failure:
5174 kfree_skb(skb);
5175 return -EINVAL;
5176}
5177
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305178static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
5179 struct wireless_dev *wdev,
5180 const void *data,
5181 int data_len)
5182{
5183 int ret = 0;
5184
5185 vos_ssr_protect(__func__);
5186 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
5187 vos_ssr_unprotect(__func__);
5188
5189 return ret;
5190}
5191
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05305192static int wlan_hdd_cfg80211_exttdls_callback(
5193#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
5194 const tANI_U8* mac,
5195#else
5196 tANI_U8* mac,
5197#endif
Atul Mittal115287b2014-07-08 13:26:33 +05305198 tANI_S32 state,
5199 tANI_S32 reason,
5200 void *ctx)
5201{
5202 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05305203 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305204 tANI_S32 global_operating_class = 0;
5205 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305206 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05305207
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305208 ENTER();
5209
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305210 if (!pAdapter) {
5211 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5212 return -EINVAL;
5213 }
5214
5215 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05305216 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305217 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305218 return -EINVAL;
5219 }
5220
5221 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305222 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305223 return -ENOTSUPP;
5224 }
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05305225 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
5226#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
5227 NULL,
5228#endif
Atul Mittal115287b2014-07-08 13:26:33 +05305229 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
5230 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
5231 GFP_KERNEL);
5232
5233 if (!skb) {
5234 hddLog(VOS_TRACE_LEVEL_ERROR,
5235 FL("cfg80211_vendor_event_alloc failed"));
5236 return -EINVAL;
5237 }
5238 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305239 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
5240 reason,
5241 state,
5242 global_operating_class,
5243 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05305244 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
5245 MAC_ADDR_ARRAY(mac));
5246
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305247 if (nla_put(skb,
5248 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
5249 VOS_MAC_ADDR_SIZE, mac) ||
5250 nla_put_s32(skb,
5251 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
5252 state) ||
5253 nla_put_s32(skb,
5254 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
5255 reason) ||
5256 nla_put_s32(skb,
5257 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
5258 channel) ||
5259 nla_put_s32(skb,
5260 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
5261 global_operating_class)
5262 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05305263 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
5264 goto nla_put_failure;
5265 }
5266
5267 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305268 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05305269 return (0);
5270
5271nla_put_failure:
5272 kfree_skb(skb);
5273 return -EINVAL;
5274}
5275
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305276static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305277 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305278 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305279 int data_len)
5280{
5281 u8 peer[6] = {0};
5282 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05305283 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5284 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
5285 eHalStatus status;
5286 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305287 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305288 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305289
5290 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305291
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305292 if (!dev) {
5293 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
5294 return -EINVAL;
5295 }
5296
5297 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5298 if (!pAdapter) {
5299 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5300 return -EINVAL;
5301 }
5302
Atul Mittal115287b2014-07-08 13:26:33 +05305303 status = wlan_hdd_validate_context(pHddCtx);
5304 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305305 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305306 return -EINVAL;
5307 }
5308 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305309 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305310 return -ENOTSUPP;
5311 }
5312 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
5313 data, data_len,
5314 wlan_hdd_tdls_config_enable_policy)) {
5315 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5316 return -EINVAL;
5317 }
5318
5319 /* Parse and fetch mac address */
5320 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
5321 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5322 return -EINVAL;
5323 }
5324
5325 memcpy(peer, nla_data(
5326 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
5327 sizeof(peer));
5328 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5329
5330 /* Parse and fetch channel */
5331 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
5332 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
5333 return -EINVAL;
5334 }
5335 pReqMsg.channel = nla_get_s32(
5336 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
5337 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
5338
5339 /* Parse and fetch global operating class */
5340 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
5341 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
5342 return -EINVAL;
5343 }
5344 pReqMsg.global_operating_class = nla_get_s32(
5345 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
5346 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
5347 pReqMsg.global_operating_class);
5348
5349 /* Parse and fetch latency ms */
5350 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
5351 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
5352 return -EINVAL;
5353 }
5354 pReqMsg.max_latency_ms = nla_get_s32(
5355 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
5356 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
5357 pReqMsg.max_latency_ms);
5358
5359 /* Parse and fetch required bandwidth kbps */
5360 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
5361 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
5362 return -EINVAL;
5363 }
5364
5365 pReqMsg.min_bandwidth_kbps = nla_get_s32(
5366 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
5367 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
5368 pReqMsg.min_bandwidth_kbps);
5369
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305370 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05305371 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05305372 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305373 wlan_hdd_cfg80211_exttdls_callback);
5374
5375 EXIT();
5376 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05305377}
5378
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305379static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
5380 struct wireless_dev *wdev,
5381 const void *data,
5382 int data_len)
5383{
5384 int ret = 0;
5385
5386 vos_ssr_protect(__func__);
5387 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
5388 vos_ssr_unprotect(__func__);
5389
5390 return ret;
5391}
5392
5393static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305394 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305395 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305396 int data_len)
5397{
5398 u8 peer[6] = {0};
5399 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05305400 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5401 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
5402 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305403 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305404 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305405
5406 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305407
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305408 if (!dev) {
5409 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
5410 return -EINVAL;
5411 }
5412
5413 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5414 if (!pAdapter) {
5415 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
5416 return -EINVAL;
5417 }
5418
Atul Mittal115287b2014-07-08 13:26:33 +05305419 status = wlan_hdd_validate_context(pHddCtx);
5420 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305421 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305422 return -EINVAL;
5423 }
5424 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305425 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305426 return -ENOTSUPP;
5427 }
5428 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
5429 data, data_len,
5430 wlan_hdd_tdls_config_disable_policy)) {
5431 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5432 return -EINVAL;
5433 }
5434 /* Parse and fetch mac address */
5435 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
5436 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5437 return -EINVAL;
5438 }
5439
5440 memcpy(peer, nla_data(
5441 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
5442 sizeof(peer));
5443 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5444
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305445 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
5446
5447 EXIT();
5448 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05305449}
5450
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305451static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
5452 struct wireless_dev *wdev,
5453 const void *data,
5454 int data_len)
5455{
5456 int ret = 0;
5457
5458 vos_ssr_protect(__func__);
5459 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
5460 vos_ssr_unprotect(__func__);
5461
5462 return ret;
5463}
5464
Dasari Srinivas7875a302014-09-26 17:50:57 +05305465static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305466__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05305467 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305468 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05305469{
5470 struct net_device *dev = wdev->netdev;
5471 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5472 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5473 struct sk_buff *skb = NULL;
5474 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305475 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305476
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305477 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305478
5479 ret = wlan_hdd_validate_context(pHddCtx);
5480 if (0 != ret)
5481 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305482 return ret;
5483 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305484 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
5485 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
5486 fset |= WIFI_FEATURE_INFRA;
5487 }
5488
5489 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
5490 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
5491 fset |= WIFI_FEATURE_INFRA_5G;
5492 }
5493
5494#ifdef WLAN_FEATURE_P2P
5495 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
5496 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
5497 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
5498 fset |= WIFI_FEATURE_P2P;
5499 }
5500#endif
5501
5502 /* Soft-AP is supported currently by default */
5503 fset |= WIFI_FEATURE_SOFT_AP;
5504
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05305505 /* HOTSPOT is a supplicant feature, enable it by default */
5506 fset |= WIFI_FEATURE_HOTSPOT;
5507
Dasari Srinivas7875a302014-09-26 17:50:57 +05305508#ifdef WLAN_FEATURE_EXTSCAN
5509 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05305510 sme_IsFeatureSupportedByFW(EXTENDED_SCAN) &&
5511 sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)) {
5512 hddLog(LOG1, FL("Enhanced EXTScan is supported by firmware"));
Dasari Srinivas7875a302014-09-26 17:50:57 +05305513 fset |= WIFI_FEATURE_EXTSCAN;
5514 }
5515#endif
5516
Dasari Srinivas7875a302014-09-26 17:50:57 +05305517 if (sme_IsFeatureSupportedByFW(NAN)) {
5518 hddLog(LOG1, FL("NAN is supported by firmware"));
5519 fset |= WIFI_FEATURE_NAN;
5520 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305521
5522 /* D2D RTT is not supported currently by default */
5523 if (sme_IsFeatureSupportedByFW(RTT)) {
5524 hddLog(LOG1, FL("RTT is supported by firmware"));
5525 fset |= WIFI_FEATURE_D2AP_RTT;
5526 }
5527
5528#ifdef FEATURE_WLAN_BATCH_SCAN
5529 if (fset & WIFI_FEATURE_EXTSCAN) {
5530 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
5531 fset &= ~WIFI_FEATURE_BATCH_SCAN;
5532 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
5533 hddLog(LOG1, FL("Batch scan is supported by firmware"));
5534 fset |= WIFI_FEATURE_BATCH_SCAN;
5535 }
5536#endif
5537
5538#ifdef FEATURE_WLAN_SCAN_PNO
5539 if (pHddCtx->cfg_ini->configPNOScanSupport &&
5540 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
5541 hddLog(LOG1, FL("PNO is supported by firmware"));
5542 fset |= WIFI_FEATURE_PNO;
5543 }
5544#endif
5545
5546 /* STA+STA is supported currently by default */
5547 fset |= WIFI_FEATURE_ADDITIONAL_STA;
5548
5549#ifdef FEATURE_WLAN_TDLS
5550 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
5551 sme_IsFeatureSupportedByFW(TDLS)) {
5552 hddLog(LOG1, FL("TDLS is supported by firmware"));
5553 fset |= WIFI_FEATURE_TDLS;
5554 }
5555
5556 /* TDLS_OFFCHANNEL is not supported currently by default */
5557#endif
5558
5559#ifdef WLAN_AP_STA_CONCURRENCY
5560 /* AP+STA concurrency is supported currently by default */
5561 fset |= WIFI_FEATURE_AP_STA;
5562#endif
5563
Mukul Sharma5add0532015-08-17 15:57:47 +05305564#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5565 fset |= WIFI_FEATURE_LINK_LAYER_STATS;
5566 hddLog(LOG1, FL("Link layer stats is supported by driver"));
5567#endif
5568
Dasari Srinivas7875a302014-09-26 17:50:57 +05305569 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
5570 NLMSG_HDRLEN);
5571
5572 if (!skb) {
5573 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5574 return -EINVAL;
5575 }
5576 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
5577
5578 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
5579 hddLog(LOGE, FL("nla put fail"));
5580 goto nla_put_failure;
5581 }
5582
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305583 ret = cfg80211_vendor_cmd_reply(skb);
5584 EXIT();
5585 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305586
5587nla_put_failure:
5588 kfree_skb(skb);
5589 return -EINVAL;
5590}
5591
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305592static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305593wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
5594 struct wireless_dev *wdev,
5595 const void *data, int data_len)
5596{
5597 int ret = 0;
5598
5599 vos_ssr_protect(__func__);
5600 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
5601 vos_ssr_unprotect(__func__);
5602
5603 return ret;
5604}
5605
Sachin Ahujac08f72a2015-09-22 15:25:47 +05305606
5607static const struct
5608nla_policy
5609qca_wlan_vendor_wifi_logger_get_ring_data_policy
5610[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1] = {
5611 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]
5612 = {.type = NLA_U32 },
5613};
5614
5615static int
5616 __wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy,
5617 struct wireless_dev *wdev,
5618 const void *data,
5619 int data_len)
5620{
5621 int ret;
5622 VOS_STATUS status;
5623 uint32_t ring_id;
5624 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5625 struct nlattr *tb
5626 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1];
5627
5628 ENTER();
5629
5630 ret = wlan_hdd_validate_context(hdd_ctx);
5631 if (0 != ret) {
5632 return ret;
5633 }
5634
5635 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX,
5636 data, data_len,
5637 qca_wlan_vendor_wifi_logger_get_ring_data_policy)) {
5638 hddLog(LOGE, FL("Invalid attribute"));
5639 return -EINVAL;
5640 }
5641
5642 /* Parse and fetch ring id */
5643 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]) {
5644 hddLog(LOGE, FL("attr ATTR failed"));
5645 return -EINVAL;
5646 }
5647
5648 ring_id = nla_get_u32(
5649 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]);
5650
5651 hddLog(LOG1, FL("Bug report triggered by framework"));
5652
5653 status = vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
5654 WLAN_LOG_INDICATOR_FRAMEWORK,
5655 WLAN_LOG_REASON_CODE_FRAMEWORK,
Abhishek Singh837adf22015-10-01 17:37:37 +05305656 TRUE, TRUE
Sachin Ahujac08f72a2015-09-22 15:25:47 +05305657 );
5658 if (VOS_STATUS_SUCCESS != status) {
5659 hddLog(LOGE, FL("Failed to trigger bug report"));
5660
5661 return -EINVAL;
5662 }
5663
5664 return 0;
5665
5666
5667}
5668
5669
5670static int
5671 wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy,
5672 struct wireless_dev *wdev,
5673 const void *data,
5674 int data_len)
5675{
5676 int ret = 0;
5677
5678 vos_ssr_protect(__func__);
5679 ret = __wlan_hdd_cfg80211_wifi_logger_get_ring_data(wiphy,
5680 wdev, data, data_len);
5681 vos_ssr_unprotect(__func__);
5682
5683 return ret;
5684
5685}
5686
5687
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305688static int
5689__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305690 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305691 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305692{
5693 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
5694 uint8_t i, feature_sets, max_feature_sets;
5695 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX + 1];
5696 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305697 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5698 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305699
5700 ENTER();
5701
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305702 ret = wlan_hdd_validate_context(pHddCtx);
5703 if (0 != ret)
5704 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305705 return ret;
5706 }
5707
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305708 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX,
5709 data, data_len, NULL)) {
5710 hddLog(LOGE, FL("Invalid ATTR"));
5711 return -EINVAL;
5712 }
5713
5714 /* Parse and fetch max feature set */
5715 if (!tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
5716 hddLog(LOGE, FL("Attr max feature set size failed"));
5717 return -EINVAL;
5718 }
5719 max_feature_sets = nla_get_u32(
5720 tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
5721 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
5722
5723 /* Fill feature combination matrix */
5724 feature_sets = 0;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305725 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5726 WIFI_FEATURE_P2P;
5727
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305728 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5729 WIFI_FEATURE_SOFT_AP;
5730
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305731 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
5732 WIFI_FEATURE_SOFT_AP;
5733
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305734 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5735 WIFI_FEATURE_SOFT_AP |
5736 WIFI_FEATURE_P2P;
5737
5738 /* Add more feature combinations here */
5739
5740 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
5741 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
5742 hddLog(LOG1, "Feature set matrix");
5743 for (i = 0; i < feature_sets; i++)
5744 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
5745
5746 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
5747 sizeof(u32) * feature_sets +
5748 NLMSG_HDRLEN);
5749
5750 if (reply_skb) {
5751 if (nla_put_u32(reply_skb,
5752 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
5753 feature_sets) ||
5754 nla_put(reply_skb,
5755 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
5756 sizeof(u32) * feature_sets, feature_set_matrix)) {
5757 hddLog(LOGE, FL("nla put fail"));
5758 kfree_skb(reply_skb);
5759 return -EINVAL;
5760 }
5761
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305762 ret = cfg80211_vendor_cmd_reply(reply_skb);
5763 EXIT();
5764 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305765 }
5766 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
5767 return -ENOMEM;
5768
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305769}
5770
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305771static int
5772wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
5773 struct wireless_dev *wdev,
5774 const void *data, int data_len)
5775{
5776 int ret = 0;
5777
5778 vos_ssr_protect(__func__);
5779 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
5780 data_len);
5781 vos_ssr_unprotect(__func__);
5782
5783 return ret;
5784}
5785
c_manjeecfd1efb2015-09-25 19:32:34 +05305786
5787static int
5788__wlan_hdd_cfg80211_get_fw_mem_dump(struct wiphy *wiphy,
5789 struct wireless_dev *wdev,
5790 const void *data, int data_len)
5791{
5792 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5793 int ret;
5794 ENTER();
5795
5796 ret = wlan_hdd_validate_context(pHddCtx);
5797 if (0 != ret)
5798 {
5799 return ret;
5800 }
5801
5802 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
5803 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
5804 {
5805 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
5806 return -EINVAL;
5807 }
5808 /*call common API for FW mem dump req*/
5809 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
5810
5811 EXIT();
5812 return ret;
5813}
5814
5815/**
5816 * wlan_hdd_cfg80211_get_fw_mem_dump() - Get FW memory dump
5817 * @wiphy: pointer to wireless wiphy structure.
5818 * @wdev: pointer to wireless_dev structure.
5819 * @data: Pointer to the NL data.
5820 * @data_len:Length of @data
5821 *
5822 * This is called when wlan driver needs to get the firmware memory dump
5823 * via vendor specific command.
5824 *
5825 * Return: 0 on success, error number otherwise.
5826 */
5827
5828static int
5829wlan_hdd_cfg80211_get_fw_mem_dump(struct wiphy *wiphy,
5830 struct wireless_dev *wdev,
5831 const void *data, int data_len)
Sushant Kaushik8e644982015-09-23 12:18:54 +05305832{
5833 int ret = 0;
5834 vos_ssr_protect(__func__);
5835 ret = __wlan_hdd_cfg80211_get_fw_mem_dump(wiphy, wdev, data,
5836 data_len);
5837 vos_ssr_unprotect(__func__);
5838 return ret;
5839}
c_manjeecfd1efb2015-09-25 19:32:34 +05305840
Sushant Kaushik8e644982015-09-23 12:18:54 +05305841static const struct
5842nla_policy
5843qca_wlan_vendor_wifi_logger_start_policy
5844[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1] = {
5845 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]
5846 = {.type = NLA_U32 },
5847 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]
5848 = {.type = NLA_U32 },
5849 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]
5850 = {.type = NLA_U32 },
5851};
5852
5853/**
5854 * __wlan_hdd_cfg80211_wifi_logger_start() - This function is used to enable
5855 * or disable the collection of packet statistics from the firmware
5856 * @wiphy: WIPHY structure pointer
5857 * @wdev: Wireless device structure pointer
5858 * @data: Pointer to the data received
5859 * @data_len: Length of the data received
5860 *
5861 * This function is used to enable or disable the collection of packet
5862 * statistics from the firmware
5863 *
5864 * Return: 0 on success and errno on failure
5865 */
5866static int __wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy,
5867 struct wireless_dev *wdev,
5868 const void *data,
5869 int data_len)
5870{
5871 eHalStatus status;
5872 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5873 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1];
5874 tAniWifiStartLog start_log;
5875
5876 status = wlan_hdd_validate_context(hdd_ctx);
5877 if (0 != status) {
5878 return -EINVAL;
5879 }
5880
5881 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX,
5882 data, data_len,
5883 qca_wlan_vendor_wifi_logger_start_policy)) {
5884 hddLog(LOGE, FL("Invalid attribute"));
5885 return -EINVAL;
5886 }
5887
5888 /* Parse and fetch ring id */
5889 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]) {
5890 hddLog(LOGE, FL("attr ATTR failed"));
5891 return -EINVAL;
5892 }
5893 start_log.ringId = nla_get_u32(
5894 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]);
5895 hddLog(LOG1, FL("Ring ID=%d"), start_log.ringId);
5896
5897 /* Parse and fetch verbose level */
5898 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]) {
5899 hddLog(LOGE, FL("attr verbose_level failed"));
5900 return -EINVAL;
5901 }
5902 start_log.verboseLevel = nla_get_u32(
5903 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]);
5904 hddLog(LOG1, FL("verbose_level=%d"), start_log.verboseLevel);
5905
5906 /* Parse and fetch flag */
5907 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]) {
5908 hddLog(LOGE, FL("attr flag failed"));
5909 return -EINVAL;
5910 }
5911 start_log.flag = nla_get_u32(
5912 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]);
5913 hddLog(LOG1, FL("flag=%d"), start_log.flag);
5914
5915 if ((RING_ID_PER_PACKET_STATS == start_log.ringId) &&
Sushant Kaushik33200572015-08-05 16:46:20 +05305916 (!hdd_ctx->cfg_ini->wlanPerPktStatsLogEnable ||
5917 !vos_isPktStatsEnabled()))
5918
Sushant Kaushik8e644982015-09-23 12:18:54 +05305919 {
5920 hddLog(LOGE, FL("per pkt stats not enabled"));
5921 return -EINVAL;
5922 }
Sushant Kaushik8e644982015-09-23 12:18:54 +05305923
Sushant Kaushik33200572015-08-05 16:46:20 +05305924 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
Sushant Kaushik8e644982015-09-23 12:18:54 +05305925 return 0;
5926}
5927
5928/**
5929 * wlan_hdd_cfg80211_wifi_logger_start() - Wrapper function used to enable
5930 * or disable the collection of packet statistics from the firmware
5931 * @wiphy: WIPHY structure pointer
5932 * @wdev: Wireless device structure pointer
5933 * @data: Pointer to the data received
5934 * @data_len: Length of the data received
5935 *
5936 * This function is used to enable or disable the collection of packet
5937 * statistics from the firmware
5938 *
5939 * Return: 0 on success and errno on failure
5940 */
5941static int wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy,
5942 struct wireless_dev *wdev,
5943 const void *data,
5944 int data_len)
c_manjeecfd1efb2015-09-25 19:32:34 +05305945{
5946 int ret = 0;
5947
5948 vos_ssr_protect(__func__);
Sushant Kaushik8e644982015-09-23 12:18:54 +05305949
5950 ret = __wlan_hdd_cfg80211_wifi_logger_start(wiphy,
5951 wdev, data, data_len);
c_manjeecfd1efb2015-09-25 19:32:34 +05305952 vos_ssr_unprotect(__func__);
5953
5954 return ret;
c_manjeecfd1efb2015-09-25 19:32:34 +05305955}
5956
5957
Agarwal Ashish738843c2014-09-25 12:27:56 +05305958static const struct nla_policy
5959wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
5960 +1] =
5961{
5962 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
5963};
5964
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305965static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305966 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305967 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305968 int data_len)
5969{
5970 struct net_device *dev = wdev->netdev;
5971 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5972 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5973 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5974 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
5975 eHalStatus status;
5976 u32 dfsFlag = 0;
5977
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305978 ENTER();
5979
Agarwal Ashish738843c2014-09-25 12:27:56 +05305980 status = wlan_hdd_validate_context(pHddCtx);
5981 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05305982 return -EINVAL;
5983 }
5984 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
5985 data, data_len,
5986 wlan_hdd_set_no_dfs_flag_config_policy)) {
5987 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5988 return -EINVAL;
5989 }
5990
5991 /* Parse and fetch required bandwidth kbps */
5992 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
5993 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
5994 return -EINVAL;
5995 }
5996
5997 dfsFlag = nla_get_u32(
5998 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
5999 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
6000 dfsFlag);
6001
6002 pHddCtx->disable_dfs_flag = dfsFlag;
6003
6004 sme_disable_dfs_channel(hHal, dfsFlag);
6005 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306006
6007 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05306008 return 0;
6009}
Atul Mittal115287b2014-07-08 13:26:33 +05306010
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306011static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
6012 struct wireless_dev *wdev,
6013 const void *data,
6014 int data_len)
6015{
6016 int ret = 0;
6017
6018 vos_ssr_protect(__func__);
6019 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
6020 vos_ssr_unprotect(__func__);
6021
6022 return ret;
6023
6024}
6025
Mukul Sharma2a271632014-10-13 14:59:01 +05306026const struct
6027nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
6028{
6029 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
6030 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
6031};
6032
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306033static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05306034 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05306035{
6036
6037 u8 bssid[6] = {0};
6038 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6039 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
6040 eHalStatus status = eHAL_STATUS_SUCCESS;
6041 v_U32_t isFwrRoamEnabled = FALSE;
6042 int ret;
6043
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306044 ENTER();
6045
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306046 ret = wlan_hdd_validate_context(pHddCtx);
6047 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306048 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05306049 }
6050
6051 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
6052 data, data_len,
6053 qca_wlan_vendor_attr);
6054 if (ret){
6055 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
6056 return -EINVAL;
6057 }
6058
6059 /* Parse and fetch Enable flag */
6060 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
6061 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
6062 return -EINVAL;
6063 }
6064
6065 isFwrRoamEnabled = nla_get_u32(
6066 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
6067
6068 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
6069
6070 /* Parse and fetch bssid */
6071 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
6072 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
6073 return -EINVAL;
6074 }
6075
6076 memcpy(bssid, nla_data(
6077 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
6078 sizeof(bssid));
6079 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
6080
6081 //Update roaming
6082 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306083 EXIT();
Mukul Sharma2a271632014-10-13 14:59:01 +05306084 return status;
6085}
6086
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306087static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
6088 struct wireless_dev *wdev, const void *data, int data_len)
6089{
6090 int ret = 0;
6091
6092 vos_ssr_protect(__func__);
6093 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
6094 vos_ssr_unprotect(__func__);
6095
6096 return ret;
6097}
6098
Sushant Kaushik847890c2015-09-28 16:05:17 +05306099static const struct
6100nla_policy
6101qca_wlan_vendor_get_wifi_info_policy[
6102 QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX +1] = {
6103 [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION] = {.type = NLA_U8 },
6104 [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION] = {.type = NLA_U8 },
6105};
6106
6107
6108/**
6109 * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info
6110 * @wiphy: pointer to wireless wiphy structure.
6111 * @wdev: pointer to wireless_dev structure.
6112 * @data: Pointer to the data to be passed via vendor interface
6113 * @data_len:Length of the data to be passed
6114 *
6115 * This is called when wlan driver needs to send wifi driver related info
6116 * (driver/fw version) to the user space application upon request.
6117 *
6118 * Return: Return the Success or Failure code.
6119 */
6120static int __wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
6121 struct wireless_dev *wdev,
6122 const void *data, int data_len)
6123{
6124 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6125 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX + 1];
6126 tSirVersionString version;
6127 uint32 version_len;
6128 uint8 attr;
6129 int status;
6130 struct sk_buff *reply_skb = NULL;
6131
6132 if (VOS_FTM_MODE == hdd_get_conparam()) {
6133 hddLog(LOGE, FL("Command not allowed in FTM mode"));
6134 return -EINVAL;
6135 }
6136
6137 status = wlan_hdd_validate_context(hdd_ctx);
6138 if (0 != status) {
6139 hddLog(LOGE, FL("HDD context is not valid"));
6140 return -EINVAL;
6141 }
6142
6143 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX, data,
6144 data_len, qca_wlan_vendor_get_wifi_info_policy)) {
6145 hddLog(LOGE, FL("WIFI_INFO_GET NL CMD parsing failed"));
6146 return -EINVAL;
6147 }
6148
6149 if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) {
6150 hddLog(LOG1, FL("Rcvd req for Driver version Driver version is %s"),
6151 QWLAN_VERSIONSTR);
6152 strlcpy(version, QWLAN_VERSIONSTR, sizeof(version));
6153 attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION;
6154 } else if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION]) {
6155 hddLog(LOG1, FL("Rcvd req for FW version FW version is %s"),
6156 hdd_ctx->fw_Version);
6157 strlcpy(version, hdd_ctx->fw_Version, sizeof(version));
6158 attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION;
6159 } else {
6160 hddLog(LOGE, FL("Invalid attribute in get wifi info request"));
6161 return -EINVAL;
6162 }
6163
6164 version_len = strlen(version);
6165 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
6166 version_len + NLA_HDRLEN + NLMSG_HDRLEN);
6167 if (!reply_skb) {
6168 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
6169 return -ENOMEM;
6170 }
6171
6172 if (nla_put(reply_skb, attr, version_len, version)) {
6173 hddLog(LOGE, FL("nla put fail"));
6174 kfree_skb(reply_skb);
6175 return -EINVAL;
6176 }
6177
6178 return cfg80211_vendor_cmd_reply(reply_skb);
6179}
6180
6181/**
6182 * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info
6183 * @wiphy: pointer to wireless wiphy structure.
6184 * @wdev: pointer to wireless_dev structure.
6185 * @data: Pointer to the data to be passed via vendor interface
6186 * @data_len:Length of the data to be passed
6187 * @data_len: Length of the data received
6188 *
6189 * This function is used to enable or disable the collection of packet
6190 * statistics from the firmware
6191 *
6192 * Return: 0 on success and errno on failure
6193 */
6194
6195static int
6196wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
6197 struct wireless_dev *wdev,
6198 const void *data, int data_len)
6199
6200
6201{
6202 int ret = 0;
6203
6204 vos_ssr_protect(__func__);
6205 ret = __wlan_hdd_cfg80211_get_wifi_info(wiphy,
6206 wdev, data, data_len);
6207 vos_ssr_unprotect(__func__);
6208
6209 return ret;
6210}
6211
6212
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306213/*
6214 * define short names for the global vendor params
6215 * used by __wlan_hdd_cfg80211_monitor_rssi()
6216 */
6217#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX
6218#define PARAM_REQUEST_ID QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID
6219#define PARAM_CONTROL QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CONTROL
6220#define PARAM_MIN_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MIN_RSSI
6221#define PARAM_MAX_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX_RSSI
6222
6223/**---------------------------------------------------------------------------
6224
6225 \brief hdd_rssi_monitor_start_done - callback to be executed when rssi
6226 monitor start is completed successfully.
6227
6228 \return - None
6229
6230 --------------------------------------------------------------------------*/
6231void hdd_rssi_monitor_start_done(void *fwRssiMonitorCbContext, VOS_STATUS status)
6232{
6233 hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext;
6234
6235 if (NULL == pHddCtx)
6236 {
6237 hddLog(VOS_TRACE_LEVEL_ERROR,
6238 "%s: HDD context is NULL",__func__);
6239 return;
6240 }
6241
6242 if (VOS_STATUS_SUCCESS == status)
6243 {
6244 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor start successful"));
6245 }
6246 else
6247 {
6248 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor start not successful"));
6249 }
6250
6251 return;
6252}
6253
6254/**---------------------------------------------------------------------------
6255
6256 \brief hdd_rssi_monitor_stop_done - callback to be executed when rssi monitor
6257 stop is completed successfully.
6258
6259 \return - None
6260
6261 --------------------------------------------------------------------------*/
6262void hdd_rssi_monitor_stop_done(void *fwRssiMonitorCbContext, VOS_STATUS status)
6263{
6264 hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext;
6265
6266 if (NULL == pHddCtx)
6267 {
6268 hddLog(VOS_TRACE_LEVEL_ERROR,
6269 "%s: HDD context is NULL",__func__);
6270 return;
6271 }
6272
6273 if (VOS_STATUS_SUCCESS == status)
6274 {
6275 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor stop successful"));
6276 }
6277 else
6278 {
6279 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor stop not successful"));
6280 }
6281
6282 return;
6283}
6284
6285/**
6286 * __wlan_hdd_cfg80211_monitor_rssi() - monitor rssi
6287 * @wiphy: Pointer to wireless phy
6288 * @wdev: Pointer to wireless device
6289 * @data: Pointer to data
6290 * @data_len: Data length
6291 *
6292 * Return: 0 on success, negative errno on failure
6293 */
6294
6295static int
6296__wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy,
6297 struct wireless_dev *wdev,
6298 const void *data,
6299 int data_len)
6300{
6301 struct net_device *dev = wdev->netdev;
6302 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6303 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6304 hdd_station_ctx_t *pHddStaCtx;
6305 struct nlattr *tb[PARAM_MAX + 1];
6306 tpSirRssiMonitorReq pReq;
6307 eHalStatus status;
6308 int ret;
6309 uint32_t control;
6310 static const struct nla_policy policy[PARAM_MAX + 1] = {
6311 [PARAM_REQUEST_ID] = { .type = NLA_U32 },
6312 [PARAM_CONTROL] = { .type = NLA_U32 },
6313 [PARAM_MIN_RSSI] = { .type = NLA_S8 },
6314 [PARAM_MAX_RSSI] = { .type = NLA_S8 },
6315 };
6316
6317 ENTER();
6318
6319 ret = wlan_hdd_validate_context(hdd_ctx);
6320 if (0 != ret) {
6321 return -EINVAL;
6322 }
6323
6324 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
6325 hddLog(LOGE, FL("Not in Connected state!"));
6326 return -ENOTSUPP;
6327 }
6328
6329 if (nla_parse(tb, PARAM_MAX, data, data_len, policy)) {
6330 hddLog(LOGE, FL("Invalid ATTR"));
6331 return -EINVAL;
6332 }
6333
6334 if (!tb[PARAM_REQUEST_ID]) {
6335 hddLog(LOGE, FL("attr request id failed"));
6336 return -EINVAL;
6337 }
6338
6339 if (!tb[PARAM_CONTROL]) {
6340 hddLog(LOGE, FL("attr control failed"));
6341 return -EINVAL;
6342 }
6343
6344 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6345
6346 pReq = vos_mem_malloc(sizeof(tSirRssiMonitorReq));
6347 if(NULL == pReq)
6348 {
6349 hddLog(LOGE,
6350 FL("vos_mem_alloc failed "));
6351 return eHAL_STATUS_FAILED_ALLOC;
6352 }
6353 vos_mem_set(pReq, sizeof(tSirRssiMonitorReq), 0);
6354
6355 pReq->requestId = nla_get_u32(tb[PARAM_REQUEST_ID]);
6356 pReq->sessionId = pAdapter->sessionId;
6357 pReq->rssiMonitorCbContext = hdd_ctx;
6358 control = nla_get_u32(tb[PARAM_CONTROL]);
6359 vos_mem_copy( &pReq->currentBssId, pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
6360
6361 hddLog(LOG1, FL("Request Id: %u Session_id: %d Control: %d"),
6362 pReq->requestId, pReq->sessionId, control);
6363
6364 if (control == QCA_WLAN_RSSI_MONITORING_START) {
6365 if (!tb[PARAM_MIN_RSSI]) {
6366 hddLog(LOGE, FL("attr min rssi failed"));
6367 return -EINVAL;
6368 }
6369
6370 if (!tb[PARAM_MAX_RSSI]) {
6371 hddLog(LOGE, FL("attr max rssi failed"));
6372 return -EINVAL;
6373 }
6374
6375 pReq->minRssi = nla_get_s8(tb[PARAM_MIN_RSSI]);
6376 pReq->maxRssi = nla_get_s8(tb[PARAM_MAX_RSSI]);
6377 pReq->rssiMonitorCallback = hdd_rssi_monitor_start_done;
6378
6379 if (!(pReq->minRssi < pReq->maxRssi)) {
6380 hddLog(LOGW, FL("min_rssi: %d must be less than max_rssi: %d"),
6381 pReq->minRssi, pReq->maxRssi);
6382 return -EINVAL;
6383 }
6384 hddLog(LOG1, FL("Min_rssi: %d Max_rssi: %d"),
6385 pReq->minRssi, pReq->maxRssi);
6386 status = sme_StartRssiMonitoring(hdd_ctx->hHal, pReq);
6387
6388 }
6389 else if (control == QCA_WLAN_RSSI_MONITORING_STOP) {
6390 pReq->rssiMonitorCallback = hdd_rssi_monitor_stop_done;
6391 status = sme_StopRssiMonitoring(hdd_ctx->hHal, pReq);
6392 }
6393 else {
6394 hddLog(LOGE, FL("Invalid control cmd: %d"), control);
6395 return -EINVAL;
6396 }
6397
6398 if (!HAL_STATUS_SUCCESS(status)) {
6399 hddLog(LOGE,
6400 FL("sme_set_rssi_monitoring failed(err=%d)"), status);
6401 return -EINVAL;
6402 }
6403
6404 return 0;
6405}
6406
6407/*
6408 * done with short names for the global vendor params
6409 * used by __wlan_hdd_cfg80211_monitor_rssi()
6410 */
6411#undef PARAM_MAX
6412#undef PARAM_CONTROL
6413#undef PARAM_REQUEST_ID
6414#undef PARAM_MAX_RSSI
6415#undef PARAM_MIN_RSSI
6416
6417/**
6418 * wlan_hdd_cfg80211_monitor_rssi() - SSR wrapper to rssi monitoring
6419 * @wiphy: wiphy structure pointer
6420 * @wdev: Wireless device structure pointer
6421 * @data: Pointer to the data received
6422 * @data_len: Length of @data
6423 *
6424 * Return: 0 on success; errno on failure
6425 */
6426static int
6427wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy, struct wireless_dev *wdev,
6428 const void *data, int data_len)
6429{
6430 int ret;
6431
6432 vos_ssr_protect(__func__);
6433 ret = __wlan_hdd_cfg80211_monitor_rssi(wiphy, wdev, data, data_len);
6434 vos_ssr_unprotect(__func__);
6435
6436 return ret;
6437}
6438
6439/**
6440 * hdd_rssi_threshold_breached_cb() - rssi breached NL event
6441 * @hddctx: HDD context
6442 * @data: rssi breached event data
6443 *
6444 * This function reads the rssi breached event %data and fill in the skb with
6445 * NL attributes and send up the NL event.
6446 * This callback execute in atomic context and must not invoke any
6447 * blocking calls.
6448 *
6449 * Return: none
6450 */
6451void hdd_rssi_threshold_breached_cb(void *hddctx,
6452 struct rssi_breach_event *data)
6453{
6454 hdd_context_t *pHddCtx = (hdd_context_t *)hddctx;
6455 int status;
6456 struct sk_buff *skb;
6457
6458 ENTER();
6459 status = wlan_hdd_validate_context(pHddCtx);
6460
6461 if (0 != status) {
6462 return;
6463 }
6464
6465 if (!data) {
6466 hddLog(LOGE, FL("data is null"));
6467 return;
6468 }
6469
6470 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
6471#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
6472 NULL,
6473#endif
6474 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
6475 QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX,
6476 GFP_KERNEL);
6477
6478 if (!skb) {
6479 hddLog(LOGE, FL("cfg80211_vendor_event_alloc failed"));
6480 return;
6481 }
6482
6483 hddLog(LOG1, "Req Id: %u Current rssi: %d",
6484 data->request_id, data->curr_rssi);
6485 hddLog(LOG1, "Current BSSID: "MAC_ADDRESS_STR,
6486 MAC_ADDR_ARRAY(data->curr_bssid.bytes));
6487
6488 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID,
6489 data->request_id) ||
6490 nla_put(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_BSSID,
6491 sizeof(data->curr_bssid), data->curr_bssid.bytes) ||
6492 nla_put_s8(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_RSSI,
6493 data->curr_rssi)) {
6494 hddLog(LOGE, FL("nla put fail"));
6495 goto fail;
6496 }
6497
6498 cfg80211_vendor_event(skb, GFP_KERNEL);
6499 return;
6500
6501fail:
6502 kfree_skb(skb);
6503 return;
6504}
6505
6506
6507
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306508/**
6509 * __wlan_hdd_cfg80211_setband() - set band
6510 * @wiphy: Pointer to wireless phy
6511 * @wdev: Pointer to wireless device
6512 * @data: Pointer to data
6513 * @data_len: Data length
6514 *
6515 * Return: 0 on success, negative errno on failure
6516 */
6517static int
6518__wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
6519 struct wireless_dev *wdev,
6520 const void *data,
6521 int data_len)
6522{
6523 struct net_device *dev = wdev->netdev;
6524 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6525 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
6526 int ret;
6527 static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1]
6528 = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 }};
6529
6530 ENTER();
6531
6532 ret = wlan_hdd_validate_context(hdd_ctx);
6533 if (0 != ret) {
6534 hddLog(LOGE, FL("HDD context is not valid"));
6535 return ret;
6536 }
6537
6538 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
6539 policy)) {
6540 hddLog(LOGE, FL("Invalid ATTR"));
6541 return -EINVAL;
6542 }
6543
6544 if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) {
6545 hddLog(LOGE, FL("attr QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE failed"));
6546 return -EINVAL;
6547 }
6548
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05306549 hdd_ctx->isSetBandByNL = TRUE;
6550 ret = hdd_setBand(dev,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306551 nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]));
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05306552 hdd_ctx->isSetBandByNL = FALSE;
6553
6554 EXIT();
6555 return ret;
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306556}
6557
6558/**
6559 * wlan_hdd_cfg80211_setband() - Wrapper to offload packets
6560 * @wiphy: wiphy structure pointer
6561 * @wdev: Wireless device structure pointer
6562 * @data: Pointer to the data received
6563 * @data_len: Length of @data
6564 *
6565 * Return: 0 on success; errno on failure
6566 */
6567static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
6568 struct wireless_dev *wdev,
6569 const void *data,
6570 int data_len)
6571{
6572 int ret = 0;
6573
6574 vos_ssr_protect(__func__);
6575 ret = __wlan_hdd_cfg80211_setband(wiphy,
6576 wdev, data, data_len);
6577 vos_ssr_unprotect(__func__);
6578
6579 return ret;
6580}
6581
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05306582#ifdef WLAN_FEATURE_OFFLOAD_PACKETS
6583/**
6584 * hdd_map_req_id_to_pattern_id() - map request id to pattern id
6585 * @hdd_ctx: HDD context
6586 * @request_id: [input] request id
6587 * @pattern_id: [output] pattern id
6588 *
6589 * This function loops through request id to pattern id array
6590 * if the slot is available, store the request id and return pattern id
6591 * if entry exists, return the pattern id
6592 *
6593 * Return: 0 on success and errno on failure
6594 */
6595static int hdd_map_req_id_to_pattern_id(hdd_context_t *hdd_ctx,
6596 uint32_t request_id,
6597 uint8_t *pattern_id)
6598{
6599 uint32_t i;
6600
6601 mutex_lock(&hdd_ctx->op_ctx.op_lock);
6602 for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++)
6603 {
6604 if (hdd_ctx->op_ctx.op_table[i].request_id == 0)
6605 {
6606 hdd_ctx->op_ctx.op_table[i].request_id = request_id;
6607 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6608 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6609 return 0;
6610 } else if (hdd_ctx->op_ctx.op_table[i].request_id ==
6611 request_id) {
6612 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6613 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6614 return 0;
6615 }
6616 }
6617 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6618 return -EINVAL;
6619}
6620
6621/**
6622 * hdd_unmap_req_id_to_pattern_id() - unmap request id to pattern id
6623 * @hdd_ctx: HDD context
6624 * @request_id: [input] request id
6625 * @pattern_id: [output] pattern id
6626 *
6627 * This function loops through request id to pattern id array
6628 * reset request id to 0 (slot available again) and
6629 * return pattern id
6630 *
6631 * Return: 0 on success and errno on failure
6632 */
6633static int hdd_unmap_req_id_to_pattern_id(hdd_context_t *hdd_ctx,
6634 uint32_t request_id,
6635 uint8_t *pattern_id)
6636{
6637 uint32_t i;
6638
6639 mutex_lock(&hdd_ctx->op_ctx.op_lock);
6640 for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++)
6641 {
6642 if (hdd_ctx->op_ctx.op_table[i].request_id == request_id)
6643 {
6644 hdd_ctx->op_ctx.op_table[i].request_id = 0;
6645 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6646 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6647 return 0;
6648 }
6649 }
6650 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6651 return -EINVAL;
6652}
6653
6654
6655/*
6656 * define short names for the global vendor params
6657 * used by __wlan_hdd_cfg80211_offloaded_packets()
6658 */
6659#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_MAX
6660#define PARAM_REQUEST_ID \
6661 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_REQUEST_ID
6662#define PARAM_CONTROL \
6663 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SENDING_CONTROL
6664#define PARAM_IP_PACKET \
6665 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_IP_PACKET_DATA
6666#define PARAM_SRC_MAC_ADDR \
6667 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SRC_MAC_ADDR
6668#define PARAM_DST_MAC_ADDR \
6669 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_DST_MAC_ADDR
6670#define PARAM_PERIOD QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_PERIOD
6671
6672/**
6673 * wlan_hdd_add_tx_ptrn() - add tx pattern
6674 * @adapter: adapter pointer
6675 * @hdd_ctx: hdd context
6676 * @tb: nl attributes
6677 *
6678 * This function reads the NL attributes and forms a AddTxPtrn message
6679 * posts it to SME.
6680 *
6681 */
6682static int
6683wlan_hdd_add_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx,
6684 struct nlattr **tb)
6685{
6686 struct sSirAddPeriodicTxPtrn *add_req;
6687 eHalStatus status;
6688 uint32_t request_id, ret, len;
6689 uint8_t pattern_id = 0;
6690 v_MACADDR_t dst_addr;
6691 uint16_t eth_type = htons(ETH_P_IP);
6692
6693 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(adapter)))
6694 {
6695 hddLog(LOGE, FL("Not in Connected state!"));
6696 return -ENOTSUPP;
6697 }
6698
6699 add_req = vos_mem_malloc(sizeof(*add_req));
6700 if (!add_req)
6701 {
6702 hddLog(LOGE, FL("memory allocation failed"));
6703 return -ENOMEM;
6704 }
6705
6706 /* Parse and fetch request Id */
6707 if (!tb[PARAM_REQUEST_ID])
6708 {
6709 hddLog(LOGE, FL("attr request id failed"));
6710 goto fail;
6711 }
6712
6713 request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
6714 hddLog(LOG1, FL("Request Id: %u"), request_id);
6715 if (request_id == 0)
6716 {
6717 hddLog(LOGE, FL("request_id cannot be zero"));
6718 return -EINVAL;
6719 }
6720
6721 if (!tb[PARAM_PERIOD])
6722 {
6723 hddLog(LOGE, FL("attr period failed"));
6724 goto fail;
6725 }
6726 add_req->usPtrnIntervalMs = nla_get_u32(tb[PARAM_PERIOD]);
6727 hddLog(LOG1, FL("Period: %u ms"), add_req->usPtrnIntervalMs);
6728 if (add_req->usPtrnIntervalMs == 0)
6729 {
6730 hddLog(LOGE, FL("Invalid interval zero, return failure"));
6731 goto fail;
6732 }
6733
6734 if (!tb[PARAM_SRC_MAC_ADDR])
6735 {
6736 hddLog(LOGE, FL("attr source mac address failed"));
6737 goto fail;
6738 }
6739 nla_memcpy(add_req->macAddress, tb[PARAM_SRC_MAC_ADDR],
6740 VOS_MAC_ADDR_SIZE);
6741 hddLog(LOG1, "input src mac address: "MAC_ADDRESS_STR,
6742 MAC_ADDR_ARRAY(add_req->macAddress));
6743
6744 if (memcmp(add_req->macAddress, adapter->macAddressCurrent.bytes,
6745 VOS_MAC_ADDR_SIZE))
6746 {
6747 hddLog(LOGE,
6748 FL("input src mac address and connected ap bssid are different"));
6749 goto fail;
6750 }
6751
6752 if (!tb[PARAM_DST_MAC_ADDR])
6753 {
6754 hddLog(LOGE, FL("attr dst mac address failed"));
6755 goto fail;
6756 }
6757 nla_memcpy(dst_addr.bytes, tb[PARAM_DST_MAC_ADDR], VOS_MAC_ADDR_SIZE);
6758 hddLog(LOG1, "input dst mac address: "MAC_ADDRESS_STR,
6759 MAC_ADDR_ARRAY(dst_addr.bytes));
6760
6761 if (!tb[PARAM_IP_PACKET])
6762 {
6763 hddLog(LOGE, FL("attr ip packet failed"));
6764 goto fail;
6765 }
6766 add_req->ucPtrnSize = nla_len(tb[PARAM_IP_PACKET]);
6767 hddLog(LOG1, FL("IP packet len: %u"), add_req->ucPtrnSize);
6768
6769 if (add_req->ucPtrnSize < 0 ||
6770 add_req->ucPtrnSize > (PERIODIC_TX_PTRN_MAX_SIZE -
6771 HDD_ETH_HEADER_LEN))
6772 {
6773 hddLog(LOGE, FL("Invalid IP packet len: %d"),
6774 add_req->ucPtrnSize);
6775 goto fail;
6776 }
6777
6778 len = 0;
6779 vos_mem_copy(&add_req->ucPattern[0], dst_addr.bytes, VOS_MAC_ADDR_SIZE);
6780 len += VOS_MAC_ADDR_SIZE;
6781 vos_mem_copy(&add_req->ucPattern[len], add_req->macAddress,
6782 VOS_MAC_ADDR_SIZE);
6783 len += VOS_MAC_ADDR_SIZE;
6784 vos_mem_copy(&add_req->ucPattern[len], &eth_type, 2);
6785 len += 2;
6786
6787 /*
6788 * This is the IP packet, add 14 bytes Ethernet (802.3) header
6789 * ------------------------------------------------------------
6790 * | 14 bytes Ethernet (802.3) header | IP header and payload |
6791 * ------------------------------------------------------------
6792 */
6793 vos_mem_copy(&add_req->ucPattern[len],
6794 nla_data(tb[PARAM_IP_PACKET]),
6795 add_req->ucPtrnSize);
6796 add_req->ucPtrnSize += len;
6797
6798 VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6799 add_req->ucPattern, add_req->ucPtrnSize);
6800
6801 ret = hdd_map_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id);
6802 if (ret)
6803 {
6804 hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret);
6805 goto fail;
6806 }
6807 add_req->ucPtrnId = pattern_id;
6808 hddLog(LOG1, FL("pattern id: %d"), add_req->ucPtrnId);
6809
6810 status = sme_AddPeriodicTxPtrn(hdd_ctx->hHal, add_req);
6811 if (!HAL_STATUS_SUCCESS(status))
6812 {
6813 hddLog(LOGE,
6814 FL("sme_AddPeriodicTxPtrn failed (err=%d)"), status);
6815 goto fail;
6816 }
6817
6818 EXIT();
6819 vos_mem_free(add_req);
6820 return 0;
6821
6822fail:
6823 vos_mem_free(add_req);
6824 return -EINVAL;
6825}
6826
6827/**
6828 * wlan_hdd_del_tx_ptrn() - delete tx pattern
6829 * @adapter: adapter pointer
6830 * @hdd_ctx: hdd context
6831 * @tb: nl attributes
6832 *
6833 * This function reads the NL attributes and forms a DelTxPtrn message
6834 * posts it to SME.
6835 *
6836 */
6837static int
6838wlan_hdd_del_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx,
6839 struct nlattr **tb)
6840{
6841 struct sSirDelPeriodicTxPtrn *del_req;
6842 eHalStatus status;
6843 uint32_t request_id, ret;
6844 uint8_t pattern_id = 0;
6845
6846 /* Parse and fetch request Id */
6847 if (!tb[PARAM_REQUEST_ID])
6848 {
6849 hddLog(LOGE, FL("attr request id failed"));
6850 return -EINVAL;
6851 }
6852 request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
6853 if (request_id == 0)
6854 {
6855 hddLog(LOGE, FL("request_id cannot be zero"));
6856 return -EINVAL;
6857 }
6858
6859 ret = hdd_unmap_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id);
6860 if (ret)
6861 {
6862 hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret);
6863 return -EINVAL;
6864 }
6865
6866 del_req = vos_mem_malloc(sizeof(*del_req));
6867 if (!del_req)
6868 {
6869 hddLog(LOGE, FL("memory allocation failed"));
6870 return -ENOMEM;
6871 }
6872
6873 vos_mem_set(del_req, sizeof(*del_req), 0);
6874 vos_mem_copy(del_req->macAddress, adapter->macAddressCurrent.bytes,
6875 VOS_MAC_ADDR_SIZE);
6876 hddLog(LOG1, MAC_ADDRESS_STR, MAC_ADDR_ARRAY(del_req->macAddress));
6877 del_req->ucPatternIdBitmap |= (0x1 << pattern_id);
6878 hddLog(LOG1, FL("Request Id: %u Pattern id: %d, bitmap %04x"),
6879 request_id, pattern_id, del_req->ucPatternIdBitmap);
6880
6881 status = sme_DelPeriodicTxPtrn(hdd_ctx->hHal, del_req);
6882 if (!HAL_STATUS_SUCCESS(status))
6883 {
6884 hddLog(LOGE,
6885 FL("sme_DelPeriodicTxPtrn failed (err=%d)"), status);
6886 goto fail;
6887 }
6888
6889 EXIT();
6890 vos_mem_free(del_req);
6891 return 0;
6892
6893fail:
6894 vos_mem_free(del_req);
6895 return -EINVAL;
6896}
6897
6898
6899/**
6900 * __wlan_hdd_cfg80211_offloaded_packets() - send offloaded packets
6901 * @wiphy: Pointer to wireless phy
6902 * @wdev: Pointer to wireless device
6903 * @data: Pointer to data
6904 * @data_len: Data length
6905 *
6906 * Return: 0 on success, negative errno on failure
6907 */
6908static int
6909__wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy,
6910 struct wireless_dev *wdev,
6911 const void *data,
6912 int data_len)
6913{
6914 struct net_device *dev = wdev->netdev;
6915 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6916 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6917 struct nlattr *tb[PARAM_MAX + 1];
6918 uint8_t control;
6919 int ret;
6920 static const struct nla_policy policy[PARAM_MAX + 1] =
6921 {
6922 [PARAM_REQUEST_ID] = { .type = NLA_U32 },
6923 [PARAM_CONTROL] = { .type = NLA_U32 },
6924 [PARAM_SRC_MAC_ADDR] = { .type = NLA_BINARY,
6925 .len = VOS_MAC_ADDR_SIZE },
6926 [PARAM_DST_MAC_ADDR] = { .type = NLA_BINARY,
6927 .len = VOS_MAC_ADDR_SIZE },
6928 [PARAM_PERIOD] = { .type = NLA_U32 },
6929 };
6930
6931 ENTER();
6932
6933 ret = wlan_hdd_validate_context(hdd_ctx);
6934 if (0 != ret)
6935 {
6936 hddLog(LOGE, FL("HDD context is not valid"));
6937 return ret;
6938 }
6939
6940 if (!sme_IsFeatureSupportedByFW(WLAN_PERIODIC_TX_PTRN))
6941 {
6942 hddLog(LOGE,
6943 FL("Periodic Tx Pattern Offload feature is not supported in FW!"));
6944 return -ENOTSUPP;
6945 }
6946
6947 if (nla_parse(tb, PARAM_MAX, data, data_len, policy))
6948 {
6949 hddLog(LOGE, FL("Invalid ATTR"));
6950 return -EINVAL;
6951 }
6952
6953 if (!tb[PARAM_CONTROL])
6954 {
6955 hddLog(LOGE, FL("attr control failed"));
6956 return -EINVAL;
6957 }
6958 control = nla_get_u32(tb[PARAM_CONTROL]);
6959 hddLog(LOG1, FL("Control: %d"), control);
6960
6961 if (control == WLAN_START_OFFLOADED_PACKETS)
6962 return wlan_hdd_add_tx_ptrn(adapter, hdd_ctx, tb);
6963 else if (control == WLAN_STOP_OFFLOADED_PACKETS)
6964 return wlan_hdd_del_tx_ptrn(adapter, hdd_ctx, tb);
6965 else
6966 {
6967 hddLog(LOGE, FL("Invalid control: %d"), control);
6968 return -EINVAL;
6969 }
6970}
6971
6972/*
6973 * done with short names for the global vendor params
6974 * used by __wlan_hdd_cfg80211_offloaded_packets()
6975 */
6976#undef PARAM_MAX
6977#undef PARAM_REQUEST_ID
6978#undef PARAM_CONTROL
6979#undef PARAM_IP_PACKET
6980#undef PARAM_SRC_MAC_ADDR
6981#undef PARAM_DST_MAC_ADDR
6982#undef PARAM_PERIOD
6983
6984/**
6985 * wlan_hdd_cfg80211_offloaded_packets() - Wrapper to offload packets
6986 * @wiphy: wiphy structure pointer
6987 * @wdev: Wireless device structure pointer
6988 * @data: Pointer to the data received
6989 * @data_len: Length of @data
6990 *
6991 * Return: 0 on success; errno on failure
6992 */
6993static int wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy,
6994 struct wireless_dev *wdev,
6995 const void *data,
6996 int data_len)
6997{
6998 int ret = 0;
6999
7000 vos_ssr_protect(__func__);
7001 ret = __wlan_hdd_cfg80211_offloaded_packets(wiphy,
7002 wdev, data, data_len);
7003 vos_ssr_unprotect(__func__);
7004
7005 return ret;
7006}
7007#endif
7008
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307009static const struct
7010nla_policy
7011qca_wlan_vendor_attr_policy[QCA_WLAN_VENDOR_ATTR_MAX+1] = {
7012 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
7013};
7014
7015/**
7016 * wlan_hdd_cfg80211_get_link_properties() - This function is used to
7017 * get link properties like nss, rate flags and operating frequency for
7018 * the connection with the given peer.
7019 * @wiphy: WIPHY structure pointer
7020 * @wdev: Wireless device structure pointer
7021 * @data: Pointer to the data received
7022 * @data_len: Length of the data received
7023 *
7024 * This function return the above link properties on success.
7025 *
7026 * Return: 0 on success and errno on failure
7027 */
7028static int wlan_hdd_cfg80211_get_link_properties(struct wiphy *wiphy,
7029 struct wireless_dev *wdev,
7030 const void *data,
7031 int data_len)
7032{
7033 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7034 struct net_device *dev = wdev->netdev;
7035 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7036 hdd_station_ctx_t *hdd_sta_ctx;
7037 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX+1];
7038 uint8_t peer_mac[VOS_MAC_ADDR_SIZE];
7039 uint32_t sta_id;
7040 struct sk_buff *reply_skb;
7041 uint32_t rate_flags = 0;
7042 uint8_t nss;
7043 uint8_t final_rate_flags = 0;
7044 uint32_t freq;
7045 v_CONTEXT_t pVosContext = NULL;
7046 ptSapContext pSapCtx = NULL;
7047
7048 if (0 != wlan_hdd_validate_context(hdd_ctx)) {
7049 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
7050 return -EINVAL;
7051 }
7052
7053 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
7054 qca_wlan_vendor_attr_policy)) {
7055 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid attribute"));
7056 return -EINVAL;
7057 }
7058
7059 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
7060 hddLog(VOS_TRACE_LEVEL_ERROR,
7061 FL("Attribute peerMac not provided for mode=%d"),
7062 adapter->device_mode);
7063 return -EINVAL;
7064 }
7065
7066 memcpy(peer_mac, nla_data(tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
7067 sizeof(peer_mac));
7068 hddLog(VOS_TRACE_LEVEL_INFO,
7069 FL("peerMac="MAC_ADDRESS_STR" for device_mode:%d"),
7070 MAC_ADDR_ARRAY(peer_mac), adapter->device_mode);
7071
7072 if (adapter->device_mode == WLAN_HDD_INFRA_STATION ||
7073 adapter->device_mode == WLAN_HDD_P2P_CLIENT) {
7074 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
7075 if ((hdd_sta_ctx->conn_info.connState !=
7076 eConnectionState_Associated) ||
7077 !vos_mem_compare(hdd_sta_ctx->conn_info.bssId, peer_mac,
7078 VOS_MAC_ADDRESS_LEN)) {
7079 hddLog(VOS_TRACE_LEVEL_ERROR,
7080 FL("Not Associated to mac "MAC_ADDRESS_STR),
7081 MAC_ADDR_ARRAY(peer_mac));
7082 return -EINVAL;
7083 }
7084
7085 nss = 1; //pronto supports only one spatial stream
7086 freq = vos_chan_to_freq(
7087 hdd_sta_ctx->conn_info.operationChannel);
7088 rate_flags = hdd_sta_ctx->conn_info.rate_flags;
7089
7090 } else if (adapter->device_mode == WLAN_HDD_P2P_GO ||
7091 adapter->device_mode == WLAN_HDD_SOFTAP) {
7092
7093 pVosContext = ( WLAN_HDD_GET_CTX(adapter))->pvosContext;
7094 pSapCtx = VOS_GET_SAP_CB(pVosContext);
7095 if(pSapCtx == NULL){
7096 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7097 FL("psapCtx is NULL"));
7098 return -ENOENT;
7099 }
7100
7101
7102 for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) {
7103 if (pSapCtx->aStaInfo[sta_id].isUsed &&
7104 !vos_is_macaddr_broadcast(
7105 &pSapCtx->aStaInfo[sta_id].macAddrSTA) &&
7106 vos_mem_compare(
7107 &pSapCtx->aStaInfo[sta_id].macAddrSTA,
7108 peer_mac, VOS_MAC_ADDRESS_LEN))
7109 break;
7110 }
7111
7112 if (WLAN_MAX_STA_COUNT == sta_id) {
7113 hddLog(VOS_TRACE_LEVEL_ERROR,
7114 FL("No active peer with mac="MAC_ADDRESS_STR),
7115 MAC_ADDR_ARRAY(peer_mac));
7116 return -EINVAL;
7117 }
7118
7119 nss = 1; //pronto supports only one spatial stream
7120 freq = vos_chan_to_freq(
7121 (WLAN_HDD_GET_AP_CTX_PTR(adapter))->operatingChannel);
7122 rate_flags = pSapCtx->aStaInfo[sta_id].rate_flags;
7123 } else {
7124 hddLog(VOS_TRACE_LEVEL_ERROR,
7125 FL("Not Associated! with mac"MAC_ADDRESS_STR),
7126 MAC_ADDR_ARRAY(peer_mac));
7127 return -EINVAL;
7128 }
7129
7130 if (!(rate_flags & eHAL_TX_RATE_LEGACY)) {
7131 if (rate_flags & eHAL_TX_RATE_VHT80) {
7132 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
7133 final_rate_flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
7134 } else if (rate_flags & eHAL_TX_RATE_VHT40) {
7135 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
7136 final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7137 } else if (rate_flags & eHAL_TX_RATE_VHT20) {
7138 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
7139 } else if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) {
7140 final_rate_flags |= RATE_INFO_FLAGS_MCS;
7141 if (rate_flags & eHAL_TX_RATE_HT40)
7142 final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7143 }
7144
7145 if (rate_flags & eHAL_TX_RATE_SGI) {
7146 if (!(final_rate_flags & RATE_INFO_FLAGS_VHT_MCS))
7147 final_rate_flags |= RATE_INFO_FLAGS_MCS;
7148 final_rate_flags |= RATE_INFO_FLAGS_SHORT_GI;
7149 }
7150 }
7151
7152 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
7153 sizeof(u8) + sizeof(u8) + sizeof(u32) + NLMSG_HDRLEN);
7154
7155 if (NULL == reply_skb) {
7156 hddLog(VOS_TRACE_LEVEL_ERROR,
7157 FL("getLinkProperties: skb alloc failed"));
7158 return -EINVAL;
7159 }
7160
7161 if (nla_put_u8(reply_skb,
7162 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_NSS,
7163 nss) ||
7164 nla_put_u8(reply_skb,
7165 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_RATE_FLAGS,
7166 final_rate_flags) ||
7167 nla_put_u32(reply_skb,
7168 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_FREQ,
7169 freq)) {
7170 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_put failed"));
7171 kfree_skb(reply_skb);
7172 return -EINVAL;
7173 }
7174
7175 return cfg80211_vendor_cmd_reply(reply_skb);
7176}
7177
Sunil Duttc69bccb2014-05-26 21:30:20 +05307178const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
7179{
Mukul Sharma2a271632014-10-13 14:59:01 +05307180 {
7181 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7182 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
7183 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7184 WIPHY_VENDOR_CMD_NEED_NETDEV |
7185 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307186 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05307187 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05307188
7189 {
7190 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7191 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
7192 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7193 WIPHY_VENDOR_CMD_NEED_NETDEV |
7194 WIPHY_VENDOR_CMD_NEED_RUNNING,
7195 .doit = wlan_hdd_cfg80211_nan_request
7196 },
7197
Sunil Duttc69bccb2014-05-26 21:30:20 +05307198#ifdef WLAN_FEATURE_LINK_LAYER_STATS
7199 {
7200 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7201 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
7202 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7203 WIPHY_VENDOR_CMD_NEED_NETDEV |
7204 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307205 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05307206 },
7207
7208 {
7209 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7210 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
7211 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7212 WIPHY_VENDOR_CMD_NEED_NETDEV |
7213 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307214 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05307215 },
7216
7217 {
7218 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7219 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
7220 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7221 WIPHY_VENDOR_CMD_NEED_NETDEV |
7222 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307223 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05307224 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05307225#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05307226#ifdef WLAN_FEATURE_EXTSCAN
7227 {
7228 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7229 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
7230 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7231 WIPHY_VENDOR_CMD_NEED_NETDEV |
7232 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307233 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05307234 },
7235 {
7236 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7237 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
7238 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7239 WIPHY_VENDOR_CMD_NEED_NETDEV |
7240 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307241 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05307242 },
7243 {
7244 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7245 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
7246 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7247 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307248 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05307249 },
7250 {
7251 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7252 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
7253 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7254 WIPHY_VENDOR_CMD_NEED_NETDEV |
7255 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307256 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05307257 },
7258 {
7259 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7260 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
7261 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7262 WIPHY_VENDOR_CMD_NEED_NETDEV |
7263 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307264 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05307265 },
7266 {
7267 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7268 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
7269 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7270 WIPHY_VENDOR_CMD_NEED_NETDEV |
7271 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307272 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05307273 },
7274 {
7275 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7276 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
7277 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7278 WIPHY_VENDOR_CMD_NEED_NETDEV |
7279 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307280 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05307281 },
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05307282 {
7283 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7284 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST,
7285 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7286 WIPHY_VENDOR_CMD_NEED_NETDEV |
7287 WIPHY_VENDOR_CMD_NEED_RUNNING,
7288 .doit = wlan_hdd_cfg80211_extscan_set_ssid_hotlist
7289 },
7290 {
7291 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7292 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SSID_HOTLIST,
7293 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7294 WIPHY_VENDOR_CMD_NEED_NETDEV |
7295 WIPHY_VENDOR_CMD_NEED_RUNNING,
7296 .doit = wlan_hdd_cfg80211_extscan_reset_ssid_hotlist
7297 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05307298#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05307299/*EXT TDLS*/
7300 {
7301 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7302 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
7303 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7304 WIPHY_VENDOR_CMD_NEED_NETDEV |
7305 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307306 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05307307 },
7308 {
7309 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7310 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
7311 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7312 WIPHY_VENDOR_CMD_NEED_NETDEV |
7313 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307314 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05307315 },
7316 {
7317 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7318 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
7319 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7320 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307321 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05307322 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05307323 {
7324 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7325 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
7326 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7327 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307328 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05307329 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05307330 {
7331 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7332 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
7333 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7334 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307335 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05307336 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05307337 {
7338 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7339 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
7340 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7341 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307342 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05307343 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05307344 {
7345 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7346 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
7347 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7348 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307349 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05307350 },
Srinivas Dasari41d97c92015-07-29 13:09:39 +05307351 {
7352 .info.vendor_id = QCA_NL80211_VENDOR_ID,
c_manjeecfd1efb2015-09-25 19:32:34 +05307353 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP,
7354 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7355 WIPHY_VENDOR_CMD_NEED_NETDEV |
7356 WIPHY_VENDOR_CMD_NEED_RUNNING,
7357 .doit = wlan_hdd_cfg80211_get_fw_mem_dump
7358 },
7359 {
7360 .info.vendor_id = QCA_NL80211_VENDOR_ID,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05307361 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND,
7362 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7363 WIPHY_VENDOR_CMD_NEED_NETDEV |
7364 WIPHY_VENDOR_CMD_NEED_RUNNING,
7365 .doit = wlan_hdd_cfg80211_setband
Sushant Kaushik8e644982015-09-23 12:18:54 +05307366 },
7367 {
7368 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7369 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_START,
7370 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7371 WIPHY_VENDOR_CMD_NEED_NETDEV,
7372 .doit = wlan_hdd_cfg80211_wifi_logger_start
7373 },
Sushant Kaushik847890c2015-09-28 16:05:17 +05307374 {
7375 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7376 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
7377 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7378 WIPHY_VENDOR_CMD_NEED_NETDEV|
7379 WIPHY_VENDOR_CMD_NEED_RUNNING,
7380 .doit = wlan_hdd_cfg80211_get_wifi_info
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307381 },
7382 {
7383 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7384 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_RING_DATA,
7385 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7386 WIPHY_VENDOR_CMD_NEED_NETDEV |
7387 WIPHY_VENDOR_CMD_NEED_RUNNING,
7388 .doit = wlan_hdd_cfg80211_wifi_logger_get_ring_data
Gupta, Kapil7c34b322015-09-30 13:12:35 +05307389 },
7390 {
7391 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7392 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI,
7393 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7394 WIPHY_VENDOR_CMD_NEED_NETDEV |
7395 WIPHY_VENDOR_CMD_NEED_RUNNING,
7396 .doit = wlan_hdd_cfg80211_monitor_rssi
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05307397 },
7398#ifdef WLAN_FEATURE_OFFLOAD_PACKETS
7399 {
7400 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7401 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OFFLOADED_PACKETS,
7402 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7403 WIPHY_VENDOR_CMD_NEED_NETDEV |
7404 WIPHY_VENDOR_CMD_NEED_RUNNING,
7405 .doit = wlan_hdd_cfg80211_offloaded_packets
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307406 },
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05307407#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307408 {
7409 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7410 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES,
7411 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7412 WIPHY_VENDOR_CMD_NEED_NETDEV |
7413 WIPHY_VENDOR_CMD_NEED_RUNNING,
7414 .doit = wlan_hdd_cfg80211_get_link_properties
7415 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05307416};
7417
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007418/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05307419static const
7420struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007421{
7422#ifdef FEATURE_WLAN_CH_AVOID
7423 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05307424 .vendor_id = QCA_NL80211_VENDOR_ID,
7425 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007426 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05307427#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
7428#ifdef WLAN_FEATURE_LINK_LAYER_STATS
7429 {
7430 /* Index = 1*/
7431 .vendor_id = QCA_NL80211_VENDOR_ID,
7432 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
7433 },
7434 {
7435 /* Index = 2*/
7436 .vendor_id = QCA_NL80211_VENDOR_ID,
7437 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
7438 },
7439 {
7440 /* Index = 3*/
7441 .vendor_id = QCA_NL80211_VENDOR_ID,
7442 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
7443 },
7444 {
7445 /* Index = 4*/
7446 .vendor_id = QCA_NL80211_VENDOR_ID,
7447 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
7448 },
7449 {
7450 /* Index = 5*/
7451 .vendor_id = QCA_NL80211_VENDOR_ID,
7452 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
7453 },
7454 {
7455 /* Index = 6*/
7456 .vendor_id = QCA_NL80211_VENDOR_ID,
7457 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
7458 },
7459#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05307460#ifdef WLAN_FEATURE_EXTSCAN
7461 {
7462 .vendor_id = QCA_NL80211_VENDOR_ID,
7463 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
7464 },
7465 {
7466 .vendor_id = QCA_NL80211_VENDOR_ID,
7467 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
7468 },
7469 {
7470 .vendor_id = QCA_NL80211_VENDOR_ID,
7471 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
7472 },
7473 {
7474 .vendor_id = QCA_NL80211_VENDOR_ID,
7475 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
7476 },
7477 {
7478 .vendor_id = QCA_NL80211_VENDOR_ID,
7479 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
7480 },
7481 {
7482 .vendor_id = QCA_NL80211_VENDOR_ID,
7483 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
7484 },
7485 {
7486 .vendor_id = QCA_NL80211_VENDOR_ID,
7487 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
7488 },
7489 {
7490 .vendor_id = QCA_NL80211_VENDOR_ID,
7491 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
7492 },
7493 {
7494 .vendor_id = QCA_NL80211_VENDOR_ID,
7495 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
7496 },
7497 {
7498 .vendor_id = QCA_NL80211_VENDOR_ID,
7499 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
7500 },
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05307501 {
7502 .vendor_id = QCA_NL80211_VENDOR_ID,
7503 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST
7504 },
7505 {
7506 .vendor_id = QCA_NL80211_VENDOR_ID,
7507 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SSID_HOTLIST
7508 },
7509 [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND_INDEX] = {
7510 .vendor_id = QCA_NL80211_VENDOR_ID,
7511 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND
7512 },
7513 [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST_INDEX] = {
7514 .vendor_id = QCA_NL80211_VENDOR_ID,
7515 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST
7516 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05307517#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05307518/*EXT TDLS*/
7519 {
7520 .vendor_id = QCA_NL80211_VENDOR_ID,
7521 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
7522 },
c_manjeecfd1efb2015-09-25 19:32:34 +05307523 [QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP_INDEX] = {
7524 .vendor_id = QCA_NL80211_VENDOR_ID,
7525 .subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP
7526 },
7527
Srinivas Dasari030bad32015-02-18 23:23:54 +05307528
7529 {
7530 .vendor_id = QCA_NL80211_VENDOR_ID,
7531 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
7532 },
7533
Sushant Kaushik084f6592015-09-10 13:11:56 +05307534 {
7535 .vendor_id = QCA_NL80211_VENDOR_ID,
7536 .subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
Gupta, Kapil7c34b322015-09-30 13:12:35 +05307537 },
7538 [QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX] = {
7539 .vendor_id = QCA_NL80211_VENDOR_ID,
7540 .subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI
7541 },
Sushant Kaushik084f6592015-09-10 13:11:56 +05307542
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007543};
7544
Jeff Johnson295189b2012-06-20 16:38:30 -07007545/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307546 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307547 * This function is called by hdd_wlan_startup()
7548 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307549 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07007550 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307551struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07007552{
7553 struct wiphy *wiphy;
7554 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307555 /*
7556 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07007557 */
7558 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
7559
7560 if (!wiphy)
7561 {
7562 /* Print error and jump into err label and free the memory */
7563 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
7564 return NULL;
7565 }
7566
Sunil Duttc69bccb2014-05-26 21:30:20 +05307567
Jeff Johnson295189b2012-06-20 16:38:30 -07007568 return wiphy;
7569}
7570
7571/*
7572 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307573 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07007574 * private ioctl to change the band value
7575 */
7576int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
7577{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307578 int i, j;
7579 eNVChannelEnabledType channelEnabledState;
7580
Jeff Johnsone7245742012-09-05 17:12:55 -07007581 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307582
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307583 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07007584 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307585
7586 if (NULL == wiphy->bands[i])
7587 {
7588 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
7589 __func__, i);
7590 continue;
7591 }
7592
7593 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
7594 {
7595 struct ieee80211_supported_band *band = wiphy->bands[i];
7596
7597 channelEnabledState = vos_nv_getChannelEnabledState(
7598 band->channels[j].hw_value);
7599
7600 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
7601 {
Abhishek Singh678227a2014-11-04 10:52:38 +05307602 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307603 continue;
7604 }
7605 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
7606 {
7607 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
7608 continue;
7609 }
7610
7611 if (NV_CHANNEL_DISABLE == channelEnabledState ||
7612 NV_CHANNEL_INVALID == channelEnabledState)
7613 {
7614 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
7615 }
7616 else if (NV_CHANNEL_DFS == channelEnabledState)
7617 {
7618 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
7619 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
7620 }
7621 else
7622 {
7623 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
7624 |IEEE80211_CHAN_RADAR);
7625 }
7626 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007627 }
7628 return 0;
7629}
7630/*
7631 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307632 * This function is called by hdd_wlan_startup()
7633 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07007634 * This function is used to initialize and register wiphy structure.
7635 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307636int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07007637 struct wiphy *wiphy,
7638 hdd_config_t *pCfg
7639 )
7640{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307641 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05307642 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7643
Jeff Johnsone7245742012-09-05 17:12:55 -07007644 ENTER();
7645
Jeff Johnson295189b2012-06-20 16:38:30 -07007646 /* Now bind the underlying wlan device with wiphy */
7647 set_wiphy_dev(wiphy, dev);
7648
7649 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07007650
Kiet Lam6c583332013-10-14 05:37:09 +05307651#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07007652 /* the flag for the other case would be initialzed in
7653 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07007654 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05307655#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07007656
Amar Singhalfddc28c2013-09-05 13:03:40 -07007657 /* This will disable updating of NL channels from passive to
7658 * active if a beacon is received on passive channel. */
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307659#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
7660 wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS;
7661#else
Amar Singhalfddc28c2013-09-05 13:03:40 -07007662 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307663#endif
Amar Singhalfddc28c2013-09-05 13:03:40 -07007664
Amar Singhala49cbc52013-10-08 18:37:44 -07007665
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007666#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07007667 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
7668 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
7669 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07007670 | WIPHY_FLAG_OFFCHAN_TX;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307671#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
7672 wiphy->regulatory_flags = REGULATORY_COUNTRY_IE_IGNORE;
7673#else
7674 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
7675#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007676#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07007677
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007678#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07007679 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08007680#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07007681 || pCfg->isFastRoamIniFeatureEnabled
7682#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007683#ifdef FEATURE_WLAN_ESE
7684 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07007685#endif
7686 )
7687 {
7688 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
7689 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08007690#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007691#ifdef FEATURE_WLAN_TDLS
7692 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
7693 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
7694#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307695#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05307696 if (pCfg->configPNOScanSupport)
7697 {
7698 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
7699 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
7700 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
7701 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
7702 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307703#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007704
Abhishek Singh10d85972015-04-17 10:27:23 +05307705#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7706 wiphy->features |= NL80211_FEATURE_HT_IBSS;
7707#endif
7708
Amar Singhalfddc28c2013-09-05 13:03:40 -07007709#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07007710 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
7711 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07007712 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07007713 driver need to determine what to do with both
7714 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07007715
7716 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07007717#else
7718 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07007719#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007720
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307721 wiphy->max_scan_ssids = MAX_SCAN_SSID;
7722
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05307723 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07007724
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307725 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
7726
Jeff Johnson295189b2012-06-20 16:38:30 -07007727 /* Supports STATION & AD-HOC modes right now */
Bhargav Shah0d2e3e52015-07-24 16:51:01 +05307728 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
7729 | BIT(NL80211_IFTYPE_ADHOC)
7730 | BIT(NL80211_IFTYPE_P2P_CLIENT)
7731 | BIT(NL80211_IFTYPE_P2P_GO)
7732 | BIT(NL80211_IFTYPE_AP);
7733
7734 if (VOS_MONITOR_MODE == hdd_get_conparam())
7735 {
7736 wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR);
7737 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007738
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05307739 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08007740 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05307741#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7742 if( pCfg->enableMCC )
7743 {
7744 /* Currently, supports up to two channels */
7745 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08007746
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05307747 if( !pCfg->allowMCCGODiffBI )
7748 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08007749
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05307750 }
7751 wiphy->iface_combinations = &wlan_hdd_iface_combination;
7752 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08007753#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05307754 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08007755
Jeff Johnson295189b2012-06-20 16:38:30 -07007756 /* Before registering we need to update the ht capabilitied based
7757 * on ini values*/
7758 if( !pCfg->ShortGI20MhzEnable )
7759 {
7760 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
7761 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
7762 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
7763 }
7764
7765 if( !pCfg->ShortGI40MhzEnable )
7766 {
7767 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
7768 }
7769
7770 if( !pCfg->nChannelBondingMode5GHz )
7771 {
7772 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
7773 }
7774
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307775 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05307776 if (true == hdd_is_5g_supported(pHddCtx))
7777 {
7778 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
7779 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307780
7781 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
7782 {
7783
7784 if (NULL == wiphy->bands[i])
7785 {
Ratheesh S P36dbc932015-08-07 14:28:57 +05307786 hddLog(VOS_TRACE_LEVEL_INFO,"%s: wiphy->bands[i] is NULL, i = %d",
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307787 __func__, i);
7788 continue;
7789 }
7790
7791 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
7792 {
7793 struct ieee80211_supported_band *band = wiphy->bands[i];
7794
7795 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
7796 {
7797 // Enable social channels for P2P
7798 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
7799 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
7800 else
7801 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
7802 continue;
7803 }
7804 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
7805 {
7806 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
7807 continue;
7808 }
7809 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007810 }
7811 /*Initialise the supported cipher suite details*/
7812 wiphy->cipher_suites = hdd_cipher_suites;
7813 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
7814
7815 /*signal strength in mBm (100*dBm) */
7816 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
7817
7818#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05307819 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07007820#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007821
Sunil Duttc69bccb2014-05-26 21:30:20 +05307822 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
7823 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007824 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
7825 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
7826
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307827 EXIT();
7828 return 0;
7829}
7830
7831/* In this function we are registering wiphy. */
7832int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
7833{
7834 ENTER();
7835 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007836 if (0 > wiphy_register(wiphy))
7837 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307838 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07007839 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
7840 return -EIO;
7841 }
7842
7843 EXIT();
7844 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307845}
Jeff Johnson295189b2012-06-20 16:38:30 -07007846
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307847/* In this function we are updating channel list when,
7848 regulatory domain is FCC and country code is US.
7849 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
7850 As per FCC smart phone is not a indoor device.
7851 GO should not opeate on indoor channels */
7852void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
7853{
7854 int j;
7855 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7856 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
7857 //Default counrtycode from NV at the time of wiphy initialization.
7858 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
7859 &defaultCountryCode[0]))
7860 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007861 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307862 }
7863 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
7864 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307865 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
7866 {
7867 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
7868 return;
7869 }
7870 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
7871 {
7872 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
7873 // Mark UNII -1 band channel as passive
7874 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
7875 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
7876 }
7877 }
7878}
7879
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05307880/* This function registers for all frame which supplicant is interested in */
7881void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07007882{
Jeff Johnson295189b2012-06-20 16:38:30 -07007883 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7884 /* Register for all P2P action, public action etc frames */
7885 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
7886
Jeff Johnsone7245742012-09-05 17:12:55 -07007887 ENTER();
7888
Jeff Johnson295189b2012-06-20 16:38:30 -07007889 /* Right now we are registering these frame when driver is getting
7890 initialized. Once we will move to 2.6.37 kernel, in which we have
7891 frame register ops, we will move this code as a part of that */
7892 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307893 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07007894 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
7895
7896 /* GAS Initial Response */
7897 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
7898 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307899
Jeff Johnson295189b2012-06-20 16:38:30 -07007900 /* GAS Comeback Request */
7901 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
7902 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
7903
7904 /* GAS Comeback Response */
7905 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
7906 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
7907
7908 /* P2P Public Action */
7909 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307910 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07007911 P2P_PUBLIC_ACTION_FRAME_SIZE );
7912
7913 /* P2P Action */
7914 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
7915 (v_U8_t*)P2P_ACTION_FRAME,
7916 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07007917
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05307918 /* WNM BSS Transition Request frame */
7919 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
7920 (v_U8_t*)WNM_BSS_ACTION_FRAME,
7921 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07007922
7923 /* WNM-Notification */
7924 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
7925 (v_U8_t*)WNM_NOTIFICATION_FRAME,
7926 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07007927}
7928
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05307929void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07007930{
Jeff Johnson295189b2012-06-20 16:38:30 -07007931 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7932 /* Register for all P2P action, public action etc frames */
7933 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
7934
Jeff Johnsone7245742012-09-05 17:12:55 -07007935 ENTER();
7936
Jeff Johnson295189b2012-06-20 16:38:30 -07007937 /* Right now we are registering these frame when driver is getting
7938 initialized. Once we will move to 2.6.37 kernel, in which we have
7939 frame register ops, we will move this code as a part of that */
7940 /* GAS Initial Request */
7941
7942 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
7943 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
7944
7945 /* GAS Initial Response */
7946 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
7947 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307948
Jeff Johnson295189b2012-06-20 16:38:30 -07007949 /* GAS Comeback Request */
7950 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
7951 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
7952
7953 /* GAS Comeback Response */
7954 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
7955 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
7956
7957 /* P2P Public Action */
7958 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307959 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07007960 P2P_PUBLIC_ACTION_FRAME_SIZE );
7961
7962 /* P2P Action */
7963 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
7964 (v_U8_t*)P2P_ACTION_FRAME,
7965 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07007966 /* WNM-Notification */
7967 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
7968 (v_U8_t*)WNM_NOTIFICATION_FRAME,
7969 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07007970}
7971
7972#ifdef FEATURE_WLAN_WAPI
7973void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05307974 const u8 *mac_addr, const u8 *key , int key_Len)
Jeff Johnson295189b2012-06-20 16:38:30 -07007975{
7976 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7977 tCsrRoamSetKey setKey;
7978 v_BOOL_t isConnected = TRUE;
7979 int status = 0;
7980 v_U32_t roamId= 0xFF;
7981 tANI_U8 *pKeyPtr = NULL;
7982 int n = 0;
7983
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307984 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
7985 __func__, hdd_device_modetoString(pAdapter->device_mode),
7986 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007987
Gopichand Nakkalae7480202013-02-11 15:24:22 +05307988 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07007989 setKey.keyId = key_index; // Store Key ID
7990 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
7991 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
7992 setKey.paeRole = 0 ; // the PAE role
7993 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
7994 {
7995 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
7996 }
7997 else
7998 {
7999 isConnected = hdd_connIsConnected(pHddStaCtx);
8000 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
8001 }
8002 setKey.keyLength = key_Len;
8003 pKeyPtr = setKey.Key;
8004 memcpy( pKeyPtr, key, key_Len);
8005
Arif Hussain6d2a3322013-11-17 19:50:10 -08008006 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07008007 __func__, key_Len);
8008 for (n = 0 ; n < key_Len; n++)
8009 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
8010 __func__,n,setKey.Key[n]);
8011
8012 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
8013 if ( isConnected )
8014 {
8015 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
8016 pAdapter->sessionId, &setKey, &roamId );
8017 }
8018 if ( status != 0 )
8019 {
8020 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8021 "[%4d] sme_RoamSetKey returned ERROR status= %d",
8022 __LINE__, status );
8023 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
8024 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308025 /* Need to clear any trace of key value in the memory.
8026 * Thus zero out the memory even though it is local
8027 * variable.
8028 */
8029 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07008030}
8031#endif /* FEATURE_WLAN_WAPI*/
8032
8033#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308034int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07008035 beacon_data_t **ppBeacon,
8036 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008037#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308038int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008039 beacon_data_t **ppBeacon,
8040 struct cfg80211_beacon_data *params,
8041 int dtim_period)
8042#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308043{
Jeff Johnson295189b2012-06-20 16:38:30 -07008044 int size;
8045 beacon_data_t *beacon = NULL;
8046 beacon_data_t *old = NULL;
8047 int head_len,tail_len;
8048
Jeff Johnsone7245742012-09-05 17:12:55 -07008049 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008050 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308051 {
8052 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8053 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008054 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308055 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008056
8057 old = pAdapter->sessionCtx.ap.beacon;
8058
8059 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308060 {
8061 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8062 FL("session(%d) old and new heads points to NULL"),
8063 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008064 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308065 }
8066
8067 if (params->tail && !params->tail_len)
8068 {
8069 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8070 FL("tail_len is zero but tail is not NULL"));
8071 return -EINVAL;
8072 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008073
Jeff Johnson295189b2012-06-20 16:38:30 -07008074#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
8075 /* Kernel 3.0 is not updating dtim_period for set beacon */
8076 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308077 {
8078 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8079 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008080 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308081 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008082#endif
8083
8084 if(params->head)
8085 head_len = params->head_len;
8086 else
8087 head_len = old->head_len;
8088
8089 if(params->tail || !old)
8090 tail_len = params->tail_len;
8091 else
8092 tail_len = old->tail_len;
8093
8094 size = sizeof(beacon_data_t) + head_len + tail_len;
8095
8096 beacon = kzalloc(size, GFP_KERNEL);
8097
8098 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308099 {
8100 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8101 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008102 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308103 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008104
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008105#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008106 if(params->dtim_period || !old )
8107 beacon->dtim_period = params->dtim_period;
8108 else
8109 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008110#else
8111 if(dtim_period || !old )
8112 beacon->dtim_period = dtim_period;
8113 else
8114 beacon->dtim_period = old->dtim_period;
8115#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308116
Jeff Johnson295189b2012-06-20 16:38:30 -07008117 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
8118 beacon->tail = beacon->head + head_len;
8119 beacon->head_len = head_len;
8120 beacon->tail_len = tail_len;
8121
8122 if(params->head) {
8123 memcpy (beacon->head,params->head,beacon->head_len);
8124 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308125 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07008126 if(old)
8127 memcpy (beacon->head,old->head,beacon->head_len);
8128 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308129
Jeff Johnson295189b2012-06-20 16:38:30 -07008130 if(params->tail) {
8131 memcpy (beacon->tail,params->tail,beacon->tail_len);
8132 }
8133 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308134 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07008135 memcpy (beacon->tail,old->tail,beacon->tail_len);
8136 }
8137
8138 *ppBeacon = beacon;
8139
8140 kfree(old);
8141
8142 return 0;
8143
8144}
Jeff Johnson295189b2012-06-20 16:38:30 -07008145
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308146v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(
8147#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
8148 const v_U8_t *pIes,
8149#else
8150 v_U8_t *pIes,
8151#endif
8152 int length, v_U8_t eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07008153{
8154 int left = length;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308155 v_U8_t *ptr = (v_U8_t *)pIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07008156 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308157
Jeff Johnson295189b2012-06-20 16:38:30 -07008158 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308159 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008160 elem_id = ptr[0];
8161 elem_len = ptr[1];
8162 left -= 2;
8163 if(elem_len > left)
8164 {
8165 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07008166 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008167 eid,elem_len,left);
8168 return NULL;
8169 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308170 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07008171 {
8172 return ptr;
8173 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308174
Jeff Johnson295189b2012-06-20 16:38:30 -07008175 left -= elem_len;
8176 ptr += (elem_len + 2);
8177 }
8178 return NULL;
8179}
8180
Jeff Johnson295189b2012-06-20 16:38:30 -07008181/* Check if rate is 11g rate or not */
8182static int wlan_hdd_rate_is_11g(u8 rate)
8183{
Sanjay Devnani28322e22013-06-21 16:13:40 -07008184 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008185 u8 i;
8186 for (i = 0; i < 8; i++)
8187 {
8188 if(rate == gRateArray[i])
8189 return TRUE;
8190 }
8191 return FALSE;
8192}
8193
8194/* Check for 11g rate and set proper 11g only mode */
8195static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
8196 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
8197{
8198 u8 i, num_rates = pIe[0];
8199
8200 pIe += 1;
8201 for ( i = 0; i < num_rates; i++)
8202 {
8203 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
8204 {
8205 /* If rate set have 11g rate than change the mode to 11G */
8206 *pSapHw_mode = eSAP_DOT11_MODE_11g;
8207 if (pIe[i] & BASIC_RATE_MASK)
8208 {
8209 /* If we have 11g rate as basic rate, it means mode
8210 is 11g only mode.
8211 */
8212 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
8213 *pCheckRatesfor11g = FALSE;
8214 }
8215 }
8216 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
8217 {
8218 *require_ht = TRUE;
8219 }
8220 }
8221 return;
8222}
8223
8224static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
8225{
8226 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
8227 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8228 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
8229 u8 checkRatesfor11g = TRUE;
8230 u8 require_ht = FALSE;
8231 u8 *pIe=NULL;
8232
8233 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
8234
8235 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
8236 pBeacon->head_len, WLAN_EID_SUPP_RATES);
8237 if (pIe != NULL)
8238 {
8239 pIe += 1;
8240 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
8241 &pConfig->SapHw_mode);
8242 }
8243
8244 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
8245 WLAN_EID_EXT_SUPP_RATES);
8246 if (pIe != NULL)
8247 {
8248
8249 pIe += 1;
8250 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
8251 &pConfig->SapHw_mode);
8252 }
8253
8254 if( pConfig->channel > 14 )
8255 {
8256 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
8257 }
8258
8259 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
8260 WLAN_EID_HT_CAPABILITY);
8261
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308262 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07008263 {
8264 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
8265 if(require_ht)
8266 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
8267 }
8268}
8269
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308270static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
8271 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
8272{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07008273 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308274 v_U8_t *pIe = NULL;
8275 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8276
8277 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
8278 pBeacon->tail, pBeacon->tail_len);
8279
8280 if (pIe)
8281 {
8282 ielen = pIe[1] + 2;
8283 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
8284 {
8285 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
8286 }
8287 else
8288 {
8289 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
8290 return -EINVAL;
8291 }
8292 *total_ielen += ielen;
8293 }
8294 return 0;
8295}
8296
Arif Hussaine7f3ea52013-09-12 21:56:36 -07008297static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
8298 v_U8_t *genie, v_U8_t *total_ielen)
8299{
8300 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8301 int left = pBeacon->tail_len;
8302 v_U8_t *ptr = pBeacon->tail;
8303 v_U8_t elem_id, elem_len;
8304 v_U16_t ielen = 0;
8305
8306 if ( NULL == ptr || 0 == left )
8307 return;
8308
8309 while (left >= 2)
8310 {
8311 elem_id = ptr[0];
8312 elem_len = ptr[1];
8313 left -= 2;
8314 if (elem_len > left)
8315 {
8316 hddLog( VOS_TRACE_LEVEL_ERROR,
8317 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
8318 elem_id, elem_len, left);
8319 return;
8320 }
8321 if (IE_EID_VENDOR == elem_id)
8322 {
8323 /* skipping the VSIE's which we don't want to include or
8324 * it will be included by existing code
8325 */
8326 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
8327#ifdef WLAN_FEATURE_WFD
8328 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
8329#endif
8330 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
8331 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
8332 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
8333 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
8334 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
8335 {
8336 ielen = ptr[1] + 2;
8337 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
8338 {
8339 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
8340 *total_ielen += ielen;
8341 }
8342 else
8343 {
8344 hddLog( VOS_TRACE_LEVEL_ERROR,
8345 "IE Length is too big "
8346 "IEs eid=%d elem_len=%d total_ie_lent=%d",
8347 elem_id, elem_len, *total_ielen);
8348 }
8349 }
8350 }
8351
8352 left -= elem_len;
8353 ptr += (elem_len + 2);
8354 }
8355 return;
8356}
8357
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008358#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008359static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
8360 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008361#else
8362static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
8363 struct cfg80211_beacon_data *params)
8364#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008365{
8366 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308367 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008368 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07008369 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008370
8371 genie = vos_mem_malloc(MAX_GENIE_LEN);
8372
8373 if(genie == NULL) {
8374
8375 return -ENOMEM;
8376 }
8377
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308378 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
8379 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008380 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308381 hddLog(LOGE,
8382 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308383 ret = -EINVAL;
8384 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008385 }
8386
8387#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308388 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
8389 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
8390 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308391 hddLog(LOGE,
8392 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308393 ret = -EINVAL;
8394 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008395 }
8396#endif
8397
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308398 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
8399 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008400 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308401 hddLog(LOGE,
8402 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308403 ret = -EINVAL;
8404 goto done;
8405 }
8406
8407 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
8408 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07008409 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008410 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008411
8412 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8413 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
8414 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
8415 {
8416 hddLog(LOGE,
8417 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008418 ret = -EINVAL;
8419 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008420 }
8421
8422 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8423 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
8424 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
8425 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
8426 ==eHAL_STATUS_FAILURE)
8427 {
8428 hddLog(LOGE,
8429 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008430 ret = -EINVAL;
8431 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008432 }
8433
8434 // Added for ProResp IE
8435 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
8436 {
8437 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
8438 u8 probe_rsp_ie_len[3] = {0};
8439 u8 counter = 0;
8440 /* Check Probe Resp Length if it is greater then 255 then Store
8441 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
8442 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
8443 Store More then 255 bytes into One Variable.
8444 */
8445 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
8446 {
8447 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
8448 {
8449 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
8450 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
8451 }
8452 else
8453 {
8454 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
8455 rem_probe_resp_ie_len = 0;
8456 }
8457 }
8458
8459 rem_probe_resp_ie_len = 0;
8460
8461 if (probe_rsp_ie_len[0] > 0)
8462 {
8463 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8464 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
8465 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
8466 probe_rsp_ie_len[0], NULL,
8467 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8468 {
8469 hddLog(LOGE,
8470 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008471 ret = -EINVAL;
8472 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008473 }
8474 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
8475 }
8476
8477 if (probe_rsp_ie_len[1] > 0)
8478 {
8479 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8480 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
8481 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
8482 probe_rsp_ie_len[1], NULL,
8483 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8484 {
8485 hddLog(LOGE,
8486 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008487 ret = -EINVAL;
8488 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008489 }
8490 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
8491 }
8492
8493 if (probe_rsp_ie_len[2] > 0)
8494 {
8495 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8496 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
8497 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
8498 probe_rsp_ie_len[2], NULL,
8499 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8500 {
8501 hddLog(LOGE,
8502 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008503 ret = -EINVAL;
8504 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008505 }
8506 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
8507 }
8508
8509 if (probe_rsp_ie_len[1] == 0 )
8510 {
8511 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8512 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
8513 eANI_BOOLEAN_FALSE) )
8514 {
8515 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008516 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008517 }
8518 }
8519
8520 if (probe_rsp_ie_len[2] == 0 )
8521 {
8522 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8523 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
8524 eANI_BOOLEAN_FALSE) )
8525 {
8526 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008527 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008528 }
8529 }
8530
8531 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8532 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
8533 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
8534 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
8535 == eHAL_STATUS_FAILURE)
8536 {
8537 hddLog(LOGE,
8538 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008539 ret = -EINVAL;
8540 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008541 }
8542 }
8543 else
8544 {
8545 // Reset WNI_CFG_PROBE_RSP Flags
8546 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
8547
8548 hddLog(VOS_TRACE_LEVEL_INFO,
8549 "%s: No Probe Response IE received in set beacon",
8550 __func__);
8551 }
8552
8553 // Added for AssocResp IE
8554 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
8555 {
8556 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8557 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
8558 params->assocresp_ies_len, NULL,
8559 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8560 {
8561 hddLog(LOGE,
8562 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008563 ret = -EINVAL;
8564 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008565 }
8566
8567 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8568 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
8569 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
8570 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
8571 == eHAL_STATUS_FAILURE)
8572 {
8573 hddLog(LOGE,
8574 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008575 ret = -EINVAL;
8576 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008577 }
8578 }
8579 else
8580 {
8581 hddLog(VOS_TRACE_LEVEL_INFO,
8582 "%s: No Assoc Response IE received in set beacon",
8583 __func__);
8584
8585 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8586 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
8587 eANI_BOOLEAN_FALSE) )
8588 {
8589 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008590 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008591 }
8592 }
8593
Jeff Johnsone7245742012-09-05 17:12:55 -07008594done:
Jeff Johnson295189b2012-06-20 16:38:30 -07008595 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308596 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008597}
Jeff Johnson295189b2012-06-20 16:38:30 -07008598
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308599/*
Jeff Johnson295189b2012-06-20 16:38:30 -07008600 * FUNCTION: wlan_hdd_validate_operation_channel
8601 * called by wlan_hdd_cfg80211_start_bss() and
8602 * wlan_hdd_cfg80211_set_channel()
8603 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308604 * channel list.
8605 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07008606VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07008607{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308608
Jeff Johnson295189b2012-06-20 16:38:30 -07008609 v_U32_t num_ch = 0;
8610 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
8611 u32 indx = 0;
8612 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308613 v_U8_t fValidChannel = FALSE, count = 0;
8614 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308615
Jeff Johnson295189b2012-06-20 16:38:30 -07008616 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
8617
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308618 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07008619 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308620 /* Validate the channel */
8621 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07008622 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308623 if ( channel == rfChannels[count].channelNum )
8624 {
8625 fValidChannel = TRUE;
8626 break;
8627 }
8628 }
8629 if (fValidChannel != TRUE)
8630 {
8631 hddLog(VOS_TRACE_LEVEL_ERROR,
8632 "%s: Invalid Channel [%d]", __func__, channel);
8633 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008634 }
8635 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308636 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008637 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308638 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
8639 valid_ch, &num_ch))
8640 {
8641 hddLog(VOS_TRACE_LEVEL_ERROR,
8642 "%s: failed to get valid channel list", __func__);
8643 return VOS_STATUS_E_FAILURE;
8644 }
8645 for (indx = 0; indx < num_ch; indx++)
8646 {
8647 if (channel == valid_ch[indx])
8648 {
8649 break;
8650 }
8651 }
8652
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05308653 if (indx >= num_ch)
8654 {
8655 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
8656 {
8657 eCsrBand band;
8658 unsigned int freq;
8659
8660 sme_GetFreqBand(hHal, &band);
8661
8662 if (eCSR_BAND_5G == band)
8663 {
8664#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
8665 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
8666 {
8667 freq = ieee80211_channel_to_frequency(channel,
8668 IEEE80211_BAND_2GHZ);
8669 }
8670 else
8671 {
8672 freq = ieee80211_channel_to_frequency(channel,
8673 IEEE80211_BAND_5GHZ);
8674 }
8675#else
8676 freq = ieee80211_channel_to_frequency(channel);
8677#endif
8678 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
8679 return VOS_STATUS_SUCCESS;
8680 }
8681 }
8682
8683 hddLog(VOS_TRACE_LEVEL_ERROR,
8684 "%s: Invalid Channel [%d]", __func__, channel);
8685 return VOS_STATUS_E_FAILURE;
8686 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008687 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05308688
Jeff Johnson295189b2012-06-20 16:38:30 -07008689 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308690
Jeff Johnson295189b2012-06-20 16:38:30 -07008691}
8692
Viral Modi3a32cc52013-02-08 11:14:52 -08008693/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308694 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -08008695 * This function is used to set the channel number
8696 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308697static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -08008698 struct ieee80211_channel *chan,
8699 enum nl80211_channel_type channel_type
8700 )
8701{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308702 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08008703 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07008704 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08008705 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308706 hdd_context_t *pHddCtx;
8707 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08008708
8709 ENTER();
8710
8711 if( NULL == dev )
8712 {
8713 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008714 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08008715 return -ENODEV;
8716 }
8717 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308718
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308719 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8720 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
8721 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08008722 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308723 "%s: device_mode = %s (%d) freq = %d", __func__,
8724 hdd_device_modetoString(pAdapter->device_mode),
8725 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308726
8727 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8728 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308729 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08008730 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308731 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08008732 }
8733
8734 /*
8735 * Do freq to chan conversion
8736 * TODO: for 11a
8737 */
8738
8739 channel = ieee80211_frequency_to_channel(freq);
8740
8741 /* Check freq range */
8742 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
8743 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
8744 {
8745 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008746 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08008747 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
8748 WNI_CFG_CURRENT_CHANNEL_STAMAX);
8749 return -EINVAL;
8750 }
8751
8752 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
8753
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05308754 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
8755 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08008756 {
8757 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
8758 {
8759 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008760 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08008761 return -EINVAL;
8762 }
8763 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8764 "%s: set channel to [%d] for device mode =%d",
8765 __func__, channel,pAdapter->device_mode);
8766 }
8767 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08008768 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08008769 )
8770 {
8771 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8772 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
8773 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8774
8775 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
8776 {
8777 /* Link is up then return cant set channel*/
8778 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008779 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08008780 return -EINVAL;
8781 }
8782
8783 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
8784 pHddStaCtx->conn_info.operationChannel = channel;
8785 pRoamProfile->ChannelInfo.ChannelList =
8786 &pHddStaCtx->conn_info.operationChannel;
8787 }
8788 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08008789 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08008790 )
8791 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05308792 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
8793 {
8794 if(VOS_STATUS_SUCCESS !=
8795 wlan_hdd_validate_operation_channel(pAdapter,channel))
8796 {
8797 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008798 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05308799 return -EINVAL;
8800 }
8801 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
8802 }
8803 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08008804 {
8805 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
8806
8807 /* If auto channel selection is configured as enable/ 1 then ignore
8808 channel set by supplicant
8809 */
8810 if ( cfg_param->apAutoChannelSelection )
8811 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05308812 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
8813 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08008814 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308815 "%s: set channel to auto channel (0) for device mode =%s (%d)",
8816 __func__, hdd_device_modetoString(pAdapter->device_mode),
8817 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08008818 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05308819 else
8820 {
8821 if(VOS_STATUS_SUCCESS !=
8822 wlan_hdd_validate_operation_channel(pAdapter,channel))
8823 {
8824 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008825 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05308826 return -EINVAL;
8827 }
8828 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
8829 }
Viral Modi3a32cc52013-02-08 11:14:52 -08008830 }
8831 }
8832 else
8833 {
8834 hddLog(VOS_TRACE_LEVEL_FATAL,
8835 "%s: Invalid device mode failed to set valid channel", __func__);
8836 return -EINVAL;
8837 }
8838 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308839 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08008840}
8841
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308842static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
8843 struct net_device *dev,
8844 struct ieee80211_channel *chan,
8845 enum nl80211_channel_type channel_type
8846 )
8847{
8848 int ret;
8849
8850 vos_ssr_protect(__func__);
8851 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
8852 vos_ssr_unprotect(__func__);
8853
8854 return ret;
8855}
8856
Jeff Johnson295189b2012-06-20 16:38:30 -07008857#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
8858static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
8859 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008860#else
8861static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
8862 struct cfg80211_beacon_data *params,
8863 const u8 *ssid, size_t ssid_len,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05308864 enum nl80211_hidden_ssid hidden_ssid,
8865 v_U8_t auth_type)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008866#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008867{
8868 tsap_Config_t *pConfig;
8869 beacon_data_t *pBeacon = NULL;
8870 struct ieee80211_mgmt *pMgmt_frame;
8871 v_U8_t *pIe=NULL;
8872 v_U16_t capab_info;
8873 eCsrAuthType RSNAuthType;
8874 eCsrEncryptionType RSNEncryptType;
8875 eCsrEncryptionType mcRSNEncryptType;
8876 int status = VOS_STATUS_SUCCESS;
8877 tpWLAN_SAPEventCB pSapEventCallback;
8878 hdd_hostapd_state_t *pHostapdState;
8879 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
8880 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05308881 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008882 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05308883 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07008884 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08008885 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05308886 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07008887 v_BOOL_t MFPCapable = VOS_FALSE;
8888 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +05308889 v_BOOL_t sapEnable11AC =
8890 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Jeff Johnson295189b2012-06-20 16:38:30 -07008891 ENTER();
8892
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05308893 iniConfig = pHddCtx->cfg_ini;
8894
Jeff Johnson295189b2012-06-20 16:38:30 -07008895 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
8896
8897 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
8898
8899 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8900
8901 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
8902
8903 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
8904
8905 //channel is already set in the set_channel Call back
8906 //pConfig->channel = pCommitConfig->channel;
8907
8908 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308909 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07008910 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
8911
8912 pConfig->dtim_period = pBeacon->dtim_period;
8913
Arif Hussain6d2a3322013-11-17 19:50:10 -08008914 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07008915 pConfig->dtim_period);
8916
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08008917 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07008918 {
8919 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07008920 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05308921 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
8922 {
8923 tANI_BOOLEAN restartNeeded;
8924 pConfig->ieee80211d = 1;
8925 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
8926 sme_setRegInfo(hHal, pConfig->countryCode);
8927 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
8928 }
8929 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07008930 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07008931 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07008932 pConfig->ieee80211d = 1;
8933 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
8934 sme_setRegInfo(hHal, pConfig->countryCode);
8935 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07008936 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07008937 else
8938 {
8939 pConfig->ieee80211d = 0;
8940 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05308941 /*
8942 * If auto channel is configured i.e. channel is 0,
8943 * so skip channel validation.
8944 */
8945 if( AUTO_CHANNEL_SELECT != pConfig->channel )
8946 {
8947 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
8948 {
8949 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008950 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05308951 return -EINVAL;
8952 }
8953 }
8954 else
8955 {
8956 if(1 != pHddCtx->is_dynamic_channel_range_set)
8957 {
8958 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
8959 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
8960 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
8961 }
8962 pHddCtx->is_dynamic_channel_range_set = 0;
8963 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008964 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07008965 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008966 {
8967 pConfig->ieee80211d = 0;
8968 }
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05308969
8970#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
8971 if (params->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
8972 pConfig->authType = eSAP_OPEN_SYSTEM;
8973 else if (params->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
8974 pConfig->authType = eSAP_SHARED_KEY;
8975 else
8976 pConfig->authType = eSAP_AUTO_SWITCH;
8977#else
8978 if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
8979 pConfig->authType = eSAP_OPEN_SYSTEM;
8980 else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
8981 pConfig->authType = eSAP_SHARED_KEY;
8982 else
8983 pConfig->authType = eSAP_AUTO_SWITCH;
8984#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008985
8986 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308987
8988 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07008989 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
8990
8991 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
8992
8993 /*Set wps station to configured*/
8994 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
8995
8996 if(pIe)
8997 {
8998 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
8999 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009000 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07009001 return -EINVAL;
9002 }
9003 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
9004 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07009005 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07009006 /* Check 15 bit of WPS IE as it contain information for wps state
9007 * WPS state
9008 */
9009 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
9010 {
9011 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
9012 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
9013 {
9014 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
9015 }
9016 }
9017 }
9018 else
9019 {
9020 pConfig->wps_state = SAP_WPS_DISABLED;
9021 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309022 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07009023
c_hpothufe599e92014-06-16 11:38:55 +05309024 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
9025 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
9026 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
9027 eCSR_ENCRYPT_TYPE_NONE;
9028
Jeff Johnson295189b2012-06-20 16:38:30 -07009029 pConfig->RSNWPAReqIELength = 0;
9030 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309031 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07009032 WLAN_EID_RSN);
9033 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309034 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009035 pConfig->RSNWPAReqIELength = pIe[1] + 2;
9036 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
9037 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309038 /* The actual processing may eventually be more extensive than
9039 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07009040 * by the app.
9041 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309042 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07009043 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
9044 &RSNEncryptType,
9045 &mcRSNEncryptType,
9046 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08009047 &MFPCapable,
9048 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07009049 pConfig->pRSNWPAReqIE[1]+2,
9050 pConfig->pRSNWPAReqIE );
9051
9052 if( VOS_STATUS_SUCCESS == status )
9053 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309054 /* Now copy over all the security attributes you have
9055 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07009056 * */
9057 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
9058 pConfig->mcRSNEncryptType = mcRSNEncryptType;
9059 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
9060 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05309061 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08009062 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07009063 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
9064 }
9065 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309066
Jeff Johnson295189b2012-06-20 16:38:30 -07009067 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
9068 pBeacon->tail, pBeacon->tail_len);
9069
9070 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
9071 {
9072 if (pConfig->pRSNWPAReqIE)
9073 {
9074 /*Mixed mode WPA/WPA2*/
9075 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
9076 pConfig->RSNWPAReqIELength += pIe[1] + 2;
9077 }
9078 else
9079 {
9080 pConfig->RSNWPAReqIELength = pIe[1] + 2;
9081 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
9082 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309083 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07009084 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
9085 &RSNEncryptType,
9086 &mcRSNEncryptType,
9087 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08009088 &MFPCapable,
9089 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07009090 pConfig->pRSNWPAReqIE[1]+2,
9091 pConfig->pRSNWPAReqIE );
9092
9093 if( VOS_STATUS_SUCCESS == status )
9094 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309095 /* Now copy over all the security attributes you have
9096 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07009097 * */
9098 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
9099 pConfig->mcRSNEncryptType = mcRSNEncryptType;
9100 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
9101 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05309102 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08009103 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07009104 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
9105 }
9106 }
9107 }
9108
Jeff Johnson4416a782013-03-25 14:17:50 -07009109 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
9110 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
9111 return -EINVAL;
9112 }
9113
Jeff Johnson295189b2012-06-20 16:38:30 -07009114 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
9115
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009116#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009117 if (params->ssid != NULL)
9118 {
9119 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
9120 pConfig->SSIDinfo.ssid.length = params->ssid_len;
9121 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
9122 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
9123 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009124#else
9125 if (ssid != NULL)
9126 {
9127 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
9128 pConfig->SSIDinfo.ssid.length = ssid_len;
9129 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
9130 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
9131 }
9132#endif
9133
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309134 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07009135 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309136
Jeff Johnson295189b2012-06-20 16:38:30 -07009137 /* default value */
9138 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
9139 pConfig->num_accept_mac = 0;
9140 pConfig->num_deny_mac = 0;
9141
9142 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
9143 pBeacon->tail, pBeacon->tail_len);
9144
9145 /* pIe for black list is following form:
9146 type : 1 byte
9147 length : 1 byte
9148 OUI : 4 bytes
9149 acl type : 1 byte
9150 no of mac addr in black list: 1 byte
9151 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309152 */
9153 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009154 {
9155 pConfig->SapMacaddr_acl = pIe[6];
9156 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08009157 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009158 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309159 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
9160 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009161 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
9162 for (i = 0; i < pConfig->num_deny_mac; i++)
9163 {
9164 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
9165 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309166 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009167 }
9168 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
9169 pBeacon->tail, pBeacon->tail_len);
9170
9171 /* pIe for white list is following form:
9172 type : 1 byte
9173 length : 1 byte
9174 OUI : 4 bytes
9175 acl type : 1 byte
9176 no of mac addr in white list: 1 byte
9177 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309178 */
9179 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009180 {
9181 pConfig->SapMacaddr_acl = pIe[6];
9182 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08009183 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009184 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309185 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
9186 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009187 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
9188 for (i = 0; i < pConfig->num_accept_mac; i++)
9189 {
9190 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
9191 acl_entry++;
9192 }
9193 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309194
Jeff Johnson295189b2012-06-20 16:38:30 -07009195 wlan_hdd_set_sapHwmode(pHostapdAdapter);
9196
Jeff Johnsone7245742012-09-05 17:12:55 -07009197#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08009198 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309199 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
9200 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +05309201 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
9202 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08009203 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
9204 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309205 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
9206 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07009207 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309208 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07009209 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309210 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009211
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309212 /* If ACS disable and selected channel <= 14
9213 * OR
9214 * ACS enabled and ACS operating band is choosen as 2.4
9215 * AND
9216 * VHT in 2.4G Disabled
9217 * THEN
9218 * Fallback to 11N mode
9219 */
9220 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
9221 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05309222 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309223 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009224 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309225 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
9226 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009227 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
9228 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009229 }
9230#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309231
Jeff Johnson295189b2012-06-20 16:38:30 -07009232 // ht_capab is not what the name conveys,this is used for protection bitmap
9233 pConfig->ht_capab =
9234 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
9235
9236 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
9237 {
9238 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
9239 return -EINVAL;
9240 }
9241
9242 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309243 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07009244 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
9245 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309246 pConfig->obssProtEnabled =
9247 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07009248
Chet Lanctot8cecea22014-02-11 19:09:36 -08009249#ifdef WLAN_FEATURE_11W
9250 pConfig->mfpCapable = MFPCapable;
9251 pConfig->mfpRequired = MFPRequired;
9252 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
9253 pConfig->mfpCapable, pConfig->mfpRequired);
9254#endif
9255
Arif Hussain6d2a3322013-11-17 19:50:10 -08009256 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07009257 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08009258 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
9259 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
9260 (int)pConfig->channel);
9261 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
9262 pConfig->SapHw_mode, pConfig->privacy,
9263 pConfig->authType);
9264 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
9265 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
9266 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
9267 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07009268
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309269 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07009270 {
9271 //Bss already started. just return.
9272 //TODO Probably it should update some beacon params.
9273 hddLog( LOGE, "Bss Already started...Ignore the request");
9274 EXIT();
9275 return 0;
9276 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309277
Agarwal Ashish51325b52014-06-16 16:50:49 +05309278 if (vos_max_concurrent_connections_reached()) {
9279 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
9280 return -EINVAL;
9281 }
9282
Jeff Johnson295189b2012-06-20 16:38:30 -07009283 pConfig->persona = pHostapdAdapter->device_mode;
9284
Peng Xu2446a892014-09-05 17:21:18 +05309285 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
9286 if ( NULL != psmeConfig)
9287 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05309288 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +05309289 sme_GetConfigParam(hHal, psmeConfig);
9290 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05309291#ifdef WLAN_FEATURE_AP_HT40_24G
9292 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
9293 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
9294 && pHddCtx->cfg_ini->apHT40_24GEnabled)
9295 {
9296 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
9297 sme_UpdateConfig (hHal, psmeConfig);
9298 }
9299#endif
Peng Xu2446a892014-09-05 17:21:18 +05309300 vos_mem_free(psmeConfig);
9301 }
Peng Xuafc34e32014-09-25 13:23:55 +05309302 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05309303
Jeff Johnson295189b2012-06-20 16:38:30 -07009304 pSapEventCallback = hdd_hostapd_SAPEventCB;
9305 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
9306 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
9307 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009308 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009309 return -EINVAL;
9310 }
9311
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309312 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07009313 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
9314
9315 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309316
Jeff Johnson295189b2012-06-20 16:38:30 -07009317 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309318 {
9319 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009320 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07009321 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009322 VOS_ASSERT(0);
9323 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309324
Jeff Johnson295189b2012-06-20 16:38:30 -07009325 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05309326 /* Initialize WMM configuation */
9327 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05309328 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009329
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009330#ifdef WLAN_FEATURE_P2P_DEBUG
9331 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
9332 {
9333 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
9334 {
9335 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
9336 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08009337 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009338 }
9339 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
9340 {
9341 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
9342 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08009343 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009344 }
9345 }
9346#endif
9347
Jeff Johnson295189b2012-06-20 16:38:30 -07009348 pHostapdState->bCommit = TRUE;
9349 EXIT();
9350
9351 return 0;
9352}
9353
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009354#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309355static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309356 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009357 struct beacon_parameters *params)
9358{
9359 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309360 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309361 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009362
9363 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309364
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309365 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9366 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
9367 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309368 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
9369 hdd_device_modetoString(pAdapter->device_mode),
9370 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009371
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309372 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9373 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309374 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009375 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309376 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009377 }
9378
Agarwal Ashish51325b52014-06-16 16:50:49 +05309379 if (vos_max_concurrent_connections_reached()) {
9380 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
9381 return -EINVAL;
9382 }
9383
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309384 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009385 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07009386 )
9387 {
9388 beacon_data_t *old,*new;
9389
9390 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309391
Jeff Johnson295189b2012-06-20 16:38:30 -07009392 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309393 {
9394 hddLog(VOS_TRACE_LEVEL_WARN,
9395 FL("already beacon info added to session(%d)"),
9396 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009397 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309398 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009399
9400 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
9401
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309402 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07009403 {
9404 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009405 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009406 return -EINVAL;
9407 }
9408
9409 pAdapter->sessionCtx.ap.beacon = new;
9410
9411 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
9412 }
9413
9414 EXIT();
9415 return status;
9416}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309417
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309418static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
9419 struct net_device *dev,
9420 struct beacon_parameters *params)
9421{
9422 int ret;
9423
9424 vos_ssr_protect(__func__);
9425 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
9426 vos_ssr_unprotect(__func__);
9427
9428 return ret;
9429}
9430
9431static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009432 struct net_device *dev,
9433 struct beacon_parameters *params)
9434{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309435 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309436 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9437 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309438 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009439
9440 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309441
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309442 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9443 TRACE_CODE_HDD_CFG80211_SET_BEACON,
9444 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
9445 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9446 __func__, hdd_device_modetoString(pAdapter->device_mode),
9447 pAdapter->device_mode);
9448
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309449 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9450 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309451 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009452 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309453 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009454 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309455
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309456 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009457 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309458 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009459 {
9460 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309461
Jeff Johnson295189b2012-06-20 16:38:30 -07009462 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309463
Jeff Johnson295189b2012-06-20 16:38:30 -07009464 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309465 {
9466 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9467 FL("session(%d) old and new heads points to NULL"),
9468 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009469 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309470 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009471
9472 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
9473
9474 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309475 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009476 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009477 return -EINVAL;
9478 }
9479
9480 pAdapter->sessionCtx.ap.beacon = new;
9481
9482 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
9483 }
9484
9485 EXIT();
9486 return status;
9487}
9488
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309489static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
9490 struct net_device *dev,
9491 struct beacon_parameters *params)
9492{
9493 int ret;
9494
9495 vos_ssr_protect(__func__);
9496 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
9497 vos_ssr_unprotect(__func__);
9498
9499 return ret;
9500}
9501
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009502#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9503
9504#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309505static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009506 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009507#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309508static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009509 struct net_device *dev)
9510#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009511{
9512 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07009513 hdd_context_t *pHddCtx = NULL;
9514 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309515 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309516 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009517
9518 ENTER();
9519
9520 if (NULL == pAdapter)
9521 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309522 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009523 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009524 return -ENODEV;
9525 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009526
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309527 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9528 TRACE_CODE_HDD_CFG80211_STOP_AP,
9529 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309530 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9531 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309532 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009533 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309534 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07009535 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009536
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009537 pScanInfo = &pHddCtx->scan_info;
9538
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309539 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9540 __func__, hdd_device_modetoString(pAdapter->device_mode),
9541 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009542
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309543 ret = wlan_hdd_scan_abort(pAdapter);
9544
Girish Gowli4bf7a632014-06-12 13:42:11 +05309545 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07009546 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309547 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9548 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309549
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309550 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07009551 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309552 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9553 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08009554
Jeff Johnsone7245742012-09-05 17:12:55 -07009555 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309556 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07009557 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309558 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07009559 }
9560
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05309561 /* Delete all associated STAs before stopping AP/P2P GO */
9562 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05309563 hdd_hostapd_stop(dev);
9564
Jeff Johnson295189b2012-06-20 16:38:30 -07009565 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009566 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07009567 )
9568 {
9569 beacon_data_t *old;
9570
9571 old = pAdapter->sessionCtx.ap.beacon;
9572
9573 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309574 {
9575 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9576 FL("session(%d) beacon data points to NULL"),
9577 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009578 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309579 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009580
Jeff Johnson295189b2012-06-20 16:38:30 -07009581 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009582
9583 mutex_lock(&pHddCtx->sap_lock);
9584 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
9585 {
Jeff Johnson4416a782013-03-25 14:17:50 -07009586 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009587 {
9588 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
9589
9590 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
9591
9592 if (!VOS_IS_STATUS_SUCCESS(status))
9593 {
9594 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009595 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009596 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309597 }
9598 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009599 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05309600 /* BSS stopped, clear the active sessions for this device mode */
9601 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009602 }
9603 mutex_unlock(&pHddCtx->sap_lock);
9604
9605 if(status != VOS_STATUS_SUCCESS)
9606 {
9607 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009608 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009609 return -EINVAL;
9610 }
9611
Jeff Johnson4416a782013-03-25 14:17:50 -07009612 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07009613 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
9614 ==eHAL_STATUS_FAILURE)
9615 {
9616 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009617 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009618 }
9619
Jeff Johnson4416a782013-03-25 14:17:50 -07009620 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07009621 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
9622 eANI_BOOLEAN_FALSE) )
9623 {
9624 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009625 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009626 }
9627
9628 // Reset WNI_CFG_PROBE_RSP Flags
9629 wlan_hdd_reset_prob_rspies(pAdapter);
9630
9631 pAdapter->sessionCtx.ap.beacon = NULL;
9632 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009633#ifdef WLAN_FEATURE_P2P_DEBUG
9634 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
9635 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
9636 {
9637 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
9638 "GO got removed");
9639 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
9640 }
9641#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009642 }
9643 EXIT();
9644 return status;
9645}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009646
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309647#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9648static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
9649 struct net_device *dev)
9650{
9651 int ret;
9652
9653 vos_ssr_protect(__func__);
9654 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
9655 vos_ssr_unprotect(__func__);
9656
9657 return ret;
9658}
9659#else
9660static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
9661 struct net_device *dev)
9662{
9663 int ret;
9664
9665 vos_ssr_protect(__func__);
9666 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
9667 vos_ssr_unprotect(__func__);
9668
9669 return ret;
9670}
9671#endif
9672
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009673#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
9674
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309675static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309676 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009677 struct cfg80211_ap_settings *params)
9678{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309679 hdd_adapter_t *pAdapter;
9680 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309681 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009682
9683 ENTER();
9684
Girish Gowlib143d7a2015-02-18 19:39:55 +05309685 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07009686 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309687 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +05309688 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309689 return -ENODEV;
9690 }
9691
9692 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9693 if (NULL == pAdapter)
9694 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309695 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309696 "%s: HDD adapter is Null", __func__);
9697 return -ENODEV;
9698 }
9699
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309700 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9701 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
9702 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309703 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
9704 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309705 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309706 "%s: HDD adapter magic is invalid", __func__);
9707 return -ENODEV;
9708 }
9709
9710 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309711 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309712 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309713 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309714 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309715 }
9716
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309717 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
9718 __func__, hdd_device_modetoString(pAdapter->device_mode),
9719 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309720
9721 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009722 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009723 )
9724 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309725 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009726
9727 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309728
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009729 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309730 {
9731 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9732 FL("already beacon info added to session(%d)"),
9733 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009734 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309735 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009736
Girish Gowlib143d7a2015-02-18 19:39:55 +05309737#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9738 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
9739 &new,
9740 &params->beacon);
9741#else
9742 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
9743 &new,
9744 &params->beacon,
9745 params->dtim_period);
9746#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009747
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309748 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009749 {
9750 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309751 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009752 return -EINVAL;
9753 }
9754 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08009755#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07009756 wlan_hdd_cfg80211_set_channel(wiphy, dev,
9757#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
9758 params->channel, params->channel_type);
9759#else
9760 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
9761#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08009762#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009763 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05309764 params->ssid_len, params->hidden_ssid,
9765 params->auth_type);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009766 }
9767
9768 EXIT();
9769 return status;
9770}
9771
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309772static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
9773 struct net_device *dev,
9774 struct cfg80211_ap_settings *params)
9775{
9776 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009777
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309778 vos_ssr_protect(__func__);
9779 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
9780 vos_ssr_unprotect(__func__);
9781
9782 return ret;
9783}
9784
9785static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009786 struct net_device *dev,
9787 struct cfg80211_beacon_data *params)
9788{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309789 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309790 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309791 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009792
9793 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309794
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309795 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9796 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
9797 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08009798 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009799 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309800
9801 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9802 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309803 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07009804 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309805 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07009806 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009807
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309808 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009809 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309810 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009811 {
9812 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309813
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009814 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309815
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009816 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309817 {
9818 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9819 FL("session(%d) beacon data points to NULL"),
9820 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009821 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309822 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009823
9824 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
9825
9826 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309827 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009828 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009829 return -EINVAL;
9830 }
9831
9832 pAdapter->sessionCtx.ap.beacon = new;
9833
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05309834 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0,
9835 pAdapter->sessionCtx.ap.sapConfig.authType);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009836 }
9837
9838 EXIT();
9839 return status;
9840}
9841
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309842static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
9843 struct net_device *dev,
9844 struct cfg80211_beacon_data *params)
9845{
9846 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009847
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309848 vos_ssr_protect(__func__);
9849 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
9850 vos_ssr_unprotect(__func__);
9851
9852 return ret;
9853}
9854
9855#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009856
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05309857static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009858 struct net_device *dev,
9859 struct bss_parameters *params)
9860{
9861 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309862 hdd_context_t *pHddCtx;
9863 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009864
9865 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309866
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309867 if (NULL == pAdapter)
9868 {
9869 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9870 "%s: HDD adapter is Null", __func__);
9871 return -ENODEV;
9872 }
9873 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309874 ret = wlan_hdd_validate_context(pHddCtx);
9875 if (0 != ret)
9876 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309877 return ret;
9878 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309879 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9880 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
9881 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309882 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9883 __func__, hdd_device_modetoString(pAdapter->device_mode),
9884 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009885
9886 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009887 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309888 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009889 {
9890 /* ap_isolate == -1 means that in change bss, upper layer doesn't
9891 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309892 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07009893 {
9894 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309895 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009896 }
9897
9898 EXIT();
9899 return 0;
9900}
9901
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05309902static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
9903 struct net_device *dev,
9904 struct bss_parameters *params)
9905{
9906 int ret;
9907
9908 vos_ssr_protect(__func__);
9909 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
9910 vos_ssr_unprotect(__func__);
9911
9912 return ret;
9913}
Kiet Lam10841362013-11-01 11:36:50 +05309914/* FUNCTION: wlan_hdd_change_country_code_cd
9915* to wait for contry code completion
9916*/
9917void* wlan_hdd_change_country_code_cb(void *pAdapter)
9918{
9919 hdd_adapter_t *call_back_pAdapter = pAdapter;
9920 complete(&call_back_pAdapter->change_country_code);
9921 return NULL;
9922}
9923
Jeff Johnson295189b2012-06-20 16:38:30 -07009924/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05309925 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07009926 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
9927 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05309928int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009929 struct net_device *ndev,
9930 enum nl80211_iftype type,
9931 u32 *flags,
9932 struct vif_params *params
9933 )
9934{
9935 struct wireless_dev *wdev;
9936 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08009937 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07009938 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009939 tCsrRoamProfile *pRoamProfile = NULL;
9940 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309941 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009942 eMib_dot11DesiredBssType connectedBssType;
9943 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309944 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009945
9946 ENTER();
9947
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309948 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08009949 {
9950 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9951 "%s: Adapter context is null", __func__);
9952 return VOS_STATUS_E_FAILURE;
9953 }
9954
9955 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9956 if (!pHddCtx)
9957 {
9958 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9959 "%s: HDD context is null", __func__);
9960 return VOS_STATUS_E_FAILURE;
9961 }
9962
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309963 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9964 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
9965 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309966 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309967 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009968 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309969 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009970 }
9971
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309972 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9973 __func__, hdd_device_modetoString(pAdapter->device_mode),
9974 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009975
Agarwal Ashish51325b52014-06-16 16:50:49 +05309976 if (vos_max_concurrent_connections_reached()) {
9977 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
9978 return -EINVAL;
9979 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309980 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07009981 wdev = ndev->ieee80211_ptr;
9982
9983#ifdef WLAN_BTAMP_FEATURE
9984 if((NL80211_IFTYPE_P2P_CLIENT == type)||
9985 (NL80211_IFTYPE_ADHOC == type)||
9986 (NL80211_IFTYPE_AP == type)||
9987 (NL80211_IFTYPE_P2P_GO == type))
9988 {
9989 pHddCtx->isAmpAllowed = VOS_FALSE;
9990 // stop AMP traffic
9991 status = WLANBAP_StopAmp();
9992 if(VOS_STATUS_SUCCESS != status )
9993 {
9994 pHddCtx->isAmpAllowed = VOS_TRUE;
9995 hddLog(VOS_TRACE_LEVEL_FATAL,
9996 "%s: Failed to stop AMP", __func__);
9997 return -EINVAL;
9998 }
9999 }
10000#endif //WLAN_BTAMP_FEATURE
10001 /* Reset the current device mode bit mask*/
10002 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
10003
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +053010004 if ((pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) &&
10005 ((type == NL80211_IFTYPE_P2P_CLIENT) ||
10006 (type == NL80211_IFTYPE_P2P_GO)))
10007 {
10008 /* Notify Mode change in case of concurrency.
10009 * Below function invokes TDLS teardown Functionality Since TDLS is
10010 * not Supported in case of concurrency i.e Once P2P session
10011 * is detected disable offchannel and teardown TDLS links
10012 */
10013 hddLog(LOG1,
10014 FL("Device mode = %d Interface type = %d"),
10015 pAdapter->device_mode, type);
10016 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
10017 }
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +053010018
Jeff Johnson295189b2012-06-20 16:38:30 -070010019 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070010020 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -070010021 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -070010022 )
10023 {
10024 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010025 if (!pWextState)
10026 {
10027 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10028 "%s: pWextState is null", __func__);
10029 return VOS_STATUS_E_FAILURE;
10030 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010031 pRoamProfile = &pWextState->roamProfile;
10032 LastBSSType = pRoamProfile->BSSType;
10033
10034 switch (type)
10035 {
10036 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070010037 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070010038 hddLog(VOS_TRACE_LEVEL_INFO,
10039 "%s: setting interface Type to INFRASTRUCTURE", __func__);
10040 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -070010041#ifdef WLAN_FEATURE_11AC
10042 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
10043 {
10044 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
10045 }
10046#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010047 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -070010048 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010049 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080010050 //Check for sub-string p2p to confirm its a p2p interface
10051 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010052 {
Mahesh A Saptasagarc48ae8a2015-08-09 00:04:35 +053010053#ifdef FEATURE_WLAN_TDLS
10054 mutex_lock(&pHddCtx->tdls_lock);
10055 wlan_hdd_tdls_exit(pAdapter, TRUE);
10056 mutex_unlock(&pHddCtx->tdls_lock);
10057#endif
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010058 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
10059 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
10060 }
10061 else
10062 {
10063 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070010064 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010065 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010066 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +053010067
Jeff Johnson295189b2012-06-20 16:38:30 -070010068 case NL80211_IFTYPE_ADHOC:
10069 hddLog(VOS_TRACE_LEVEL_INFO,
10070 "%s: setting interface Type to ADHOC", __func__);
10071 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
10072 pRoamProfile->phyMode =
10073 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -070010074 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -070010075 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +053010076 hdd_set_ibss_ops( pAdapter );
10077 hdd_ibss_init_tx_rx( pAdapter );
Nirav Shah7e3c8132015-06-22 23:51:42 +053010078
10079 status = hdd_sta_id_hash_attach(pAdapter);
10080 if (VOS_STATUS_SUCCESS != status) {
10081 hddLog(VOS_TRACE_LEVEL_ERROR,
10082 FL("Failed to initialize hash for IBSS"));
10083 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010084 break;
10085
10086 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010087 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070010088 {
10089 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
10090 "%s: setting interface Type to %s", __func__,
10091 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
10092
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080010093 //Cancel any remain on channel for GO mode
10094 if (NL80211_IFTYPE_P2P_GO == type)
10095 {
10096 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
10097 }
Mohit Khanna0f232092012-09-11 14:46:08 -070010098 if (NL80211_IFTYPE_AP == type)
10099 {
10100 /* As Loading WLAN Driver one interface being created for p2p device
10101 * address. This will take one HW STA and the max number of clients
10102 * that can connect to softAP will be reduced by one. so while changing
10103 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
10104 * interface as it is not required in SoftAP mode.
10105 */
10106
10107 // Get P2P Adapter
10108 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
10109
10110 if (pP2pAdapter)
10111 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +053010112 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +053010113 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -070010114 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
10115 }
10116 }
Swaroop Goltia2e32212014-04-09 23:37:33 +053010117 //Disable IMPS & BMPS for SAP/GO
10118 if(VOS_STATUS_E_FAILURE ==
10119 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
10120 {
10121 //Fail to Exit BMPS
10122 VOS_ASSERT(0);
10123 }
Deepthi Gowri500fc472014-08-11 19:53:10 +053010124
10125 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
10126
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010127#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -070010128
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010129 /* A Mutex Lock is introduced while changing the mode to
10130 * protect the concurrent access for the Adapters by TDLS
10131 * module.
10132 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010133 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010134#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010135 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +053010136 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010137 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -070010138 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
10139 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010140#ifdef FEATURE_WLAN_TDLS
10141 mutex_unlock(&pHddCtx->tdls_lock);
10142#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070010143 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
10144 (pConfig->apRandomBssidEnabled))
10145 {
10146 /* To meet Android requirements create a randomized
10147 MAC address of the form 02:1A:11:Fx:xx:xx */
10148 get_random_bytes(&ndev->dev_addr[3], 3);
10149 ndev->dev_addr[0] = 0x02;
10150 ndev->dev_addr[1] = 0x1A;
10151 ndev->dev_addr[2] = 0x11;
10152 ndev->dev_addr[3] |= 0xF0;
10153 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
10154 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -080010155 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
10156 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070010157 }
10158
Jeff Johnson295189b2012-06-20 16:38:30 -070010159 hdd_set_ap_ops( pAdapter->dev );
10160
Kiet Lam10841362013-11-01 11:36:50 +053010161 /* This is for only SAP mode where users can
10162 * control country through ini.
10163 * P2P GO follows station country code
10164 * acquired during the STA scanning. */
10165 if((NL80211_IFTYPE_AP == type) &&
10166 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
10167 {
10168 int status = 0;
10169 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
10170 "%s: setting country code from INI ", __func__);
10171 init_completion(&pAdapter->change_country_code);
10172 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
10173 (void *)(tSmeChangeCountryCallback)
10174 wlan_hdd_change_country_code_cb,
10175 pConfig->apCntryCode, pAdapter,
10176 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +053010177 eSIR_FALSE,
10178 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +053010179 if (eHAL_STATUS_SUCCESS == status)
10180 {
10181 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010182 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +053010183 &pAdapter->change_country_code,
10184 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010185 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +053010186 {
10187 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010188 FL("SME Timed out while setting country code %ld"),
10189 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -080010190
10191 if (pHddCtx->isLogpInProgress)
10192 {
10193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10194 "%s: LOGP in Progress. Ignore!!!", __func__);
10195 return -EAGAIN;
10196 }
Kiet Lam10841362013-11-01 11:36:50 +053010197 }
10198 }
10199 else
10200 {
10201 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010202 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +053010203 return -EINVAL;
10204 }
10205 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010206 status = hdd_init_ap_mode(pAdapter);
10207 if(status != VOS_STATUS_SUCCESS)
10208 {
10209 hddLog(VOS_TRACE_LEVEL_FATAL,
10210 "%s: Error initializing the ap mode", __func__);
10211 return -EINVAL;
10212 }
10213 hdd_set_conparam(1);
10214
Nirav Shah7e3c8132015-06-22 23:51:42 +053010215 status = hdd_sta_id_hash_attach(pAdapter);
10216 if (VOS_STATUS_SUCCESS != status)
10217 {
10218 hddLog(VOS_TRACE_LEVEL_ERROR,
10219 FL("Failed to initialize hash for AP"));
10220 return -EINVAL;
10221 }
10222
Jeff Johnson295189b2012-06-20 16:38:30 -070010223 /*interface type changed update in wiphy structure*/
10224 if(wdev)
10225 {
10226 wdev->iftype = type;
10227 pHddCtx->change_iface = type;
10228 }
10229 else
10230 {
10231 hddLog(VOS_TRACE_LEVEL_ERROR,
10232 "%s: ERROR !!!! Wireless dev is NULL", __func__);
10233 return -EINVAL;
10234 }
10235 goto done;
10236 }
10237
10238 default:
10239 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
10240 __func__);
10241 return -EOPNOTSUPP;
10242 }
10243 }
10244 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010245 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070010246 )
10247 {
10248 switch(type)
10249 {
10250 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070010251 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070010252 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +053010253
10254 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010255#ifdef FEATURE_WLAN_TDLS
10256
10257 /* A Mutex Lock is introduced while changing the mode to
10258 * protect the concurrent access for the Adapters by TDLS
10259 * module.
10260 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010261 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010262#endif
c_hpothu002231a2015-02-05 14:58:51 +053010263 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010264 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080010265 //Check for sub-string p2p to confirm its a p2p interface
10266 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010267 {
10268 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
10269 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
10270 }
10271 else
10272 {
10273 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070010274 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010275 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010276 hdd_set_conparam(0);
10277 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070010278 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
10279 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010280#ifdef FEATURE_WLAN_TDLS
10281 mutex_unlock(&pHddCtx->tdls_lock);
10282#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +053010283 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -070010284 if( VOS_STATUS_SUCCESS != status )
10285 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -070010286 /* In case of JB, for P2P-GO, only change interface will be called,
10287 * This is the right place to enable back bmps_imps()
10288 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053010289 if (pHddCtx->hdd_wlan_suspended)
10290 {
10291 hdd_set_pwrparams(pHddCtx);
10292 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010293 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070010294 goto done;
10295 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010296 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070010297 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070010298 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
10299 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -070010300 goto done;
10301 default:
10302 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
10303 __func__);
10304 return -EOPNOTSUPP;
10305
10306 }
10307
10308 }
10309 else
10310 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010311 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
10312 __func__, hdd_device_modetoString(pAdapter->device_mode),
10313 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010314 return -EOPNOTSUPP;
10315 }
10316
10317
10318 if(pRoamProfile)
10319 {
10320 if ( LastBSSType != pRoamProfile->BSSType )
10321 {
10322 /*interface type changed update in wiphy structure*/
10323 wdev->iftype = type;
10324
10325 /*the BSS mode changed, We need to issue disconnect
10326 if connected or in IBSS disconnect state*/
10327 if ( hdd_connGetConnectedBssType(
10328 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
10329 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
10330 {
10331 /*need to issue a disconnect to CSR.*/
10332 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10333 if( eHAL_STATUS_SUCCESS ==
10334 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10335 pAdapter->sessionId,
10336 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
10337 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010338 ret = wait_for_completion_interruptible_timeout(
10339 &pAdapter->disconnect_comp_var,
10340 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10341 if (ret <= 0)
10342 {
10343 hddLog(VOS_TRACE_LEVEL_ERROR,
10344 FL("wait on disconnect_comp_var failed %ld"), ret);
10345 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010346 }
10347 }
10348 }
10349 }
10350
10351done:
10352 /*set bitmask based on updated value*/
10353 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -070010354
10355 /* Only STA mode support TM now
10356 * all other mode, TM feature should be disabled */
10357 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
10358 (~VOS_STA & pHddCtx->concurrency_mode) )
10359 {
10360 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
10361 }
10362
Jeff Johnson295189b2012-06-20 16:38:30 -070010363#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010364 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053010365 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -070010366 {
10367 //we are ok to do AMP
10368 pHddCtx->isAmpAllowed = VOS_TRUE;
10369 }
10370#endif //WLAN_BTAMP_FEATURE
10371 EXIT();
10372 return 0;
10373}
10374
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053010375/*
10376 * FUNCTION: wlan_hdd_cfg80211_change_iface
10377 * wrapper function to protect the actual implementation from SSR.
10378 */
10379int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
10380 struct net_device *ndev,
10381 enum nl80211_iftype type,
10382 u32 *flags,
10383 struct vif_params *params
10384 )
10385{
10386 int ret;
10387
10388 vos_ssr_protect(__func__);
10389 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
10390 vos_ssr_unprotect(__func__);
10391
10392 return ret;
10393}
10394
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010395#ifdef FEATURE_WLAN_TDLS
10396static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053010397 struct net_device *dev,
10398#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
10399 const u8 *mac,
10400#else
10401 u8 *mac,
10402#endif
10403 bool update, tCsrStaParams *StaParams)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010404{
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010405 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010406 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010407 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010408 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010409 hdd_adapter_t *pAdapter;
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053010410 VOS_STATUS status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010411
10412 ENTER();
10413
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010414 if (!dev) {
10415 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
10416 return -EINVAL;
10417 }
10418
10419 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10420 if (!pAdapter) {
10421 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
10422 return -EINVAL;
10423 }
10424
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053010425 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010426 {
10427 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10428 "Invalid arguments");
10429 return -EINVAL;
10430 }
Hoonki Lee27511902013-03-14 18:19:06 -070010431
10432 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
10433 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
10434 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010435 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070010436 "%s: TDLS mode is disabled OR not enabled in FW."
10437 MAC_ADDRESS_STR " Request declined.",
10438 __func__, MAC_ADDR_ARRAY(mac));
10439 return -ENOTSUPP;
10440 }
10441
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010442 if (pHddCtx->isLogpInProgress)
10443 {
10444 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10445 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053010446 wlan_hdd_tdls_set_link_status(pAdapter,
10447 mac,
10448 eTDLS_LINK_IDLE,
10449 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010450 return -EBUSY;
10451 }
10452
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053010453 mutex_lock(&pHddCtx->tdls_lock);
Naresh Jayaram9c6f4462014-02-13 12:20:31 +053010454 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010455
10456 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010457 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010458 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
10459 __func__, MAC_ADDR_ARRAY(mac), update);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053010460 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010461 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010462 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010463
10464 /* in add station, we accept existing valid staId if there is */
10465 if ((0 == update) &&
10466 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
10467 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010468 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010469 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010470 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010471 " link_status %d. staId %d. add station ignored.",
10472 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010473 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010474 return 0;
10475 }
10476 /* in change station, we accept only when staId is valid */
10477 if ((1 == update) &&
10478 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
10479 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
10480 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010481 tANI_U16 staId = pTdlsPeer->staId;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010482 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010483 "%s: " MAC_ADDRESS_STR
10484 " link status %d. staId %d. change station %s.",
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010485 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, staId,
10486 (TDLS_STA_INDEX_VALID(staId)) ? "ignored" : "declined");
10487 mutex_unlock(&pHddCtx->tdls_lock);
10488 return (TDLS_STA_INDEX_VALID(staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010489 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010490 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010491
10492 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053010493 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010494 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010495 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10496 "%s: " MAC_ADDRESS_STR
10497 " TDLS setup is ongoing. Request declined.",
10498 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -070010499 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010500 }
10501
10502 /* first to check if we reached to maximum supported TDLS peer.
10503 TODO: for now, return -EPERM looks working fine,
10504 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010505 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
10506 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010507 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010508 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10509 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010510 " TDLS Max peer already connected. Request declined."
10511 " Num of peers (%d), Max allowed (%d).",
10512 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
10513 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070010514 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010515 }
10516 else
10517 {
10518 hddTdlsPeer_t *pTdlsPeer;
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010519 mutex_lock(&pHddCtx->tdls_lock);
10520 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010521 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010522 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010523 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010524 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10525 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
10526 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010527 return -EPERM;
10528 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010529 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010530 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010531 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +053010532 wlan_hdd_tdls_set_link_status(pAdapter,
10533 mac,
10534 eTDLS_LINK_CONNECTING,
10535 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010536
Jeff Johnsond75fe012013-04-06 10:53:06 -070010537 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053010538 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010539 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010540 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010541 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -070010542 if(StaParams->htcap_present)
10543 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010544 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070010545 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010546 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070010547 "ht_capa->extended_capabilities: %0x",
10548 StaParams->HTCap.extendedHtCapInfo);
10549 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010551 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010552 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070010553 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -070010554 if(StaParams->vhtcap_present)
10555 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010556 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070010557 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
10558 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
10559 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
10560 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010561 {
10562 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010563 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010564 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010565 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010566 "[%d]: %x ", i, StaParams->supported_rates[i]);
10567 }
Jeff Johnsond75fe012013-04-06 10:53:06 -070010568 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053010569 else if ((1 == update) && (NULL == StaParams))
10570 {
10571 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10572 "%s : update is true, but staParams is NULL. Error!", __func__);
10573 return -EPERM;
10574 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010575
10576 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
10577
10578 if (!update)
10579 {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053010580 /*Before adding sta make sure that device exited from BMPS*/
10581 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
10582 {
10583 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10584 "%s: Adding tdls peer sta. Disable BMPS", __func__);
10585 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
10586 if (status != VOS_STATUS_SUCCESS) {
10587 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
10588 }
10589 }
10590
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010591 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010592 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010593 if (ret != eHAL_STATUS_SUCCESS) {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053010594 hddLog(VOS_TRACE_LEVEL_ERROR,
10595 FL("Failed to add TDLS peer STA. Enable Bmps"));
10596 wlan_hdd_tdls_check_bmps(pAdapter);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010597 return -EPERM;
10598 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010599 }
10600 else
10601 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010602 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010603 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010604 if (ret != eHAL_STATUS_SUCCESS) {
10605 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
10606 return -EPERM;
10607 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010608 }
10609
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010610 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010611 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
10612
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010613 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010614 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010616 "%s: timeout waiting for tdls add station indication %ld",
10617 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010618 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010619 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010620
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010621 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
10622 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010624 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010625 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010626 }
10627
10628 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -070010629
10630error:
Atul Mittal115287b2014-07-08 13:26:33 +053010631 wlan_hdd_tdls_set_link_status(pAdapter,
10632 mac,
10633 eTDLS_LINK_IDLE,
10634 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -070010635 return -EPERM;
10636
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010637}
10638#endif
10639
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053010640static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010641 struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053010642#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
10643 const u8 *mac,
10644#else
Jeff Johnson295189b2012-06-20 16:38:30 -070010645 u8 *mac,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053010646#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010647 struct station_parameters *params)
10648{
10649 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053010650 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +053010651 hdd_context_t *pHddCtx;
10652 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010653 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010654 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070010655#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010656 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010657 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +053010658 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070010659#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070010660
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053010661 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010662
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053010663 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +053010664 if ((NULL == pAdapter))
10665 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010666 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053010667 "invalid adapter ");
10668 return -EINVAL;
10669 }
10670
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010671 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10672 TRACE_CODE_HDD_CHANGE_STATION,
10673 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +053010674 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +053010675
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010676 ret = wlan_hdd_validate_context(pHddCtx);
10677 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +053010678 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010679 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +053010680 }
10681
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010682 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10683
10684 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010685 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010686 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10687 "invalid HDD station context");
10688 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010689 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010690 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
10691
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010692 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
10693 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -070010694 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010695 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -070010696 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010697 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -070010698 WLANTL_STA_AUTHENTICATED);
10699
Gopichand Nakkala29149562013-05-10 21:43:41 +053010700 if (status != VOS_STATUS_SUCCESS)
10701 {
10702 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10703 "%s: Not able to change TL state to AUTHENTICATED", __func__);
10704 return -EINVAL;
10705 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010706 }
10707 }
Hoonki Leea6d49be2013-04-05 09:43:25 -070010708 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
10709 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +053010710#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010711 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
10712 StaParams.capability = params->capability;
10713 StaParams.uapsd_queues = params->uapsd_queues;
10714 StaParams.max_sp = params->max_sp;
10715
Naresh Jayaram3180aa42014-02-12 21:47:26 +053010716 /* Convert (first channel , number of channels) tuple to
10717 * the total list of channels. This goes with the assumption
10718 * that if the first channel is < 14, then the next channels
10719 * are an incremental of 1 else an incremental of 4 till the number
10720 * of channels.
10721 */
10722 if (0 != params->supported_channels_len) {
10723 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
10724 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
10725 {
10726 int wifi_chan_index;
10727 StaParams.supported_channels[j] = params->supported_channels[i];
10728 wifi_chan_index =
10729 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
10730 no_of_channels = params->supported_channels[i+1];
10731 for(k=1; k <= no_of_channels; k++)
10732 {
10733 StaParams.supported_channels[j+1] =
10734 StaParams.supported_channels[j] + wifi_chan_index;
10735 j+=1;
10736 }
10737 }
10738 StaParams.supported_channels_len = j;
10739 }
10740 vos_mem_copy(StaParams.supported_oper_classes,
10741 params->supported_oper_classes,
10742 params->supported_oper_classes_len);
10743 StaParams.supported_oper_classes_len =
10744 params->supported_oper_classes_len;
10745
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010746 if (0 != params->ext_capab_len)
10747 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
10748 sizeof(StaParams.extn_capability));
10749
10750 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070010751 {
10752 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010753 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070010754 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010755
10756 StaParams.supported_rates_len = params->supported_rates_len;
10757
10758 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
10759 * The supported_rates array , for all the structures propogating till Add Sta
10760 * to the firmware has to be modified , if the supplicant (ieee80211) is
10761 * modified to send more rates.
10762 */
10763
10764 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
10765 */
10766 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
10767 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
10768
10769 if (0 != StaParams.supported_rates_len) {
10770 int i = 0;
10771 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
10772 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010773 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010774 "Supported Rates with Length %d", StaParams.supported_rates_len);
10775 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010776 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010777 "[%d]: %0x", i, StaParams.supported_rates[i]);
10778 }
10779
10780 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070010781 {
10782 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010783 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070010784 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010785
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010786 if (0 != params->ext_capab_len ) {
10787 /*Define A Macro : TODO Sunil*/
10788 if ((1<<4) & StaParams.extn_capability[3]) {
10789 isBufSta = 1;
10790 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +053010791 /* TDLS Channel Switching Support */
10792 if ((1<<6) & StaParams.extn_capability[3]) {
10793 isOffChannelSupported = 1;
10794 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010795 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +053010796 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
10797 &StaParams, isBufSta,
10798 isOffChannelSupported);
10799
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010800 if (VOS_STATUS_SUCCESS != status) {
10801 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10802 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
10803 return -EINVAL;
10804 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010805 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
10806
10807 if (VOS_STATUS_SUCCESS != status) {
10808 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10809 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
10810 return -EINVAL;
10811 }
10812 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -070010813#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +053010814 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010815 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010816 return status;
10817}
10818
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053010819#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
10820static int wlan_hdd_change_station(struct wiphy *wiphy,
10821 struct net_device *dev,
10822 const u8 *mac,
10823 struct station_parameters *params)
10824#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053010825static int wlan_hdd_change_station(struct wiphy *wiphy,
10826 struct net_device *dev,
10827 u8 *mac,
10828 struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053010829#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053010830{
10831 int ret;
10832
10833 vos_ssr_protect(__func__);
10834 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
10835 vos_ssr_unprotect(__func__);
10836
10837 return ret;
10838}
10839
Jeff Johnson295189b2012-06-20 16:38:30 -070010840/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053010841 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -070010842 * This function is used to initialize the key information
10843 */
10844#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053010845static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010846 struct net_device *ndev,
10847 u8 key_index, bool pairwise,
10848 const u8 *mac_addr,
10849 struct key_params *params
10850 )
10851#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053010852static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010853 struct net_device *ndev,
10854 u8 key_index, const u8 *mac_addr,
10855 struct key_params *params
10856 )
10857#endif
10858{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010859 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070010860 tCsrRoamSetKey setKey;
10861 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010862 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010863 v_U32_t roamId= 0xFF;
10864 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070010865 hdd_hostapd_state_t *pHostapdState;
10866 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070010867 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010868 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010869
10870 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010871
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010872 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10873 TRACE_CODE_HDD_CFG80211_ADD_KEY,
10874 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010875 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10876 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010877 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010878 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010879 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010880 }
10881
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010882 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10883 __func__, hdd_device_modetoString(pAdapter->device_mode),
10884 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010885
10886 if (CSR_MAX_NUM_KEY <= key_index)
10887 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010888 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070010889 key_index);
10890
10891 return -EINVAL;
10892 }
10893
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010894 if (CSR_MAX_KEY_LEN < params->key_len)
10895 {
10896 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
10897 params->key_len);
10898
10899 return -EINVAL;
10900 }
10901
10902 hddLog(VOS_TRACE_LEVEL_INFO,
10903 "%s: called with key index = %d & key length %d",
10904 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070010905
10906 /*extract key idx, key len and key*/
10907 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
10908 setKey.keyId = key_index;
10909 setKey.keyLength = params->key_len;
10910 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
10911
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010912 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070010913 {
10914 case WLAN_CIPHER_SUITE_WEP40:
10915 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
10916 break;
10917
10918 case WLAN_CIPHER_SUITE_WEP104:
10919 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
10920 break;
10921
10922 case WLAN_CIPHER_SUITE_TKIP:
10923 {
10924 u8 *pKey = &setKey.Key[0];
10925 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
10926
10927 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
10928
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010929 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -070010930
10931 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010932 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070010933 |--------------|----------|----------|
10934 <---16bytes---><--8bytes--><--8bytes-->
10935
10936 */
10937 /*Sme expects the 32 bytes key to be in the below order
10938
10939 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010940 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070010941 |--------------|----------|----------|
10942 <---16bytes---><--8bytes--><--8bytes-->
10943 */
10944 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010945 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -070010946
10947 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010948 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070010949
10950 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010951 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070010952
10953
10954 break;
10955 }
10956
10957 case WLAN_CIPHER_SUITE_CCMP:
10958 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
10959 break;
10960
10961#ifdef FEATURE_WLAN_WAPI
10962 case WLAN_CIPHER_SUITE_SMS4:
10963 {
10964 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
10965 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
10966 params->key, params->key_len);
10967 return 0;
10968 }
10969#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070010970
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010971#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010972 case WLAN_CIPHER_SUITE_KRK:
10973 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
10974 break;
10975#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070010976
10977#ifdef WLAN_FEATURE_11W
10978 case WLAN_CIPHER_SUITE_AES_CMAC:
10979 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -070010980 break;
Chet Lanctot186b5732013-03-18 10:26:30 -070010981#endif
10982
Jeff Johnson295189b2012-06-20 16:38:30 -070010983 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -070010984 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070010985 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053010986 status = -EOPNOTSUPP;
10987 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070010988 }
10989
10990 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
10991 __func__, setKey.encType);
10992
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010993 if (
Jeff Johnson295189b2012-06-20 16:38:30 -070010994#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
10995 (!pairwise)
10996#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010997 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -070010998#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010999 )
11000 {
11001 /* set group key*/
11002 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11003 "%s- %d: setting Broadcast key",
11004 __func__, __LINE__);
11005 setKey.keyDirection = eSIR_RX_ONLY;
11006 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
11007 }
11008 else
11009 {
11010 /* set pairwise key*/
11011 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11012 "%s- %d: setting pairwise key",
11013 __func__, __LINE__);
11014 setKey.keyDirection = eSIR_TX_RX;
11015 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
11016 }
11017 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
11018 {
11019 setKey.keyDirection = eSIR_TX_RX;
11020 /*Set the group key*/
11021 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
11022 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011023
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011024 if ( 0 != status )
11025 {
11026 hddLog(VOS_TRACE_LEVEL_ERROR,
11027 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011028 status = -EINVAL;
11029 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011030 }
11031 /*Save the keys here and call sme_RoamSetKey for setting
11032 the PTK after peer joins the IBSS network*/
11033 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
11034 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011035 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011036 }
Gopichand Nakkala29149562013-05-10 21:43:41 +053011037 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
11038 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
11039 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011040 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011041 if( pHostapdState->bssState == BSS_START )
11042 {
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011043 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11044 vos_status = wlan_hdd_check_ula_done(pAdapter);
11045
11046 if ( vos_status != VOS_STATUS_SUCCESS )
11047 {
11048 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11049 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
11050 __LINE__, vos_status );
11051
11052 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
11053
11054 status = -EINVAL;
11055 goto end;
11056 }
11057
Jeff Johnson295189b2012-06-20 16:38:30 -070011058 status = WLANSAP_SetKeySta( pVosContext, &setKey);
11059
11060 if ( status != eHAL_STATUS_SUCCESS )
11061 {
11062 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11063 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
11064 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011065 status = -EINVAL;
11066 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011067 }
11068 }
11069
11070 /* Saving WEP keys */
11071 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
11072 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
11073 {
11074 //Save the wep key in ap context. Issue setkey after the BSS is started.
11075 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
11076 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
11077 }
11078 else
11079 {
11080 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011081 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011082 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
11083 }
11084 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011085 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
11086 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011087 {
11088 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11089 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11090
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011091#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11092 if (!pairwise)
11093#else
11094 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
11095#endif
11096 {
11097 /* set group key*/
11098 if (pHddStaCtx->roam_info.deferKeyComplete)
11099 {
11100 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11101 "%s- %d: Perform Set key Complete",
11102 __func__, __LINE__);
11103 hdd_PerformRoamSetKeyComplete(pAdapter);
11104 }
11105 }
11106
Jeff Johnson295189b2012-06-20 16:38:30 -070011107 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
11108
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -080011109 pWextState->roamProfile.Keys.defaultIndex = key_index;
11110
11111
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011112 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070011113 params->key, params->key_len);
11114
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011115
Jeff Johnson295189b2012-06-20 16:38:30 -070011116 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
11117
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011118 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011119 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011120 __func__, setKey.peerMac[0], setKey.peerMac[1],
11121 setKey.peerMac[2], setKey.peerMac[3],
11122 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070011123 setKey.keyDirection);
11124
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011125 vos_status = wlan_hdd_check_ula_done(pAdapter);
Nirav Shah4f765af2015-01-21 19:51:30 +053011126
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011127 if ( vos_status != VOS_STATUS_SUCCESS )
11128 {
11129 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011130 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
11131 __LINE__, vos_status );
11132
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011133 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011134
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011135 status = -EINVAL;
11136 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011137
11138 }
11139
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011140#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011141 /* The supplicant may attempt to set the PTK once pre-authentication
11142 is done. Save the key in the UMAC and include it in the ADD BSS
11143 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011144 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011145 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011146 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011147 hddLog(VOS_TRACE_LEVEL_INFO_MED,
11148 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011149 status = 0;
11150 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011151 }
11152 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
11153 {
11154 hddLog(VOS_TRACE_LEVEL_ERROR,
11155 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011156 status = -EINVAL;
11157 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011158 }
11159#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -070011160
11161 /* issue set key request to SME*/
11162 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
11163 pAdapter->sessionId, &setKey, &roamId );
11164
11165 if ( 0 != status )
11166 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011167 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011168 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
11169 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011170 status = -EINVAL;
11171 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011172 }
11173
11174
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011175 /* in case of IBSS as there was no information available about WEP keys during
11176 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -070011177 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011178 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
11179 !( ( IW_AUTH_KEY_MGMT_802_1X
11180 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -070011181 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
11182 )
11183 &&
11184 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
11185 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
11186 )
11187 )
11188 {
11189 setKey.keyDirection = eSIR_RX_ONLY;
11190 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
11191
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011192 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011193 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011194 __func__, setKey.peerMac[0], setKey.peerMac[1],
11195 setKey.peerMac[2], setKey.peerMac[3],
11196 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070011197 setKey.keyDirection);
11198
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011199 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011200 pAdapter->sessionId, &setKey, &roamId );
11201
11202 if ( 0 != status )
11203 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011204 hddLog(VOS_TRACE_LEVEL_ERROR,
11205 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011206 __func__, status);
11207 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011208 status = -EINVAL;
11209 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011210 }
11211 }
11212 }
11213
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011214end:
11215 /* Need to clear any trace of key value in the memory.
11216 * Thus zero out the memory even though it is local
11217 * variable.
11218 */
11219 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011220 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011221 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011222}
11223
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011224#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11225static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
11226 struct net_device *ndev,
11227 u8 key_index, bool pairwise,
11228 const u8 *mac_addr,
11229 struct key_params *params
11230 )
11231#else
11232static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
11233 struct net_device *ndev,
11234 u8 key_index, const u8 *mac_addr,
11235 struct key_params *params
11236 )
11237#endif
11238{
11239 int ret;
11240 vos_ssr_protect(__func__);
11241#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11242 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
11243 mac_addr, params);
11244#else
11245 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
11246 params);
11247#endif
11248 vos_ssr_unprotect(__func__);
11249
11250 return ret;
11251}
11252
Jeff Johnson295189b2012-06-20 16:38:30 -070011253/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011254 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011255 * This function is used to get the key information
11256 */
11257#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011258static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011259 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011260 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011261 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070011262 const u8 *mac_addr, void *cookie,
11263 void (*callback)(void *cookie, struct key_params*)
11264 )
11265#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011266static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011267 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011268 struct net_device *ndev,
11269 u8 key_index, const u8 *mac_addr, void *cookie,
11270 void (*callback)(void *cookie, struct key_params*)
11271 )
11272#endif
11273{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011274 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011275 hdd_wext_state_t *pWextState = NULL;
11276 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011277 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011278 hdd_context_t *pHddCtx;
11279 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070011280
11281 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011282
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011283 if (NULL == pAdapter)
11284 {
11285 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11286 "%s: HDD adapter is Null", __func__);
11287 return -ENODEV;
11288 }
11289
11290 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11291 ret = wlan_hdd_validate_context(pHddCtx);
11292 if (0 != ret)
11293 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011294 return ret;
11295 }
11296
11297 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11298 pRoamProfile = &(pWextState->roamProfile);
11299
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011300 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11301 __func__, hdd_device_modetoString(pAdapter->device_mode),
11302 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011303
Jeff Johnson295189b2012-06-20 16:38:30 -070011304 memset(&params, 0, sizeof(params));
11305
11306 if (CSR_MAX_NUM_KEY <= key_index)
11307 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011308 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070011309 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011310 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011311
11312 switch(pRoamProfile->EncryptionType.encryptionType[0])
11313 {
11314 case eCSR_ENCRYPT_TYPE_NONE:
11315 params.cipher = IW_AUTH_CIPHER_NONE;
11316 break;
11317
11318 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
11319 case eCSR_ENCRYPT_TYPE_WEP40:
11320 params.cipher = WLAN_CIPHER_SUITE_WEP40;
11321 break;
11322
11323 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
11324 case eCSR_ENCRYPT_TYPE_WEP104:
11325 params.cipher = WLAN_CIPHER_SUITE_WEP104;
11326 break;
11327
11328 case eCSR_ENCRYPT_TYPE_TKIP:
11329 params.cipher = WLAN_CIPHER_SUITE_TKIP;
11330 break;
11331
11332 case eCSR_ENCRYPT_TYPE_AES:
11333 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
11334 break;
11335
11336 default:
11337 params.cipher = IW_AUTH_CIPHER_NONE;
11338 break;
11339 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011340
c_hpothuaaf19692014-05-17 17:01:48 +053011341 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11342 TRACE_CODE_HDD_CFG80211_GET_KEY,
11343 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011344
Jeff Johnson295189b2012-06-20 16:38:30 -070011345 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
11346 params.seq_len = 0;
11347 params.seq = NULL;
11348 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
11349 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011350 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011351 return 0;
11352}
11353
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011354#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11355static int wlan_hdd_cfg80211_get_key(
11356 struct wiphy *wiphy,
11357 struct net_device *ndev,
11358 u8 key_index, bool pairwise,
11359 const u8 *mac_addr, void *cookie,
11360 void (*callback)(void *cookie, struct key_params*)
11361 )
11362#else
11363static int wlan_hdd_cfg80211_get_key(
11364 struct wiphy *wiphy,
11365 struct net_device *ndev,
11366 u8 key_index, const u8 *mac_addr, void *cookie,
11367 void (*callback)(void *cookie, struct key_params*)
11368 )
11369#endif
11370{
11371 int ret;
11372
11373 vos_ssr_protect(__func__);
11374#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11375 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
11376 mac_addr, cookie, callback);
11377#else
11378 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
11379 callback);
11380#endif
11381 vos_ssr_unprotect(__func__);
11382
11383 return ret;
11384}
11385
Jeff Johnson295189b2012-06-20 16:38:30 -070011386/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011387 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011388 * This function is used to delete the key information
11389 */
11390#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011391static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011392 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011393 u8 key_index,
11394 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070011395 const u8 *mac_addr
11396 )
11397#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011398static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011399 struct net_device *ndev,
11400 u8 key_index,
11401 const u8 *mac_addr
11402 )
11403#endif
11404{
11405 int status = 0;
11406
11407 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011408 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -070011409 //it is observed that this is invalidating peer
11410 //key index whenever re-key is done. This is affecting data link.
11411 //It should be ok to ignore del_key.
11412#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011413 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
11414 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070011415 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
11416 tCsrRoamSetKey setKey;
11417 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011418
Jeff Johnson295189b2012-06-20 16:38:30 -070011419 ENTER();
11420
11421 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
11422 __func__,pAdapter->device_mode);
11423
11424 if (CSR_MAX_NUM_KEY <= key_index)
11425 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011426 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011427 key_index);
11428
11429 return -EINVAL;
11430 }
11431
11432 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11433 setKey.keyId = key_index;
11434
11435 if (mac_addr)
11436 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
11437 else
11438 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
11439
11440 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
11441
11442 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070011443 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011444 )
11445 {
11446
11447 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -070011448 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
11449 if( pHostapdState->bssState == BSS_START)
11450 {
11451 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011452
Jeff Johnson295189b2012-06-20 16:38:30 -070011453 if ( status != eHAL_STATUS_SUCCESS )
11454 {
11455 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11456 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
11457 __LINE__, status );
11458 }
11459 }
11460 }
11461 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011462 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -070011463 )
11464 {
11465 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11466
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011467 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
11468
11469 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011470 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011471 __func__, setKey.peerMac[0], setKey.peerMac[1],
11472 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -070011473 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011474 if(pAdapter->sessionCtx.station.conn_info.connState ==
11475 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -070011476 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011477 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011478 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011479
Jeff Johnson295189b2012-06-20 16:38:30 -070011480 if ( 0 != status )
11481 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011482 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011483 "%s: sme_RoamSetKey failure, returned %d",
11484 __func__, status);
11485 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
11486 return -EINVAL;
11487 }
11488 }
11489 }
11490#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070011491 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011492 return status;
11493}
11494
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011495#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11496static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
11497 struct net_device *ndev,
11498 u8 key_index,
11499 bool pairwise,
11500 const u8 *mac_addr
11501 )
11502#else
11503static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
11504 struct net_device *ndev,
11505 u8 key_index,
11506 const u8 *mac_addr
11507 )
11508#endif
11509{
11510 int ret;
11511
11512 vos_ssr_protect(__func__);
11513#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11514 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
11515 mac_addr);
11516#else
11517 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
11518#endif
11519 vos_ssr_unprotect(__func__);
11520
11521 return ret;
11522}
11523
Jeff Johnson295189b2012-06-20 16:38:30 -070011524/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011525 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011526 * This function is used to set the default tx key index
11527 */
11528#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011529static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011530 struct net_device *ndev,
11531 u8 key_index,
11532 bool unicast, bool multicast)
11533#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011534static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011535 struct net_device *ndev,
11536 u8 key_index)
11537#endif
11538{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011539 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011540 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +053011541 hdd_wext_state_t *pWextState;
11542 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011543 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011544
11545 ENTER();
11546
Gopichand Nakkala29149562013-05-10 21:43:41 +053011547 if ((NULL == pAdapter))
11548 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011549 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053011550 "invalid adapter");
11551 return -EINVAL;
11552 }
11553
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011554 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11555 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
11556 pAdapter->sessionId, key_index));
11557
Gopichand Nakkala29149562013-05-10 21:43:41 +053011558 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11559 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11560
11561 if ((NULL == pWextState) || (NULL == pHddStaCtx))
11562 {
11563 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11564 "invalid Wext state or HDD context");
11565 return -EINVAL;
11566 }
11567
Arif Hussain6d2a3322013-11-17 19:50:10 -080011568 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011569 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011570
Jeff Johnson295189b2012-06-20 16:38:30 -070011571 if (CSR_MAX_NUM_KEY <= key_index)
11572 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011573 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011574 key_index);
11575
11576 return -EINVAL;
11577 }
11578
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011579 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11580 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011581 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011582 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011583 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011584 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011585
Jeff Johnson295189b2012-06-20 16:38:30 -070011586 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070011587 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011588 )
Jeff Johnson295189b2012-06-20 16:38:30 -070011589 {
Gopichand Nakkala29149562013-05-10 21:43:41 +053011590 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -080011591 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011592 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -080011593 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -070011594 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011595 {
11596 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -070011597 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011598
Jeff Johnson295189b2012-06-20 16:38:30 -070011599 tCsrRoamSetKey setKey;
11600 v_U32_t roamId= 0xFF;
11601 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011602
11603 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011604 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011605
Jeff Johnson295189b2012-06-20 16:38:30 -070011606 Keys->defaultIndex = (u8)key_index;
11607 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11608 setKey.keyId = key_index;
11609 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011610
11611 vos_mem_copy(&setKey.Key[0],
11612 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070011613 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011614
Gopichand Nakkala29149562013-05-10 21:43:41 +053011615 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011616
11617 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -070011618 &pHddStaCtx->conn_info.bssId[0],
11619 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011620
Gopichand Nakkala29149562013-05-10 21:43:41 +053011621 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
11622 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
11623 eCSR_ENCRYPT_TYPE_WEP104)
11624 {
11625 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
11626 even though ap is configured for WEP-40 encryption. In this canse the key length
11627 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
11628 type(104) and switching encryption type to 40*/
11629 pWextState->roamProfile.EncryptionType.encryptionType[0] =
11630 eCSR_ENCRYPT_TYPE_WEP40;
11631 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
11632 eCSR_ENCRYPT_TYPE_WEP40;
11633 }
11634
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011635 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -070011636 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011637
Jeff Johnson295189b2012-06-20 16:38:30 -070011638 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011639 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011640 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011641
Jeff Johnson295189b2012-06-20 16:38:30 -070011642 if ( 0 != status )
11643 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011644 hddLog(VOS_TRACE_LEVEL_ERROR,
11645 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011646 status);
11647 return -EINVAL;
11648 }
11649 }
11650 }
11651
11652 /* In SoftAp mode setting key direction for default mode */
11653 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
11654 {
11655 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
11656 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
11657 (eCSR_ENCRYPT_TYPE_AES !=
11658 pWextState->roamProfile.EncryptionType.encryptionType[0])
11659 )
11660 {
11661 /* Saving key direction for default key index to TX default */
11662 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
11663 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
11664 }
11665 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011666 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011667 return status;
11668}
11669
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011670#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11671static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
11672 struct net_device *ndev,
11673 u8 key_index,
11674 bool unicast, bool multicast)
11675#else
11676static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
11677 struct net_device *ndev,
11678 u8 key_index)
11679#endif
11680{
11681 int ret;
11682 vos_ssr_protect(__func__);
11683#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11684 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
11685 multicast);
11686#else
11687 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
11688#endif
11689 vos_ssr_unprotect(__func__);
11690
11691 return ret;
11692}
11693
Jeff Johnson295189b2012-06-20 16:38:30 -070011694/*
11695 * FUNCTION: wlan_hdd_cfg80211_inform_bss
11696 * This function is used to inform the BSS details to nl80211 interface.
11697 */
11698static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
11699 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
11700{
11701 struct net_device *dev = pAdapter->dev;
11702 struct wireless_dev *wdev = dev->ieee80211_ptr;
11703 struct wiphy *wiphy = wdev->wiphy;
11704 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
11705 int chan_no;
11706 int ie_length;
11707 const char *ie;
11708 unsigned int freq;
11709 struct ieee80211_channel *chan;
11710 int rssi = 0;
11711 struct cfg80211_bss *bss = NULL;
11712
Jeff Johnson295189b2012-06-20 16:38:30 -070011713 if( NULL == pBssDesc )
11714 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011715 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011716 return bss;
11717 }
11718
11719 chan_no = pBssDesc->channelId;
11720 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
11721 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
11722
11723 if( NULL == ie )
11724 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011725 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011726 return bss;
11727 }
11728
11729#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
11730 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
11731 {
11732 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
11733 }
11734 else
11735 {
11736 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
11737 }
11738#else
11739 freq = ieee80211_channel_to_frequency(chan_no);
11740#endif
11741
11742 chan = __ieee80211_get_channel(wiphy, freq);
11743
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +053011744 if (!chan) {
11745 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
11746 return NULL;
11747 }
11748
Abhishek Singhaee43942014-06-16 18:55:47 +053011749 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -070011750
Anand N Sunkad9f80b742015-07-30 20:05:51 +053011751 return cfg80211_inform_bss(wiphy, chan,
11752#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11753 CFG80211_BSS_FTYPE_UNKNOWN,
11754#endif
11755 pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011756 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -070011757 pBssDesc->capabilityInfo,
11758 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +053011759 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -070011760}
11761
11762
11763
11764/*
11765 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
11766 * This function is used to inform the BSS details to nl80211 interface.
11767 */
11768struct cfg80211_bss*
11769wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
11770 tSirBssDescription *bss_desc
11771 )
11772{
11773 /*
11774 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
11775 already exists in bss data base of cfg80211 for that particular BSS ID.
11776 Using cfg80211_inform_bss_frame to update the bss entry instead of
11777 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
11778 now there is no possibility to get the mgmt(probe response) frame from PE,
11779 converting bss_desc to ieee80211_mgmt(probe response) and passing to
11780 cfg80211_inform_bss_frame.
11781 */
11782 struct net_device *dev = pAdapter->dev;
11783 struct wireless_dev *wdev = dev->ieee80211_ptr;
11784 struct wiphy *wiphy = wdev->wiphy;
11785 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080011786#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
11787 qcom_ie_age *qie_age = NULL;
11788 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
11789#else
Jeff Johnson295189b2012-06-20 16:38:30 -070011790 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080011791#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011792 const char *ie =
11793 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
11794 unsigned int freq;
11795 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053011796 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011797 struct cfg80211_bss *bss_status = NULL;
11798 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
11799 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -070011800 hdd_context_t *pHddCtx;
11801 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -070011802#ifdef WLAN_OPEN_SOURCE
11803 struct timespec ts;
11804#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011805
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011806
Wilson Yangf80a0542013-10-07 13:02:37 -070011807 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11808 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -070011809 if (0 != status)
11810 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070011811 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070011812 }
11813
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053011814 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -070011815 if (!mgmt)
11816 {
11817 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11818 "%s: memory allocation failed ", __func__);
11819 return NULL;
11820 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070011821
Jeff Johnson295189b2012-06-20 16:38:30 -070011822 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -070011823
11824#ifdef WLAN_OPEN_SOURCE
11825 /* Android does not want the timestamp from the frame.
11826 Instead it wants a monotonic increasing value */
11827 get_monotonic_boottime(&ts);
11828 mgmt->u.probe_resp.timestamp =
11829 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
11830#else
11831 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -070011832 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
11833 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -070011834
11835#endif
11836
Jeff Johnson295189b2012-06-20 16:38:30 -070011837 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
11838 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080011839
11840#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
11841 /* GPS Requirement: need age ie per entry. Using vendor specific. */
11842 /* Assuming this is the last IE, copy at the end */
11843 ie_length -=sizeof(qcom_ie_age);
11844 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
11845 qie_age->element_id = QCOM_VENDOR_IE_ID;
11846 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
11847 qie_age->oui_1 = QCOM_OUI1;
11848 qie_age->oui_2 = QCOM_OUI2;
11849 qie_age->oui_3 = QCOM_OUI3;
11850 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
11851 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
11852#endif
11853
Jeff Johnson295189b2012-06-20 16:38:30 -070011854 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +053011855 if (bss_desc->fProbeRsp)
11856 {
11857 mgmt->frame_control |=
11858 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
11859 }
11860 else
11861 {
11862 mgmt->frame_control |=
11863 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
11864 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011865
11866#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011867 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070011868 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
11869 {
11870 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
11871 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011872 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070011873 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
11874
11875 {
11876 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
11877 }
11878 else
11879 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053011880 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
11881 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -070011882 kfree(mgmt);
11883 return NULL;
11884 }
11885#else
11886 freq = ieee80211_channel_to_frequency(chan_no);
11887#endif
11888 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080011889 /*when the band is changed on the fly using the GUI, three things are done
11890 * 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)
11891 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
11892 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
11893 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
11894 * and discards the channels correponding to previous band and calls back with zero bss results.
11895 * 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
11896 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
11897 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
11898 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
11899 * So drop the bss and continue to next bss.
11900 */
11901 if(chan == NULL)
11902 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053011903 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -070011904 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080011905 return NULL;
11906 }
Hanumantha Reddy Pothula904bcef2015-06-19 11:56:29 +053011907 /*To keep the rssi icon of the connected AP in the scan window
11908 *and the rssi icon of the wireless networks in sync
11909 * */
11910 if (( eConnectionState_Associated ==
11911 pAdapter->sessionCtx.station.conn_info.connState ) &&
11912 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
11913 pAdapter->sessionCtx.station.conn_info.bssId,
11914 WNI_CFG_BSSID_LEN)) &&
11915 (pHddCtx->hdd_wlan_suspended == FALSE))
11916 {
11917 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
11918 rssi = (pAdapter->rssi * 100);
11919 }
11920 else
11921 {
11922 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
11923 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011924
Nirav Shah20ac06f2013-12-12 18:14:06 +053011925 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
Sushant Kaushik0b343422015-05-25 17:15:55 +053011926 " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
11927 vos_freq_to_chan(chan->center_freq), (int)(rssi/100));
Nirav Shah20ac06f2013-12-12 18:14:06 +053011928
Jeff Johnson295189b2012-06-20 16:38:30 -070011929 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
11930 frame_len, rssi, GFP_KERNEL);
11931 kfree(mgmt);
11932 return bss_status;
11933}
11934
11935/*
11936 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
11937 * This function is used to update the BSS data base of CFG8011
11938 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011939struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011940 tCsrRoamInfo *pRoamInfo
11941 )
11942{
11943 tCsrRoamConnectedProfile roamProfile;
11944 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11945 struct cfg80211_bss *bss = NULL;
11946
11947 ENTER();
11948
11949 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
11950 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
11951
11952 if (NULL != roamProfile.pBssDesc)
11953 {
Girish Gowlif4b68022014-08-28 23:18:57 +053011954 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
11955 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070011956
11957 if (NULL == bss)
11958 {
11959 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
11960 __func__);
11961 }
11962
11963 sme_RoamFreeConnectProfile(hHal, &roamProfile);
11964 }
11965 else
11966 {
11967 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
11968 __func__);
11969 }
11970 return bss;
11971}
11972
11973/*
11974 * FUNCTION: wlan_hdd_cfg80211_update_bss
11975 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011976static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
11977 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -070011978 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011979{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011980 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011981 tCsrScanResultInfo *pScanResult;
11982 eHalStatus status = 0;
11983 tScanResultHandle pResult;
11984 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070011985 hdd_context_t *pHddCtx;
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053011986 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070011987 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011988
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011989 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11990 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
11991 NO_SESSION, pAdapter->sessionId));
11992
Wilson Yangf80a0542013-10-07 13:02:37 -070011993 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11994
11995 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -070011996 {
Wilson Yangf80a0542013-10-07 13:02:37 -070011997 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11998 "%s:LOGP in Progress. Ignore!!!",__func__);
11999 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -070012000 }
12001
Wilson Yangf80a0542013-10-07 13:02:37 -070012002
12003 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +053012004 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -070012005 {
12006 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12007 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
12008 return VOS_STATUS_E_PERM;
12009 }
12010
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012011 if (pAdapter->request != NULL)
12012 {
12013 if ((pAdapter->request->n_ssids == 1)
12014 && (pAdapter->request->ssids != NULL)
12015 && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7))
12016 is_p2p_scan = true;
12017 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012018 /*
12019 * start getting scan results and populate cgf80211 BSS database
12020 */
12021 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
12022
12023 /* no scan results */
12024 if (NULL == pResult)
12025 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053012026 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
12027 __func__, status);
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053012028 wlan_hdd_get_frame_logs(pAdapter,
12029 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Jeff Johnson295189b2012-06-20 16:38:30 -070012030 return status;
12031 }
12032
12033 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
12034
12035 while (pScanResult)
12036 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012037 /*
12038 * cfg80211_inform_bss() is not updating ie field of bss entry, if
12039 * entry already exists in bss data base of cfg80211 for that
12040 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
12041 * bss entry instead of cfg80211_inform_bss, But this call expects
12042 * mgmt packet as input. As of now there is no possibility to get
12043 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -070012044 * ieee80211_mgmt(probe response) and passing to c
12045 * fg80211_inform_bss_frame.
12046 * */
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012047 if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) &&
12048 !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) )
12049 {
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012050 pScanResult = sme_ScanResultGetNext(hHal, pResult);
12051 continue; //Skip the non p2p bss entries
12052 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012053 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
12054 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012055
Jeff Johnson295189b2012-06-20 16:38:30 -070012056
12057 if (NULL == bss_status)
12058 {
12059 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012060 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012061 }
12062 else
12063 {
Yue Maf49ba872013-08-19 12:04:25 -070012064 cfg80211_put_bss(
12065#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
12066 wiphy,
12067#endif
12068 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012069 }
12070
12071 pScanResult = sme_ScanResultGetNext(hHal, pResult);
12072 }
12073
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012074 sme_ScanResultPurge(hHal, pResult);
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012075 is_p2p_scan = false;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012076 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012077}
12078
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012079void
12080hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
12081{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012082 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080012083 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012084} /****** end hddPrintMacAddr() ******/
12085
12086void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070012087hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012088{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012089 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012090 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070012091 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
12092 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
12093 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012094} /****** end hddPrintPmkId() ******/
12095
12096//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
12097//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
12098
12099//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
12100//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
12101
12102#define dump_bssid(bssid) \
12103 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070012104 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
12105 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012106 }
12107
12108#define dump_pmkid(pMac, pmkid) \
12109 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070012110 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
12111 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012112 }
12113
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070012114#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012115/*
12116 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
12117 * This function is used to notify the supplicant of a new PMKSA candidate.
12118 */
12119int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012120 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012121 int index, bool preauth )
12122{
Jeff Johnsone7245742012-09-05 17:12:55 -070012123#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012124 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070012125 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012126
12127 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070012128 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012129
12130 if( NULL == pRoamInfo )
12131 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012132 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012133 return -EINVAL;
12134 }
12135
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070012136 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
12137 {
12138 dump_bssid(pRoamInfo->bssid);
12139 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012140 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070012141 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012142#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012143 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012144}
12145#endif //FEATURE_WLAN_LFR
12146
Yue Maef608272013-04-08 23:09:17 -070012147#ifdef FEATURE_WLAN_LFR_METRICS
12148/*
12149 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
12150 * 802.11r/LFR metrics reporting function to report preauth initiation
12151 *
12152 */
12153#define MAX_LFR_METRICS_EVENT_LENGTH 100
12154VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
12155 tCsrRoamInfo *pRoamInfo)
12156{
12157 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12158 union iwreq_data wrqu;
12159
12160 ENTER();
12161
12162 if (NULL == pAdapter)
12163 {
12164 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12165 return VOS_STATUS_E_FAILURE;
12166 }
12167
12168 /* create the event */
12169 memset(&wrqu, 0, sizeof(wrqu));
12170 memset(metrics_notification, 0, sizeof(metrics_notification));
12171
12172 wrqu.data.pointer = metrics_notification;
12173 wrqu.data.length = scnprintf(metrics_notification,
12174 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
12175 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
12176
12177 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12178
12179 EXIT();
12180
12181 return VOS_STATUS_SUCCESS;
12182}
12183
12184/*
12185 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
12186 * 802.11r/LFR metrics reporting function to report preauth completion
12187 * or failure
12188 */
12189VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
12190 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
12191{
12192 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12193 union iwreq_data wrqu;
12194
12195 ENTER();
12196
12197 if (NULL == pAdapter)
12198 {
12199 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12200 return VOS_STATUS_E_FAILURE;
12201 }
12202
12203 /* create the event */
12204 memset(&wrqu, 0, sizeof(wrqu));
12205 memset(metrics_notification, 0, sizeof(metrics_notification));
12206
12207 scnprintf(metrics_notification, sizeof(metrics_notification),
12208 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
12209 MAC_ADDR_ARRAY(pRoamInfo->bssid));
12210
12211 if (1 == preauth_status)
12212 strncat(metrics_notification, " TRUE", 5);
12213 else
12214 strncat(metrics_notification, " FALSE", 6);
12215
12216 wrqu.data.pointer = metrics_notification;
12217 wrqu.data.length = strlen(metrics_notification);
12218
12219 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12220
12221 EXIT();
12222
12223 return VOS_STATUS_SUCCESS;
12224}
12225
12226/*
12227 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
12228 * 802.11r/LFR metrics reporting function to report handover initiation
12229 *
12230 */
12231VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
12232 tCsrRoamInfo *pRoamInfo)
12233{
12234 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12235 union iwreq_data wrqu;
12236
12237 ENTER();
12238
12239 if (NULL == pAdapter)
12240 {
12241 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12242 return VOS_STATUS_E_FAILURE;
12243 }
12244
12245 /* create the event */
12246 memset(&wrqu, 0, sizeof(wrqu));
12247 memset(metrics_notification, 0, sizeof(metrics_notification));
12248
12249 wrqu.data.pointer = metrics_notification;
12250 wrqu.data.length = scnprintf(metrics_notification,
12251 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
12252 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
12253
12254 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12255
12256 EXIT();
12257
12258 return VOS_STATUS_SUCCESS;
12259}
12260#endif
12261
Jeff Johnson295189b2012-06-20 16:38:30 -070012262/*
12263 * FUNCTION: hdd_cfg80211_scan_done_callback
12264 * scanning callback function, called after finishing scan
12265 *
12266 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012267static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070012268 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
12269{
12270 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012271 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070012272 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012273 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012274 struct cfg80211_scan_request *req = NULL;
12275 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012276 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012277 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012278 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012279 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012280
12281 ENTER();
12282
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012283 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal5c2e02d2015-05-05 17:35:29 +053012284 if (NULL == pHddCtx) {
12285 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null"));
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012286 goto allow_suspend;
12287 }
12288
12289 pScanInfo = &pHddCtx->scan_info;
12290
Jeff Johnson295189b2012-06-20 16:38:30 -070012291 hddLog(VOS_TRACE_LEVEL_INFO,
12292 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080012293 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012294 __func__, halHandle, pContext, (int) scanId, (int) status);
12295
Kiet Lamac06e2c2013-10-23 16:25:07 +053012296 pScanInfo->mScanPendingCounter = 0;
12297
Jeff Johnson295189b2012-06-20 16:38:30 -070012298 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012299 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070012300 &pScanInfo->scan_req_completion_event,
12301 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012302 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070012303 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012304 hddLog(VOS_TRACE_LEVEL_ERROR,
12305 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070012306 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070012307 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070012308 }
12309
Yue Maef608272013-04-08 23:09:17 -070012310 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070012311 {
12312 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070012313 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070012314 }
12315
12316 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012317 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070012318 {
12319 hddLog(VOS_TRACE_LEVEL_INFO,
12320 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080012321 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070012322 (int) scanId);
12323 }
12324
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012325 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012326 pAdapter);
12327
12328 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012329 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012330
12331
12332 /* If any client wait scan result through WEXT
12333 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012334 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070012335 {
12336 /* The other scan request waiting for current scan finish
12337 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012338 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070012339 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012340 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070012341 }
12342 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012343 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070012344 {
12345 struct net_device *dev = pAdapter->dev;
12346 union iwreq_data wrqu;
12347 int we_event;
12348 char *msg;
12349
12350 memset(&wrqu, '\0', sizeof(wrqu));
12351 we_event = SIOCGIWSCAN;
12352 msg = NULL;
12353 wireless_send_event(dev, we_event, &wrqu, msg);
12354 }
12355 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012356 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012357
12358 /* Get the Scan Req */
12359 req = pAdapter->request;
12360
12361 if (!req)
12362 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012363 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070012364 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -070012365 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070012366 }
12367
Jeff Johnson295189b2012-06-20 16:38:30 -070012368 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -070012369 /* Scan is no longer pending */
12370 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012371
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012372 /* last_scan_timestamp is used to decide if new scan
12373 * is needed or not on station interface. If last station
12374 * scan time and new station scan time is less then
12375 * last_scan_timestamp ; driver will return cached scan.
12376 */
12377 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
12378 {
12379 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
12380
12381 if ( req->n_channels )
12382 {
12383 for (i = 0; i < req->n_channels ; i++ )
12384 {
12385 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
12386 }
12387 /* store no of channel scanned */
12388 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
12389 }
12390
12391 }
12392
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070012393 /*
12394 * cfg80211_scan_done informing NL80211 about completion
12395 * of scanning
12396 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012397 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
12398 {
12399 aborted = true;
12400 }
12401 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080012402 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070012403
Siddharth Bhal76972212014-10-15 16:22:51 +053012404 if (pHddCtx->spoofMacAddr.isEnabled || pHddCtx->spoofMacAddr.isReqDeferred) {
12405 /* Generate new random mac addr for next scan */
12406 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
12407 hdd_processSpoofMacAddrRequest(pHddCtx);
12408 }
12409
Jeff Johnsone7245742012-09-05 17:12:55 -070012410allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070012411 /* release the wake lock at the end of the scan*/
Sushant Kaushik83392fa2015-05-05 17:44:40 +053012412 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070012413
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070012414 /* Acquire wakelock to handle the case where APP's tries to suspend
12415 * immediatly after the driver gets connect request(i.e after scan)
12416 * from supplicant, this result in app's is suspending and not able
12417 * to process the connect request to AP */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053012418 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070012419
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070012420#ifdef FEATURE_WLAN_TDLS
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053012421 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070012422#endif
12423
Jeff Johnson295189b2012-06-20 16:38:30 -070012424 EXIT();
12425 return 0;
12426}
12427
12428/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053012429 * FUNCTION: hdd_isConnectionInProgress
12430 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012431 *
12432 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012433v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012434{
12435 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
12436 hdd_station_ctx_t *pHddStaCtx = NULL;
12437 hdd_adapter_t *pAdapter = NULL;
12438 VOS_STATUS status = 0;
12439 v_U8_t staId = 0;
12440 v_U8_t *staMac = NULL;
12441
c_hpothu9b781ba2013-12-30 20:57:45 +053012442 if (TRUE == pHddCtx->btCoexModeSet)
12443 {
12444 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +053012445 FL("BTCoex Mode operation in progress"));
12446 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +053012447 }
12448
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012449 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
12450
12451 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
12452 {
12453 pAdapter = pAdapterNode->pAdapter;
12454
12455 if( pAdapter )
12456 {
12457 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012458 "%s: Adapter with device mode %s (%d) exists",
12459 __func__, hdd_device_modetoString(pAdapter->device_mode),
12460 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012461 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053012462 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
12463 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
12464 (eConnectionState_Connecting ==
12465 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
12466 {
12467 hddLog(VOS_TRACE_LEVEL_ERROR,
12468 "%s: %p(%d) Connection is in progress", __func__,
12469 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
12470 return VOS_TRUE;
12471 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012472 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053012473 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012474 {
12475 hddLog(VOS_TRACE_LEVEL_ERROR,
12476 "%s: %p(%d) Reassociation is in progress", __func__,
12477 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
12478 return VOS_TRUE;
12479 }
12480 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012481 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
12482 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012483 {
12484 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12485 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012486 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012487 {
12488 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
12489 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080012490 "%s: client " MAC_ADDRESS_STR
12491 " is in the middle of WPS/EAPOL exchange.", __func__,
12492 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053012493 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012494 }
12495 }
12496 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
12497 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
12498 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012499 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
12500 ptSapContext pSapCtx = NULL;
12501 pSapCtx = VOS_GET_SAP_CB(pVosContext);
12502 if(pSapCtx == NULL){
12503 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12504 FL("psapCtx is NULL"));
12505 return VOS_FALSE;
12506 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012507 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
12508 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012509 if ((pSapCtx->aStaInfo[staId].isUsed) &&
12510 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012511 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012512 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012513
12514 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080012515 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
12516 "middle of WPS/EAPOL exchange.", __func__,
12517 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053012518 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012519 }
12520 }
12521 }
12522 }
12523 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
12524 pAdapterNode = pNext;
12525 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053012526 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012527}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012528
12529/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012530 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070012531 * this scan respond to scan trigger and update cfg80211 scan database
12532 * later, scan dump command can be used to recieve scan results
12533 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012534int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080012535#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
12536 struct net_device *dev,
12537#endif
12538 struct cfg80211_scan_request *request)
12539{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053012540 hdd_adapter_t *pAdapter = NULL;
12541 hdd_context_t *pHddCtx = NULL;
12542 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012543 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012544 tCsrScanRequest scanRequest;
12545 tANI_U8 *channelList = NULL, i;
12546 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012547 int status;
12548 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012549 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012550 int ret = 0;
Sushant Kaushik86592172015-04-27 16:35:03 +053012551 v_U8_t *pWpsIe=NULL;
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053012552 bool is_p2p_scan = false;
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053012553 v_S7_t rssi=0;
12554 hdd_station_ctx_t *pHddStaCtx=NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012555
Siddharth Bhal0c162d02014-05-06 19:50:42 +053012556#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
12557 struct net_device *dev = NULL;
12558 if (NULL == request)
12559 {
12560 hddLog(VOS_TRACE_LEVEL_ERROR,
12561 "%s: scan req param null", __func__);
12562 return -EINVAL;
12563 }
12564 dev = request->wdev->netdev;
12565#endif
12566
12567 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
12568 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
12569 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12570
Jeff Johnson295189b2012-06-20 16:38:30 -070012571 ENTER();
12572
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012573 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
12574 __func__, hdd_device_modetoString(pAdapter->device_mode),
12575 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012576
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012577 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012578 if (0 != status)
12579 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012580 return status;
12581 }
12582
Siddharth Bhal0c162d02014-05-06 19:50:42 +053012583 if (NULL == pwextBuf)
12584 {
12585 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
12586 __func__);
12587 return -EIO;
12588 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012589 cfg_param = pHddCtx->cfg_ini;
12590 pScanInfo = &pHddCtx->scan_info;
12591
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053012592 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12593 if ( (pHddStaCtx != NULL) && (TRUE == hdd_connIsConnected(pHddStaCtx)))
12594 {
12595 wlan_hdd_get_roam_rssi(pAdapter, &rssi);
12596 hddLog(VOS_TRACE_LEVEL_INFO, FL("rssi: %d"), rssi);
12597 }
12598
Jeff Johnson295189b2012-06-20 16:38:30 -070012599#ifdef WLAN_BTAMP_FEATURE
12600 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012601 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070012602 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080012603 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012604 "%s: No scanning when AMP is on", __func__);
12605 return -EOPNOTSUPP;
12606 }
12607#endif
12608 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012609 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070012610 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012611 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012612 "%s: Not scanning on device_mode = %s (%d)",
12613 __func__, hdd_device_modetoString(pAdapter->device_mode),
12614 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012615 return -EOPNOTSUPP;
12616 }
12617
12618 if (TRUE == pScanInfo->mScanPending)
12619 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053012620 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
12621 {
12622 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
12623 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012624 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070012625 }
12626
Hanumantha Reddy Pothula4b6be062015-08-18 14:06:24 +053012627 // Don't allow scan if PNO scan is going on.
12628 if (pHddCtx->isPnoEnable)
12629 {
12630 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12631 FL("pno scan in progress"));
12632 return -EBUSY;
12633 }
12634
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012635 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070012636 //Channel and action frame is pending
12637 //Otherwise Cancel Remain On Channel and allow Scan
12638 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012639 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070012640 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053012641 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070012642 return -EBUSY;
12643 }
12644
Jeff Johnson295189b2012-06-20 16:38:30 -070012645 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
12646 {
12647 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080012648 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012649 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012650 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012651 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
12652 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053012653 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012654 "%s: MAX TM Level Scan not allowed", __func__);
12655 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012656 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070012657 }
12658 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
12659
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012660 /* Check if scan is allowed at this point of time.
12661 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012662 if (hdd_isConnectionInProgress(pHddCtx))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012663 {
12664 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
12665 return -EBUSY;
12666 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012667
Jeff Johnson295189b2012-06-20 16:38:30 -070012668 vos_mem_zero( &scanRequest, sizeof(scanRequest));
12669
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012670 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
12671 * Becasue of this, driver is assuming that this is not wildcard scan and so
12672 * is not aging out the scan results.
12673 */
12674 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070012675 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012676 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012677 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012678
12679 if ((request->ssids) && (0 < request->n_ssids))
12680 {
12681 tCsrSSIDInfo *SsidInfo;
12682 int j;
12683 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
12684 /* Allocate num_ssid tCsrSSIDInfo structure */
12685 SsidInfo = scanRequest.SSIDs.SSIDList =
12686 ( tCsrSSIDInfo *)vos_mem_malloc(
12687 request->n_ssids*sizeof(tCsrSSIDInfo));
12688
12689 if(NULL == scanRequest.SSIDs.SSIDList)
12690 {
12691 hddLog(VOS_TRACE_LEVEL_ERROR,
12692 "%s: memory alloc failed SSIDInfo buffer", __func__);
12693 return -ENOMEM;
12694 }
12695
12696 /* copy all the ssid's and their length */
12697 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
12698 {
12699 /* get the ssid length */
12700 SsidInfo->SSID.length = request->ssids[j].ssid_len;
12701 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
12702 SsidInfo->SSID.length);
12703 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
12704 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
12705 j, SsidInfo->SSID.ssId);
12706 }
12707 /* set the scan type to active */
12708 scanRequest.scanType = eSIR_ACTIVE_SCAN;
12709 }
12710 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070012711 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053012712 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12713 TRACE_CODE_HDD_CFG80211_SCAN,
12714 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070012715 /* set the scan type to active */
12716 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070012717 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012718 else
12719 {
12720 /*Set the scan type to default type, in this case it is ACTIVE*/
12721 scanRequest.scanType = pScanInfo->scan_mode;
12722 }
12723 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
12724 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070012725
12726 /* set BSSType to default type */
12727 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
12728
12729 /*TODO: scan the requested channels only*/
12730
12731 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012732 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070012733 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012734 hddLog(VOS_TRACE_LEVEL_WARN,
12735 "No of Scan Channels exceeded limit: %d", request->n_channels);
12736 request->n_channels = MAX_CHANNEL;
12737 }
12738
12739 hddLog(VOS_TRACE_LEVEL_INFO,
12740 "No of Scan Channels: %d", request->n_channels);
12741
12742
12743 if( request->n_channels )
12744 {
12745 char chList [(request->n_channels*5)+1];
12746 int len;
12747 channelList = vos_mem_malloc( request->n_channels );
12748 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053012749 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012750 hddLog(VOS_TRACE_LEVEL_ERROR,
12751 "%s: memory alloc failed channelList", __func__);
12752 status = -ENOMEM;
12753 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053012754 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012755
12756 for( i = 0, len = 0; i < request->n_channels ; i++ )
12757 {
12758 channelList[i] = request->channels[i]->hw_value;
12759 len += snprintf(chList+len, 5, "%d ", channelList[i]);
12760 }
12761
Nirav Shah20ac06f2013-12-12 18:14:06 +053012762 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012763 "Channel-List: %s ", chList);
12764 }
c_hpothu53512302014-04-15 18:49:53 +053012765
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012766 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
12767 scanRequest.ChannelInfo.ChannelList = channelList;
12768
12769 /* set requestType to full scan */
12770 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
12771
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012772 /* if there is back to back scan happening in driver with in
12773 * nDeferScanTimeInterval interval driver should defer new scan request
12774 * and should provide last cached scan results instead of new channel list.
12775 * This rule is not applicable if scan is p2p scan.
12776 * This condition will work only in case when last request no of channels
12777 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053012778 * This should be done only in connected state
Sushant Kaushik86592172015-04-27 16:35:03 +053012779 * Scan shouldn't be defered for WPS scan case.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012780 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012781
Sushant Kaushik86592172015-04-27 16:35:03 +053012782 pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len);
12783 /* if wps ie is NULL , then only defer scan */
12784 if ( pWpsIe == NULL &&
12785 (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
Agarwal Ashish57e84372014-12-05 18:26:53 +053012786 {
12787 if ( pScanInfo->last_scan_timestamp !=0 &&
12788 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
12789 {
12790 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
12791 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
12792 vos_mem_compare(pScanInfo->last_scan_channelList,
12793 channelList, pScanInfo->last_scan_numChannels))
12794 {
12795 hddLog(VOS_TRACE_LEVEL_WARN,
12796 " New and old station scan time differ is less then %u",
12797 pHddCtx->cfg_ini->nDeferScanTimeInterval);
12798
12799 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012800 pAdapter);
12801
Agarwal Ashish57e84372014-12-05 18:26:53 +053012802 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053012803 "Return old cached scan as all channels and no of channels are same");
12804
Agarwal Ashish57e84372014-12-05 18:26:53 +053012805 if (0 > ret)
12806 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012807
Agarwal Ashish57e84372014-12-05 18:26:53 +053012808 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053012809
12810 status = eHAL_STATUS_SUCCESS;
12811 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053012812 }
12813 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012814 }
12815
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012816 /* Flush the scan results(only p2p beacons) for STA scan and P2P
12817 * search (Flush on both full scan and social scan but not on single
12818 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
12819 */
12820
12821 /* Supplicant does single channel scan after 8-way handshake
12822 * and in that case driver shoudnt flush scan results. If
12823 * driver flushes the scan results here and unfortunately if
12824 * the AP doesnt respond to our probe req then association
12825 * fails which is not desired
12826 */
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053012827 if ((request->n_ssids == 1)
12828 && (request->ssids != NULL)
12829 && vos_mem_compare(&request->ssids[0], "DIRECT-", 7))
12830 is_p2p_scan = true;
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012831
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053012832 if( is_p2p_scan ||
12833 (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) )
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012834 {
12835 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
12836 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
12837 pAdapter->sessionId );
12838 }
12839
12840 if( request->ie_len )
12841 {
12842 /* save this for future association (join requires this) */
12843 /*TODO: Array needs to be converted to dynamic allocation,
12844 * as multiple ie.s can be sent in cfg80211_scan_request structure
12845 * CR 597966
12846 */
12847 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
12848 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
12849 pScanInfo->scanAddIE.length = request->ie_len;
12850
12851 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
12852 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
12853 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070012854 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053012855 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070012856 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012857 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
12858 memcpy( pwextBuf->roamProfile.addIEScan,
12859 request->ie, request->ie_len);
12860 }
12861 else
12862 {
12863 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
12864 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070012865 }
12866
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012867 }
12868 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
12869 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
12870
12871 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
12872 request->ie_len);
12873 if (pP2pIe != NULL)
12874 {
12875#ifdef WLAN_FEATURE_P2P_DEBUG
12876 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
12877 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
12878 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053012879 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012880 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
12881 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
12882 "Go nego completed to Connection is started");
12883 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
12884 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053012885 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012886 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
12887 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070012888 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012889 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
12890 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
12891 "Disconnected state to Connection is started");
12892 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
12893 "for 4way Handshake");
12894 }
12895#endif
12896
12897 /* no_cck will be set during p2p find to disable 11b rates */
12898 if(TRUE == request->no_cck)
12899 {
12900 hddLog(VOS_TRACE_LEVEL_INFO,
12901 "%s: This is a P2P Search", __func__);
12902 scanRequest.p2pSearch = 1;
12903
12904 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053012905 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012906 /* set requestType to P2P Discovery */
12907 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
12908 }
12909
12910 /*
12911 Skip Dfs Channel in case of P2P Search
12912 if it is set in ini file
12913 */
12914 if(cfg_param->skipDfsChnlInP2pSearch)
12915 {
12916 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012917 }
12918 else
12919 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012920 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012921 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012922
Agarwal Ashish4f616132013-12-30 23:32:50 +053012923 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012924 }
12925 }
12926
12927 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
12928
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053012929#ifdef FEATURE_WLAN_TDLS
12930 /* if tdls disagree scan right now, return immediately.
12931 tdls will schedule the scan when scan is allowed. (return SUCCESS)
12932 or will reject the scan if any TDLS is in progress. (return -EBUSY)
12933 */
12934 status = wlan_hdd_tdls_scan_callback (pAdapter,
12935 wiphy,
12936#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
12937 dev,
12938#endif
12939 request);
12940 if(status <= 0)
12941 {
12942 if(!status)
12943 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
12944 "scan rejected %d", __func__, status);
12945 else
12946 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
12947 __func__, status);
12948
12949 return status;
12950 }
12951#endif
12952
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070012953 /* acquire the wakelock to avoid the apps suspend during the scan. To
12954 * address the following issues.
12955 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
12956 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
12957 * for long time, this result in apps running at full power for long time.
12958 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
12959 * be stuck in full power because of resume BMPS
12960 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053012961 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070012962
Nirav Shah20ac06f2013-12-12 18:14:06 +053012963 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
12964 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012965 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
12966 scanRequest.requestType, scanRequest.scanType,
12967 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053012968 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
12969
Siddharth Bhal76972212014-10-15 16:22:51 +053012970 if (pHddCtx->spoofMacAddr.isEnabled)
12971 {
12972 hddLog(VOS_TRACE_LEVEL_INFO,
12973 "%s: MAC Spoofing enabled for current scan", __func__);
12974 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
12975 * to fill TxBds for probe request during current scan
12976 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053012977 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053012978 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053012979
12980 if(status != VOS_STATUS_SUCCESS)
12981 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +053012982 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053012983 status = -EFAULT;
Ganesh Kondabattini6d3b4902015-05-12 23:19:22 +053012984#ifdef FEATURE_WLAN_TDLS
12985 wlan_hdd_tdls_scan_done_callback(pAdapter);
12986#endif
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053012987 goto free_mem;
12988 }
Siddharth Bhal76972212014-10-15 16:22:51 +053012989 }
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053012990 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
Jeff Johnsone7245742012-09-05 17:12:55 -070012991 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070012992 pAdapter->sessionId, &scanRequest, &scanId,
12993 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070012994
Jeff Johnson295189b2012-06-20 16:38:30 -070012995 if (eHAL_STATUS_SUCCESS != status)
12996 {
12997 hddLog(VOS_TRACE_LEVEL_ERROR,
12998 "%s: sme_ScanRequest returned error %d", __func__, status);
12999 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070013000 if(eHAL_STATUS_RESOURCES == status)
13001 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053013002 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
13003 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070013004 status = -EBUSY;
13005 } else {
13006 status = -EIO;
13007 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013008 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013009
13010#ifdef FEATURE_WLAN_TDLS
13011 wlan_hdd_tdls_scan_done_callback(pAdapter);
13012#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013013 goto free_mem;
13014 }
13015
13016 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053013017 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013018 pAdapter->request = request;
13019 pScanInfo->scanId = scanId;
13020
13021 complete(&pScanInfo->scan_req_completion_event);
13022
13023free_mem:
13024 if( scanRequest.SSIDs.SSIDList )
13025 {
13026 vos_mem_free(scanRequest.SSIDs.SSIDList);
13027 }
13028
13029 if( channelList )
13030 vos_mem_free( channelList );
13031
13032 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013033 return status;
13034}
13035
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053013036int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
13037#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13038 struct net_device *dev,
13039#endif
13040 struct cfg80211_scan_request *request)
13041{
13042 int ret;
13043
13044 vos_ssr_protect(__func__);
13045 ret = __wlan_hdd_cfg80211_scan(wiphy,
13046#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13047 dev,
13048#endif
13049 request);
13050 vos_ssr_unprotect(__func__);
13051
13052 return ret;
13053}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013054
13055void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
13056{
13057 v_U8_t iniDot11Mode =
13058 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
13059 eHddDot11Mode hddDot11Mode = iniDot11Mode;
13060
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053013061 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
13062 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013063 switch ( iniDot11Mode )
13064 {
13065 case eHDD_DOT11_MODE_AUTO:
13066 case eHDD_DOT11_MODE_11ac:
13067 case eHDD_DOT11_MODE_11ac_ONLY:
13068#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053013069 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
13070 sme_IsFeatureSupportedByFW(DOT11AC) )
13071 hddDot11Mode = eHDD_DOT11_MODE_11ac;
13072 else
13073 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013074#else
13075 hddDot11Mode = eHDD_DOT11_MODE_11n;
13076#endif
13077 break;
13078 case eHDD_DOT11_MODE_11n:
13079 case eHDD_DOT11_MODE_11n_ONLY:
13080 hddDot11Mode = eHDD_DOT11_MODE_11n;
13081 break;
13082 default:
13083 hddDot11Mode = iniDot11Mode;
13084 break;
13085 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053013086#ifdef WLAN_FEATURE_AP_HT40_24G
13087 if (operationChannel > SIR_11B_CHANNEL_END)
13088#endif
13089 {
13090 /* This call decides required channel bonding mode */
13091 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013092 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
13093 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053013094 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013095}
13096
Jeff Johnson295189b2012-06-20 16:38:30 -070013097/*
13098 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013099 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070013100 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013101int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013102 const u8 *ssid, size_t ssid_len, const u8 *bssid,
13103 const u8 *bssid_hint, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070013104{
13105 int status = 0;
13106 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080013107 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013108 v_U32_t roamId;
13109 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070013110 eCsrAuthType RSNAuthType;
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013111 const u8 *pValidBssid = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013112
13113 ENTER();
13114
13115 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080013116 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13117
13118 status = wlan_hdd_validate_context(pHddCtx);
13119 if (status)
13120 {
Yue Mae36e3552014-03-05 17:06:20 -080013121 return status;
13122 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013123
Jeff Johnson295189b2012-06-20 16:38:30 -070013124 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
13125 {
13126 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
13127 return -EINVAL;
13128 }
13129
13130 pRoamProfile = &pWextState->roamProfile;
13131
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013132 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070013133 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013134 hdd_station_ctx_t *pHddStaCtx;
13135 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013136
Siddharth Bhalda0d1622015-04-24 15:47:49 +053013137 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
13138
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013139 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070013140 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
13141 {
13142 /*QoS not enabled in cfg file*/
13143 pRoamProfile->uapsd_mask = 0;
13144 }
13145 else
13146 {
13147 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013148 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070013149 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
13150 }
13151
13152 pRoamProfile->SSIDs.numOfSSIDs = 1;
13153 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
13154 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013155 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070013156 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
13157 ssid, ssid_len);
13158
13159 if (bssid)
13160 {
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013161 pValidBssid = bssid;
13162 }
13163 else if (bssid_hint)
13164 {
13165 pValidBssid = bssid_hint;
13166 }
13167 if (pValidBssid)
13168 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013169 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013170 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), pValidBssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070013171 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013172 /* Save BSSID in seperate variable as well, as RoamProfile
13173 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070013174 case of join failure we should send valid BSSID to supplicant
13175 */
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013176 vos_mem_copy((void *)(pWextState->req_bssId), pValidBssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070013177 WNI_CFG_BSSID_LEN);
13178 }
Dhanashri Atre51981c62013-06-13 11:47:57 -070013179 else
13180 {
13181 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
13182 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013183
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053013184 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
13185 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070013186 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
13187 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013188 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013189 /*set gen ie*/
13190 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
13191 /*set auth*/
13192 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
13193 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013194#ifdef FEATURE_WLAN_WAPI
13195 if (pAdapter->wapi_info.nWapiMode)
13196 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013197 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013198 switch (pAdapter->wapi_info.wapiAuthMode)
13199 {
13200 case WAPI_AUTH_MODE_PSK:
13201 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013202 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013203 pAdapter->wapi_info.wapiAuthMode);
13204 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
13205 break;
13206 }
13207 case WAPI_AUTH_MODE_CERT:
13208 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013209 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013210 pAdapter->wapi_info.wapiAuthMode);
13211 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
13212 break;
13213 }
13214 } // End of switch
13215 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
13216 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
13217 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013218 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013219 pRoamProfile->AuthType.numEntries = 1;
13220 pRoamProfile->EncryptionType.numEntries = 1;
13221 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
13222 pRoamProfile->mcEncryptionType.numEntries = 1;
13223 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
13224 }
13225 }
13226#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013227#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053013228 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013229 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
13230 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
13231 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053013232 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
13233 sizeof (tSirGtkOffloadParams));
13234 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013235 }
13236#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013237 pRoamProfile->csrPersona = pAdapter->device_mode;
13238
Jeff Johnson32d95a32012-09-10 13:15:23 -070013239 if( operatingChannel )
13240 {
13241 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
13242 pRoamProfile->ChannelInfo.numOfChannels = 1;
13243 }
Chet Lanctot186b5732013-03-18 10:26:30 -070013244 else
13245 {
13246 pRoamProfile->ChannelInfo.ChannelList = NULL;
13247 pRoamProfile->ChannelInfo.numOfChannels = 0;
13248 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013249 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
13250 {
13251 hdd_select_cbmode(pAdapter,operatingChannel);
13252 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053013253
Agarwal Ashish40f9b872015-09-01 16:17:35 +053013254 /*
13255 * Change conn_state to connecting before sme_RoamConnect(),
13256 * because sme_RoamConnect() has a direct path to call
13257 * hdd_smeRoamCallback(), which will change the conn_state
13258 * If direct path, conn_state will be accordingly changed
13259 * to NotConnected or Associated by either
13260 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
13261 * in sme_RoamCallback()
13262 * if sme_RomConnect is to be queued,
13263 * Connecting state will remain until it is completed.
13264 * If connection state is not changed,
13265 * connection state will remain in eConnectionState_NotConnected state.
13266 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
13267 * if conn state is eConnectionState_NotConnected.
13268 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
13269 * informed of connect result indication which is an issue.
13270 */
13271
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053013272 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
13273 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053013274 {
13275 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish40f9b872015-09-01 16:17:35 +053013276 FL("Set HDD connState to eConnectionState_Connecting"));
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080013277 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
13278 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053013279 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013280 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070013281 pAdapter->sessionId, pRoamProfile, &roamId);
13282
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053013283 if ((eHAL_STATUS_SUCCESS != status) &&
13284 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
13285 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053013286
13287 {
Agarwal Ashish40f9b872015-09-01 16:17:35 +053013288 hddLog(VOS_TRACE_LEVEL_ERROR,
13289 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
13290 pAdapter->sessionId, status);
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080013291 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053013292 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080013293 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053013294 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080013295
13296 pRoamProfile->ChannelInfo.ChannelList = NULL;
13297 pRoamProfile->ChannelInfo.numOfChannels = 0;
13298
Jeff Johnson295189b2012-06-20 16:38:30 -070013299 }
13300 else
13301 {
13302 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
13303 return -EINVAL;
13304 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080013305 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013306 return status;
13307}
13308
13309/*
13310 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
13311 * This function is used to set the authentication type (OPEN/SHARED).
13312 *
13313 */
13314static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
13315 enum nl80211_auth_type auth_type)
13316{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013317 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013318 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13319
13320 ENTER();
13321
13322 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013323 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070013324 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013325 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053013326 hddLog(VOS_TRACE_LEVEL_INFO,
13327 "%s: set authentication type to AUTOSWITCH", __func__);
13328 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
13329 break;
13330
13331 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013332#ifdef WLAN_FEATURE_VOWIFI_11R
13333 case NL80211_AUTHTYPE_FT:
13334#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013335 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070013336 "%s: set authentication type to OPEN", __func__);
13337 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
13338 break;
13339
13340 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013341 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070013342 "%s: set authentication type to SHARED", __func__);
13343 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
13344 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013345#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070013346 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013347 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070013348 "%s: set authentication type to CCKM WPA", __func__);
13349 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
13350 break;
13351#endif
13352
13353
13354 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013355 hddLog(VOS_TRACE_LEVEL_ERROR,
13356 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013357 auth_type);
13358 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
13359 return -EINVAL;
13360 }
13361
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013362 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070013363 pHddStaCtx->conn_info.authType;
13364 return 0;
13365}
13366
13367/*
13368 * FUNCTION: wlan_hdd_set_akm_suite
13369 * This function is used to set the key mgmt type(PSK/8021x).
13370 *
13371 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013372static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070013373 u32 key_mgmt
13374 )
13375{
13376 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13377 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053013378 /* Should be in ieee802_11_defs.h */
13379#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
13380#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070013381 /*set key mgmt type*/
13382 switch(key_mgmt)
13383 {
13384 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053013385 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053013386#ifdef WLAN_FEATURE_VOWIFI_11R
13387 case WLAN_AKM_SUITE_FT_PSK:
13388#endif
13389 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070013390 __func__);
13391 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
13392 break;
13393
13394 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053013395 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053013396#ifdef WLAN_FEATURE_VOWIFI_11R
13397 case WLAN_AKM_SUITE_FT_8021X:
13398#endif
13399 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070013400 __func__);
13401 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
13402 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013403#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070013404#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
13405#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
13406 case WLAN_AKM_SUITE_CCKM:
13407 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
13408 __func__);
13409 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
13410 break;
13411#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070013412#ifndef WLAN_AKM_SUITE_OSEN
13413#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
13414 case WLAN_AKM_SUITE_OSEN:
13415 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
13416 __func__);
13417 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
13418 break;
13419#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013420
13421 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013422 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013423 __func__, key_mgmt);
13424 return -EINVAL;
13425
13426 }
13427 return 0;
13428}
13429
13430/*
13431 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013432 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070013433 * (NONE/WEP40/WEP104/TKIP/CCMP).
13434 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013435static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
13436 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070013437 bool ucast
13438 )
13439{
13440 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013441 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013442 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13443
13444 ENTER();
13445
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013446 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070013447 {
Ratheesh S P36dbc932015-08-07 14:28:57 +053013448 hddLog(VOS_TRACE_LEVEL_INFO, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070013449 __func__, cipher);
13450 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
13451 }
13452 else
13453 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013454
Jeff Johnson295189b2012-06-20 16:38:30 -070013455 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013456 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070013457 {
13458 case IW_AUTH_CIPHER_NONE:
13459 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
13460 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013461
Jeff Johnson295189b2012-06-20 16:38:30 -070013462 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053013463 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070013464 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013465
Jeff Johnson295189b2012-06-20 16:38:30 -070013466 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053013467 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070013468 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013469
Jeff Johnson295189b2012-06-20 16:38:30 -070013470 case WLAN_CIPHER_SUITE_TKIP:
13471 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
13472 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013473
Jeff Johnson295189b2012-06-20 16:38:30 -070013474 case WLAN_CIPHER_SUITE_CCMP:
13475 encryptionType = eCSR_ENCRYPT_TYPE_AES;
13476 break;
13477#ifdef FEATURE_WLAN_WAPI
13478 case WLAN_CIPHER_SUITE_SMS4:
13479 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
13480 break;
13481#endif
13482
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013483#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070013484 case WLAN_CIPHER_SUITE_KRK:
13485 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
13486 break;
13487#endif
13488 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013489 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013490 __func__, cipher);
13491 return -EOPNOTSUPP;
13492 }
13493 }
13494
13495 if (ucast)
13496 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013497 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013498 __func__, encryptionType);
13499 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
13500 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013501 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070013502 encryptionType;
13503 }
13504 else
13505 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013506 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013507 __func__, encryptionType);
13508 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
13509 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
13510 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
13511 }
13512
13513 return 0;
13514}
13515
13516
13517/*
13518 * FUNCTION: wlan_hdd_cfg80211_set_ie
13519 * This function is used to parse WPA/RSN IE's.
13520 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013521int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013522#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
13523 const u8 *ie,
13524#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013525 u8 *ie,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013526#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013527 size_t ie_len
13528 )
13529{
13530 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013531#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
13532 const u8 *genie = ie;
13533#else
Jeff Johnson295189b2012-06-20 16:38:30 -070013534 u8 *genie = ie;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013535#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013536 v_U16_t remLen = ie_len;
13537#ifdef FEATURE_WLAN_WAPI
13538 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
13539 u16 *tmp;
13540 v_U16_t akmsuiteCount;
13541 int *akmlist;
13542#endif
13543 ENTER();
13544
13545 /* clear previous assocAddIE */
13546 pWextState->assocAddIE.length = 0;
13547 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070013548 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013549
13550 while (remLen >= 2)
13551 {
13552 v_U16_t eLen = 0;
13553 v_U8_t elementId;
13554 elementId = *genie++;
13555 eLen = *genie++;
13556 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013557
Arif Hussain6d2a3322013-11-17 19:50:10 -080013558 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070013559 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013560
13561 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070013562 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013563 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013564 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 -070013565 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013566 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013567 "%s: Invalid WPA IE", __func__);
13568 return -EINVAL;
13569 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013570 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070013571 {
13572 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013573 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070013574 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013575
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013576 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013577 {
Jeff Johnson902c9832012-12-10 14:28:09 -080013578 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
13579 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070013580 VOS_ASSERT(0);
13581 return -ENOMEM;
13582 }
13583 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
13584 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
13585 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013586
Jeff Johnson295189b2012-06-20 16:38:30 -070013587 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
13588 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
13589 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
13590 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013591 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
13592 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013593 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
13594 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
13595 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
13596 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
13597 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
13598 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013599 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053013600 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070013601 {
13602 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013603 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070013604 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013605
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013606 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013607 {
Jeff Johnson902c9832012-12-10 14:28:09 -080013608 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
13609 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070013610 VOS_ASSERT(0);
13611 return -ENOMEM;
13612 }
13613 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
13614 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
13615 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013616
Jeff Johnson295189b2012-06-20 16:38:30 -070013617 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
13618 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
13619 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013620#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013621 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
13622 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013623 /*Consider WFD IE, only for P2P Client */
13624 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
13625 {
13626 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013627 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070013628 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013629
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013630 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013631 {
Jeff Johnson902c9832012-12-10 14:28:09 -080013632 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
13633 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070013634 VOS_ASSERT(0);
13635 return -ENOMEM;
13636 }
13637 // WFD IE is saved to Additional IE ; it should be accumulated to handle
13638 // WPS IE + P2P IE + WFD IE
13639 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
13640 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013641
Jeff Johnson295189b2012-06-20 16:38:30 -070013642 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
13643 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
13644 }
13645#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013646 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013647 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070013648 HS20_OUI_TYPE_SIZE)) )
13649 {
13650 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013651 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070013652 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013653
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013654 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070013655 {
Jeff Johnson902c9832012-12-10 14:28:09 -080013656 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
13657 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070013658 VOS_ASSERT(0);
13659 return -ENOMEM;
13660 }
13661 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
13662 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013663
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070013664 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
13665 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
13666 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070013667 /* Appending OSEN Information Element in Assiciation Request */
13668 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
13669 OSEN_OUI_TYPE_SIZE)) )
13670 {
13671 v_U16_t curAddIELen = pWextState->assocAddIE.length;
13672 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
13673 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013674
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013675 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070013676 {
13677 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
13678 "Need bigger buffer space");
13679 VOS_ASSERT(0);
13680 return -ENOMEM;
13681 }
13682 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
13683 pWextState->assocAddIE.length += eLen + 2;
13684
13685 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
13686 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
13687 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
13688 }
13689
Abhishek Singh4322e622015-06-10 15:42:54 +053013690 /* Update only for WPA IE */
13691 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
13692 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070013693
13694 /* populating as ADDIE in beacon frames */
13695 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013696 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, (u8 *)genie - 2, eLen + 2,
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070013697 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
13698 {
13699 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
13700 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
13701 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
13702 {
13703 hddLog(LOGE,
13704 "Coldn't pass "
13705 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
13706 }
13707 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
13708 else
13709 hddLog(LOGE,
13710 "Could not pass on "
13711 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
13712
13713 /* IBSS mode doesn't contain params->proberesp_ies still
13714 beaconIE's need to be populated in probe response frames */
13715 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
13716 {
13717 u16 rem_probe_resp_ie_len = eLen + 2;
13718 u8 probe_rsp_ie_len[3] = {0};
13719 u8 counter = 0;
13720
13721 /* Check Probe Resp Length if it is greater then 255 then
13722 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
13723 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
13724 not able Store More then 255 bytes into One Variable */
13725
13726 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
13727 {
13728 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
13729 {
13730 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
13731 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
13732 }
13733 else
13734 {
13735 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
13736 rem_probe_resp_ie_len = 0;
13737 }
13738 }
13739
13740 rem_probe_resp_ie_len = 0;
13741
13742 if (probe_rsp_ie_len[0] > 0)
13743 {
13744 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
13745 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
13746 (tANI_U8*)(genie - 2),
13747 probe_rsp_ie_len[0], NULL,
13748 eANI_BOOLEAN_FALSE)
13749 == eHAL_STATUS_FAILURE)
13750 {
13751 hddLog(LOGE,
13752 "Could not pass"
13753 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
13754 }
13755 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
13756 }
13757
13758 if (probe_rsp_ie_len[1] > 0)
13759 {
13760 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
13761 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
13762 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
13763 probe_rsp_ie_len[1], NULL,
13764 eANI_BOOLEAN_FALSE)
13765 == eHAL_STATUS_FAILURE)
13766 {
13767 hddLog(LOGE,
13768 "Could not pass"
13769 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
13770 }
13771 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
13772 }
13773
13774 if (probe_rsp_ie_len[2] > 0)
13775 {
13776 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
13777 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
13778 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
13779 probe_rsp_ie_len[2], NULL,
13780 eANI_BOOLEAN_FALSE)
13781 == eHAL_STATUS_FAILURE)
13782 {
13783 hddLog(LOGE,
13784 "Could not pass"
13785 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
13786 }
13787 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
13788 }
13789
13790 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
13791 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
13792 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
13793 {
13794 hddLog(LOGE,
13795 "Could not pass"
13796 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
13797 }
13798 }
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070013799 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070013800 break;
13801 case DOT11F_EID_RSN:
13802 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
13803 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
13804 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
13805 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
13806 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
13807 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053013808
13809 /* Appending Extended Capabilities with Interworking bit set
13810 * in Assoc Req.
13811 *
13812 * In assoc req this EXT Cap will only be taken into account if
13813 * interworkingService bit is set to 1. Currently
13814 * driver is only interested in interworkingService capability
13815 * from supplicant. If in future any other EXT Cap info is
13816 * required from supplicat, it needs to be handled while
13817 * sending Assoc Req in LIM.
13818 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013819 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013820 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013821 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013822 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013823 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013824
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013825 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013826 {
Jeff Johnson902c9832012-12-10 14:28:09 -080013827 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
13828 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013829 VOS_ASSERT(0);
13830 return -ENOMEM;
13831 }
13832 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
13833 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013834
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013835 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
13836 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
13837 break;
13838 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013839#ifdef FEATURE_WLAN_WAPI
13840 case WLAN_EID_WAPI:
13841 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070013842 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070013843 pAdapter->wapi_info.nWapiMode);
13844 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013845 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070013846 akmsuiteCount = WPA_GET_LE16(tmp);
13847 tmp = tmp + 1;
13848 akmlist = (int *)(tmp);
13849 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
13850 {
13851 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
13852 }
13853 else
13854 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013855 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070013856 VOS_ASSERT(0);
13857 return -EINVAL;
13858 }
13859
13860 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
13861 {
13862 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013863 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013864 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013865 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013866 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013867 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013868 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013869 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013870 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
13871 }
13872 break;
13873#endif
13874 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013875 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013876 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013877 /* when Unknown IE is received we should break and continue
13878 * to the next IE in the buffer instead we were returning
13879 * so changing this to break */
13880 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013881 }
13882 genie += eLen;
13883 remLen -= eLen;
13884 }
13885 EXIT();
13886 return 0;
13887}
13888
13889/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053013890 * FUNCTION: hdd_isWPAIEPresent
13891 * Parse the received IE to find the WPA IE
13892 *
13893 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013894static bool hdd_isWPAIEPresent(
13895#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
13896 const u8 *ie,
13897#else
13898 u8 *ie,
13899#endif
13900 u8 ie_len)
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053013901{
13902 v_U8_t eLen = 0;
13903 v_U16_t remLen = ie_len;
13904 v_U8_t elementId = 0;
13905
13906 while (remLen >= 2)
13907 {
13908 elementId = *ie++;
13909 eLen = *ie++;
13910 remLen -= 2;
13911 if (eLen > remLen)
13912 {
13913 hddLog(VOS_TRACE_LEVEL_ERROR,
13914 "%s: IE length is wrong %d", __func__, eLen);
13915 return FALSE;
13916 }
13917 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
13918 {
13919 /* OUI - 0x00 0X50 0XF2
13920 WPA Information Element - 0x01
13921 WPA version - 0x01*/
13922 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
13923 return TRUE;
13924 }
13925 ie += eLen;
13926 remLen -= eLen;
13927 }
13928 return FALSE;
13929}
13930
13931/*
Jeff Johnson295189b2012-06-20 16:38:30 -070013932 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013933 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070013934 * parameters during connect operation.
13935 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013936int wlan_hdd_cfg80211_set_privacy(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070013937 struct cfg80211_connect_params *req
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013938 )
Jeff Johnson295189b2012-06-20 16:38:30 -070013939{
13940 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013941 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013942 ENTER();
13943
13944 /*set wpa version*/
13945 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
13946
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013947 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070013948 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053013949 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070013950 {
13951 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
13952 }
13953 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
13954 {
13955 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
13956 }
13957 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013958
13959 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013960 pWextState->wpaVersion);
13961
13962 /*set authentication type*/
13963 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
13964
13965 if (0 > status)
13966 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013967 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013968 "%s: failed to set authentication type ", __func__);
13969 return status;
13970 }
13971
13972 /*set key mgmt type*/
13973 if (req->crypto.n_akm_suites)
13974 {
13975 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
13976 if (0 > status)
13977 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013978 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070013979 __func__);
13980 return status;
13981 }
13982 }
13983
13984 /*set pairwise cipher type*/
13985 if (req->crypto.n_ciphers_pairwise)
13986 {
13987 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
13988 req->crypto.ciphers_pairwise[0], true);
13989 if (0 > status)
13990 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013991 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013992 "%s: failed to set unicast cipher type", __func__);
13993 return status;
13994 }
13995 }
13996 else
13997 {
13998 /*Reset previous cipher suite to none*/
13999 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
14000 if (0 > status)
14001 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014002 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014003 "%s: failed to set unicast cipher type", __func__);
14004 return status;
14005 }
14006 }
14007
14008 /*set group cipher type*/
14009 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
14010 false);
14011
14012 if (0 > status)
14013 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014014 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070014015 __func__);
14016 return status;
14017 }
14018
Chet Lanctot186b5732013-03-18 10:26:30 -070014019#ifdef WLAN_FEATURE_11W
14020 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
14021#endif
14022
Jeff Johnson295189b2012-06-20 16:38:30 -070014023 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
14024 if (req->ie_len)
14025 {
14026 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
14027 if ( 0 > status)
14028 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014029 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070014030 __func__);
14031 return status;
14032 }
14033 }
14034
14035 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014036 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070014037 {
14038 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
14039 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
14040 )
14041 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014042 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070014043 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
14044 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014045 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070014046 __func__);
14047 return -EOPNOTSUPP;
14048 }
14049 else
14050 {
14051 u8 key_len = req->key_len;
14052 u8 key_idx = req->key_idx;
14053
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014054 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070014055 && (CSR_MAX_NUM_KEY > key_idx)
14056 )
14057 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014058 hddLog(VOS_TRACE_LEVEL_INFO,
14059 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070014060 __func__, key_idx, key_len);
14061 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014062 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070014063 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014064 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070014065 (u8)key_len;
14066 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
14067 }
14068 }
14069 }
14070 }
14071
14072 return status;
14073}
14074
14075/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014076 * FUNCTION: wlan_hdd_try_disconnect
14077 * This function is used to disconnect from previous
14078 * connection
14079 */
14080static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
14081{
14082 long ret = 0;
14083 hdd_station_ctx_t *pHddStaCtx;
14084 eMib_dot11DesiredBssType connectedBssType;
14085
14086 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14087
14088 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
14089
14090 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
14091 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
14092 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
14093 {
14094 /* Issue disconnect to CSR */
14095 INIT_COMPLETION(pAdapter->disconnect_comp_var);
14096 if( eHAL_STATUS_SUCCESS ==
14097 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
14098 pAdapter->sessionId,
14099 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
14100 {
14101 ret = wait_for_completion_interruptible_timeout(
14102 &pAdapter->disconnect_comp_var,
14103 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
14104 if (0 >= ret)
14105 {
14106 hddLog(LOGE, FL("Failed to receive disconnect event"));
14107 return -EALREADY;
14108 }
14109 }
14110 }
14111 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
14112 {
14113 ret = wait_for_completion_interruptible_timeout(
14114 &pAdapter->disconnect_comp_var,
14115 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
14116 if (0 >= ret)
14117 {
14118 hddLog(LOGE, FL("Failed to receive disconnect event"));
14119 return -EALREADY;
14120 }
14121 }
14122
14123 return 0;
14124}
14125
14126/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053014127 * FUNCTION: __wlan_hdd_cfg80211_connect
14128 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070014129 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014130static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070014131 struct net_device *ndev,
14132 struct cfg80211_connect_params *req
14133 )
14134{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014135 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014136 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070014137 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053014138 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014139
14140 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014141
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014142 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14143 TRACE_CODE_HDD_CFG80211_CONNECT,
14144 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014145 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053014146 "%s: device_mode = %s (%d)", __func__,
14147 hdd_device_modetoString(pAdapter->device_mode),
14148 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070014149
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014150 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080014151 if (!pHddCtx)
14152 {
14153 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14154 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053014155 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080014156 }
14157
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014158 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014159 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070014160 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014161 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014162 }
14163
Agarwal Ashish51325b52014-06-16 16:50:49 +053014164 if (vos_max_concurrent_connections_reached()) {
14165 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
14166 return -ECONNREFUSED;
14167 }
14168
Jeff Johnson295189b2012-06-20 16:38:30 -070014169#ifdef WLAN_BTAMP_FEATURE
14170 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014171 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070014172 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014173 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014174 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080014175 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070014176 }
14177#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014178
14179 //If Device Mode is Station Concurrent Sessions Exit BMps
14180 //P2P Mode will be taken care in Open/close adapter
14181 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053014182 (vos_concurrent_open_sessions_running())) {
14183 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
14184 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014185 }
14186
14187 /*Try disconnecting if already in connected state*/
14188 status = wlan_hdd_try_disconnect(pAdapter);
14189 if ( 0 > status)
14190 {
14191 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
14192 " connection"));
14193 return -EALREADY;
14194 }
14195
Jeff Johnson295189b2012-06-20 16:38:30 -070014196 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014197 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070014198
14199 if ( 0 > status)
14200 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014201 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070014202 __func__);
14203 return status;
14204 }
Mohit Khanna765234a2012-09-11 15:08:35 -070014205 if ( req->channel )
14206 {
14207 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
14208 req->ssid_len, req->bssid,
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053014209 req->bssid_hint,
Mohit Khanna765234a2012-09-11 15:08:35 -070014210 req->channel->hw_value);
14211 }
14212 else
14213 {
14214 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053014215 req->ssid_len, req->bssid,
14216 req->bssid_hint, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -070014217 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014218
Sushant Kaushikd7083982015-03-18 14:33:24 +053014219 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070014220 {
14221 //ReEnable BMPS if disabled
14222 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
14223 (NULL != pHddCtx))
14224 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053014225 if (pHddCtx->hdd_wlan_suspended)
14226 {
14227 hdd_set_pwrparams(pHddCtx);
14228 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014229 //ReEnable Bmps and Imps back
14230 hdd_enable_bmps_imps(pHddCtx);
14231 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053014232 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014233 return status;
14234 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014235 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014236 EXIT();
14237 return status;
14238}
14239
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014240static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
14241 struct net_device *ndev,
14242 struct cfg80211_connect_params *req)
14243{
14244 int ret;
14245 vos_ssr_protect(__func__);
14246 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
14247 vos_ssr_unprotect(__func__);
14248
14249 return ret;
14250}
Jeff Johnson295189b2012-06-20 16:38:30 -070014251
14252/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014253 * FUNCTION: wlan_hdd_disconnect
14254 * This function is used to issue a disconnect request to SME
14255 */
14256int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
14257{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014258 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014259 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014260 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014261 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014262
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014263 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014264
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014265 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014266 if (0 != status)
14267 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014268 return status;
14269 }
14270
Sushant Kaushikb4834d22015-07-15 15:29:05 +053014271 if (pHddStaCtx->conn_info.connState == eConnectionState_Connecting)
14272 {
14273 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
14274 pAdapter->sessionId);
14275 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014276 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053014277
Agarwal Ashish47d18112014-08-04 19:55:07 +053014278 /* Need to apply spin lock before decreasing active sessions
14279 * as there can be chance for double decrement if context switch
14280 * Calls hdd_DisConnectHandler.
14281 */
14282
14283 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053014284 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
14285 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053014286 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
14287 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053014288 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
14289 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053014290
Abhishek Singhf4669da2014-05-26 15:07:49 +053014291 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053014292 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
14293
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014294 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014295
Mihir Shete182a0b22014-08-18 16:08:48 +053014296 /*
14297 * stop tx queues before deleting STA/BSS context from the firmware.
14298 * tx has to be disabled because the firmware can get busy dropping
14299 * the tx frames after BSS/STA has been deleted and will not send
14300 * back a response resulting in WDI timeout
14301 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053014302 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053014303 netif_tx_disable(pAdapter->dev);
14304 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053014305
Mihir Shete182a0b22014-08-18 16:08:48 +053014306 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014307 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
14308 pAdapter->sessionId, reason);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014309 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
14310 {
14311 hddLog(VOS_TRACE_LEVEL_INFO,
14312 FL("status = %d, already disconnected"),
14313 (int)status );
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014314
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014315 }
14316 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014317 {
14318 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080014319 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014320 __func__, (int)status );
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014321 result = -EINVAL;
14322 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014323 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014324 ret = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014325 &pAdapter->disconnect_comp_var,
14326 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014327 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status ))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014328 {
14329 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053014330 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014331 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053014332 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014333 else if (ret == -ERESTARTSYS)
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053014334 {
14335 hddLog(VOS_TRACE_LEVEL_ERROR,
14336 "%s: Failed to disconnect, wait interrupted", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014337 result = -ERESTARTSYS;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014338 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014339disconnected:
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014340 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14341 FL("Set HDD connState to eConnectionState_NotConnected"));
14342 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
14343
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014344 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014345 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014346}
14347
14348
14349/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014350 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070014351 * This function is used to issue a disconnect request to SME
14352 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014353static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070014354 struct net_device *dev,
14355 u16 reason
14356 )
14357{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014358 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014359 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014360 tCsrRoamProfile *pRoamProfile;
14361 hdd_station_ctx_t *pHddStaCtx;
14362 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053014363#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080014364 tANI_U8 staIdx;
14365#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014366
Jeff Johnson295189b2012-06-20 16:38:30 -070014367 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014368
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014369 if (!pAdapter) {
14370 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
14371 return -EINVAL;
14372 }
14373
14374 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14375 if (!pHddStaCtx) {
14376 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
14377 return -EINVAL;
14378 }
14379
14380 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14381 status = wlan_hdd_validate_context(pHddCtx);
14382 if (0 != status)
14383 {
14384 return status;
14385 }
14386
14387 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
14388
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014389 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14390 TRACE_CODE_HDD_CFG80211_DISCONNECT,
14391 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053014392 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
14393 __func__, hdd_device_modetoString(pAdapter->device_mode),
14394 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070014395
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014396 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
14397 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070014398
Jeff Johnson295189b2012-06-20 16:38:30 -070014399 if (NULL != pRoamProfile)
14400 {
14401 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053014402 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
14403 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070014404 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014405 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070014406 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053014407 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070014408 switch(reason)
14409 {
14410 case WLAN_REASON_MIC_FAILURE:
14411 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
14412 break;
14413
14414 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
14415 case WLAN_REASON_DISASSOC_AP_BUSY:
14416 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
14417 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
14418 break;
14419
14420 case WLAN_REASON_PREV_AUTH_NOT_VALID:
14421 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053014422 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070014423 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
14424 break;
14425
Jeff Johnson295189b2012-06-20 16:38:30 -070014426 default:
14427 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
14428 break;
14429 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053014430 pScanInfo = &pHddCtx->scan_info;
14431 if (pScanInfo->mScanPending)
14432 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053014433 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053014434 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053014435 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053014436 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053014437 }
Agarwal Ashishc089cec2015-08-10 13:10:04 +053014438 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080014439#ifdef FEATURE_WLAN_TDLS
14440 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080014441 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080014442 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080014443 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
14444 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080014445 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014446 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080014447 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014449 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080014450 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014451 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014452 status = sme_DeleteTdlsPeerSta(
14453 WLAN_HDD_GET_HAL_CTX(pAdapter),
14454 pAdapter->sessionId,
14455 mac);
14456 if (status != eHAL_STATUS_SUCCESS) {
14457 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
14458 return -EPERM;
14459 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080014460 }
14461 }
14462#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053014463 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014464 status = wlan_hdd_disconnect(pAdapter, reasonCode);
14465 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070014466 {
14467 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080014468 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014469 __func__, (int)status );
14470 return -EINVAL;
14471 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014472 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053014473 else
14474 {
14475 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
14476 "called while in %d state", __func__,
14477 pHddStaCtx->conn_info.connState);
14478 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014479 }
14480 else
14481 {
14482 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
14483 }
14484
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014485 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070014486 return status;
14487}
14488
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014489static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
14490 struct net_device *dev,
14491 u16 reason
14492 )
14493{
14494 int ret;
14495 vos_ssr_protect(__func__);
14496 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
14497 vos_ssr_unprotect(__func__);
14498
14499 return ret;
14500}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014501
Jeff Johnson295189b2012-06-20 16:38:30 -070014502/*
14503 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014504 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070014505 * settings in IBSS mode.
14506 */
14507static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014508 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070014509 struct cfg80211_ibss_params *params
14510 )
14511{
14512 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014513 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070014514 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
14515 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014516
Jeff Johnson295189b2012-06-20 16:38:30 -070014517 ENTER();
14518
14519 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070014520 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070014521
14522 if (params->ie_len && ( NULL != params->ie) )
14523 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070014524 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
14525 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070014526 {
14527 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
14528 encryptionType = eCSR_ENCRYPT_TYPE_AES;
14529 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070014530 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070014531 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070014532 tDot11fIEWPA dot11WPAIE;
14533 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070014534 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070014535
Wilson Yang00256342013-10-10 23:13:38 -070014536 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070014537 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
14538 params->ie_len, DOT11F_EID_WPA);
14539 if ( NULL != ie )
14540 {
14541 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
14542 // Unpack the WPA IE
14543 //Skip past the EID byte and length byte - and four byte WiFi OUI
14544 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
14545 &ie[2+4],
14546 ie[1] - 4,
14547 &dot11WPAIE);
14548 /*Extract the multicast cipher, the encType for unicast
14549 cipher for wpa-none is none*/
14550 encryptionType =
14551 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
14552 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014553 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070014554
Jeff Johnson295189b2012-06-20 16:38:30 -070014555 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
14556
14557 if (0 > status)
14558 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014559 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070014560 __func__);
14561 return status;
14562 }
14563 }
14564
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014565 pWextState->roamProfile.AuthType.authType[0] =
14566 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070014567 eCSR_AUTH_TYPE_OPEN_SYSTEM;
14568
14569 if (params->privacy)
14570 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014571 /* Security enabled IBSS, At this time there is no information available
14572 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070014573 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014574 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070014575 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014576 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070014577 *enable privacy bit in beacons */
14578
14579 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
14580 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070014581 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
14582 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070014583 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
14584 pWextState->roamProfile.EncryptionType.numEntries = 1;
14585 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070014586 return status;
14587}
14588
14589/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014590 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014591 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070014592 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014593static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070014594 struct net_device *dev,
14595 struct cfg80211_ibss_params *params
14596 )
14597{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014598 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070014599 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
14600 tCsrRoamProfile *pRoamProfile;
14601 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014602 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14603 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014604 tSirMacAddr bssid;
Jeff Johnson295189b2012-06-20 16:38:30 -070014605
14606 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014607
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014608 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14609 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
14610 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014611 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053014612 "%s: device_mode = %s (%d)", __func__,
14613 hdd_device_modetoString(pAdapter->device_mode),
14614 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070014615
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014616 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014617 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070014618 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014619 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014620 }
14621
14622 if (NULL == pWextState)
14623 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014624 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070014625 __func__);
14626 return -EIO;
14627 }
14628
Agarwal Ashish51325b52014-06-16 16:50:49 +053014629 if (vos_max_concurrent_connections_reached()) {
14630 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
14631 return -ECONNREFUSED;
14632 }
14633
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014634 /*Try disconnecting if already in connected state*/
14635 status = wlan_hdd_try_disconnect(pAdapter);
14636 if ( 0 > status)
14637 {
14638 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
14639 " IBSS connection"));
14640 return -EALREADY;
14641 }
14642
Jeff Johnson295189b2012-06-20 16:38:30 -070014643 pRoamProfile = &pWextState->roamProfile;
14644
14645 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
14646 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014647 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080014648 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014649 return -EINVAL;
14650 }
14651
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070014652 /* BSSID is provided by upper layers hence no need to AUTO generate */
14653 if (NULL != params->bssid) {
14654 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
14655 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
14656 hddLog (VOS_TRACE_LEVEL_ERROR,
14657 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
14658 return -EIO;
14659 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014660 vos_mem_copy((v_U8_t *)bssid, (v_U8_t *)params->bssid, sizeof(bssid));
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070014661 }
krunal sonie9002db2013-11-25 14:24:17 -080014662 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
14663 {
14664 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
14665 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
14666 {
14667 hddLog (VOS_TRACE_LEVEL_ERROR,
14668 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
14669 return -EIO;
14670 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014671
14672 vos_mem_copy((v_U8_t *)bssid,
krunal sonie9002db2013-11-25 14:24:17 -080014673 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014674 sizeof(bssid));
krunal sonie9002db2013-11-25 14:24:17 -080014675 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070014676
Jeff Johnson295189b2012-06-20 16:38:30 -070014677 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070014678 if (NULL !=
14679#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
14680 params->chandef.chan)
14681#else
14682 params->channel)
14683#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014684 {
14685 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014686 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
14687 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
14688 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14689 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070014690
14691 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014692 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070014693 ieee80211_frequency_to_channel(
14694#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
14695 params->chandef.chan->center_freq);
14696#else
14697 params->channel->center_freq);
14698#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014699
14700 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
14701 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070014702 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014703 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
14704 __func__);
14705 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070014706 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014707
14708 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070014709 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014710 if (channelNum == validChan[indx])
14711 {
14712 break;
14713 }
14714 }
14715 if (indx >= numChans)
14716 {
14717 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014718 __func__, channelNum);
14719 return -EINVAL;
14720 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014721 /* Set the Operational Channel */
14722 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
14723 channelNum);
14724 pRoamProfile->ChannelInfo.numOfChannels = 1;
14725 pHddStaCtx->conn_info.operationChannel = channelNum;
14726 pRoamProfile->ChannelInfo.ChannelList =
14727 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070014728 }
14729
14730 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014731 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070014732 if (status < 0)
14733 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014734 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070014735 __func__);
14736 return status;
14737 }
14738
14739 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014740 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053014741 params->ssid_len, params->bssid, NULL,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014742 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070014743
14744 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -070014745 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014746
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014747 EXIT();
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014748 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014749}
14750
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014751static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
14752 struct net_device *dev,
14753 struct cfg80211_ibss_params *params
14754 )
14755{
14756 int ret = 0;
14757
14758 vos_ssr_protect(__func__);
14759 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
14760 vos_ssr_unprotect(__func__);
14761
14762 return ret;
14763}
14764
Jeff Johnson295189b2012-06-20 16:38:30 -070014765/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014766 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014767 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070014768 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014769static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070014770 struct net_device *dev
14771 )
14772{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014773 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014774 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
14775 tCsrRoamProfile *pRoamProfile;
14776 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014777 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014778
14779 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014780
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014781 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14782 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
14783 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014784 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014785 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014786 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014787 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014788 }
14789
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053014790 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
14791 hdd_device_modetoString(pAdapter->device_mode),
14792 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070014793 if (NULL == pWextState)
14794 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014795 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070014796 __func__);
14797 return -EIO;
14798 }
14799
14800 pRoamProfile = &pWextState->roamProfile;
14801
14802 /* Issue disconnect only if interface type is set to IBSS */
14803 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
14804 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014805 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070014806 __func__);
14807 return -EINVAL;
14808 }
14809
14810 /* Issue Disconnect request */
14811 INIT_COMPLETION(pAdapter->disconnect_comp_var);
14812 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
14813 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
14814
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014815 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070014816 return 0;
14817}
14818
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014819static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
14820 struct net_device *dev
14821 )
14822{
14823 int ret = 0;
14824
14825 vos_ssr_protect(__func__);
14826 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
14827 vos_ssr_unprotect(__func__);
14828
14829 return ret;
14830}
14831
Jeff Johnson295189b2012-06-20 16:38:30 -070014832/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053014833 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070014834 * This function is used to set the phy parameters
14835 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
14836 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053014837static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070014838 u32 changed)
14839{
14840 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
14841 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014842 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014843
14844 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014845
14846 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014847 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
14848 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014849
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014850 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014851 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014852 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014853 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014854 }
14855
Jeff Johnson295189b2012-06-20 16:38:30 -070014856 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
14857 {
14858 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
14859 WNI_CFG_RTS_THRESHOLD_STAMAX :
14860 wiphy->rts_threshold;
14861
14862 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014863 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070014864 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014865 hddLog(VOS_TRACE_LEVEL_ERROR,
14866 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070014867 __func__, rts_threshold);
14868 return -EINVAL;
14869 }
14870
14871 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
14872 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014873 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070014874 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014875 hddLog(VOS_TRACE_LEVEL_ERROR,
14876 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070014877 __func__, rts_threshold);
14878 return -EIO;
14879 }
14880
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014881 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014882 rts_threshold);
14883 }
14884
14885 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
14886 {
14887 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
14888 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
14889 wiphy->frag_threshold;
14890
14891 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014892 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014893 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014894 hddLog(VOS_TRACE_LEVEL_ERROR,
14895 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014896 frag_threshold);
14897 return -EINVAL;
14898 }
14899
14900 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
14901 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014902 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070014903 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014904 hddLog(VOS_TRACE_LEVEL_ERROR,
14905 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070014906 __func__, frag_threshold);
14907 return -EIO;
14908 }
14909
14910 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
14911 frag_threshold);
14912 }
14913
14914 if ((changed & WIPHY_PARAM_RETRY_SHORT)
14915 || (changed & WIPHY_PARAM_RETRY_LONG))
14916 {
14917 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
14918 wiphy->retry_short :
14919 wiphy->retry_long;
14920
14921 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
14922 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
14923 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014924 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070014925 __func__, retry_value);
14926 return -EINVAL;
14927 }
14928
14929 if (changed & WIPHY_PARAM_RETRY_SHORT)
14930 {
14931 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
14932 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014933 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070014934 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014935 hddLog(VOS_TRACE_LEVEL_ERROR,
14936 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070014937 __func__, retry_value);
14938 return -EIO;
14939 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014940 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070014941 __func__, retry_value);
14942 }
14943 else if (changed & WIPHY_PARAM_RETRY_SHORT)
14944 {
14945 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
14946 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014947 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070014948 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014949 hddLog(VOS_TRACE_LEVEL_ERROR,
14950 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070014951 __func__, retry_value);
14952 return -EIO;
14953 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014954 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070014955 __func__, retry_value);
14956 }
14957 }
14958
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014959 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070014960 return 0;
14961}
14962
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053014963static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
14964 u32 changed)
14965{
14966 int ret;
14967
14968 vos_ssr_protect(__func__);
14969 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
14970 vos_ssr_unprotect(__func__);
14971
14972 return ret;
14973}
14974
Jeff Johnson295189b2012-06-20 16:38:30 -070014975/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053014976 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070014977 * This function is used to set the txpower
14978 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053014979static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070014980#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
14981 struct wireless_dev *wdev,
14982#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014983#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014984 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070014985#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014986 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070014987#endif
14988 int dbm)
14989{
14990 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014991 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014992 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
14993 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014994 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014995
14996 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014997
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014998 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14999 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
15000 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015001 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015002 if (0 != status)
15003 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015004 return status;
15005 }
15006
15007 hHal = pHddCtx->hHal;
15008
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015009 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
15010 dbm, ccmCfgSetCallback,
15011 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015012 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015013 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015014 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
15015 return -EIO;
15016 }
15017
15018 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
15019 dbm);
15020
15021 switch(type)
15022 {
15023 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
15024 /* Fall through */
15025 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
15026 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
15027 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015028 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
15029 __func__);
15030 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070015031 }
15032 break;
15033 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015034 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070015035 __func__);
15036 return -EOPNOTSUPP;
15037 break;
15038 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015039 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
15040 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070015041 return -EIO;
15042 }
15043
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015044 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015045 return 0;
15046}
15047
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015048static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
15049#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15050 struct wireless_dev *wdev,
15051#endif
15052#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
15053 enum tx_power_setting type,
15054#else
15055 enum nl80211_tx_power_setting type,
15056#endif
15057 int dbm)
15058{
15059 int ret;
15060 vos_ssr_protect(__func__);
15061 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
15062#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15063 wdev,
15064#endif
15065#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
15066 type,
15067#else
15068 type,
15069#endif
15070 dbm);
15071 vos_ssr_unprotect(__func__);
15072
15073 return ret;
15074}
15075
Jeff Johnson295189b2012-06-20 16:38:30 -070015076/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015077 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070015078 * This function is used to read the txpower
15079 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015080static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070015081#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15082 struct wireless_dev *wdev,
15083#endif
15084 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070015085{
15086
15087 hdd_adapter_t *pAdapter;
15088 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015089 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015090
Jeff Johnsone7245742012-09-05 17:12:55 -070015091 ENTER();
15092
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015093 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015094 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015095 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015096 *dbm = 0;
15097 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015098 }
15099
Jeff Johnson295189b2012-06-20 16:38:30 -070015100 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
15101 if (NULL == pAdapter)
15102 {
15103 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
15104 return -ENOENT;
15105 }
15106
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053015107 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15108 TRACE_CODE_HDD_CFG80211_GET_TXPOWER,
15109 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070015110 wlan_hdd_get_classAstats(pAdapter);
15111 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
15112
Jeff Johnsone7245742012-09-05 17:12:55 -070015113 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015114 return 0;
15115}
15116
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015117static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
15118#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15119 struct wireless_dev *wdev,
15120#endif
15121 int *dbm)
15122{
15123 int ret;
15124
15125 vos_ssr_protect(__func__);
15126 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
15127#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15128 wdev,
15129#endif
15130 dbm);
15131 vos_ssr_unprotect(__func__);
15132
15133 return ret;
15134}
15135
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015136static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015137#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15138 const u8* mac,
15139#else
15140 u8* mac,
15141#endif
15142 struct station_info *sinfo)
Jeff Johnson295189b2012-06-20 16:38:30 -070015143{
15144 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
15145 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15146 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053015147 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070015148
15149 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
15150 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070015151
15152 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
15153 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
15154 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
15155 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
15156 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
15157 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
15158 tANI_U16 maxRate = 0;
15159 tANI_U16 myRate;
15160 tANI_U16 currentRate = 0;
15161 tANI_U8 maxSpeedMCS = 0;
15162 tANI_U8 maxMCSIdx = 0;
15163 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053015164 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070015165 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015166 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015167
Leo Chang6f8870f2013-03-26 18:11:36 -070015168#ifdef WLAN_FEATURE_11AC
15169 tANI_U32 vht_mcs_map;
15170 eDataRate11ACMaxMcs vhtMaxMcs;
15171#endif /* WLAN_FEATURE_11AC */
15172
Jeff Johnsone7245742012-09-05 17:12:55 -070015173 ENTER();
15174
Jeff Johnson295189b2012-06-20 16:38:30 -070015175 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
15176 (0 == ssidlen))
15177 {
15178 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
15179 " Invalid ssidlen, %d", __func__, ssidlen);
15180 /*To keep GUI happy*/
15181 return 0;
15182 }
15183
Mukul Sharma811205f2014-07-09 21:07:30 +053015184 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
15185 {
15186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15187 "%s: Roaming in progress, so unable to proceed this request", __func__);
15188 return 0;
15189 }
15190
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015191 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015192 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015193 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015194 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015195 }
15196
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +053015197 wlan_hdd_get_station_stats(pAdapter);
15198 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070015199
Kiet Lam3b17fc82013-09-27 05:24:08 +053015200 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
15201 sinfo->filled |= STATION_INFO_SIGNAL;
15202
c_hpothu09f19542014-05-30 21:53:31 +053015203 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053015204 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
15205 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053015206 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053015207 {
15208 rate_flags = pAdapter->maxRateFlags;
15209 }
c_hpothu44ff4e02014-05-08 00:13:57 +053015210
Jeff Johnson295189b2012-06-20 16:38:30 -070015211 //convert to the UI units of 100kbps
15212 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
15213
15214#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070015215 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 -070015216 sinfo->signal,
15217 pCfg->reportMaxLinkSpeed,
15218 myRate,
15219 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070015220 (int) pCfg->linkSpeedRssiMid,
15221 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070015222 (int) rate_flags,
15223 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070015224#endif //LINKSPEED_DEBUG_ENABLED
15225
15226 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
15227 {
15228 // we do not want to necessarily report the current speed
15229 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
15230 {
15231 // report the max possible speed
15232 rssidx = 0;
15233 }
15234 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
15235 {
15236 // report the max possible speed with RSSI scaling
15237 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
15238 {
15239 // report the max possible speed
15240 rssidx = 0;
15241 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070015242 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070015243 {
15244 // report middle speed
15245 rssidx = 1;
15246 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070015247 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
15248 {
15249 // report middle speed
15250 rssidx = 2;
15251 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015252 else
15253 {
15254 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070015255 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070015256 }
15257 }
15258 else
15259 {
15260 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
15261 hddLog(VOS_TRACE_LEVEL_ERROR,
15262 "%s: Invalid value for reportMaxLinkSpeed: %u",
15263 __func__, pCfg->reportMaxLinkSpeed);
15264 rssidx = 0;
15265 }
15266
15267 maxRate = 0;
15268
15269 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053015270 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
15271 OperationalRates, &ORLeng))
15272 {
15273 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
15274 /*To keep GUI happy*/
15275 return 0;
15276 }
15277
Jeff Johnson295189b2012-06-20 16:38:30 -070015278 for (i = 0; i < ORLeng; i++)
15279 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015280 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070015281 {
15282 /* Validate Rate Set */
15283 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
15284 {
15285 currentRate = supported_data_rate[j].supported_rate[rssidx];
15286 break;
15287 }
15288 }
15289 /* Update MAX rate */
15290 maxRate = (currentRate > maxRate)?currentRate:maxRate;
15291 }
15292
15293 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053015294 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
15295 ExtendedRates, &ERLeng))
15296 {
15297 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
15298 /*To keep GUI happy*/
15299 return 0;
15300 }
15301
Jeff Johnson295189b2012-06-20 16:38:30 -070015302 for (i = 0; i < ERLeng; i++)
15303 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015304 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070015305 {
15306 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
15307 {
15308 currentRate = supported_data_rate[j].supported_rate[rssidx];
15309 break;
15310 }
15311 }
15312 /* Update MAX rate */
15313 maxRate = (currentRate > maxRate)?currentRate:maxRate;
15314 }
c_hpothu79aab322014-07-14 21:11:01 +053015315
Kiet Lamb69f8dc2013-11-15 15:34:27 +053015316 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053015317 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053015318 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053015319 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070015320 {
c_hpothu79aab322014-07-14 21:11:01 +053015321 if (rate_flags & eHAL_TX_RATE_VHT80)
15322 mode = 2;
15323 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
15324 mode = 1;
15325 else
15326 mode = 0;
15327
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053015328 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
15329 MCSRates, &MCSLeng))
15330 {
15331 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
15332 /*To keep GUI happy*/
15333 return 0;
15334 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015335 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070015336#ifdef WLAN_FEATURE_11AC
15337 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015338 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070015339 {
Leo Chang6f8870f2013-03-26 18:11:36 -070015340 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015341 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070015342 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070015343 {
Leo Chang6f8870f2013-03-26 18:11:36 -070015344 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070015345 }
Leo Chang6f8870f2013-03-26 18:11:36 -070015346 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070015347 {
Leo Chang6f8870f2013-03-26 18:11:36 -070015348 maxMCSIdx = 7;
15349 }
15350 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
15351 {
15352 maxMCSIdx = 8;
15353 }
15354 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
15355 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015356 //VHT20 is supporting 0~8
15357 if (rate_flags & eHAL_TX_RATE_VHT20)
15358 maxMCSIdx = 8;
15359 else
15360 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070015361 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015362
c_hpothu79aab322014-07-14 21:11:01 +053015363 if (0 != rssidx)/*check for scaled */
15364 {
15365 //get middle rate MCS index if rssi=1/2
15366 for (i=0; i <= maxMCSIdx; i++)
15367 {
15368 if (sinfo->signal <= rssiMcsTbl[mode][i])
15369 {
15370 maxMCSIdx = i;
15371 break;
15372 }
15373 }
15374 }
15375
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015376 if (rate_flags & eHAL_TX_RATE_VHT80)
15377 {
15378 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
15379 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
15380 }
15381 else if (rate_flags & eHAL_TX_RATE_VHT40)
15382 {
15383 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
15384 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
15385 }
15386 else if (rate_flags & eHAL_TX_RATE_VHT20)
15387 {
15388 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
15389 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
15390 }
15391
Leo Chang6f8870f2013-03-26 18:11:36 -070015392 maxSpeedMCS = 1;
15393 if (currentRate > maxRate)
15394 {
15395 maxRate = currentRate;
15396 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015397
Leo Chang6f8870f2013-03-26 18:11:36 -070015398 }
15399 else
15400#endif /* WLAN_FEATURE_11AC */
15401 {
15402 if (rate_flags & eHAL_TX_RATE_HT40)
15403 {
15404 rateFlag |= 1;
15405 }
15406 if (rate_flags & eHAL_TX_RATE_SGI)
15407 {
15408 rateFlag |= 2;
15409 }
15410
Girish Gowli01abcee2014-07-31 20:18:55 +053015411 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053015412 if (rssidx == 1 || rssidx == 2)
15413 {
15414 //get middle rate MCS index if rssi=1/2
15415 for (i=0; i <= 7; i++)
15416 {
15417 if (sinfo->signal <= rssiMcsTbl[mode][i])
15418 {
15419 temp = i+1;
15420 break;
15421 }
15422 }
15423 }
c_hpothu79aab322014-07-14 21:11:01 +053015424
15425 for (i = 0; i < MCSLeng; i++)
15426 {
Leo Chang6f8870f2013-03-26 18:11:36 -070015427 for (j = 0; j < temp; j++)
15428 {
15429 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
15430 {
15431 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053015432 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070015433 break;
15434 }
15435 }
15436 if ((j < temp) && (currentRate > maxRate))
15437 {
15438 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070015439 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015440 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053015441 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070015442 }
15443 }
15444
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015445 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
15446 {
15447 maxRate = myRate;
15448 maxSpeedMCS = 1;
15449 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
15450 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015451 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053015452 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070015453 {
15454 maxRate = myRate;
15455 if (rate_flags & eHAL_TX_RATE_LEGACY)
15456 {
15457 maxSpeedMCS = 0;
15458 }
15459 else
15460 {
15461 maxSpeedMCS = 1;
15462 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
15463 }
15464 }
15465
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015466 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070015467 {
15468 sinfo->txrate.legacy = maxRate;
15469#ifdef LINKSPEED_DEBUG_ENABLED
15470 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
15471#endif //LINKSPEED_DEBUG_ENABLED
15472 }
15473 else
15474 {
15475 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070015476#ifdef WLAN_FEATURE_11AC
15477 sinfo->txrate.nss = 1;
15478 if (rate_flags & eHAL_TX_RATE_VHT80)
15479 {
15480 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015481 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070015482 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015483 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070015484 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015485 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
15486 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
15487 }
15488 else if (rate_flags & eHAL_TX_RATE_VHT20)
15489 {
15490 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
15491 }
15492#endif /* WLAN_FEATURE_11AC */
15493 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
15494 {
15495 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
15496 if (rate_flags & eHAL_TX_RATE_HT40)
15497 {
15498 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
15499 }
Leo Chang6f8870f2013-03-26 18:11:36 -070015500 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015501 if (rate_flags & eHAL_TX_RATE_SGI)
15502 {
15503 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
15504 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015505
Jeff Johnson295189b2012-06-20 16:38:30 -070015506#ifdef LINKSPEED_DEBUG_ENABLED
15507 pr_info("Reporting MCS rate %d flags %x\n",
15508 sinfo->txrate.mcs,
15509 sinfo->txrate.flags );
15510#endif //LINKSPEED_DEBUG_ENABLED
15511 }
15512 }
15513 else
15514 {
15515 // report current rate instead of max rate
15516
15517 if (rate_flags & eHAL_TX_RATE_LEGACY)
15518 {
15519 //provide to the UI in units of 100kbps
15520 sinfo->txrate.legacy = myRate;
15521#ifdef LINKSPEED_DEBUG_ENABLED
15522 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
15523#endif //LINKSPEED_DEBUG_ENABLED
15524 }
15525 else
15526 {
15527 //must be MCS
15528 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070015529#ifdef WLAN_FEATURE_11AC
15530 sinfo->txrate.nss = 1;
15531 if (rate_flags & eHAL_TX_RATE_VHT80)
15532 {
15533 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
15534 }
15535 else
15536#endif /* WLAN_FEATURE_11AC */
15537 {
15538 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
15539 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015540 if (rate_flags & eHAL_TX_RATE_SGI)
15541 {
15542 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
15543 }
15544 if (rate_flags & eHAL_TX_RATE_HT40)
15545 {
15546 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
15547 }
Leo Chang6f8870f2013-03-26 18:11:36 -070015548#ifdef WLAN_FEATURE_11AC
15549 else if (rate_flags & eHAL_TX_RATE_VHT80)
15550 {
15551 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
15552 }
15553#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070015554#ifdef LINKSPEED_DEBUG_ENABLED
15555 pr_info("Reporting actual MCS rate %d flags %x\n",
15556 sinfo->txrate.mcs,
15557 sinfo->txrate.flags );
15558#endif //LINKSPEED_DEBUG_ENABLED
15559 }
15560 }
15561 sinfo->filled |= STATION_INFO_TX_BITRATE;
15562
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070015563 sinfo->tx_packets =
15564 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
15565 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
15566 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
15567 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
15568
15569 sinfo->tx_retries =
15570 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
15571 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
15572 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
15573 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
15574
15575 sinfo->tx_failed =
15576 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
15577 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
15578 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
15579 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
15580
15581 sinfo->filled |=
15582 STATION_INFO_TX_PACKETS |
15583 STATION_INFO_TX_RETRIES |
15584 STATION_INFO_TX_FAILED;
15585
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015586 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15587 TRACE_CODE_HDD_CFG80211_GET_STA,
15588 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070015589 EXIT();
15590 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015591}
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015592#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
15593static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
15594 const u8* mac, struct station_info *sinfo)
15595#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015596static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
15597 u8* mac, struct station_info *sinfo)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015598#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015599{
15600 int ret;
15601
15602 vos_ssr_protect(__func__);
15603 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
15604 vos_ssr_unprotect(__func__);
15605
15606 return ret;
15607}
15608
15609static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070015610 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070015611{
15612 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053015613 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070015614 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015615 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015616
Jeff Johnsone7245742012-09-05 17:12:55 -070015617 ENTER();
15618
Jeff Johnson295189b2012-06-20 16:38:30 -070015619 if (NULL == pAdapter)
15620 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080015621 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015622 return -ENODEV;
15623 }
15624
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015625 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15626 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
15627 pAdapter->sessionId, timeout));
15628
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053015629 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015630 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015631 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015632 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015633 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015634 }
15635
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053015636 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
15637 (TRUE == pHddCtx->hdd_wlan_suspended) &&
15638 (pHddCtx->cfg_ini->fhostArpOffload) &&
15639 (eConnectionState_Associated ==
15640 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
15641 {
Amar Singhald53568e2013-09-26 11:03:45 -070015642
15643 hddLog(VOS_TRACE_LEVEL_INFO,
15644 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053015645 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053015646 if (!VOS_IS_STATUS_SUCCESS(vos_status))
15647 {
15648 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015649 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053015650 __func__, vos_status);
15651 }
15652 }
15653
Jeff Johnson295189b2012-06-20 16:38:30 -070015654 /**The get power cmd from the supplicant gets updated by the nl only
15655 *on successful execution of the function call
15656 *we are oppositely mapped w.r.t mode in the driver
15657 **/
15658 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
15659
15660 if (VOS_STATUS_E_FAILURE == vos_status)
15661 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015662 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15663 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015664 return -EINVAL;
15665 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015666 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015667 return 0;
15668}
15669
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015670static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
15671 struct net_device *dev, bool mode, int timeout)
15672{
15673 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070015674
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015675 vos_ssr_protect(__func__);
15676 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
15677 vos_ssr_unprotect(__func__);
15678
15679 return ret;
15680}
Sushant Kaushik084f6592015-09-10 13:11:56 +053015681
Jeff Johnson295189b2012-06-20 16:38:30 -070015682#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015683static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
15684 struct net_device *netdev,
15685 u8 key_index)
15686{
15687 ENTER();
15688 return 0;
15689}
15690
Jeff Johnson295189b2012-06-20 16:38:30 -070015691static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015692 struct net_device *netdev,
15693 u8 key_index)
15694{
15695 int ret;
15696 vos_ssr_protect(__func__);
15697 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
15698 vos_ssr_unprotect(__func__);
15699 return ret;
15700}
15701#endif //LINUX_VERSION_CODE
15702
15703#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
15704static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
15705 struct net_device *dev,
15706 struct ieee80211_txq_params *params)
15707{
15708 ENTER();
15709 return 0;
15710}
15711#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
15712static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
15713 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070015714{
Jeff Johnsone7245742012-09-05 17:12:55 -070015715 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070015716 return 0;
15717}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015718#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070015719
15720#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
15721static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015722 struct net_device *dev,
15723 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070015724{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015725 int ret;
15726
15727 vos_ssr_protect(__func__);
15728 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
15729 vos_ssr_unprotect(__func__);
15730 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070015731}
15732#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
15733static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
15734 struct ieee80211_txq_params *params)
15735{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015736 int ret;
15737
15738 vos_ssr_protect(__func__);
15739 ret = __wlan_hdd_set_txq_params(wiphy, params);
15740 vos_ssr_unprotect(__func__);
15741 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070015742}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015743#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015744
Naresh Jayaram69e3f282014-10-14 12:29:12 +053015745static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015746 struct net_device *dev,
15747 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070015748{
15749 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015750 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015751 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015752 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015753 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053015754 v_CONTEXT_t pVosContext = NULL;
15755 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015756
Jeff Johnsone7245742012-09-05 17:12:55 -070015757 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015758
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015759 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070015760 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015761 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015762 return -EINVAL;
15763 }
15764
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015765 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15766 TRACE_CODE_HDD_CFG80211_DEL_STA,
15767 pAdapter->sessionId, pAdapter->device_mode));
15768
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015769 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15770 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015771 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015772 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015773 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015774 }
15775
Jeff Johnson295189b2012-06-20 16:38:30 -070015776 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070015777 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070015778 )
15779 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053015780 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
15781 pSapCtx = VOS_GET_SAP_CB(pVosContext);
15782 if(pSapCtx == NULL){
15783 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15784 FL("psapCtx is NULL"));
15785 return -ENOENT;
15786 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015787 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070015788 {
15789 v_U16_t i;
15790 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
15791 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053015792 if ((pSapCtx->aStaInfo[i].isUsed) &&
15793 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070015794 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015795 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053015796 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015797 ETHER_ADDR_LEN);
15798
Jeff Johnson295189b2012-06-20 16:38:30 -070015799 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080015800 "%s: Delete STA with MAC::"
15801 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015802 __func__,
15803 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
15804 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070015805 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053015806 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015807 }
15808 }
15809 }
15810 else
15811 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015812
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015813 vos_status = hdd_softap_GetStaId(pAdapter,
15814 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015815 if (!VOS_IS_STATUS_SUCCESS(vos_status))
15816 {
15817 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080015818 "%s: Skip this DEL STA as this is not used::"
15819 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015820 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015821 return -ENOENT;
15822 }
15823
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053015824 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015825 {
15826 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080015827 "%s: Skip this DEL STA as deauth is in progress::"
15828 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015829 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015830 return -ENOENT;
15831 }
15832
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053015833 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015834
Jeff Johnson295189b2012-06-20 16:38:30 -070015835 hddLog(VOS_TRACE_LEVEL_INFO,
15836 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080015837 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015838 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015839 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015840
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015841 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015842 if (!VOS_IS_STATUS_SUCCESS(vos_status))
15843 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053015844 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015845 hddLog(VOS_TRACE_LEVEL_INFO,
15846 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080015847 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015848 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015849 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015850 return -ENOENT;
15851 }
15852
Jeff Johnson295189b2012-06-20 16:38:30 -070015853 }
15854 }
15855
15856 EXIT();
15857
15858 return 0;
15859}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053015860
15861#ifdef CFG80211_DEL_STA_V2
15862static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
15863 struct net_device *dev,
15864 struct station_del_parameters *param)
15865#else
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015866#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
15867static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
15868 struct net_device *dev, const u8 *mac)
15869#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015870static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
15871 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053015872#endif
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015873#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015874{
15875 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015876 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070015877
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015878 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015879
Naresh Jayaram69e3f282014-10-14 12:29:12 +053015880#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015881 if (NULL == param) {
15882 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015883 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015884 return -EINVAL;
15885 }
15886
15887 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
15888 param->subtype, &delStaParams);
15889
Naresh Jayaram69e3f282014-10-14 12:29:12 +053015890#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053015891 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015892 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053015893#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015894 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
15895
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015896 vos_ssr_unprotect(__func__);
15897
15898 return ret;
15899}
15900
15901static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015902 struct net_device *dev,
15903#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15904 const u8 *mac,
15905#else
15906 u8 *mac,
15907#endif
15908 struct station_parameters *params)
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015909{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015910 hdd_adapter_t *pAdapter;
15911 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015912 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015913#ifdef FEATURE_WLAN_TDLS
15914 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015915
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015916 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015917
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015918 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15919 if (NULL == pAdapter)
15920 {
15921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15922 "%s: Adapter is NULL",__func__);
15923 return -EINVAL;
15924 }
15925 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15926 status = wlan_hdd_validate_context(pHddCtx);
15927 if (0 != status)
15928 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015929 return status;
15930 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015931
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015932 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15933 TRACE_CODE_HDD_CFG80211_ADD_STA,
15934 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015935 mask = params->sta_flags_mask;
15936
15937 set = params->sta_flags_set;
15938
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015939 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015940 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
15941 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015942
15943 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
15944 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080015945 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015946 }
15947 }
15948#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015949 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015950 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015951}
15952
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015953#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
15954static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
15955 struct net_device *dev, const u8 *mac,
15956 struct station_parameters *params)
15957#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015958static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
15959 struct net_device *dev, u8 *mac, struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015960#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015961{
15962 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015963
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015964 vos_ssr_protect(__func__);
15965 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
15966 vos_ssr_unprotect(__func__);
15967
15968 return ret;
15969}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015970#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070015971
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053015972static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070015973 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015974{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015975 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15976 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015977 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015978 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015979 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053015980 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070015981
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015982 ENTER();
15983
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015984 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015985 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015986 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015987 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015988 return -EINVAL;
15989 }
15990
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053015991 if (!pmksa) {
15992 hddLog(LOGE, FL("pmksa is NULL"));
15993 return -EINVAL;
15994 }
15995
15996 if (!pmksa->bssid || !pmksa->pmkid) {
15997 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
15998 pmksa->bssid, pmksa->pmkid);
15999 return -EINVAL;
16000 }
16001
16002 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
16003 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
16004
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016005 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16006 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016007 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016008 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016009 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016010 }
16011
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016012 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016013 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16014
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016015 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
16016 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016017
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016018 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016019 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016020 &pmk_id, 1, FALSE);
16021
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016022 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16023 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
16024 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016025
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016026 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016027 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016028}
16029
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016030static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
16031 struct cfg80211_pmksa *pmksa)
16032{
16033 int ret;
16034
16035 vos_ssr_protect(__func__);
16036 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
16037 vos_ssr_unprotect(__func__);
16038
16039 return ret;
16040}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016041
Wilson Yang6507c4e2013-10-01 20:11:19 -070016042
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016043static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070016044 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016045{
Wilson Yang6507c4e2013-10-01 20:11:19 -070016046 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16047 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016048 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080016049 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016050
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016051 ENTER();
16052
Wilson Yang6507c4e2013-10-01 20:11:19 -070016053 /* Validate pAdapter */
16054 if (NULL == pAdapter)
16055 {
16056 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
16057 return -EINVAL;
16058 }
16059
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016060 if (!pmksa) {
16061 hddLog(LOGE, FL("pmksa is NULL"));
16062 return -EINVAL;
16063 }
16064
16065 if (!pmksa->bssid) {
16066 hddLog(LOGE, FL("pmksa->bssid is NULL"));
16067 return -EINVAL;
16068 }
16069
Kiet Lam98c46a12014-10-31 15:34:57 -070016070 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
16071 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
16072
Wilson Yang6507c4e2013-10-01 20:11:19 -070016073 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16074 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070016075 if (0 != status)
16076 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070016077 return status;
16078 }
16079
16080 /*Retrieve halHandle*/
16081 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16082
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016083 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16084 TRACE_CODE_HDD_CFG80211_DEL_PMKSA,
16085 pAdapter->sessionId, 0));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016086 /* Delete the PMKID CSR cache */
16087 if (eHAL_STATUS_SUCCESS !=
16088 sme_RoamDelPMKIDfromCache(halHandle,
16089 pAdapter->sessionId, pmksa->bssid, FALSE)) {
16090 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
16091 MAC_ADDR_ARRAY(pmksa->bssid));
16092 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016093 }
16094
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016095 EXIT();
16096 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016097}
16098
Wilson Yang6507c4e2013-10-01 20:11:19 -070016099
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016100static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
16101 struct cfg80211_pmksa *pmksa)
16102{
16103 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016104
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016105 vos_ssr_protect(__func__);
16106 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
16107 vos_ssr_unprotect(__func__);
16108
16109 return ret;
16110
16111}
16112
16113static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016114{
Wilson Yang6507c4e2013-10-01 20:11:19 -070016115 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16116 tHalHandle halHandle;
16117 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080016118 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016119
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016120 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070016121
16122 /* Validate pAdapter */
16123 if (NULL == pAdapter)
16124 {
16125 hddLog(VOS_TRACE_LEVEL_ERROR,
16126 "%s: Invalid Adapter" ,__func__);
16127 return -EINVAL;
16128 }
16129
16130 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16131 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070016132 if (0 != status)
16133 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070016134 return status;
16135 }
16136
16137 /*Retrieve halHandle*/
16138 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16139
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016140 /* Flush the PMKID cache in CSR */
16141 if (eHAL_STATUS_SUCCESS !=
16142 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
16143 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
16144 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016145 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016146 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080016147 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016148}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016149
16150static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
16151{
16152 int ret;
16153
16154 vos_ssr_protect(__func__);
16155 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
16156 vos_ssr_unprotect(__func__);
16157
16158 return ret;
16159}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016160#endif
16161
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016162#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016163static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
16164 struct net_device *dev,
16165 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016166{
16167 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16168 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016169 hdd_context_t *pHddCtx;
16170 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016171
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016172 ENTER();
16173
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016174 if (NULL == pAdapter)
16175 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080016176 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016177 return -ENODEV;
16178 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016179 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16180 ret = wlan_hdd_validate_context(pHddCtx);
16181 if (0 != ret)
16182 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016183 return ret;
16184 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016185 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016186 if (NULL == pHddStaCtx)
16187 {
16188 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
16189 return -EINVAL;
16190 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016191
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016192 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16193 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
16194 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016195 // Added for debug on reception of Re-assoc Req.
16196 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
16197 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080016198 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016199 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080016200 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016201 }
16202
16203#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080016204 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016205 ftie->ie_len);
16206#endif
16207
16208 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053016209 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
16210 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016211 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016212
16213 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016214 return 0;
16215}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016216
16217static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
16218 struct net_device *dev,
16219 struct cfg80211_update_ft_ies_params *ftie)
16220{
16221 int ret;
16222
16223 vos_ssr_protect(__func__);
16224 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
16225 vos_ssr_unprotect(__func__);
16226
16227 return ret;
16228}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016229#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016230
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016231#ifdef FEATURE_WLAN_SCAN_PNO
16232
16233void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
16234 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
16235{
16236 int ret;
16237 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
16238 hdd_context_t *pHddCtx;
16239
Nirav Shah80830bf2013-12-31 16:35:12 +053016240 ENTER();
16241
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016242 if (NULL == pAdapter)
16243 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053016244 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016245 "%s: HDD adapter is Null", __func__);
16246 return ;
16247 }
16248
16249 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16250 if (NULL == pHddCtx)
16251 {
16252 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16253 "%s: HDD context is Null!!!", __func__);
16254 return ;
16255 }
16256
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016257 spin_lock(&pHddCtx->schedScan_lock);
16258 if (TRUE == pHddCtx->isWiphySuspended)
16259 {
16260 pHddCtx->isSchedScanUpdatePending = TRUE;
16261 spin_unlock(&pHddCtx->schedScan_lock);
16262 hddLog(VOS_TRACE_LEVEL_INFO,
16263 "%s: Update cfg80211 scan database after it resume", __func__);
16264 return ;
16265 }
16266 spin_unlock(&pHddCtx->schedScan_lock);
16267
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016268 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
16269
16270 if (0 > ret)
16271 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Mahesh A Saptasagarfb49cdd2015-10-16 18:41:59 +053016272 else
16273 {
16274 /* Acquire wakelock to handle the case where APP's tries to suspend
16275 * immediatly after the driver gets connect request(i.e after pno)
16276 * from supplicant, this result in app's is suspending and not able
16277 * to process the connect request to AP */
16278 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
16279 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016280 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016281 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16282 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016283}
16284
16285/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016286 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053016287 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016288 */
16289static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
16290{
16291 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
16292 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016293 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016294 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16295 int status = 0;
16296 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
16297
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053016298 /* The current firmware design does not allow PNO during any
16299 * active sessions. Hence, determine the active sessions
16300 * and return a failure.
16301 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016302 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
16303 {
16304 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016305 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016306
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016307 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
16308 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
16309 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
16310 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
16311 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053016312 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016313 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016314 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016315 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016316 }
16317 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
16318 pAdapterNode = pNext;
16319 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016320 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016321}
16322
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016323void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
16324{
16325 hdd_adapter_t *pAdapter = callbackContext;
16326 hdd_context_t *pHddCtx;
16327
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016328 ENTER();
16329
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016330 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
16331 {
16332 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16333 FL("Invalid adapter or adapter has invalid magic"));
16334 return;
16335 }
16336
16337 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16338 if (0 != wlan_hdd_validate_context(pHddCtx))
16339 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016340 return;
16341 }
16342
c_hpothub53c45d2014-08-18 16:53:14 +053016343 if (VOS_STATUS_SUCCESS != status)
16344 {
16345 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016346 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053016347 pHddCtx->isPnoEnable = FALSE;
16348 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016349
16350 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
16351 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016352 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016353}
16354
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016355/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053016356 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
16357 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016358 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053016359static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016360 struct net_device *dev, struct cfg80211_sched_scan_request *request)
16361{
16362 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016363 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016364 hdd_context_t *pHddCtx;
16365 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053016366 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053016367 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
16368 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016369 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
16370 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016371 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053016372 hdd_config_t *pConfig = NULL;
16373 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016374
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016375 ENTER();
16376
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016377 if (NULL == pAdapter)
16378 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016379 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016380 "%s: HDD adapter is Null", __func__);
16381 return -ENODEV;
16382 }
16383
16384 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016385 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016386
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016387 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016388 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016389 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016390 }
16391
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053016392 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016393 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
16394 if (NULL == hHal)
16395 {
16396 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16397 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016398 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016399 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016400 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16401 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START,
16402 pAdapter->sessionId, pAdapter->device_mode));
Sushant Kaushik2fe89932014-09-03 10:58:09 +053016403 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053016404 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053016405 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053016406 {
16407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16408 "%s: aborting the existing scan is unsuccessfull", __func__);
16409 return -EBUSY;
16410 }
16411
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016412 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016413 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053016414 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016415 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016416 return -EBUSY;
16417 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016418
c_hpothu37f21312014-04-09 21:49:54 +053016419 if (TRUE == pHddCtx->isPnoEnable)
16420 {
16421 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
16422 FL("already PNO is enabled"));
16423 return -EBUSY;
16424 }
c_hpothu225aa7c2014-10-22 17:45:13 +053016425
16426 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
16427 {
16428 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16429 "%s: abort ROC failed ", __func__);
16430 return -EBUSY;
16431 }
16432
c_hpothu37f21312014-04-09 21:49:54 +053016433 pHddCtx->isPnoEnable = TRUE;
16434
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016435 pnoRequest.enable = 1; /*Enable PNO */
16436 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016437
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016438 if (( !pnoRequest.ucNetworksCount ) ||
16439 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016440 {
16441 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053016442 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016443 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053016444 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016445 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016446 goto error;
16447 }
16448
16449 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
16450 {
16451 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053016452 "%s: Incorrect number of channels %d",
16453 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016454 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016455 goto error;
16456 }
16457
16458 /* Framework provides one set of channels(all)
16459 * common for all saved profile */
16460 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
16461 channels_allowed, &num_channels_allowed))
16462 {
16463 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16464 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016465 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016466 goto error;
16467 }
16468 /* Checking each channel against allowed channel list */
16469 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053016470 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016471 {
Nirav Shah80830bf2013-12-31 16:35:12 +053016472 char chList [(request->n_channels*5)+1];
16473 int len;
16474 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016475 {
Nirav Shah80830bf2013-12-31 16:35:12 +053016476 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016477 {
Nirav Shah80830bf2013-12-31 16:35:12 +053016478 if (request->channels[i]->hw_value == channels_allowed[indx])
16479 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053016480 if ((!pConfig->enableDFSPnoChnlScan) &&
16481 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
16482 {
16483 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16484 "%s : Dropping DFS channel : %d",
16485 __func__,channels_allowed[indx]);
16486 num_ignore_dfs_ch++;
16487 break;
16488 }
16489
Nirav Shah80830bf2013-12-31 16:35:12 +053016490 valid_ch[num_ch++] = request->channels[i]->hw_value;
16491 len += snprintf(chList+len, 5, "%d ",
16492 request->channels[i]->hw_value);
16493 break ;
16494 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016495 }
16496 }
Nirav Shah80830bf2013-12-31 16:35:12 +053016497 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016498
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053016499 /*If all channels are DFS and dropped, then ignore the PNO request*/
16500 if (num_ignore_dfs_ch == request->n_channels)
16501 {
16502 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16503 "%s : All requested channels are DFS channels", __func__);
16504 ret = -EINVAL;
16505 goto error;
16506 }
16507 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016508
16509 pnoRequest.aNetworks =
16510 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
16511 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016512 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016513 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16514 FL("failed to allocate memory aNetworks %u"),
16515 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
16516 goto error;
16517 }
16518 vos_mem_zero(pnoRequest.aNetworks,
16519 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
16520
16521 /* Filling per profile params */
16522 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
16523 {
16524 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016525 request->match_sets[i].ssid.ssid_len;
16526
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016527 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
16528 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016529 {
16530 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053016531 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016532 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016533 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016534 goto error;
16535 }
16536
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016537 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016538 request->match_sets[i].ssid.ssid,
16539 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053016540 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16541 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016542 i, pnoRequest.aNetworks[i].ssId.ssId);
16543 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
16544 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
16545 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016546
16547 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016548 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
16549 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016550
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016551 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016552 }
16553
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053016554 for (i = 0; i < request->n_ssids; i++)
16555 {
16556 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016557 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053016558 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016559 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053016560 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016561 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053016562 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016563 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053016564 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016565 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053016566 break;
16567 }
16568 j++;
16569 }
16570 }
16571 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16572 "Number of hidden networks being Configured = %d",
16573 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053016574 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080016575 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016576
16577 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
16578 if (pnoRequest.p24GProbeTemplate == NULL)
16579 {
16580 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16581 FL("failed to allocate memory p24GProbeTemplate %u"),
16582 SIR_PNO_MAX_PB_REQ_SIZE);
16583 goto error;
16584 }
16585
16586 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
16587 if (pnoRequest.p5GProbeTemplate == NULL)
16588 {
16589 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16590 FL("failed to allocate memory p5GProbeTemplate %u"),
16591 SIR_PNO_MAX_PB_REQ_SIZE);
16592 goto error;
16593 }
16594
16595 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
16596 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
16597
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053016598 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
16599 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053016600 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016601 pnoRequest.us24GProbeTemplateLen = request->ie_len;
16602 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
16603 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053016604
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016605 pnoRequest.us5GProbeTemplateLen = request->ie_len;
16606 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
16607 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053016608 }
16609
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053016610 /* Driver gets only one time interval which is hardcoded in
16611 * supplicant for 10000ms. Taking power consumption into account 6 timers
16612 * will be used, Timervalue is increased exponentially i.e 10,20,40,
16613 * 80,160,320 secs. And number of scan cycle for each timer
16614 * is configurable through INI param gPNOScanTimerRepeatValue.
16615 * If it is set to 0 only one timer will be used and PNO scan cycle
16616 * will be repeated after each interval specified by supplicant
16617 * till PNO is disabled.
16618 */
16619 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016620 pnoRequest.scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053016621 else
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016622 pnoRequest.scanTimers.ucScanTimersCount =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053016623 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
16624
16625 tempInterval = (request->interval)/1000;
16626 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16627 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
16628 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016629 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++)
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053016630 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016631 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053016632 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016633 pnoRequest.scanTimers.aTimerValues[i].uTimerValue = tempInterval;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053016634 tempInterval *= 2;
16635 }
16636 //Repeat last timer until pno disabled.
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016637 pnoRequest.scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053016638
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016639 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016640
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016641 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016642 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
16643 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016644 pAdapter->pno_req_status = 0;
16645
Nirav Shah80830bf2013-12-31 16:35:12 +053016646 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16647 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016648 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
16649 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053016650
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016651 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016652 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016653 hdd_cfg80211_sched_scan_done_callback, pAdapter);
16654 if (eHAL_STATUS_SUCCESS != status)
16655 {
16656 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053016657 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016658 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016659 goto error;
16660 }
16661
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016662 ret = wait_for_completion_timeout(
16663 &pAdapter->pno_comp_var,
16664 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
16665 if (0 >= ret)
16666 {
16667 // Did not receive the response for PNO enable in time.
16668 // Assuming the PNO enable was success.
16669 // Returning error from here, because we timeout, results
16670 // in side effect of Wifi (Wifi Setting) not to work.
16671 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16672 FL("Timed out waiting for PNO to be Enabled"));
16673 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016674 }
16675
16676 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053016677 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016678
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016679error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016680 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16681 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053016682 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016683 if (pnoRequest.aNetworks)
16684 vos_mem_free(pnoRequest.aNetworks);
16685 if (pnoRequest.p24GProbeTemplate)
16686 vos_mem_free(pnoRequest.p24GProbeTemplate);
16687 if (pnoRequest.p5GProbeTemplate)
16688 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016689
16690 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016691 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016692}
16693
16694/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053016695 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
16696 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016697 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053016698static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
16699 struct net_device *dev, struct cfg80211_sched_scan_request *request)
16700{
16701 int ret;
16702
16703 vos_ssr_protect(__func__);
16704 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
16705 vos_ssr_unprotect(__func__);
16706
16707 return ret;
16708}
16709
16710/*
16711 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
16712 * Function to disable PNO
16713 */
16714static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016715 struct net_device *dev)
16716{
16717 eHalStatus status = eHAL_STATUS_FAILURE;
16718 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16719 hdd_context_t *pHddCtx;
16720 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016721 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016722 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016723
16724 ENTER();
16725
16726 if (NULL == pAdapter)
16727 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016728 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016729 "%s: HDD adapter is Null", __func__);
16730 return -ENODEV;
16731 }
16732
16733 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016734
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016735 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016736 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016737 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016738 "%s: HDD context is Null", __func__);
16739 return -ENODEV;
16740 }
16741
16742 /* The return 0 is intentional when isLogpInProgress and
16743 * isLoadUnloadInProgress. We did observe a crash due to a return of
16744 * failure in sched_scan_stop , especially for a case where the unload
16745 * of the happens at the same time. The function __cfg80211_stop_sched_scan
16746 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
16747 * success. If it returns a failure , then its next invocation due to the
16748 * clean up of the second interface will have the dev pointer corresponding
16749 * to the first one leading to a crash.
16750 */
16751 if (pHddCtx->isLogpInProgress)
16752 {
16753 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16754 "%s: LOGP in Progress. Ignore!!!", __func__);
Mahesh A Saptasagar0c11d822015-10-08 19:54:08 +053016755 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016756 return ret;
16757 }
16758
Mihir Shete18156292014-03-11 15:38:30 +053016759 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016760 {
16761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16762 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
16763 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016764 }
16765
16766 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
16767 if (NULL == hHal)
16768 {
16769 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16770 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016771 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016772 }
16773
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016774 pnoRequest.enable = 0; /* Disable PNO */
16775 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016776
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016777 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16778 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP,
16779 pAdapter->sessionId, pAdapter->device_mode));
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016780 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016781 pAdapter->sessionId,
16782 NULL, pAdapter);
16783 if (eHAL_STATUS_SUCCESS != status)
16784 {
16785 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16786 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016787 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016788 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016789 }
c_hpothu37f21312014-04-09 21:49:54 +053016790 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016791
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016792error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016793 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016794 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016795
16796 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016797 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016798}
16799
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053016800/*
16801 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
16802 * NL interface to disable PNO
16803 */
16804static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
16805 struct net_device *dev)
16806{
16807 int ret;
16808
16809 vos_ssr_protect(__func__);
16810 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
16811 vos_ssr_unprotect(__func__);
16812
16813 return ret;
16814}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016815#endif /*FEATURE_WLAN_SCAN_PNO*/
16816
16817
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016818#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053016819#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053016820static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
16821 struct net_device *dev,
16822 u8 *peer, u8 action_code,
16823 u8 dialog_token,
16824 u16 status_code, u32 peer_capability,
16825 const u8 *buf, size_t len)
16826#else /* TDLS_MGMT_VERSION2 */
16827#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
16828static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
16829 struct net_device *dev,
16830 const u8 *peer, u8 action_code,
16831 u8 dialog_token, u16 status_code,
16832 u32 peer_capability, bool initiator,
16833 const u8 *buf, size_t len)
16834#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
16835static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
16836 struct net_device *dev,
16837 const u8 *peer, u8 action_code,
16838 u8 dialog_token, u16 status_code,
16839 u32 peer_capability, const u8 *buf,
16840 size_t len)
16841#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
16842static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
16843 struct net_device *dev,
16844 u8 *peer, u8 action_code,
16845 u8 dialog_token,
16846 u16 status_code, u32 peer_capability,
16847 const u8 *buf, size_t len)
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053016848#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053016849static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
16850 struct net_device *dev,
16851 u8 *peer, u8 action_code,
16852 u8 dialog_token,
16853 u16 status_code, const u8 *buf,
16854 size_t len)
16855#endif
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053016856#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016857{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016858 hdd_adapter_t *pAdapter;
16859 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016860 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070016861 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080016862 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070016863 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053016864 int ret;
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053016865 hddTdlsPeer_t *pTdlsPeer;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053016866#if !(TDLS_MGMT_VERSION2) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0))
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053016867 u32 peer_capability = 0;
16868#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053016869 tANI_U16 numCurrTdlsPeers;
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053016870 hdd_station_ctx_t *pHddStaCtx = NULL;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016871
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016872 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16873 if (NULL == pAdapter)
16874 {
16875 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16876 "%s: Adapter is NULL",__func__);
16877 return -EINVAL;
16878 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016879 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16880 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
16881 pAdapter->sessionId, action_code));
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053016882
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016883 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016884 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016885 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016886 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016887 "Invalid arguments");
16888 return -EINVAL;
16889 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053016890
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080016891 if (pHddCtx->isLogpInProgress)
16892 {
16893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16894 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053016895 wlan_hdd_tdls_set_link_status(pAdapter,
16896 peer,
16897 eTDLS_LINK_IDLE,
16898 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080016899 return -EBUSY;
16900 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053016901
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016902 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
16903 {
16904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16905 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
16906 return -EAGAIN;
16907 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053016908
Hoonki Lee27511902013-03-14 18:19:06 -070016909 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016910 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053016911 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070016912 "%s: TDLS mode is disabled OR not enabled in FW."
16913 MAC_ADDRESS_STR " action %d declined.",
16914 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016915 return -ENOTSUPP;
16916 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080016917
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053016918 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16919
16920 if( NULL == pHddStaCtx )
16921 {
16922 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16923 "%s: HDD station context NULL ",__func__);
16924 return -EINVAL;
16925 }
16926
16927 /* STA should be connected and authenticated
16928 * before sending any TDLS frames
16929 */
16930 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
16931 (FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
16932 {
16933 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16934 "STA is not connected or unauthenticated. "
16935 "connState %u, uIsAuthenticated %u",
16936 pHddStaCtx->conn_info.connState,
16937 pHddStaCtx->conn_info.uIsAuthenticated);
16938 return -EAGAIN;
16939 }
16940
Hoonki Lee27511902013-03-14 18:19:06 -070016941 /* other than teardown frame, other mgmt frames are not sent if disabled */
16942 if (SIR_MAC_TDLS_TEARDOWN != action_code)
16943 {
16944 /* if tdls_mode is disabled to respond to peer's request */
16945 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
16946 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053016947 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070016948 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070016949 " TDLS mode is disabled. action %d declined.",
16950 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070016951
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053016952 return -ENOTSUPP;
Hoonki Lee27511902013-03-14 18:19:06 -070016953 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053016954
16955 if (vos_max_concurrent_connections_reached())
16956 {
16957 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
16958 return -EINVAL;
16959 }
Hoonki Lee27511902013-03-14 18:19:06 -070016960 }
16961
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016962 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
16963 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053016964 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016965 {
16966 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016967 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070016968 " TDLS setup is ongoing. action %d declined.",
16969 __func__, MAC_ADDR_ARRAY(peer), action_code);
16970 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016971 }
16972 }
16973
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016974 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
16975 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080016976 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053016977 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
16978 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080016979 {
16980 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
16981 we return error code at 'add_station()'. Hence we have this
16982 check again in addtion to add_station().
16983 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016984 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080016985 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016986 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16987 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053016988 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
16989 __func__, MAC_ADDR_ARRAY(peer), action_code,
16990 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053016991 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080016992 }
16993 else
16994 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016995 /* maximum reached. tweak to send error code to peer and return
16996 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080016997 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016998 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16999 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053017000 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
17001 __func__, MAC_ADDR_ARRAY(peer), status_code,
17002 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070017003 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017004 /* fall through to send setup resp with failure status
17005 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080017006 }
17007 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017008 else
17009 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017010 mutex_lock(&pHddCtx->tdls_lock);
17011 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070017012 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017013 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017014 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017015 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070017016 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
17017 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017018 return -EPERM;
17019 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017020 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017021 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080017022 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017023
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017024 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053017025 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017026 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
17027 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017028
Hoonki Leea34dd892013-02-05 22:56:02 -080017029 /*Except teardown responder will not be used so just make 0*/
17030 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017031 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080017032 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070017033
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017034 mutex_lock(&pHddCtx->tdls_lock);
17035 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070017036
17037 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
17038 responder = pTdlsPeer->is_responder;
17039 else
Hoonki Leea34dd892013-02-05 22:56:02 -080017040 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070017041 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053017042 "%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 -070017043 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
17044 dialog_token, status_code, len);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017045 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070017046 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080017047 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017048 mutex_unlock(&pHddCtx->tdls_lock);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017049 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017050
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053017051 /* Discard TDLS setup if peer is removed by user app */
17052 if ((pHddCtx->cfg_ini->fTDLSExternalControl) &&
17053 ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
17054 (SIR_MAC_TDLS_SETUP_CNF == action_code) ||
17055 (SIR_MAC_TDLS_DIS_REQ == action_code))) {
17056
17057 mutex_lock(&pHddCtx->tdls_lock);
17058 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
17059 if (pTdlsPeer && (FALSE == pTdlsPeer->isForcedPeer)) {
17060 mutex_unlock(&pHddCtx->tdls_lock);
17061 hddLog(LOGE, FL("TDLS External Control enabled, but peer "
17062 MAC_ADDRESS_STR " is not forced, so reject the action code %d"),
17063 MAC_ADDR_ARRAY(peer), action_code);
17064 return -EINVAL;
17065 }
17066 mutex_unlock(&pHddCtx->tdls_lock);
17067 }
17068
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053017069 /* For explicit trigger of DIS_REQ come out of BMPS for
17070 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070017071 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053017072 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
17073 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070017074 {
17075 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
17076 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017077 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053017078 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017079 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
17080 if (status != VOS_STATUS_SUCCESS) {
17081 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
17082 }
Hoonki Lee14621352013-04-16 17:51:19 -070017083 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017084 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017085 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017086 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
17087 }
17088 }
Hoonki Lee14621352013-04-16 17:51:19 -070017089 }
17090
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017091 /* make sure doesn't call send_mgmt() while it is pending */
17092 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
17093 {
17094 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080017095 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017096 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017097 ret = -EBUSY;
17098 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017099 }
17100
17101 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017102 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
17103
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017104 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter),
17105 pAdapter->sessionId, peer, action_code, dialog_token,
17106 status_code, peer_capability, (tANI_U8 *)buf, len,
17107 responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017108
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017109 if (VOS_STATUS_SUCCESS != status)
17110 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017111 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17112 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017113 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017114 ret = -EINVAL;
17115 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017116 }
17117
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017118 if ((SIR_MAC_TDLS_DIS_REQ == action_code) ||
17119 (SIR_MAC_TDLS_DIS_RSP == action_code))
17120 {
17121 /* for DIS_REQ/DIS_RSP, supplicant don't consider the return status.
17122 * So we no need to wait for tdls_mgmt_comp for sending ack status.
17123 */
17124 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17125 "%s: tx done for frm %u", __func__, action_code);
17126 return 0;
17127 }
17128
17129 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17130 "%s: Wait for tdls_mgmt_comp. Timeout %u ms", __func__,
17131 WAIT_TIME_TDLS_MGMT);
17132
Hoonki Leed37cbb32013-04-20 00:31:14 -070017133 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
17134 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
17135
17136 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017137 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070017138 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070017139 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070017140 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017141 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080017142
17143 if (pHddCtx->isLogpInProgress)
17144 {
17145 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17146 "%s: LOGP in Progress. Ignore!!!", __func__);
17147 return -EAGAIN;
17148 }
Abhishek Singh837adf22015-10-01 17:37:37 +053017149 if (rc <= 0)
17150 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
17151 WLAN_LOG_INDICATOR_HOST_DRIVER,
17152 WLAN_LOG_REASON_HDD_TIME_OUT,
17153 TRUE, TRUE);
Yue Ma4f55ef32014-01-23 16:45:33 -080017154
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017155 ret = -EINVAL;
17156 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017157 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017158 else
17159 {
17160 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17161 "%s: Mgmt Tx Completion status %ld TxCompletion %u",
17162 __func__, rc, pAdapter->mgmtTxCompletionStatus);
17163 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017164
Gopichand Nakkala05922802013-03-14 12:23:19 -070017165 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070017166 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017167 ret = max_sta_failed;
17168 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070017169 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017170
Hoonki Leea34dd892013-02-05 22:56:02 -080017171 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
17172 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017173 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, TRUE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017174 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
17175 }
Hoonki Leea34dd892013-02-05 22:56:02 -080017176 }
17177 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
17178 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017179 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, FALSE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017180 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
17181 }
Hoonki Leea34dd892013-02-05 22:56:02 -080017182 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017183
17184 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017185
17186tx_failed:
17187 /* add_station will be called before sending TDLS_SETUP_REQ and
17188 * TDLS_SETUP_RSP and as part of add_station driver will enable
17189 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
17190 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
17191 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
17192 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
17193 */
17194
17195 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
17196 (SIR_MAC_TDLS_SETUP_RSP == action_code))
17197 wlan_hdd_tdls_check_bmps(pAdapter);
17198 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017199}
17200
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017201#if TDLS_MGMT_VERSION2
17202static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
17203 u8 *peer, u8 action_code, u8 dialog_token,
17204 u16 status_code, u32 peer_capability,
17205 const u8 *buf, size_t len)
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017206#else /* TDLS_MGMT_VERSION2 */
17207#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
17208static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17209 struct net_device *dev,
17210 const u8 *peer, u8 action_code,
17211 u8 dialog_token, u16 status_code,
17212 u32 peer_capability, bool initiator,
17213 const u8 *buf, size_t len)
17214#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
17215static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17216 struct net_device *dev,
17217 const u8 *peer, u8 action_code,
17218 u8 dialog_token, u16 status_code,
17219 u32 peer_capability, const u8 *buf,
17220 size_t len)
17221#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
17222static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17223 struct net_device *dev,
17224 u8 *peer, u8 action_code,
17225 u8 dialog_token,
17226 u16 status_code, u32 peer_capability,
17227 const u8 *buf, size_t len)
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017228#else
17229static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
17230 u8 *peer, u8 action_code, u8 dialog_token,
17231 u16 status_code, const u8 *buf, size_t len)
17232#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017233#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017234{
17235 int ret;
17236
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017237 vos_ssr_protect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017238#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017239 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17240 dialog_token, status_code,
17241 peer_capability, buf, len);
17242#else /* TDLS_MGMT_VERSION2 */
17243#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
17244 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17245 dialog_token, status_code,
17246 peer_capability, initiator,
17247 buf, len);
17248#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
17249 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17250 dialog_token, status_code,
17251 peer_capability, buf, len);
17252#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
17253 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17254 dialog_token, status_code,
17255 peer_capability, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017256#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017257 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17258 dialog_token, status_code, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017259#endif
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017260#endif
17261 vos_ssr_unprotect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017262
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017263 return ret;
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017264}
Atul Mittal115287b2014-07-08 13:26:33 +053017265
17266int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017267#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
17268 const u8 *peer,
17269#else
Atul Mittal115287b2014-07-08 13:26:33 +053017270 u8 *peer,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017271#endif
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017272 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053017273 cfg80211_exttdls_callback callback)
17274{
17275
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017276 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053017277 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053017278 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053017279 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17280 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
17281 __func__, MAC_ADDR_ARRAY(peer));
17282
17283 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
17284 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
17285
17286 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017287 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
17288 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
17289 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053017290 return -ENOTSUPP;
17291 }
17292
17293 /* To cater the requirement of establishing the TDLS link
17294 * irrespective of the data traffic , get an entry of TDLS peer.
17295 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053017296 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053017297 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
17298 if (pTdlsPeer == NULL) {
17299 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17300 "%s: peer " MAC_ADDRESS_STR " not existing",
17301 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053017302 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053017303 return -EINVAL;
17304 }
17305
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053017306 /* check FW TDLS Off Channel capability */
17307 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053017308 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053017309 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017310 {
17311 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
17312 pTdlsPeer->peerParams.global_operating_class =
17313 tdls_peer_params->global_operating_class;
17314 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
17315 pTdlsPeer->peerParams.min_bandwidth_kbps =
17316 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053017317 /* check configured channel is valid, non dfs and
17318 * not current operating channel */
17319 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
17320 tdls_peer_params->channel)) &&
17321 (pHddStaCtx) &&
17322 (tdls_peer_params->channel !=
17323 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017324 {
17325 pTdlsPeer->isOffChannelConfigured = TRUE;
17326 }
17327 else
17328 {
17329 pTdlsPeer->isOffChannelConfigured = FALSE;
17330 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17331 "%s: Configured Tdls Off Channel is not valid", __func__);
17332
17333 }
17334 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053017335 "%s: tdls_off_channel %d isOffChannelConfigured %d "
17336 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017337 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053017338 pTdlsPeer->isOffChannelConfigured,
17339 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017340 }
17341 else
17342 {
17343 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053017344 "%s: TDLS off channel FW capability %d, "
17345 "host capab %d or Invalid TDLS Peer Params", __func__,
17346 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
17347 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017348 }
17349
Atul Mittal115287b2014-07-08 13:26:33 +053017350 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
17351
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017352 mutex_unlock(&pHddCtx->tdls_lock);
17353
Atul Mittal115287b2014-07-08 13:26:33 +053017354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17355 " %s TDLS Add Force Peer Failed",
17356 __func__);
17357 return -EINVAL;
17358 }
17359 /*EXT TDLS*/
17360
17361 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017362 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053017363 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17364 " %s TDLS set callback Failed",
17365 __func__);
17366 return -EINVAL;
17367 }
17368
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017369 mutex_unlock(&pHddCtx->tdls_lock);
17370
Atul Mittal115287b2014-07-08 13:26:33 +053017371 return(0);
17372
17373}
17374
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017375int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter,
17376#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
17377 const u8 *peer
17378#else
17379 u8 *peer
17380#endif
17381)
Atul Mittal115287b2014-07-08 13:26:33 +053017382{
17383
17384 hddTdlsPeer_t *pTdlsPeer;
17385 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17386 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17387 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
17388 __func__, MAC_ADDR_ARRAY(peer));
17389
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053017390 if (0 != wlan_hdd_validate_context(pHddCtx)) {
17391 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
17392 return -EINVAL;
17393 }
17394
Atul Mittal115287b2014-07-08 13:26:33 +053017395 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
17396 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
17397
17398 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017399 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
17400 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
17401 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053017402 return -ENOTSUPP;
17403 }
17404
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017405 mutex_lock(&pHddCtx->tdls_lock);
17406 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Atul Mittal115287b2014-07-08 13:26:33 +053017407
17408 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017409 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053017410 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053017411 " peer not existing",
Atul Mittal115287b2014-07-08 13:26:33 +053017412 __func__, MAC_ADDR_ARRAY(peer));
17413 return -EINVAL;
17414 }
17415 else {
17416 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
17417 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017418 /* if channel switch is configured, reset
17419 the channel for this peer */
17420 if (TRUE == pTdlsPeer->isOffChannelConfigured)
17421 {
17422 pTdlsPeer->peerParams.channel = 0;
17423 pTdlsPeer->isOffChannelConfigured = FALSE;
17424 }
Atul Mittal115287b2014-07-08 13:26:33 +053017425 }
17426
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017427 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017428 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017429 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053017430 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017431 }
Atul Mittal115287b2014-07-08 13:26:33 +053017432
17433 /*EXT TDLS*/
17434
17435 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017436 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053017437 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17438 " %s TDLS set callback Failed",
17439 __func__);
17440 return -EINVAL;
17441 }
Atul Mittal115287b2014-07-08 13:26:33 +053017442
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017443 mutex_unlock(&pHddCtx->tdls_lock);
17444
17445 return(0);
Atul Mittal115287b2014-07-08 13:26:33 +053017446}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017447static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017448#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
17449 const u8 *peer,
17450#else
17451 u8 *peer,
17452#endif
17453 enum nl80211_tdls_operation oper)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017454{
17455 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17456 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017457 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017458 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017459
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017460 ENTER();
17461
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053017462 if (!pAdapter) {
17463 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
17464 return -EINVAL;
17465 }
17466
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017467 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17468 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
17469 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017470 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017471 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017472 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070017473 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017474 return -EINVAL;
17475 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080017476
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017477 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017478 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080017479 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017480 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080017481 }
17482
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017483
17484 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080017485 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017486 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080017487 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017488 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
17489 "Cannot process TDLS commands",
17490 pHddCtx->cfg_ini->fEnableTDLSSupport,
17491 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017492 return -ENOTSUPP;
17493 }
17494
17495 switch (oper) {
17496 case NL80211_TDLS_ENABLE_LINK:
17497 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017498 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053017499 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053017500 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Agarwal Ashish16020c42014-12-29 22:01:11 +053017501 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017502 tANI_U16 numCurrTdlsPeers = 0;
17503 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053017504 tANI_U8 suppChannelLen = 0;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017505
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053017506 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17507 " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR,
17508 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017509
Sunil Dutt41de4e22013-11-14 18:09:02 +053017510 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053017511 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053017512 if ( NULL == pTdlsPeer ) {
17513 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
17514 " (oper %d) not exsting. ignored",
17515 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
17516 return -EINVAL;
17517 }
17518
17519 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17520 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
17521 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
17522 "NL80211_TDLS_ENABLE_LINK");
17523
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070017524 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
17525 {
17526 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
17527 MAC_ADDRESS_STR " failed",
17528 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
17529 return -EINVAL;
17530 }
17531
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053017532 /* before starting tdls connection, set tdls
17533 * off channel established status to default value */
17534 pTdlsPeer->isOffChannelEstablished = FALSE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017535 /* TDLS Off Channel, Disable tdls channel switch,
17536 when there are more than one tdls link */
17537 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053017538 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017539 {
17540 /* get connected peer and send disable tdls off chan */
17541 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053017542 if ((connPeer) &&
17543 (connPeer->isOffChannelSupported == TRUE) &&
17544 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017545 {
17546 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17547 "%s: More then one peer connected, Disable "
17548 "TDLS channel switch", __func__);
17549
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053017550 connPeer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017551
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017552 ret = sme_SendTdlsChanSwitchReq(
17553 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017554 pAdapter->sessionId,
17555 connPeer->peerMac,
17556 connPeer->peerParams.channel,
17557 TDLS_OFF_CHANNEL_BW_OFFSET,
17558 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017559 if (ret != VOS_STATUS_SUCCESS) {
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053017560 hddLog(VOS_TRACE_LEVEL_ERROR,
17561 FL("Failed to send TDLS switch channel request"));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017562 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017563 }
17564 else
17565 {
17566 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17567 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053017568 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017569 "isOffChannelConfigured %d",
17570 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053017571 (connPeer ? (connPeer->isOffChannelSupported)
17572 : -1),
17573 (connPeer ? (connPeer->isOffChannelConfigured)
17574 : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017575 }
17576 }
17577
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017578 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017579 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053017580 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053017581
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053017582 if (0 != wlan_hdd_tdls_get_link_establish_params(
17583 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017584 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053017585 return -EINVAL;
17586 }
17587 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053017588
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017589 ret = sme_SendTdlsLinkEstablishParams(
17590 WLAN_HDD_GET_HAL_CTX(pAdapter),
17591 pAdapter->sessionId, peer,
17592 &tdlsLinkEstablishParams);
17593 if (ret != VOS_STATUS_SUCCESS) {
17594 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
17595 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053017596 /* Send TDLS peer UAPSD capabilities to the firmware and
17597 * register with the TL on after the response for this operation
17598 * is received .
17599 */
17600 ret = wait_for_completion_interruptible_timeout(
17601 &pAdapter->tdls_link_establish_req_comp,
17602 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
17603 if (ret <= 0)
17604 {
17605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053017606 FL("Link Establish Request Failed Status %ld"),
17607 ret);
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053017608 return -EINVAL;
17609 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053017610 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017611
Atul Mittal115287b2014-07-08 13:26:33 +053017612 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
17613 eTDLS_LINK_CONNECTED,
17614 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053017615 staDesc.ucSTAId = pTdlsPeer->staId;
17616 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017617 ret = WLANTL_UpdateTdlsSTAClient(
17618 pHddCtx->pvosContext,
17619 &staDesc);
17620 if (ret != VOS_STATUS_SUCCESS) {
17621 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
17622 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053017623
Gopichand Nakkala471708b2013-06-04 20:03:01 +053017624 /* Mark TDLS client Authenticated .*/
17625 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
17626 pTdlsPeer->staId,
17627 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070017628 if (VOS_STATUS_SUCCESS == status)
17629 {
Hoonki Lee14621352013-04-16 17:51:19 -070017630 if (pTdlsPeer->is_responder == 0)
17631 {
17632 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +053017633 tdlsConnInfo_t *tdlsInfo;
17634
17635 tdlsInfo = wlan_hdd_get_conn_info(pHddCtx, staId);
17636
17637 /* Initialize initiator wait callback */
17638 vos_timer_init(
17639 &pTdlsPeer->initiatorWaitTimeoutTimer,
17640 VOS_TIMER_TYPE_SW,
17641 wlan_hdd_tdls_initiator_wait_cb,
17642 tdlsInfo);
Hoonki Lee14621352013-04-16 17:51:19 -070017643
17644 wlan_hdd_tdls_timer_restart(pAdapter,
17645 &pTdlsPeer->initiatorWaitTimeoutTimer,
17646 WAIT_TIME_TDLS_INITIATOR);
17647 /* suspend initiator TX until it receives direct packet from the
17648 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017649 ret = WLANTL_SuspendDataTx(
17650 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
17651 &staId, NULL);
17652 if (ret != VOS_STATUS_SUCCESS) {
17653 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
17654 }
Hoonki Lee14621352013-04-16 17:51:19 -070017655 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017656
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053017657 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053017658 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053017659 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053017660 suppChannelLen =
17661 tdlsLinkEstablishParams.supportedChannelsLen;
17662
17663 if ((suppChannelLen > 0) &&
17664 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
17665 {
17666 tANI_U8 suppPeerChannel = 0;
17667 int i = 0;
17668 for (i = 0U; i < suppChannelLen; i++)
17669 {
17670 suppPeerChannel =
17671 tdlsLinkEstablishParams.supportedChannels[i];
17672
17673 pTdlsPeer->isOffChannelSupported = FALSE;
17674 if (suppPeerChannel ==
17675 pTdlsPeer->peerParams.channel)
17676 {
17677 pTdlsPeer->isOffChannelSupported = TRUE;
17678 break;
17679 }
17680 }
17681 }
17682 else
17683 {
17684 pTdlsPeer->isOffChannelSupported = FALSE;
17685 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053017686 }
17687 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17688 "%s: TDLS channel switch request for channel "
17689 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053017690 "%d isOffChannelSupported %d", __func__,
17691 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053017692 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053017693 suppChannelLen,
17694 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053017695
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017696 /* TDLS Off Channel, Enable tdls channel switch,
17697 when their is only one tdls link and it supports */
17698 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
17699 if ((numCurrTdlsPeers == 1) &&
17700 (TRUE == pTdlsPeer->isOffChannelSupported) &&
17701 (TRUE == pTdlsPeer->isOffChannelConfigured))
17702 {
17703 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17704 "%s: Send TDLS channel switch request for channel %d",
17705 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053017706
17707 pTdlsPeer->isOffChannelEstablished = TRUE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017708 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
17709 pAdapter->sessionId,
17710 pTdlsPeer->peerMac,
17711 pTdlsPeer->peerParams.channel,
17712 TDLS_OFF_CHANNEL_BW_OFFSET,
17713 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017714 if (ret != VOS_STATUS_SUCCESS) {
17715 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
17716 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017717 }
17718 else
17719 {
17720 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17721 "%s: TDLS channel switch request not sent"
17722 " numCurrTdlsPeers %d "
17723 "isOffChannelSupported %d "
17724 "isOffChannelConfigured %d",
17725 __func__, numCurrTdlsPeers,
17726 pTdlsPeer->isOffChannelSupported,
17727 pTdlsPeer->isOffChannelConfigured);
17728 }
17729
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070017730 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017731 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053017732
17733 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053017734 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
17735 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053017736 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053017737 int ac;
17738 uint8 ucAc[4] = { WLANTL_AC_VO,
17739 WLANTL_AC_VI,
17740 WLANTL_AC_BK,
17741 WLANTL_AC_BE };
17742 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
17743 for(ac=0; ac < 4; ac++)
17744 {
17745 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
17746 pTdlsPeer->staId, ucAc[ac],
17747 tlTid[ac], tlTid[ac], 0, 0,
17748 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017749 if (status != VOS_STATUS_SUCCESS) {
17750 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
17751 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053017752 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053017753 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017754 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017755 }
17756 break;
17757 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080017758 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017759 tANI_U16 numCurrTdlsPeers = 0;
17760 hddTdlsPeer_t *connPeer = NULL;
17761
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053017762 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17763 " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR,
17764 __func__, MAC_ADDR_ARRAY(peer));
17765
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053017766 mutex_lock(&pHddCtx->tdls_lock);
17767 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Sunil Dutt41de4e22013-11-14 18:09:02 +053017768
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053017769
Sunil Dutt41de4e22013-11-14 18:09:02 +053017770 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053017771 mutex_unlock(&pHddCtx->tdls_lock);
Sunil Dutt41de4e22013-11-14 18:09:02 +053017772 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
17773 " (oper %d) not exsting. ignored",
17774 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
17775 return -EINVAL;
17776 }
17777
17778 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17779 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
17780 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
17781 "NL80211_TDLS_DISABLE_LINK");
17782
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017783 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080017784 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070017785 long status;
17786
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053017787 /* set tdls off channel status to false for this peer */
17788 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053017789 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
17790 eTDLS_LINK_TEARING,
17791 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
17792 eTDLS_LINK_UNSPECIFIED:
17793 eTDLS_LINK_DROPPED_BY_REMOTE);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053017794 mutex_unlock(&pHddCtx->tdls_lock);
17795
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070017796 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
17797
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017798 status = sme_DeleteTdlsPeerSta(
17799 WLAN_HDD_GET_HAL_CTX(pAdapter),
17800 pAdapter->sessionId, peer );
17801 if (status != VOS_STATUS_SUCCESS) {
17802 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
17803 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070017804
17805 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
17806 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053017807
17808 mutex_lock(&pHddCtx->tdls_lock);
17809 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
17810 if ( NULL == pTdlsPeer ) {
17811 mutex_unlock(&pHddCtx->tdls_lock);
17812 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
17813 " peer was freed in other context",
17814 __func__, MAC_ADDR_ARRAY(peer));
17815 return -EINVAL;
17816 }
17817
Atul Mittal271a7652014-09-12 13:18:22 +053017818 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053017819 eTDLS_LINK_IDLE,
17820 eTDLS_LINK_UNSPECIFIED);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053017821 mutex_unlock(&pHddCtx->tdls_lock);
17822
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070017823 if (status <= 0)
17824 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070017825 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17826 "%s: Del station failed status %ld",
17827 __func__, status);
17828 return -EPERM;
17829 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017830
17831 /* TDLS Off Channel, Enable tdls channel switch,
17832 when their is only one tdls link and it supports */
17833 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
17834 if (numCurrTdlsPeers == 1)
17835 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053017836 tSirMacAddr peerMac;
17837 int channel;
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053017838
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053017839 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017840 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053017841
17842 if (connPeer == NULL) {
17843 mutex_unlock(&pHddCtx->tdls_lock);
17844 hddLog(VOS_TRACE_LEVEL_ERROR,
17845 "%s connPeer is NULL", __func__);
17846 return -EINVAL;
17847 }
17848
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053017849 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
17850 channel = connPeer->peerParams.channel;
17851
17852 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17853 "%s: TDLS channel switch "
17854 "isOffChannelSupported %d "
17855 "isOffChannelConfigured %d "
17856 "isOffChannelEstablished %d",
17857 __func__,
17858 (connPeer ? connPeer->isOffChannelSupported : -1),
17859 (connPeer ? connPeer->isOffChannelConfigured : -1),
17860 (connPeer ? connPeer->isOffChannelEstablished : -1));
17861
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017862 if ((connPeer) &&
17863 (connPeer->isOffChannelSupported == TRUE) &&
17864 (connPeer->isOffChannelConfigured == TRUE))
17865 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053017866 connPeer->isOffChannelEstablished = TRUE;
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053017867 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017868 status = sme_SendTdlsChanSwitchReq(
17869 WLAN_HDD_GET_HAL_CTX(pAdapter),
17870 pAdapter->sessionId,
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053017871 peerMac,
17872 channel,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017873 TDLS_OFF_CHANNEL_BW_OFFSET,
17874 TDLS_CHANNEL_SWITCH_ENABLE);
17875 if (status != VOS_STATUS_SUCCESS) {
17876 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
17877 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017878 }
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053017879 else
17880 mutex_unlock(&pHddCtx->tdls_lock);
17881 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017882 else
17883 {
17884 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17885 "%s: TDLS channel switch request not sent "
17886 "numCurrTdlsPeers %d ",
17887 __func__, numCurrTdlsPeers);
17888 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080017889 }
17890 else
17891 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053017892 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17894 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080017895 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080017896 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017897 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017898 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053017899 {
Atul Mittal115287b2014-07-08 13:26:33 +053017900 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053017901
Atul Mittal115287b2014-07-08 13:26:33 +053017902 if (0 != status)
17903 {
17904 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053017905 FL("Error in TDLS Teardown"));
Atul Mittal115287b2014-07-08 13:26:33 +053017906 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053017907 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053017908 break;
17909 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017910 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053017911 {
Atul Mittal115287b2014-07-08 13:26:33 +053017912 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
17913 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017914 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053017915 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053017916
Atul Mittal115287b2014-07-08 13:26:33 +053017917 if (0 != status)
17918 {
17919 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053017920 FL("Error in TDLS Setup"));
Atul Mittal115287b2014-07-08 13:26:33 +053017921 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053017922 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053017923 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053017924 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017925 case NL80211_TDLS_DISCOVERY_REQ:
17926 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053017927 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053017928 "%s: Driver doesn't support in-driver setup/teardown/discovery "
c_hpothu6ff1c3c2013-10-01 19:01:57 +053017929 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017930 return -ENOTSUPP;
17931 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053017932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17933 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017934 return -ENOTSUPP;
17935 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017936
17937 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017938 return 0;
17939}
Chilam NG571c65a2013-01-19 12:27:36 +053017940
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017941static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017942#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
17943 const u8 *peer,
17944#else
17945 u8 *peer,
17946#endif
17947 enum nl80211_tdls_operation oper)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017948{
17949 int ret;
17950
17951 vos_ssr_protect(__func__);
17952 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
17953 vos_ssr_unprotect(__func__);
17954
17955 return ret;
17956}
17957
Chilam NG571c65a2013-01-19 12:27:36 +053017958int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
17959 struct net_device *dev, u8 *peer)
17960{
Arif Hussaina7c8e412013-11-20 11:06:42 -080017961 hddLog(VOS_TRACE_LEVEL_INFO,
17962 "tdls send discover req: "MAC_ADDRESS_STR,
17963 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053017964
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017965#if TDLS_MGMT_VERSION2
17966 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
17967 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
17968#else
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017969#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
17970 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
17971 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, 0, NULL, 0);
17972#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
17973 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
17974 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
17975#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
17976 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
17977 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
17978#else
Chilam NG571c65a2013-01-19 12:27:36 +053017979 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
17980 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017981#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017982#endif /* KERNEL_VERSION */
Chilam NG571c65a2013-01-19 12:27:36 +053017983}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017984#endif
17985
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053017986#ifdef WLAN_FEATURE_GTK_OFFLOAD
17987/*
17988 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
17989 * Callback rountine called upon receiving response for
17990 * get offload info
17991 */
17992void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
17993 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
17994{
17995
17996 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053017997 tANI_U8 tempReplayCounter[8];
17998 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053017999
18000 ENTER();
18001
18002 if (NULL == pAdapter)
18003 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053018004 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018005 "%s: HDD adapter is Null", __func__);
18006 return ;
18007 }
18008
18009 if (NULL == pGtkOffloadGetInfoRsp)
18010 {
18011 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18012 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
18013 return ;
18014 }
18015
18016 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
18017 {
18018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18019 "%s: wlan Failed to get replay counter value",
18020 __func__);
18021 return ;
18022 }
18023
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018024 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
18025 /* Update replay counter */
18026 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
18027 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
18028
18029 {
18030 /* changing from little to big endian since supplicant
18031 * works on big endian format
18032 */
18033 int i;
18034 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
18035
18036 for (i = 0; i < 8; i++)
18037 {
18038 tempReplayCounter[7-i] = (tANI_U8)p[i];
18039 }
18040 }
18041
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018042 /* Update replay counter to NL */
18043 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018044 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018045}
18046
18047/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018048 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018049 * This function is used to offload GTK rekeying job to the firmware.
18050 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018051int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018052 struct cfg80211_gtk_rekey_data *data)
18053{
18054 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
18055 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
18056 hdd_station_ctx_t *pHddStaCtx;
18057 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018058 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018059 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018060 eHalStatus status = eHAL_STATUS_FAILURE;
18061
18062 ENTER();
18063
18064 if (NULL == pAdapter)
18065 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053018066 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018067 "%s: HDD adapter is Null", __func__);
18068 return -ENODEV;
18069 }
18070
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053018071 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18072 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
18073 pAdapter->sessionId, pAdapter->device_mode));
18074
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018075 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018076 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018077 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018078 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018079 }
18080
18081 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
18082 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
18083 if (NULL == hHal)
18084 {
18085 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18086 "%s: HAL context is Null!!!", __func__);
18087 return -EAGAIN;
18088 }
18089
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018090 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
18091 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
18092 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
18093 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018094 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018095 {
18096 /* changing from big to little endian since driver
18097 * works on little endian format
18098 */
18099 tANI_U8 *p =
18100 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
18101 int i;
18102
18103 for (i = 0; i < 8; i++)
18104 {
18105 p[7-i] = data->replay_ctr[i];
18106 }
18107 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018108
18109 if (TRUE == pHddCtx->hdd_wlan_suspended)
18110 {
18111 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018112 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
18113 sizeof (tSirGtkOffloadParams));
18114 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018115 pAdapter->sessionId);
18116
18117 if (eHAL_STATUS_SUCCESS != status)
18118 {
18119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18120 "%s: sme_SetGTKOffload failed, returned %d",
18121 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053018122
18123 /* Need to clear any trace of key value in the memory.
18124 * Thus zero out the memory even though it is local
18125 * variable.
18126 */
18127 vos_mem_zero(&hddGtkOffloadReqParams,
18128 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018129 return status;
18130 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18132 "%s: sme_SetGTKOffload successfull", __func__);
18133 }
18134 else
18135 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18137 "%s: wlan not suspended GTKOffload request is stored",
18138 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018139 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018140
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053018141 /* Need to clear any trace of key value in the memory.
18142 * Thus zero out the memory even though it is local
18143 * variable.
18144 */
18145 vos_mem_zero(&hddGtkOffloadReqParams,
18146 sizeof(hddGtkOffloadReqParams));
18147
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018148 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018149 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018150}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018151
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018152int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
18153 struct cfg80211_gtk_rekey_data *data)
18154{
18155 int ret;
18156
18157 vos_ssr_protect(__func__);
18158 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
18159 vos_ssr_unprotect(__func__);
18160
18161 return ret;
18162}
18163#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018164/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018165 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018166 * This function is used to set access control policy
18167 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018168static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
18169 struct net_device *dev,
18170 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018171{
18172 int i;
18173 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
18174 hdd_hostapd_state_t *pHostapdState;
18175 tsap_Config_t *pConfig;
18176 v_CONTEXT_t pVosContext = NULL;
18177 hdd_context_t *pHddCtx;
18178 int status;
18179
18180 ENTER();
18181
18182 if (NULL == pAdapter)
18183 {
18184 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
18185 "%s: HDD adapter is Null", __func__);
18186 return -ENODEV;
18187 }
18188
18189 if (NULL == params)
18190 {
18191 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
18192 "%s: params is Null", __func__);
18193 return -EINVAL;
18194 }
18195
18196 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
18197 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018198 if (0 != status)
18199 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018200 return status;
18201 }
18202
18203 pVosContext = pHddCtx->pvosContext;
18204 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
18205
18206 if (NULL == pHostapdState)
18207 {
18208 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
18209 "%s: pHostapdState is Null", __func__);
18210 return -EINVAL;
18211 }
18212
18213 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
18214 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053018215 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18216 TRACE_CODE_HDD_CFG80211_SET_MAC_ACL,
18217 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018218
18219 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
18220 {
18221 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
18222
18223 /* default value */
18224 pConfig->num_accept_mac = 0;
18225 pConfig->num_deny_mac = 0;
18226
18227 /**
18228 * access control policy
18229 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
18230 * listed in hostapd.deny file.
18231 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
18232 * listed in hostapd.accept file.
18233 */
18234 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
18235 {
18236 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
18237 }
18238 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
18239 {
18240 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
18241 }
18242 else
18243 {
18244 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18245 "%s:Acl Policy : %d is not supported",
18246 __func__, params->acl_policy);
18247 return -ENOTSUPP;
18248 }
18249
18250 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
18251 {
18252 pConfig->num_accept_mac = params->n_acl_entries;
18253 for (i = 0; i < params->n_acl_entries; i++)
18254 {
18255 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18256 "** Add ACL MAC entry %i in WhiletList :"
18257 MAC_ADDRESS_STR, i,
18258 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
18259
18260 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
18261 sizeof(qcmacaddr));
18262 }
18263 }
18264 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
18265 {
18266 pConfig->num_deny_mac = params->n_acl_entries;
18267 for (i = 0; i < params->n_acl_entries; i++)
18268 {
18269 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18270 "** Add ACL MAC entry %i in BlackList :"
18271 MAC_ADDRESS_STR, i,
18272 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
18273
18274 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
18275 sizeof(qcmacaddr));
18276 }
18277 }
18278
18279 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
18280 {
18281 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18282 "%s: SAP Set Mac Acl fail", __func__);
18283 return -EINVAL;
18284 }
18285 }
18286 else
18287 {
18288 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053018289 "%s: Invalid device_mode = %s (%d)",
18290 __func__, hdd_device_modetoString(pAdapter->device_mode),
18291 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018292 return -EINVAL;
18293 }
18294
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018295 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018296 return 0;
18297}
18298
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018299static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
18300 struct net_device *dev,
18301 const struct cfg80211_acl_data *params)
18302{
18303 int ret;
18304 vos_ssr_protect(__func__);
18305 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
18306 vos_ssr_unprotect(__func__);
18307
18308 return ret;
18309}
18310
Leo Chang9056f462013-08-01 19:21:11 -070018311#ifdef WLAN_NL80211_TESTMODE
18312#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070018313void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070018314(
18315 void *pAdapter,
18316 void *indCont
18317)
18318{
Leo Changd9df8aa2013-09-26 13:32:26 -070018319 tSirLPHBInd *lphbInd;
18320 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053018321 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070018322
18323 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070018324 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070018325
c_hpothu73f35e62014-04-18 13:40:08 +053018326 if (pAdapter == NULL)
18327 {
18328 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18329 "%s: pAdapter is NULL\n",__func__);
18330 return;
18331 }
18332
Leo Chang9056f462013-08-01 19:21:11 -070018333 if (NULL == indCont)
18334 {
18335 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070018336 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070018337 return;
18338 }
18339
c_hpothu73f35e62014-04-18 13:40:08 +053018340 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070018341 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070018342 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053018343 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070018344 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070018345 GFP_ATOMIC);
18346 if (!skb)
18347 {
18348 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18349 "LPHB timeout, NL buffer alloc fail");
18350 return;
18351 }
18352
Leo Changac3ba772013-10-07 09:47:04 -070018353 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070018354 {
18355 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18356 "WLAN_HDD_TM_ATTR_CMD put fail");
18357 goto nla_put_failure;
18358 }
Leo Changac3ba772013-10-07 09:47:04 -070018359 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070018360 {
18361 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18362 "WLAN_HDD_TM_ATTR_TYPE put fail");
18363 goto nla_put_failure;
18364 }
Leo Changac3ba772013-10-07 09:47:04 -070018365 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070018366 sizeof(tSirLPHBInd), lphbInd))
18367 {
18368 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18369 "WLAN_HDD_TM_ATTR_DATA put fail");
18370 goto nla_put_failure;
18371 }
Leo Chang9056f462013-08-01 19:21:11 -070018372 cfg80211_testmode_event(skb, GFP_ATOMIC);
18373 return;
18374
18375nla_put_failure:
18376 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18377 "NLA Put fail");
18378 kfree_skb(skb);
18379
18380 return;
18381}
18382#endif /* FEATURE_WLAN_LPHB */
18383
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018384static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070018385{
18386 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
18387 int err = 0;
18388#ifdef FEATURE_WLAN_LPHB
18389 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070018390 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018391
18392 ENTER();
18393
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053018394 err = wlan_hdd_validate_context(pHddCtx);
18395 if (0 != err)
18396 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053018397 return err;
18398 }
Leo Chang9056f462013-08-01 19:21:11 -070018399#endif /* FEATURE_WLAN_LPHB */
18400
18401 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
18402 if (err)
18403 {
18404 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18405 "%s Testmode INV ATTR", __func__);
18406 return err;
18407 }
18408
18409 if (!tb[WLAN_HDD_TM_ATTR_CMD])
18410 {
18411 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18412 "%s Testmode INV CMD", __func__);
18413 return -EINVAL;
18414 }
18415
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053018416 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18417 TRACE_CODE_HDD_CFG80211_TESTMODE,
18418 NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])));
Leo Chang9056f462013-08-01 19:21:11 -070018419 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
18420 {
18421#ifdef FEATURE_WLAN_LPHB
18422 /* Low Power Heartbeat configuration request */
18423 case WLAN_HDD_TM_CMD_WLAN_HB:
18424 {
18425 int buf_len;
18426 void *buf;
18427 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080018428 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070018429
18430 if (!tb[WLAN_HDD_TM_ATTR_DATA])
18431 {
18432 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18433 "%s Testmode INV DATA", __func__);
18434 return -EINVAL;
18435 }
18436
18437 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
18438 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080018439
18440 hb_params_temp =(tSirLPHBReq *)buf;
18441 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
18442 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
18443 return -EINVAL;
18444
Leo Chang9056f462013-08-01 19:21:11 -070018445 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
18446 if (NULL == hb_params)
18447 {
18448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18449 "%s Request Buffer Alloc Fail", __func__);
18450 return -EINVAL;
18451 }
18452
18453 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070018454 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
18455 hb_params,
18456 wlan_hdd_cfg80211_lphb_ind_handler);
18457 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070018458 {
Leo Changd9df8aa2013-09-26 13:32:26 -070018459 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18460 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070018461 vos_mem_free(hb_params);
18462 }
Leo Chang9056f462013-08-01 19:21:11 -070018463 return 0;
18464 }
18465#endif /* FEATURE_WLAN_LPHB */
18466 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018467 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18468 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070018469 return -EOPNOTSUPP;
18470 }
18471
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018472 EXIT();
18473 return err;
Leo Chang9056f462013-08-01 19:21:11 -070018474}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018475
Anand N Sunkade9adb1b2015-07-29 09:56:45 +053018476static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy,
18477#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
18478 struct wireless_dev *wdev,
18479#endif
18480 void *data, int len)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018481{
18482 int ret;
18483
18484 vos_ssr_protect(__func__);
18485 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
18486 vos_ssr_unprotect(__func__);
18487
18488 return ret;
18489}
Leo Chang9056f462013-08-01 19:21:11 -070018490#endif /* CONFIG_NL80211_TESTMODE */
18491
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018492static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018493 struct net_device *dev,
18494 int idx, struct survey_info *survey)
18495{
18496 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
18497 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053018498 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018499 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053018500 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018501 v_S7_t snr,rssi;
18502 int status, i, j, filled = 0;
18503
18504 ENTER();
18505
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018506 if (NULL == pAdapter)
18507 {
18508 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
18509 "%s: HDD adapter is Null", __func__);
18510 return -ENODEV;
18511 }
18512
18513 if (NULL == wiphy)
18514 {
18515 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
18516 "%s: wiphy is Null", __func__);
18517 return -ENODEV;
18518 }
18519
18520 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
18521 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018522 if (0 != status)
18523 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018524 return status;
18525 }
18526
Mihir Sheted9072e02013-08-21 17:02:29 +053018527 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
18528
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018529 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053018530 0 != pAdapter->survey_idx ||
18531 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018532 {
18533 /* The survey dump ops when implemented completely is expected to
18534 * return a survey of all channels and the ops is called by the
18535 * kernel with incremental values of the argument 'idx' till it
18536 * returns -ENONET. But we can only support the survey for the
18537 * operating channel for now. survey_idx is used to track
18538 * that the ops is called only once and then return -ENONET for
18539 * the next iteration
18540 */
18541 pAdapter->survey_idx = 0;
18542 return -ENONET;
18543 }
18544
Mukul Sharma9d5233b2015-06-11 20:28:20 +053018545 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
18546 {
18547 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18548 "%s: Roaming in progress, hence return ", __func__);
18549 return -ENONET;
18550 }
18551
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018552 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
18553
18554 wlan_hdd_get_snr(pAdapter, &snr);
18555 wlan_hdd_get_rssi(pAdapter, &rssi);
18556
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053018557 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18558 TRACE_CODE_HDD_CFG80211_DUMP_SURVEY,
18559 pAdapter->sessionId, pAdapter->device_mode));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018560 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
18561 hdd_wlan_get_freq(channel, &freq);
18562
18563
18564 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
18565 {
18566 if (NULL == wiphy->bands[i])
18567 {
18568 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
18569 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
18570 continue;
18571 }
18572
18573 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
18574 {
18575 struct ieee80211_supported_band *band = wiphy->bands[i];
18576
18577 if (band->channels[j].center_freq == (v_U16_t)freq)
18578 {
18579 survey->channel = &band->channels[j];
18580 /* The Rx BDs contain SNR values in dB for the received frames
18581 * while the supplicant expects noise. So we calculate and
18582 * return the value of noise (dBm)
18583 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
18584 */
18585 survey->noise = rssi - snr;
18586 survey->filled = SURVEY_INFO_NOISE_DBM;
18587 filled = 1;
18588 }
18589 }
18590 }
18591
18592 if (filled)
18593 pAdapter->survey_idx = 1;
18594 else
18595 {
18596 pAdapter->survey_idx = 0;
18597 return -ENONET;
18598 }
18599
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018600 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018601 return 0;
18602}
18603
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018604static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
18605 struct net_device *dev,
18606 int idx, struct survey_info *survey)
18607{
18608 int ret;
18609
18610 vos_ssr_protect(__func__);
18611 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
18612 vos_ssr_unprotect(__func__);
18613
18614 return ret;
18615}
18616
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018617/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053018618 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018619 * this is called when cfg80211 driver resume
18620 * driver updates latest sched_scan scan result(if any) to cfg80211 database
18621 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053018622int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018623{
18624 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
18625 hdd_adapter_t *pAdapter;
18626 hdd_adapter_list_node_t *pAdapterNode, *pNext;
18627 VOS_STATUS status = VOS_STATUS_SUCCESS;
18628
18629 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018630
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053018631 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018632 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018633 return 0;
18634 }
18635
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053018636 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN,
18637 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018638 spin_lock(&pHddCtx->schedScan_lock);
18639 pHddCtx->isWiphySuspended = FALSE;
18640 if (TRUE != pHddCtx->isSchedScanUpdatePending)
18641 {
18642 spin_unlock(&pHddCtx->schedScan_lock);
18643 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18644 "%s: Return resume is not due to PNO indication", __func__);
18645 return 0;
18646 }
18647 // Reset flag to avoid updatating cfg80211 data old results again
18648 pHddCtx->isSchedScanUpdatePending = FALSE;
18649 spin_unlock(&pHddCtx->schedScan_lock);
18650
18651 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
18652
18653 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
18654 {
18655 pAdapter = pAdapterNode->pAdapter;
18656 if ( (NULL != pAdapter) &&
18657 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
18658 {
18659 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053018660 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018661 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
18662 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053018663 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018664 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053018665 {
18666 /* Acquire wakelock to handle the case where APP's tries to
18667 * suspend immediately after updating the scan results. Whis
18668 * results in app's is in suspended state and not able to
18669 * process the connect request to AP
18670 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053018671 hdd_prevent_suspend_timeout(2000,
18672 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018673 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053018674 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018675
18676 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18677 "%s : cfg80211 scan result database updated", __func__);
18678
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018679 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018680 return 0;
18681
18682 }
18683 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
18684 pAdapterNode = pNext;
18685 }
18686
18687 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18688 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018689 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018690 return 0;
18691}
18692
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053018693int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
18694{
18695 int ret;
18696
18697 vos_ssr_protect(__func__);
18698 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
18699 vos_ssr_unprotect(__func__);
18700
18701 return ret;
18702}
18703
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018704/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053018705 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018706 * this is called when cfg80211 driver suspends
18707 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053018708int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018709 struct cfg80211_wowlan *wow)
18710{
18711 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053018712 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018713
18714 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018715
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053018716 ret = wlan_hdd_validate_context(pHddCtx);
18717 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018718 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053018719 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018720 }
18721
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053018722
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053018723 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18724 TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN,
18725 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018726 pHddCtx->isWiphySuspended = TRUE;
18727
18728 EXIT();
18729
18730 return 0;
18731}
18732
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053018733int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
18734 struct cfg80211_wowlan *wow)
18735{
18736 int ret;
18737
18738 vos_ssr_protect(__func__);
18739 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
18740 vos_ssr_unprotect(__func__);
18741
18742 return ret;
18743}
Jeff Johnson295189b2012-06-20 16:38:30 -070018744/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018745static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070018746{
18747 .add_virtual_intf = wlan_hdd_add_virtual_intf,
18748 .del_virtual_intf = wlan_hdd_del_virtual_intf,
18749 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
18750 .change_station = wlan_hdd_change_station,
18751#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
18752 .add_beacon = wlan_hdd_cfg80211_add_beacon,
18753 .del_beacon = wlan_hdd_cfg80211_del_beacon,
18754 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070018755#else
18756 .start_ap = wlan_hdd_cfg80211_start_ap,
18757 .change_beacon = wlan_hdd_cfg80211_change_beacon,
18758 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070018759#endif
18760 .change_bss = wlan_hdd_cfg80211_change_bss,
18761 .add_key = wlan_hdd_cfg80211_add_key,
18762 .get_key = wlan_hdd_cfg80211_get_key,
18763 .del_key = wlan_hdd_cfg80211_del_key,
18764 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080018765#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070018766 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080018767#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070018768 .scan = wlan_hdd_cfg80211_scan,
18769 .connect = wlan_hdd_cfg80211_connect,
18770 .disconnect = wlan_hdd_cfg80211_disconnect,
18771 .join_ibss = wlan_hdd_cfg80211_join_ibss,
18772 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
18773 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
18774 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
18775 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070018776 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
18777 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053018778 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070018779#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
18780 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
18781 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
18782 .set_txq_params = wlan_hdd_set_txq_params,
18783#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070018784 .get_station = wlan_hdd_cfg80211_get_station,
18785 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
18786 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070018787 .add_station = wlan_hdd_cfg80211_add_station,
18788#ifdef FEATURE_WLAN_LFR
18789 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
18790 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
18791 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
18792#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070018793#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
18794 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
18795#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018796#ifdef FEATURE_WLAN_TDLS
18797 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
18798 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
18799#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018800#ifdef WLAN_FEATURE_GTK_OFFLOAD
18801 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
18802#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018803#ifdef FEATURE_WLAN_SCAN_PNO
18804 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
18805 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
18806#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018807 .resume = wlan_hdd_cfg80211_resume_wlan,
18808 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018809 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070018810#ifdef WLAN_NL80211_TESTMODE
18811 .testmode_cmd = wlan_hdd_cfg80211_testmode,
18812#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018813 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070018814};
18815