blob: b74cb3cbc31d5d23cbe555aa61fed9cad7011b8f [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 {
1859 hddLog(VOS_TRACE_LEVEL_FATAL,
1860 "%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) ||
3465 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3466 {
3467 hddLog(VOS_TRACE_LEVEL_ERROR,
3468 FL("EXTScan not enabled/supported by Firmware"));
3469 return -EINVAL;
3470 }
3471
Dino Mycle6fb96c12014-06-10 11:52:40 +05303472 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3473 data, dataLen,
3474 wlan_hdd_extscan_config_policy)) {
3475 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3476 return -EINVAL;
3477 }
3478
3479 /* Parse and fetch request Id */
3480 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3481 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3482 return -EINVAL;
3483 }
3484
Dino Myclee8843b32014-07-04 14:21:45 +05303485 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303486 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303487 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303488
Dino Myclee8843b32014-07-04 14:21:45 +05303489 reqMsg.sessionId = pAdapter->sessionId;
3490 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303491
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303492 vos_spin_lock_acquire(&hdd_context_lock);
3493 context = &pHddCtx->ext_scan_context;
3494 context->request_id = reqMsg.requestId;
3495 INIT_COMPLETION(context->response_event);
3496 vos_spin_lock_release(&hdd_context_lock);
3497
Dino Myclee8843b32014-07-04 14:21:45 +05303498 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303499 if (!HAL_STATUS_SUCCESS(status)) {
3500 hddLog(VOS_TRACE_LEVEL_ERROR,
3501 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303502 return -EINVAL;
3503 }
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303504
3505 rc = wait_for_completion_timeout(&context->response_event,
3506 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3507 if (!rc) {
3508 hddLog(LOGE, FL("Target response timed out"));
3509 return -ETIMEDOUT;
3510 }
3511
3512 ret = wlan_hdd_send_ext_scan_capability(pHddCtx);
3513 if (ret)
3514 hddLog(LOGE, FL("Failed to send ext scan capability to user space"));
3515
3516 return ret;
3517
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303518 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303519 return 0;
3520}
3521
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303522static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3523 struct wireless_dev *wdev,
3524 const void *data, int dataLen)
3525{
3526 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303527
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303528 vos_ssr_protect(__func__);
3529 ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen);
3530 vos_ssr_unprotect(__func__);
3531
3532 return ret;
3533}
3534
3535static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3536 struct wireless_dev *wdev,
3537 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303538{
Dino Myclee8843b32014-07-04 14:21:45 +05303539 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303540 struct net_device *dev = wdev->netdev;
3541 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3542 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3543 struct nlattr
3544 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3545 eHalStatus status;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303546 struct hdd_ext_scan_context *context;
3547 unsigned long rc;
3548 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303549
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303550 ENTER();
3551
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303552 if (VOS_FTM_MODE == hdd_get_conparam()) {
3553 hddLog(LOGE, FL("Command not allowed in FTM mode"));
3554 return -EINVAL;
3555 }
3556
Dino Mycle6fb96c12014-06-10 11:52:40 +05303557 status = wlan_hdd_validate_context(pHddCtx);
3558 if (0 != status)
3559 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303560 return -EINVAL;
3561 }
Dino Myclee8843b32014-07-04 14:21:45 +05303562 /* check the EXTScan Capability */
3563 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3564 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3565 {
3566 hddLog(VOS_TRACE_LEVEL_ERROR,
3567 FL("EXTScan not enabled/supported by Firmware"));
3568 return -EINVAL;
3569 }
3570
Dino Mycle6fb96c12014-06-10 11:52:40 +05303571 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3572 data, dataLen,
3573 wlan_hdd_extscan_config_policy)) {
3574 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3575 return -EINVAL;
3576 }
3577 /* Parse and fetch request Id */
3578 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3579 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3580 return -EINVAL;
3581 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303582
Dino Myclee8843b32014-07-04 14:21:45 +05303583 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303584 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3585
Dino Myclee8843b32014-07-04 14:21:45 +05303586 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303587
Dino Myclee8843b32014-07-04 14:21:45 +05303588 reqMsg.sessionId = pAdapter->sessionId;
3589 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303590
3591 /* Parse and fetch flush parameter */
3592 if (!tb
3593 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3594 {
3595 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3596 goto failed;
3597 }
Dino Myclee8843b32014-07-04 14:21:45 +05303598 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303599 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3600
Dino Myclee8843b32014-07-04 14:21:45 +05303601 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303602
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303603 spin_lock(&hdd_context_lock);
3604 context = &pHddCtx->ext_scan_context;
3605 context->request_id = reqMsg.requestId;
3606 context->ignore_cached_results = false;
3607 INIT_COMPLETION(context->response_event);
3608 spin_unlock(&hdd_context_lock);
3609
Dino Myclee8843b32014-07-04 14:21:45 +05303610 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303611 if (!HAL_STATUS_SUCCESS(status)) {
3612 hddLog(VOS_TRACE_LEVEL_ERROR,
3613 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303614 return -EINVAL;
3615 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303616
3617 rc = wait_for_completion_timeout(&context->response_event,
3618 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3619 if (!rc) {
3620 hddLog(LOGE, FL("Target response timed out"));
3621 retval = -ETIMEDOUT;
3622 spin_lock(&hdd_context_lock);
3623 context->ignore_cached_results = true;
3624 spin_unlock(&hdd_context_lock);
3625 } else {
3626 spin_lock(&hdd_context_lock);
3627 retval = context->response_status;
3628 spin_unlock(&hdd_context_lock);
3629 }
3630
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303631 EXIT();
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303632 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303633
3634failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303635 return -EINVAL;
3636}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303637static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3638 struct wireless_dev *wdev,
3639 const void *data, int dataLen)
3640{
3641 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303642
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303643 vos_ssr_protect(__func__);
3644 ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen);
3645 vos_ssr_unprotect(__func__);
3646
3647 return ret;
3648}
3649
3650static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303651 struct wireless_dev *wdev,
Edhar, Mahesh Kumared8631f2015-01-20 14:31:47 +05303652 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303653{
3654 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3655 struct net_device *dev = wdev->netdev;
3656 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3657 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3658 struct nlattr
3659 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3660 struct nlattr
3661 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3662 struct nlattr *apTh;
3663 eHalStatus status;
3664 tANI_U8 i = 0;
3665 int rem;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303666 struct hdd_ext_scan_context *context;
3667 tANI_U32 request_id;
3668 unsigned long rc;
3669 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303670
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303671 ENTER();
3672
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303673 if (VOS_FTM_MODE == hdd_get_conparam()) {
3674 hddLog(LOGE, FL("Command not allowed in FTM mode"));
3675 return -EINVAL;
3676 }
3677
Dino Mycle6fb96c12014-06-10 11:52:40 +05303678 status = wlan_hdd_validate_context(pHddCtx);
3679 if (0 != status)
3680 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303681 return -EINVAL;
3682 }
Dino Myclee8843b32014-07-04 14:21:45 +05303683 /* check the EXTScan Capability */
3684 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3685 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3686 {
3687 hddLog(VOS_TRACE_LEVEL_ERROR,
3688 FL("EXTScan not enabled/supported by Firmware"));
3689 return -EINVAL;
3690 }
3691
Dino Mycle6fb96c12014-06-10 11:52:40 +05303692 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3693 data, dataLen,
3694 wlan_hdd_extscan_config_policy)) {
3695 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3696 return -EINVAL;
3697 }
3698
3699 /* Parse and fetch request Id */
3700 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3701 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3702 return -EINVAL;
3703 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303704 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3705 vos_mem_malloc(sizeof(*pReqMsg));
3706 if (!pReqMsg) {
3707 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3708 return -ENOMEM;
3709 }
3710
Dino Myclee8843b32014-07-04 14:21:45 +05303711
Dino Mycle6fb96c12014-06-10 11:52:40 +05303712 pReqMsg->requestId = nla_get_u32(
3713 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3714 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3715
3716 /* Parse and fetch number of APs */
3717 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3718 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3719 goto fail;
3720 }
3721
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303722 /* Parse and fetch lost ap sample size */
3723 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE]) {
3724 hddLog(LOGE, FL("attr lost ap sample size failed"));
3725 goto fail;
3726 }
3727
3728 pReqMsg->lostBssidSampleSize = nla_get_u32(
3729 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE]);
3730 hddLog(LOG1, FL("Lost ap sample size %d"), pReqMsg->lostBssidSampleSize);
3731
Dino Mycle6fb96c12014-06-10 11:52:40 +05303732 pReqMsg->sessionId = pAdapter->sessionId;
3733 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3734
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303735 pReqMsg->numBssid = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303736 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303737 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numBssid);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303738
3739 nla_for_each_nested(apTh,
3740 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3741 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3742 nla_data(apTh), nla_len(apTh),
3743 NULL)) {
3744 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3745 goto fail;
3746 }
3747
3748 /* Parse and fetch MAC address */
3749 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3750 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3751 goto fail;
3752 }
3753 memcpy(pReqMsg->ap[i].bssid, nla_data(
3754 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3755 sizeof(tSirMacAddr));
3756 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3757
3758 /* Parse and fetch low RSSI */
3759 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3760 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3761 goto fail;
3762 }
3763 pReqMsg->ap[i].low = nla_get_s32(
3764 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3765 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3766
3767 /* Parse and fetch high RSSI */
3768 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3769 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3770 goto fail;
3771 }
3772 pReqMsg->ap[i].high = nla_get_s32(
3773 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3774 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3775 pReqMsg->ap[i].high);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303776 i++;
3777 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303778
3779 context = &pHddCtx->ext_scan_context;
3780 spin_lock(&hdd_context_lock);
3781 INIT_COMPLETION(context->response_event);
3782 context->request_id = request_id = pReqMsg->requestId;
3783 spin_unlock(&hdd_context_lock);
3784
Dino Mycle6fb96c12014-06-10 11:52:40 +05303785 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3786 if (!HAL_STATUS_SUCCESS(status)) {
3787 hddLog(VOS_TRACE_LEVEL_ERROR,
3788 FL("sme_SetBssHotlist failed(err=%d)"), status);
3789 vos_mem_free(pReqMsg);
3790 return -EINVAL;
3791 }
3792
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303793 /* request was sent -- wait for the response */
3794 rc = wait_for_completion_timeout(&context->response_event,
3795 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3796
3797 if (!rc) {
3798 hddLog(LOGE, FL("sme_SetBssHotlist timed out"));
3799 retval = -ETIMEDOUT;
3800 } else {
3801 spin_lock(&hdd_context_lock);
3802 if (context->request_id == request_id)
3803 retval = context->response_status;
3804 else
3805 retval = -EINVAL;
3806 spin_unlock(&hdd_context_lock);
3807 }
3808
Dino Myclee8843b32014-07-04 14:21:45 +05303809 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303810 EXIT();
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303811 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303812
3813fail:
3814 vos_mem_free(pReqMsg);
3815 return -EINVAL;
3816}
3817
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303818static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3819 struct wireless_dev *wdev,
3820 const void *data, int dataLen)
3821{
3822 int ret = 0;
3823
3824 vos_ssr_protect(__func__);
3825 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
3826 dataLen);
3827 vos_ssr_unprotect(__func__);
3828
3829 return ret;
3830}
3831
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303832/*
3833 * define short names for the global vendor params
3834 * used by wlan_hdd_cfg80211_extscan_set_ssid_hotlist()
3835 */
3836#define PARAM_MAX \
3837QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
3838#define PARAM_REQUEST_ID \
3839QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
3840#define PARAMS_LOST_SSID_SAMPLE_SIZE \
3841QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_LOST_SSID_SAMPLE_SIZE
3842#define PARAMS_NUM_SSID \
3843QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID
3844#define THRESHOLD_PARAM \
3845QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM
3846#define PARAM_SSID \
3847QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_SSID
3848#define PARAM_BAND \
3849QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_BAND
3850#define PARAM_RSSI_LOW \
3851QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_LOW
3852#define PARAM_RSSI_HIGH \
3853QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_HIGH
3854
3855/**
3856 * __wlan_hdd_cfg80211_extscan_set_ssid_hotlist() - set ssid hot list
3857 * @wiphy: Pointer to wireless phy
3858 * @wdev: Pointer to wireless device
3859 * @data: Pointer to data
3860 * @data_len: Data length
3861 *
3862 * Return: 0 on success, negative errno on failure
3863 */
3864static int
3865__wlan_hdd_cfg80211_extscan_set_ssid_hotlist(struct wiphy *wiphy,
3866 struct wireless_dev *wdev,
3867 const void *data,
3868 int data_len)
3869{
3870 tSirEXTScanSetSsidHotListReqParams *request;
3871 struct net_device *dev = wdev->netdev;
3872 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3873 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
3874 struct nlattr *tb[PARAM_MAX + 1];
3875 struct nlattr *tb2[PARAM_MAX + 1];
3876 struct nlattr *ssids;
3877 struct hdd_ext_scan_context *context;
3878 uint32_t request_id;
3879 char ssid_string[SIR_MAC_MAX_SSID_LENGTH + 1] = {'\0'};
3880 int ssid_len;
3881 eHalStatus status;
3882 int i, rem, retval;
3883 unsigned long rc;
3884
3885 ENTER();
3886
3887 if (VOS_FTM_MODE == hdd_get_conparam()) {
3888 hddLog(LOGE, FL("Command not allowed in FTM mode"));
3889 return -EINVAL;
3890 }
3891
3892 retval = wlan_hdd_validate_context(hdd_ctx);
3893 if (0 != retval) {
3894 hddLog(LOGE, FL("HDD context is not valid"));
3895 return -EINVAL;
3896 }
3897
3898 /* check the EXTScan Capability */
3899 if ( (TRUE != hdd_ctx->cfg_ini->fEnableEXTScan) ||
3900 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3901 {
3902 hddLog(VOS_TRACE_LEVEL_ERROR,
3903 FL("EXTScan not enabled/supported by Firmware"));
3904 return -EINVAL;
3905 }
3906
3907 if (nla_parse(tb, PARAM_MAX,
3908 data, data_len,
3909 wlan_hdd_extscan_config_policy)) {
3910 hddLog(LOGE, FL("Invalid ATTR"));
3911 return -EINVAL;
3912 }
3913
3914 request = vos_mem_malloc(sizeof(*request));
3915 if (!request) {
3916 hddLog(LOGE, FL("vos_mem_malloc failed"));
3917 return -ENOMEM;
3918 }
3919
3920 /* Parse and fetch request Id */
3921 if (!tb[PARAM_REQUEST_ID]) {
3922 hddLog(LOGE, FL("attr request id failed"));
3923 goto fail;
3924 }
3925
3926 request->request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
3927 hddLog(LOG1, FL("Request Id %d"), request->request_id);
3928
3929 /* Parse and fetch lost SSID sample size */
3930 if (!tb[PARAMS_LOST_SSID_SAMPLE_SIZE]) {
3931 hddLog(LOGE, FL("attr number of Ssid failed"));
3932 goto fail;
3933 }
3934 request->lost_ssid_sample_size =
3935 nla_get_u32(tb[PARAMS_LOST_SSID_SAMPLE_SIZE]);
3936 hddLog(LOG1, FL("Lost SSID Sample Size %d"),
3937 request->lost_ssid_sample_size);
3938
3939 /* Parse and fetch number of hotlist SSID */
3940 if (!tb[PARAMS_NUM_SSID]) {
3941 hddLog(LOGE, FL("attr number of Ssid failed"));
3942 goto fail;
3943 }
3944 request->ssid_count = nla_get_u32(tb[PARAMS_NUM_SSID]);
3945 hddLog(LOG1, FL("Number of SSID %d"), request->ssid_count);
3946
3947 request->session_id = adapter->sessionId;
3948 hddLog(LOG1, FL("Session Id (%d)"), request->session_id);
3949
3950 i = 0;
3951 nla_for_each_nested(ssids, tb[THRESHOLD_PARAM], rem) {
3952 if (i >= WLAN_EXTSCAN_MAX_HOTLIST_SSIDS) {
3953 hddLog(LOGE,
3954 FL("Too Many SSIDs, %d exceeds %d"),
3955 i, WLAN_EXTSCAN_MAX_HOTLIST_SSIDS);
3956 break;
3957 }
3958 if (nla_parse(tb2, PARAM_MAX,
3959 nla_data(ssids), nla_len(ssids),
3960 wlan_hdd_extscan_config_policy)) {
3961 hddLog(LOGE, FL("nla_parse failed"));
3962 goto fail;
3963 }
3964
3965 /* Parse and fetch SSID */
3966 if (!tb2[PARAM_SSID]) {
3967 hddLog(LOGE, FL("attr ssid failed"));
3968 goto fail;
3969 }
3970 nla_memcpy(ssid_string,
3971 tb2[PARAM_SSID],
3972 sizeof(ssid_string));
3973 hddLog(LOG1, FL("SSID %s"),
3974 ssid_string);
3975 ssid_len = strlen(ssid_string);
3976 memcpy(request->ssid[i].ssid.ssId, ssid_string, ssid_len);
3977 request->ssid[i].ssid.length = ssid_len;
3978 request->ssid[i].ssid.ssId[ssid_len] = '\0';
3979 hddLog(LOG1, FL("After copying SSID %s"),
3980 request->ssid[i].ssid.ssId);
3981 hddLog(LOG1, FL("After copying length: %d"),
3982 ssid_len);
3983
3984 /* Parse and fetch low RSSI */
3985 if (!tb2[PARAM_BAND]) {
3986 hddLog(LOGE, FL("attr band failed"));
3987 goto fail;
3988 }
3989 request->ssid[i].band = nla_get_u8(tb2[PARAM_BAND]);
3990 hddLog(LOG1, FL("band %d"), request->ssid[i].band);
3991
3992 /* Parse and fetch low RSSI */
3993 if (!tb2[PARAM_RSSI_LOW]) {
3994 hddLog(LOGE, FL("attr low RSSI failed"));
3995 goto fail;
3996 }
3997 request->ssid[i].rssi_low = nla_get_s32(tb2[PARAM_RSSI_LOW]);
3998 hddLog(LOG1, FL("RSSI low %d"), request->ssid[i].rssi_low);
3999
4000 /* Parse and fetch high RSSI */
4001 if (!tb2[PARAM_RSSI_HIGH]) {
4002 hddLog(LOGE, FL("attr high RSSI failed"));
4003 goto fail;
4004 }
4005 request->ssid[i].rssi_high = nla_get_u32(tb2[PARAM_RSSI_HIGH]);
4006 hddLog(LOG1, FL("RSSI high %d"), request->ssid[i].rssi_high);
4007 i++;
4008 }
4009
4010 context = &hdd_ctx->ext_scan_context;
4011 spin_lock(&hdd_context_lock);
4012 INIT_COMPLETION(context->response_event);
4013 context->request_id = request_id = request->request_id;
4014 spin_unlock(&hdd_context_lock);
4015
4016 status = sme_set_ssid_hotlist(hdd_ctx->hHal, request);
4017 if (!HAL_STATUS_SUCCESS(status)) {
4018 hddLog(LOGE,
4019 FL("sme_set_ssid_hotlist failed(err=%d)"), status);
4020 goto fail;
4021 }
4022
4023 vos_mem_free(request);
4024
4025 /* request was sent -- wait for the response */
4026 rc = wait_for_completion_timeout(&context->response_event,
4027 msecs_to_jiffies
4028 (WLAN_WAIT_TIME_EXTSCAN));
4029 if (!rc) {
4030 hddLog(LOGE, FL("sme_set_ssid_hotlist timed out"));
4031 retval = -ETIMEDOUT;
4032 } else {
4033 spin_lock(&hdd_context_lock);
4034 if (context->request_id == request_id)
4035 retval = context->response_status;
4036 else
4037 retval = -EINVAL;
4038 spin_unlock(&hdd_context_lock);
4039 }
4040
4041 return retval;
4042
4043fail:
4044 vos_mem_free(request);
4045 return -EINVAL;
4046}
4047
4048/*
4049 * done with short names for the global vendor params
4050 * used by wlan_hdd_cfg80211_extscan_set_ssid_hotlist()
4051 */
4052#undef PARAM_MAX
4053#undef PARAM_REQUEST_ID
4054#undef PARAMS_NUM_SSID
4055#undef THRESHOLD_PARAM
4056#undef PARAM_SSID
4057#undef PARAM_BAND
4058#undef PARAM_RSSI_LOW
4059#undef PARAM_RSSI_HIGH
4060
4061static int wlan_hdd_cfg80211_extscan_set_ssid_hotlist(struct wiphy *wiphy,
4062 struct wireless_dev *wdev,
4063 const void *data, int dataLen)
4064{
4065 int ret = 0;
4066
4067 vos_ssr_protect(__func__);
4068 ret = __wlan_hdd_cfg80211_extscan_set_ssid_hotlist(wiphy, wdev, data,
4069 dataLen);
4070 vos_ssr_unprotect(__func__);
4071
4072 return ret;
4073}
4074
4075static int
4076__wlan_hdd_cfg80211_extscan_reset_ssid_hotlist(struct wiphy *wiphy,
4077 struct wireless_dev *wdev,
4078 const void *data,
4079 int data_len)
4080{
4081 tSirEXTScanResetSsidHotlistReqParams request;
4082 struct net_device *dev = wdev->netdev;
4083 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4084 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
4085 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4086 struct hdd_ext_scan_context *context;
4087 uint32_t request_id;
4088 eHalStatus status;
4089 int retval;
4090 unsigned long rc;
4091
4092 ENTER();
4093
4094 if (VOS_FTM_MODE == hdd_get_conparam()) {
4095 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4096 return -EINVAL;
4097 }
4098
4099 retval = wlan_hdd_validate_context(hdd_ctx);
4100 if (0 != retval) {
4101 hddLog(LOGE, FL("HDD context is not valid"));
4102 return -EINVAL;
4103 }
4104
4105 /* check the EXTScan Capability */
4106 if ( (TRUE != hdd_ctx->cfg_ini->fEnableEXTScan) ||
4107 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4108 {
4109 hddLog(LOGE,
4110 FL("EXTScan not enabled/supported by Firmware"));
4111 return -EINVAL;
4112 }
4113
4114 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4115 data, data_len,
4116 wlan_hdd_extscan_config_policy)) {
4117 hddLog(LOGE, FL("Invalid ATTR"));
4118 return -EINVAL;
4119 }
4120
4121 /* Parse and fetch request Id */
4122 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4123 hddLog(LOGE, FL("attr request id failed"));
4124 return -EINVAL;
4125 }
4126
4127 request.requestId = nla_get_u32(
4128 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4129 request.sessionId = adapter->sessionId;
4130 hddLog(LOG1, FL("Request Id %d Session Id %d"), request.requestId,
4131 request.sessionId);
4132
4133 context = &hdd_ctx->ext_scan_context;
4134 spin_lock(&hdd_context_lock);
4135 INIT_COMPLETION(context->response_event);
4136 context->request_id = request_id = request.requestId;
4137 spin_unlock(&hdd_context_lock);
4138
4139 status = sme_reset_ssid_hotlist(hdd_ctx->hHal, &request);
4140 if (!HAL_STATUS_SUCCESS(status)) {
4141 hddLog(LOGE,
4142 FL("sme_reset_ssid_hotlist failed(err=%d)"), status);
4143 return -EINVAL;
4144 }
4145
4146 /* request was sent -- wait for the response */
4147 rc = wait_for_completion_timeout(&context->response_event,
4148 msecs_to_jiffies
4149 (WLAN_WAIT_TIME_EXTSCAN));
4150 if (!rc) {
4151 hddLog(LOGE, FL("sme_reset_ssid_hotlist timed out"));
4152 retval = -ETIMEDOUT;
4153 } else {
4154 spin_lock(&hdd_context_lock);
4155 if (context->request_id == request_id)
4156 retval = context->response_status;
4157 else
4158 retval = -EINVAL;
4159 spin_unlock(&hdd_context_lock);
4160 }
4161
4162 return retval;
4163}
4164
4165static int
4166wlan_hdd_cfg80211_extscan_reset_ssid_hotlist(struct wiphy *wiphy,
4167 struct wireless_dev *wdev,
4168 const void *data,
4169 int data_len)
4170{
4171 int ret;
4172
4173 vos_ssr_protect(__func__);
4174 ret = __wlan_hdd_cfg80211_extscan_reset_ssid_hotlist(wiphy, wdev,
4175 data, data_len);
4176 vos_ssr_unprotect(__func__);
4177
4178 return ret;
4179}
4180
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304181static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304182 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304183 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304184{
4185 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4186 tANI_U32 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
4187 tANI_U8 numChannels = 0;
4188 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304189 tANI_U32 requestId, maxChannels;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304190 tWifiBand wifiBand;
4191 eHalStatus status;
4192 struct sk_buff *replySkb;
4193 tANI_U8 i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304194 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304195
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304196 ENTER();
4197
Dino Mycle6fb96c12014-06-10 11:52:40 +05304198 status = wlan_hdd_validate_context(pHddCtx);
4199 if (0 != status)
4200 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304201 return -EINVAL;
4202 }
Dino Myclee8843b32014-07-04 14:21:45 +05304203
Dino Mycle6fb96c12014-06-10 11:52:40 +05304204 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4205 data, dataLen,
4206 wlan_hdd_extscan_config_policy)) {
4207 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4208 return -EINVAL;
4209 }
4210
4211 /* Parse and fetch request Id */
4212 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4213 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4214 return -EINVAL;
4215 }
4216 requestId = nla_get_u32(
4217 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4218 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
4219
4220 /* Parse and fetch wifi band */
4221 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
4222 {
4223 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
4224 return -EINVAL;
4225 }
4226 wifiBand = nla_get_u32(
4227 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
4228 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
4229
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304230 /* Parse and fetch max channels */
4231 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS])
4232 {
4233 hddLog(LOGE, FL("attr max channels failed"));
4234 return -EINVAL;
4235 }
4236 maxChannels = nla_get_u32(
4237 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS]);
4238 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max channels %d"), maxChannels);
4239
Dino Mycle6fb96c12014-06-10 11:52:40 +05304240 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
4241 wifiBand, ChannelList,
4242 &numChannels);
4243 if (eHAL_STATUS_SUCCESS != status) {
4244 hddLog(VOS_TRACE_LEVEL_ERROR,
4245 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
4246 return -EINVAL;
4247 }
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304248
4249 numChannels = VOS_MIN(numChannels, maxChannels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304250 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of channels (%d)"), numChannels);
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304251
Dino Mycle6fb96c12014-06-10 11:52:40 +05304252 for (i = 0; i < numChannels; i++)
4253 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %u ", ChannelList[i]);
4254
4255 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
4256 sizeof(u32) * numChannels +
4257 NLMSG_HDRLEN);
4258
4259 if (!replySkb) {
4260 hddLog(VOS_TRACE_LEVEL_ERROR,
4261 FL("valid channels: buffer alloc fail"));
4262 return -EINVAL;
4263 }
4264 if (nla_put_u32(replySkb,
4265 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
4266 numChannels) ||
4267 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
4268 sizeof(u32) * numChannels, ChannelList)) {
4269
4270 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4271 kfree_skb(replySkb);
4272 return -EINVAL;
4273 }
4274
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304275 ret = cfg80211_vendor_cmd_reply(replySkb);
4276
4277 EXIT();
4278 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304279}
4280
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304281static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
4282 struct wireless_dev *wdev,
4283 const void *data, int dataLen)
4284{
4285 int ret = 0;
4286
4287 vos_ssr_protect(__func__);
4288 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
4289 dataLen);
4290 vos_ssr_unprotect(__func__);
4291
4292 return ret;
4293}
4294
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304295static int hdd_extscan_start_fill_bucket_channel_spec(
4296 hdd_context_t *pHddCtx,
4297 tpSirEXTScanStartReqParams pReqMsg,
4298 struct nlattr **tb)
4299{
4300 struct nlattr *bucket[
4301 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4302 struct nlattr *channel[
4303 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4304 struct nlattr *buckets;
4305 struct nlattr *channels;
4306 int rem1, rem2;
4307 eHalStatus status;
4308 tANI_U8 bktIndex, j, numChannels;
4309 tANI_U32 chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
4310 tANI_U32 passive_max_chn_time, active_max_chn_time;
4311
4312 bktIndex = 0;
4313
4314 nla_for_each_nested(buckets,
4315 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
4316 if (nla_parse(bucket,
4317 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4318 nla_data(buckets), nla_len(buckets), NULL)) {
4319 hddLog(LOGE, FL("nla_parse failed"));
4320 return -EINVAL;
4321 }
4322
4323 /* Parse and fetch bucket spec */
4324 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
4325 hddLog(LOGE, FL("attr bucket index failed"));
4326 return -EINVAL;
4327 }
4328 pReqMsg->buckets[bktIndex].bucket = nla_get_u8(
4329 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
4330 hddLog(LOG1, FL("Bucket spec Index %d"),
4331 pReqMsg->buckets[bktIndex].bucket);
4332
4333 /* Parse and fetch wifi band */
4334 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
4335 hddLog(LOGE, FL("attr wifi band failed"));
4336 return -EINVAL;
4337 }
4338 pReqMsg->buckets[bktIndex].band = nla_get_u8(
4339 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
4340 hddLog(LOG1, FL("Wifi band %d"),
4341 pReqMsg->buckets[bktIndex].band);
4342
4343 /* Parse and fetch period */
4344 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
4345 hddLog(LOGE, FL("attr period failed"));
4346 return -EINVAL;
4347 }
4348 pReqMsg->buckets[bktIndex].period = nla_get_u32(
4349 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
4350 hddLog(LOG1, FL("period %d"),
4351 pReqMsg->buckets[bktIndex].period);
4352
4353 /* Parse and fetch report events */
4354 if (!bucket[
4355 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
4356 hddLog(LOGE, FL("attr report events failed"));
4357 return -EINVAL;
4358 }
4359 pReqMsg->buckets[bktIndex].reportEvents = nla_get_u8(
4360 bucket[
4361 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
4362 hddLog(LOG1, FL("report events %d"),
4363 pReqMsg->buckets[bktIndex].reportEvents);
4364
4365 /* Parse and fetch max period */
4366 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]) {
4367 hddLog(LOGE, FL("attr max period failed"));
4368 return -EINVAL;
4369 }
4370 pReqMsg->buckets[bktIndex].max_period = nla_get_u32(
4371 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]);
4372 hddLog(LOG1, FL("max period %u"),
4373 pReqMsg->buckets[bktIndex].max_period);
4374
4375 /* Parse and fetch exponent */
4376 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]) {
4377 hddLog(LOGE, FL("attr exponent failed"));
4378 return -EINVAL;
4379 }
4380 pReqMsg->buckets[bktIndex].exponent = nla_get_u32(
4381 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]);
4382 hddLog(LOG1, FL("exponent %u"),
4383 pReqMsg->buckets[bktIndex].exponent);
4384
4385 /* Parse and fetch step count */
4386 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]) {
4387 hddLog(LOGE, FL("attr step count failed"));
4388 return -EINVAL;
4389 }
4390 pReqMsg->buckets[bktIndex].step_count = nla_get_u32(
4391 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]);
4392 hddLog(LOG1, FL("Step count %u"),
4393 pReqMsg->buckets[bktIndex].step_count);
4394
4395 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &passive_max_chn_time);
4396 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &active_max_chn_time);
4397
4398 /* Framework shall pass the channel list if the input WiFi band is
4399 * WIFI_BAND_UNSPECIFIED.
4400 * If the input WiFi band is specified (any value other than
4401 * WIFI_BAND_UNSPECIFIED) then driver populates the channel list
4402 */
4403 if (pReqMsg->buckets[bktIndex].band != WIFI_BAND_UNSPECIFIED) {
4404 numChannels = 0;
4405 hddLog(LOG1, "WiFi band is specified, driver to fill channel list");
4406 status = sme_GetValidChannelsByBand(pHddCtx->hHal,
4407 pReqMsg->buckets[bktIndex].band,
4408 chanList, &numChannels);
4409 if (!HAL_STATUS_SUCCESS(status)) {
4410 hddLog(LOGE,
4411 FL("sme_GetValidChannelsByBand failed (err=%d)"),
4412 status);
4413 return -EINVAL;
4414 }
4415
4416 pReqMsg->buckets[bktIndex].numChannels =
4417 VOS_MIN(numChannels, WLAN_EXTSCAN_MAX_CHANNELS);
4418 hddLog(LOG1, FL("Num channels %d"),
4419 pReqMsg->buckets[bktIndex].numChannels);
4420
4421 for (j = 0; j < pReqMsg->buckets[bktIndex].numChannels;
4422 j++) {
4423 pReqMsg->buckets[bktIndex].channels[j].channel =
4424 chanList[j];
4425 pReqMsg->buckets[bktIndex].channels[j].
4426 chnlClass = 0;
4427 if (CSR_IS_CHANNEL_DFS(
4428 vos_freq_to_chan(chanList[j]))) {
4429 pReqMsg->buckets[bktIndex].channels[j].
4430 passive = 1;
4431 pReqMsg->buckets[bktIndex].channels[j].
4432 dwellTimeMs = passive_max_chn_time;
4433 } else {
4434 pReqMsg->buckets[bktIndex].channels[j].
4435 passive = 0;
4436 pReqMsg->buckets[bktIndex].channels[j].
4437 dwellTimeMs = active_max_chn_time;
4438 }
4439
4440 hddLog(LOG1,
4441 "Channel %u Passive %u Dwell time %u ms",
4442 pReqMsg->buckets[bktIndex].channels[j].channel,
4443 pReqMsg->buckets[bktIndex].channels[j].passive,
4444 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
4445 }
4446
4447 bktIndex++;
4448 continue;
4449 }
4450
4451 /* Parse and fetch number of channels */
4452 if (!bucket[
4453 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]) {
4454 hddLog(LOGE, FL("attr num channels failed"));
4455 return -EINVAL;
4456 }
4457
4458 pReqMsg->buckets[bktIndex].numChannels =
4459 nla_get_u32(bucket[
4460 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
4461 hddLog(LOG1, FL("num channels %d"),
4462 pReqMsg->buckets[bktIndex].numChannels);
4463
4464 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
4465 hddLog(LOGE, FL("attr channel spec failed"));
4466 return -EINVAL;
4467 }
4468
4469 j = 0;
4470 nla_for_each_nested(channels,
4471 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
4472 if (nla_parse(channel,
4473 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4474 nla_data(channels), nla_len(channels),
4475 wlan_hdd_extscan_config_policy)) {
4476 hddLog(LOGE, FL("nla_parse failed"));
4477 return -EINVAL;
4478 }
4479
4480 /* Parse and fetch channel */
4481 if (!channel[
4482 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
4483 hddLog(LOGE, FL("attr channel failed"));
4484 return -EINVAL;
4485 }
4486 pReqMsg->buckets[bktIndex].channels[j].channel =
4487 nla_get_u32(channel[
4488 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
4489 hddLog(LOG1, FL("channel %u"),
4490 pReqMsg->buckets[bktIndex].channels[j].channel);
4491
4492 /* Parse and fetch dwell time */
4493 if (!channel[
4494 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
4495 hddLog(LOGE, FL("attr dwelltime failed"));
4496 return -EINVAL;
4497 }
4498 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs =
4499 nla_get_u32(channel[
4500 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
4501
4502 hddLog(LOG1, FL("Dwell time (%u ms)"),
4503 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
4504
4505
4506 /* Parse and fetch channel spec passive */
4507 if (!channel[
4508 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
4509 hddLog(LOGE,
4510 FL("attr channel spec passive failed"));
4511 return -EINVAL;
4512 }
4513 pReqMsg->buckets[bktIndex].channels[j].passive =
4514 nla_get_u8(channel[
4515 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
4516 hddLog(LOG1, FL("Chnl spec passive %u"),
4517 pReqMsg->buckets[bktIndex].channels[j].passive);
4518
4519 j++;
4520 }
4521
4522 bktIndex++;
4523 }
4524
4525 return 0;
4526}
4527
4528
4529/*
4530 * define short names for the global vendor params
4531 * used by wlan_hdd_cfg80211_extscan_start()
4532 */
4533#define PARAM_MAX \
4534QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
4535#define PARAM_REQUEST_ID \
4536QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
4537#define PARAM_BASE_PERIOD \
4538QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD
4539#define PARAM_MAX_AP_PER_SCAN \
4540QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN
4541#define PARAM_RPT_THRHLD_PERCENT \
4542QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT
4543#define PARAM_RPT_THRHLD_NUM_SCANS \
4544QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS
4545#define PARAM_NUM_BUCKETS \
4546QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS
4547
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304548static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304549 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304550 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304551{
Dino Myclee8843b32014-07-04 14:21:45 +05304552 tpSirEXTScanStartReqParams pReqMsg = NULL;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304553 struct net_device *dev = wdev->netdev;
4554 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4555 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4556 struct nlattr *tb[PARAM_MAX + 1];
4557 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304558 eHalStatus status;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304559 tANI_U32 request_id;
4560 struct hdd_ext_scan_context *context;
4561 unsigned long rc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304562
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304563 ENTER();
4564
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304565 if (VOS_FTM_MODE == hdd_get_conparam()) {
4566 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4567 return -EINVAL;
4568 }
4569
Dino Mycle6fb96c12014-06-10 11:52:40 +05304570 status = wlan_hdd_validate_context(pHddCtx);
4571 if (0 != status)
4572 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304573 return -EINVAL;
4574 }
Dino Myclee8843b32014-07-04 14:21:45 +05304575 /* check the EXTScan Capability */
4576 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4577 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4578 {
4579 hddLog(VOS_TRACE_LEVEL_ERROR,
4580 FL("EXTScan not enabled/supported by Firmware"));
4581 return -EINVAL;
4582 }
4583
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304584 if (nla_parse(tb, PARAM_MAX,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304585 data, dataLen,
4586 wlan_hdd_extscan_config_policy)) {
4587 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4588 return -EINVAL;
4589 }
4590
4591 /* Parse and fetch request Id */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304592 if (!tb[PARAM_REQUEST_ID]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304593 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4594 return -EINVAL;
4595 }
4596
Dino Myclee8843b32014-07-04 14:21:45 +05304597 pReqMsg = (tpSirEXTScanStartReqParams)
4598 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304599 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05304600 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
4601 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304602 }
4603
4604 pReqMsg->requestId = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304605 tb[PARAM_REQUEST_ID]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304606 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4607
4608 pReqMsg->sessionId = pAdapter->sessionId;
4609 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4610
4611 /* Parse and fetch base period */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304612 if (!tb[PARAM_BASE_PERIOD]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304613 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
4614 goto fail;
4615 }
4616 pReqMsg->basePeriod = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304617 tb[PARAM_BASE_PERIOD]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304618 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
4619 pReqMsg->basePeriod);
4620
4621 /* Parse and fetch max AP per scan */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304622 if (!tb[PARAM_MAX_AP_PER_SCAN]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304623 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
4624 goto fail;
4625 }
4626 pReqMsg->maxAPperScan = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304627 tb[PARAM_MAX_AP_PER_SCAN]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304628 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
4629 pReqMsg->maxAPperScan);
4630
4631 /* Parse and fetch report threshold */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304632 if (!tb[PARAM_RPT_THRHLD_PERCENT]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304633 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
4634 goto fail;
4635 }
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304636 pReqMsg->reportThresholdPercent = nla_get_u8(
4637 tb[PARAM_RPT_THRHLD_PERCENT]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304638 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304639 pReqMsg->reportThresholdPercent);
4640
4641 /* Parse and fetch report threshold num scans */
4642 if (!tb[PARAM_RPT_THRHLD_NUM_SCANS]) {
4643 hddLog(LOGE, FL("attr report_threshold num scans failed"));
4644 goto fail;
4645 }
4646 pReqMsg->reportThresholdNumScans = nla_get_u8(
4647 tb[PARAM_RPT_THRHLD_NUM_SCANS]);
4648 hddLog(LOG1, FL("Report Threshold num scans %d"),
4649 pReqMsg->reportThresholdNumScans);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304650
4651 /* Parse and fetch number of buckets */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304652 if (!tb[PARAM_NUM_BUCKETS]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304653 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
4654 goto fail;
4655 }
4656 pReqMsg->numBuckets = nla_get_u8(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304657 tb[PARAM_NUM_BUCKETS]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304658 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
4659 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
4660 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
4661 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
4662 }
4663 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
4664 pReqMsg->numBuckets);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304665
Dino Mycle6fb96c12014-06-10 11:52:40 +05304666 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
4667 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
4668 goto fail;
4669 }
4670
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304671 pReqMsg->homeAwayTime = pHddCtx->cfg_ini->nRestTimeConc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304672
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304673 if (hdd_extscan_start_fill_bucket_channel_spec(pHddCtx, pReqMsg, tb))
4674 goto fail;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304675
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304676 context = &pHddCtx->ext_scan_context;
4677 spin_lock(&hdd_context_lock);
4678 INIT_COMPLETION(context->response_event);
4679 context->request_id = request_id = pReqMsg->requestId;
4680 spin_unlock(&hdd_context_lock);
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304681
Dino Mycle6fb96c12014-06-10 11:52:40 +05304682 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
4683 if (!HAL_STATUS_SUCCESS(status)) {
4684 hddLog(VOS_TRACE_LEVEL_ERROR,
4685 FL("sme_EXTScanStart failed(err=%d)"), status);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304686 goto fail;
4687 }
4688
4689 /* request was sent -- wait for the response */
4690 rc = wait_for_completion_timeout(&context->response_event,
4691 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4692
4693 if (!rc) {
4694 hddLog(LOGE, FL("sme_ExtScanStart timed out"));
4695 retval = -ETIMEDOUT;
4696 } else {
4697 spin_lock(&hdd_context_lock);
4698 if (context->request_id == request_id)
4699 retval = context->response_status;
4700 else
4701 retval = -EINVAL;
4702 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304703 }
4704
Dino Myclee8843b32014-07-04 14:21:45 +05304705 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304706 EXIT();
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304707 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304708
4709fail:
4710 vos_mem_free(pReqMsg);
4711 return -EINVAL;
4712}
4713
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304714/*
4715 * done with short names for the global vendor params
4716 * used by wlan_hdd_cfg80211_extscan_start()
4717 */
4718#undef PARAM_MAX
4719#undef PARAM_REQUEST_ID
4720#undef PARAM_BASE_PERIOD
4721#undef PARAMS_MAX_AP_PER_SCAN
4722#undef PARAMS_RPT_THRHLD_PERCENT
4723#undef PARAMS_RPT_THRHLD_NUM_SCANS
4724#undef PARAMS_NUM_BUCKETS
4725
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304726static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
4727 struct wireless_dev *wdev,
4728 const void *data, int dataLen)
4729{
4730 int ret = 0;
4731
4732 vos_ssr_protect(__func__);
4733 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
4734 vos_ssr_unprotect(__func__);
4735
4736 return ret;
4737}
4738
4739static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304740 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304741 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304742{
Dino Myclee8843b32014-07-04 14:21:45 +05304743 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304744 struct net_device *dev = wdev->netdev;
4745 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4746 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4747 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4748 eHalStatus status;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304749 int retval;
4750 unsigned long rc;
4751 struct hdd_ext_scan_context *context;
4752 tANI_U32 request_id;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304753
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304754 ENTER();
4755
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304756 if (VOS_FTM_MODE == hdd_get_conparam()) {
4757 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4758 return -EINVAL;
4759 }
4760
Dino Mycle6fb96c12014-06-10 11:52:40 +05304761 status = wlan_hdd_validate_context(pHddCtx);
4762 if (0 != status)
4763 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304764 return -EINVAL;
4765 }
Dino Myclee8843b32014-07-04 14:21:45 +05304766 /* check the EXTScan Capability */
4767 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4768 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4769 {
4770 hddLog(VOS_TRACE_LEVEL_ERROR,
4771 FL("EXTScan not enabled/supported by Firmware"));
4772 return -EINVAL;
4773 }
4774
Dino Mycle6fb96c12014-06-10 11:52:40 +05304775 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4776 data, dataLen,
4777 wlan_hdd_extscan_config_policy)) {
4778 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4779 return -EINVAL;
4780 }
4781
4782 /* Parse and fetch request Id */
4783 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4784 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4785 return -EINVAL;
4786 }
4787
Dino Myclee8843b32014-07-04 14:21:45 +05304788 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304789 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304790 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304791
Dino Myclee8843b32014-07-04 14:21:45 +05304792 reqMsg.sessionId = pAdapter->sessionId;
4793 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304794
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304795 context = &pHddCtx->ext_scan_context;
4796 spin_lock(&hdd_context_lock);
4797 INIT_COMPLETION(context->response_event);
4798 context->request_id = request_id = reqMsg.sessionId;
4799 spin_unlock(&hdd_context_lock);
4800
Dino Myclee8843b32014-07-04 14:21:45 +05304801 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304802 if (!HAL_STATUS_SUCCESS(status)) {
4803 hddLog(VOS_TRACE_LEVEL_ERROR,
4804 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304805 return -EINVAL;
4806 }
4807
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304808 /* request was sent -- wait for the response */
4809 rc = wait_for_completion_timeout(&context->response_event,
4810 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4811
4812 if (!rc) {
4813 hddLog(LOGE, FL("sme_ExtScanStop timed out"));
4814 retval = -ETIMEDOUT;
4815 } else {
4816 spin_lock(&hdd_context_lock);
4817 if (context->request_id == request_id)
4818 retval = context->response_status;
4819 else
4820 retval = -EINVAL;
4821 spin_unlock(&hdd_context_lock);
4822 }
4823
4824 return retval;
4825
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304826 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304827 return 0;
4828}
4829
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304830static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
4831 struct wireless_dev *wdev,
4832 const void *data, int dataLen)
4833{
4834 int ret = 0;
4835
4836 vos_ssr_protect(__func__);
4837 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
4838 vos_ssr_unprotect(__func__);
4839
4840 return ret;
4841}
4842
4843static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304844 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304845 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304846{
Dino Myclee8843b32014-07-04 14:21:45 +05304847 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304848 struct net_device *dev = wdev->netdev;
4849 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4850 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4851 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4852 eHalStatus status;
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304853 struct hdd_ext_scan_context *context;
4854 tANI_U32 request_id;
4855 unsigned long rc;
4856 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304857
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304858 ENTER();
4859
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304860 if (VOS_FTM_MODE == hdd_get_conparam()) {
4861 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4862 return -EINVAL;
4863 }
4864
Dino Mycle6fb96c12014-06-10 11:52:40 +05304865 status = wlan_hdd_validate_context(pHddCtx);
4866 if (0 != status)
4867 {
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304868 hddLog(LOGE, FL("HDD context is not valid"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304869 return -EINVAL;
4870 }
Dino Myclee8843b32014-07-04 14:21:45 +05304871 /* check the EXTScan Capability */
4872 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4873 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4874 {
4875 hddLog(VOS_TRACE_LEVEL_ERROR,
4876 FL("EXTScan not enabled/supported by Firmware"));
4877 return -EINVAL;
4878 }
4879
Dino Mycle6fb96c12014-06-10 11:52:40 +05304880 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4881 data, dataLen,
4882 wlan_hdd_extscan_config_policy)) {
4883 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4884 return -EINVAL;
4885 }
4886
4887 /* Parse and fetch request Id */
4888 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4889 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4890 return -EINVAL;
4891 }
4892
Dino Myclee8843b32014-07-04 14:21:45 +05304893 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304894 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304895 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304896
Dino Myclee8843b32014-07-04 14:21:45 +05304897 reqMsg.sessionId = pAdapter->sessionId;
4898 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304899
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304900 context = &pHddCtx->ext_scan_context;
4901 spin_lock(&hdd_context_lock);
4902 INIT_COMPLETION(context->response_event);
4903 context->request_id = request_id = reqMsg.requestId;
4904 spin_unlock(&hdd_context_lock);
4905
Dino Myclee8843b32014-07-04 14:21:45 +05304906 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304907 if (!HAL_STATUS_SUCCESS(status)) {
4908 hddLog(VOS_TRACE_LEVEL_ERROR,
4909 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304910 return -EINVAL;
4911 }
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304912
4913 /* request was sent -- wait for the response */
4914 rc = wait_for_completion_timeout(&context->response_event,
4915 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4916 if (!rc) {
4917 hddLog(LOGE, FL("sme_ResetBssHotlist timed out"));
4918 retval = -ETIMEDOUT;
4919 } else {
4920 spin_lock(&hdd_context_lock);
4921 if (context->request_id == request_id)
4922 retval = context->response_status;
4923 else
4924 retval = -EINVAL;
4925 spin_unlock(&hdd_context_lock);
4926 }
4927
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304928 EXIT();
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304929 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304930}
4931
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304932static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
4933 struct wireless_dev *wdev,
4934 const void *data, int dataLen)
4935{
4936 int ret = 0;
4937
4938 vos_ssr_protect(__func__);
4939 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
4940 vos_ssr_unprotect(__func__);
4941
4942 return ret;
4943}
Dino Mycle6fb96c12014-06-10 11:52:40 +05304944#endif /* WLAN_FEATURE_EXTSCAN */
4945
Atul Mittal115287b2014-07-08 13:26:33 +05304946/*EXT TDLS*/
4947static const struct nla_policy
4948wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
4949{
4950 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4951 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
4952 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
4953 {.type = NLA_S32 },
4954 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
4955 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
4956
4957};
4958
4959static const struct nla_policy
4960wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
4961{
4962 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4963
4964};
4965
4966static const struct nla_policy
4967wlan_hdd_tdls_config_state_change_policy[
4968 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
4969{
4970 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
4971 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
4972 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304973 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
4974 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
4975 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304976
4977};
4978
4979static const struct nla_policy
4980wlan_hdd_tdls_config_get_status_policy[
4981 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
4982{
4983 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
4984 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
4985 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304986 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
4987 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
4988 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304989
4990};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304991
4992static const struct nla_policy
4993wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
4994{
4995 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
4996};
4997
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304998static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304999 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305000 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305001 int data_len)
5002{
5003
5004 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5005 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
5006
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305007 ENTER();
5008
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305009 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305010 return -EINVAL;
5011 }
5012 if (FALSE == pHddCtx->cfg_ini->enableMacSpoofing) {
Ratheesh S P36dbc932015-08-07 14:28:57 +05305013 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN disabled in ini"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305014 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05305015 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305016 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
Ratheesh S P36dbc932015-08-07 14:28:57 +05305017 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN not supported by FW"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305018 return -ENOTSUPP;
5019 }
5020
5021 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
5022 data, data_len, wlan_hdd_mac_config)) {
5023 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5024 return -EINVAL;
5025 }
5026
5027 /* Parse and fetch mac address */
5028 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
5029 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5030 return -EINVAL;
5031 }
5032
5033 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
5034 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
5035 VOS_MAC_ADDR_LAST_3_BYTES);
5036
Siddharth Bhal76972212014-10-15 16:22:51 +05305037 pHddCtx->spoofMacAddr.isEnabled = TRUE;
5038
5039 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305040 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
5041 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05305042 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
5043 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
5044 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
5045 {
5046 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
5047 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
5048 VOS_MAC_ADDRESS_LEN);
5049 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305050 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305051
Siddharth Bhal76972212014-10-15 16:22:51 +05305052 if (VOS_STATUS_SUCCESS != hdd_processSpoofMacAddrRequest(pHddCtx))
5053 {
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305054 hddLog(LOGE, FL("Failed to send Spoof Mac Addr to FW"));
5055 }
5056
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305057 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305058 return 0;
5059}
5060
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305061static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
5062 struct wireless_dev *wdev,
5063 const void *data,
5064 int data_len)
5065{
5066 int ret = 0;
5067
5068 vos_ssr_protect(__func__);
5069 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
5070 vos_ssr_unprotect(__func__);
5071
5072 return ret;
5073}
5074
5075static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305076 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305077 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305078 int data_len)
5079{
5080 u8 peer[6] = {0};
5081 struct net_device *dev = wdev->netdev;
5082 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5083 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5084 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
5085 eHalStatus ret;
5086 tANI_S32 state;
5087 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305088 tANI_S32 global_operating_class = 0;
5089 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05305090 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305091 int retVal;
5092
5093 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305094
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305095 if (!pAdapter) {
5096 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5097 return -EINVAL;
5098 }
5099
Atul Mittal115287b2014-07-08 13:26:33 +05305100 ret = wlan_hdd_validate_context(pHddCtx);
5101 if (0 != ret) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305102 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305103 return -EINVAL;
5104 }
5105 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305106 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305107 return -ENOTSUPP;
5108 }
5109 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
5110 data, data_len,
5111 wlan_hdd_tdls_config_get_status_policy)) {
5112 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5113 return -EINVAL;
5114 }
5115
5116 /* Parse and fetch mac address */
5117 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
5118 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5119 return -EINVAL;
5120 }
5121
5122 memcpy(peer, nla_data(
5123 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
5124 sizeof(peer));
5125 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5126
Konamki, Sreelakshmiabb59ed2015-06-12 12:13:23 +05305127 wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
Atul Mittal115287b2014-07-08 13:26:33 +05305128
Atul Mittal115287b2014-07-08 13:26:33 +05305129 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305130 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05305131 NLMSG_HDRLEN);
5132
5133 if (!skb) {
5134 hddLog(VOS_TRACE_LEVEL_ERROR,
5135 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5136 return -EINVAL;
5137 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305138 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 +05305139 reason,
5140 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305141 global_operating_class,
5142 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05305143 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305144 if (nla_put_s32(skb,
5145 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
5146 state) ||
5147 nla_put_s32(skb,
5148 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
5149 reason) ||
5150 nla_put_s32(skb,
5151 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
5152 global_operating_class) ||
5153 nla_put_s32(skb,
5154 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
5155 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05305156
5157 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
5158 goto nla_put_failure;
5159 }
5160
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305161 retVal = cfg80211_vendor_cmd_reply(skb);
5162 EXIT();
5163 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05305164
5165nla_put_failure:
5166 kfree_skb(skb);
5167 return -EINVAL;
5168}
5169
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305170static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
5171 struct wireless_dev *wdev,
5172 const void *data,
5173 int data_len)
5174{
5175 int ret = 0;
5176
5177 vos_ssr_protect(__func__);
5178 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
5179 vos_ssr_unprotect(__func__);
5180
5181 return ret;
5182}
5183
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05305184static int wlan_hdd_cfg80211_exttdls_callback(
5185#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
5186 const tANI_U8* mac,
5187#else
5188 tANI_U8* mac,
5189#endif
Atul Mittal115287b2014-07-08 13:26:33 +05305190 tANI_S32 state,
5191 tANI_S32 reason,
5192 void *ctx)
5193{
5194 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05305195 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305196 tANI_S32 global_operating_class = 0;
5197 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305198 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05305199
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305200 ENTER();
5201
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305202 if (!pAdapter) {
5203 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5204 return -EINVAL;
5205 }
5206
5207 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05305208 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305209 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305210 return -EINVAL;
5211 }
5212
5213 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305214 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305215 return -ENOTSUPP;
5216 }
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05305217 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
5218#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
5219 NULL,
5220#endif
Atul Mittal115287b2014-07-08 13:26:33 +05305221 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
5222 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
5223 GFP_KERNEL);
5224
5225 if (!skb) {
5226 hddLog(VOS_TRACE_LEVEL_ERROR,
5227 FL("cfg80211_vendor_event_alloc failed"));
5228 return -EINVAL;
5229 }
5230 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305231 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
5232 reason,
5233 state,
5234 global_operating_class,
5235 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05305236 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
5237 MAC_ADDR_ARRAY(mac));
5238
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305239 if (nla_put(skb,
5240 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
5241 VOS_MAC_ADDR_SIZE, mac) ||
5242 nla_put_s32(skb,
5243 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
5244 state) ||
5245 nla_put_s32(skb,
5246 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
5247 reason) ||
5248 nla_put_s32(skb,
5249 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
5250 channel) ||
5251 nla_put_s32(skb,
5252 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
5253 global_operating_class)
5254 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05305255 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
5256 goto nla_put_failure;
5257 }
5258
5259 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305260 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05305261 return (0);
5262
5263nla_put_failure:
5264 kfree_skb(skb);
5265 return -EINVAL;
5266}
5267
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305268static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305269 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305270 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305271 int data_len)
5272{
5273 u8 peer[6] = {0};
5274 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05305275 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5276 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
5277 eHalStatus status;
5278 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305279 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305280 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305281
5282 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305283
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305284 if (!dev) {
5285 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
5286 return -EINVAL;
5287 }
5288
5289 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5290 if (!pAdapter) {
5291 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5292 return -EINVAL;
5293 }
5294
Atul Mittal115287b2014-07-08 13:26:33 +05305295 status = wlan_hdd_validate_context(pHddCtx);
5296 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305297 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305298 return -EINVAL;
5299 }
5300 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305301 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305302 return -ENOTSUPP;
5303 }
5304 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
5305 data, data_len,
5306 wlan_hdd_tdls_config_enable_policy)) {
5307 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5308 return -EINVAL;
5309 }
5310
5311 /* Parse and fetch mac address */
5312 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
5313 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5314 return -EINVAL;
5315 }
5316
5317 memcpy(peer, nla_data(
5318 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
5319 sizeof(peer));
5320 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5321
5322 /* Parse and fetch channel */
5323 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
5324 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
5325 return -EINVAL;
5326 }
5327 pReqMsg.channel = nla_get_s32(
5328 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
5329 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
5330
5331 /* Parse and fetch global operating class */
5332 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
5333 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
5334 return -EINVAL;
5335 }
5336 pReqMsg.global_operating_class = nla_get_s32(
5337 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
5338 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
5339 pReqMsg.global_operating_class);
5340
5341 /* Parse and fetch latency ms */
5342 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
5343 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
5344 return -EINVAL;
5345 }
5346 pReqMsg.max_latency_ms = nla_get_s32(
5347 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
5348 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
5349 pReqMsg.max_latency_ms);
5350
5351 /* Parse and fetch required bandwidth kbps */
5352 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
5353 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
5354 return -EINVAL;
5355 }
5356
5357 pReqMsg.min_bandwidth_kbps = nla_get_s32(
5358 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
5359 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
5360 pReqMsg.min_bandwidth_kbps);
5361
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305362 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05305363 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05305364 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305365 wlan_hdd_cfg80211_exttdls_callback);
5366
5367 EXIT();
5368 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05305369}
5370
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305371static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
5372 struct wireless_dev *wdev,
5373 const void *data,
5374 int data_len)
5375{
5376 int ret = 0;
5377
5378 vos_ssr_protect(__func__);
5379 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
5380 vos_ssr_unprotect(__func__);
5381
5382 return ret;
5383}
5384
5385static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305386 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305387 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305388 int data_len)
5389{
5390 u8 peer[6] = {0};
5391 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05305392 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5393 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
5394 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305395 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305396 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305397
5398 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305399
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305400 if (!dev) {
5401 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
5402 return -EINVAL;
5403 }
5404
5405 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5406 if (!pAdapter) {
5407 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
5408 return -EINVAL;
5409 }
5410
Atul Mittal115287b2014-07-08 13:26:33 +05305411 status = wlan_hdd_validate_context(pHddCtx);
5412 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305413 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305414 return -EINVAL;
5415 }
5416 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305417 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305418 return -ENOTSUPP;
5419 }
5420 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
5421 data, data_len,
5422 wlan_hdd_tdls_config_disable_policy)) {
5423 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5424 return -EINVAL;
5425 }
5426 /* Parse and fetch mac address */
5427 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
5428 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5429 return -EINVAL;
5430 }
5431
5432 memcpy(peer, nla_data(
5433 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
5434 sizeof(peer));
5435 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5436
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305437 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
5438
5439 EXIT();
5440 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05305441}
5442
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305443static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
5444 struct wireless_dev *wdev,
5445 const void *data,
5446 int data_len)
5447{
5448 int ret = 0;
5449
5450 vos_ssr_protect(__func__);
5451 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
5452 vos_ssr_unprotect(__func__);
5453
5454 return ret;
5455}
5456
Dasari Srinivas7875a302014-09-26 17:50:57 +05305457static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305458__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05305459 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305460 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05305461{
5462 struct net_device *dev = wdev->netdev;
5463 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5464 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5465 struct sk_buff *skb = NULL;
5466 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305467 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305468
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305469 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305470
5471 ret = wlan_hdd_validate_context(pHddCtx);
5472 if (0 != ret)
5473 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305474 return ret;
5475 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305476 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
5477 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
5478 fset |= WIFI_FEATURE_INFRA;
5479 }
5480
5481 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
5482 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
5483 fset |= WIFI_FEATURE_INFRA_5G;
5484 }
5485
5486#ifdef WLAN_FEATURE_P2P
5487 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
5488 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
5489 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
5490 fset |= WIFI_FEATURE_P2P;
5491 }
5492#endif
5493
5494 /* Soft-AP is supported currently by default */
5495 fset |= WIFI_FEATURE_SOFT_AP;
5496
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05305497 /* HOTSPOT is a supplicant feature, enable it by default */
5498 fset |= WIFI_FEATURE_HOTSPOT;
5499
Dasari Srinivas7875a302014-09-26 17:50:57 +05305500#ifdef WLAN_FEATURE_EXTSCAN
5501 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
5502 sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) {
5503 hddLog(LOG1, FL("EXTScan is supported by firmware"));
5504 fset |= WIFI_FEATURE_EXTSCAN;
5505 }
5506#endif
5507
Dasari Srinivas7875a302014-09-26 17:50:57 +05305508 if (sme_IsFeatureSupportedByFW(NAN)) {
5509 hddLog(LOG1, FL("NAN is supported by firmware"));
5510 fset |= WIFI_FEATURE_NAN;
5511 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305512
5513 /* D2D RTT is not supported currently by default */
5514 if (sme_IsFeatureSupportedByFW(RTT)) {
5515 hddLog(LOG1, FL("RTT is supported by firmware"));
5516 fset |= WIFI_FEATURE_D2AP_RTT;
5517 }
5518
5519#ifdef FEATURE_WLAN_BATCH_SCAN
5520 if (fset & WIFI_FEATURE_EXTSCAN) {
5521 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
5522 fset &= ~WIFI_FEATURE_BATCH_SCAN;
5523 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
5524 hddLog(LOG1, FL("Batch scan is supported by firmware"));
5525 fset |= WIFI_FEATURE_BATCH_SCAN;
5526 }
5527#endif
5528
5529#ifdef FEATURE_WLAN_SCAN_PNO
5530 if (pHddCtx->cfg_ini->configPNOScanSupport &&
5531 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
5532 hddLog(LOG1, FL("PNO is supported by firmware"));
5533 fset |= WIFI_FEATURE_PNO;
5534 }
5535#endif
5536
5537 /* STA+STA is supported currently by default */
5538 fset |= WIFI_FEATURE_ADDITIONAL_STA;
5539
5540#ifdef FEATURE_WLAN_TDLS
5541 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
5542 sme_IsFeatureSupportedByFW(TDLS)) {
5543 hddLog(LOG1, FL("TDLS is supported by firmware"));
5544 fset |= WIFI_FEATURE_TDLS;
5545 }
5546
5547 /* TDLS_OFFCHANNEL is not supported currently by default */
5548#endif
5549
5550#ifdef WLAN_AP_STA_CONCURRENCY
5551 /* AP+STA concurrency is supported currently by default */
5552 fset |= WIFI_FEATURE_AP_STA;
5553#endif
5554
Mukul Sharma5add0532015-08-17 15:57:47 +05305555#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5556 fset |= WIFI_FEATURE_LINK_LAYER_STATS;
5557 hddLog(LOG1, FL("Link layer stats is supported by driver"));
5558#endif
5559
Dasari Srinivas7875a302014-09-26 17:50:57 +05305560 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
5561 NLMSG_HDRLEN);
5562
5563 if (!skb) {
5564 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5565 return -EINVAL;
5566 }
5567 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
5568
5569 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
5570 hddLog(LOGE, FL("nla put fail"));
5571 goto nla_put_failure;
5572 }
5573
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305574 ret = cfg80211_vendor_cmd_reply(skb);
5575 EXIT();
5576 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305577
5578nla_put_failure:
5579 kfree_skb(skb);
5580 return -EINVAL;
5581}
5582
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305583static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305584wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
5585 struct wireless_dev *wdev,
5586 const void *data, int data_len)
5587{
5588 int ret = 0;
5589
5590 vos_ssr_protect(__func__);
5591 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
5592 vos_ssr_unprotect(__func__);
5593
5594 return ret;
5595}
5596
Sachin Ahujac08f72a2015-09-22 15:25:47 +05305597
5598static const struct
5599nla_policy
5600qca_wlan_vendor_wifi_logger_get_ring_data_policy
5601[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1] = {
5602 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]
5603 = {.type = NLA_U32 },
5604};
5605
5606static int
5607 __wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy,
5608 struct wireless_dev *wdev,
5609 const void *data,
5610 int data_len)
5611{
5612 int ret;
5613 VOS_STATUS status;
5614 uint32_t ring_id;
5615 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5616 struct nlattr *tb
5617 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1];
5618
5619 ENTER();
5620
5621 ret = wlan_hdd_validate_context(hdd_ctx);
5622 if (0 != ret) {
5623 return ret;
5624 }
5625
5626 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX,
5627 data, data_len,
5628 qca_wlan_vendor_wifi_logger_get_ring_data_policy)) {
5629 hddLog(LOGE, FL("Invalid attribute"));
5630 return -EINVAL;
5631 }
5632
5633 /* Parse and fetch ring id */
5634 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]) {
5635 hddLog(LOGE, FL("attr ATTR failed"));
5636 return -EINVAL;
5637 }
5638
5639 ring_id = nla_get_u32(
5640 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]);
5641
5642 hddLog(LOG1, FL("Bug report triggered by framework"));
5643
5644 status = vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
5645 WLAN_LOG_INDICATOR_FRAMEWORK,
5646 WLAN_LOG_REASON_CODE_FRAMEWORK,
Abhishek Singh837adf22015-10-01 17:37:37 +05305647 TRUE, TRUE
Sachin Ahujac08f72a2015-09-22 15:25:47 +05305648 );
5649 if (VOS_STATUS_SUCCESS != status) {
5650 hddLog(LOGE, FL("Failed to trigger bug report"));
5651
5652 return -EINVAL;
5653 }
5654
5655 return 0;
5656
5657
5658}
5659
5660
5661static int
5662 wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy,
5663 struct wireless_dev *wdev,
5664 const void *data,
5665 int data_len)
5666{
5667 int ret = 0;
5668
5669 vos_ssr_protect(__func__);
5670 ret = __wlan_hdd_cfg80211_wifi_logger_get_ring_data(wiphy,
5671 wdev, data, data_len);
5672 vos_ssr_unprotect(__func__);
5673
5674 return ret;
5675
5676}
5677
5678
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305679static int
5680__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305681 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305682 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305683{
5684 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
5685 uint8_t i, feature_sets, max_feature_sets;
5686 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX + 1];
5687 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305688 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5689 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305690
5691 ENTER();
5692
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305693 ret = wlan_hdd_validate_context(pHddCtx);
5694 if (0 != ret)
5695 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305696 return ret;
5697 }
5698
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305699 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX,
5700 data, data_len, NULL)) {
5701 hddLog(LOGE, FL("Invalid ATTR"));
5702 return -EINVAL;
5703 }
5704
5705 /* Parse and fetch max feature set */
5706 if (!tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
5707 hddLog(LOGE, FL("Attr max feature set size failed"));
5708 return -EINVAL;
5709 }
5710 max_feature_sets = nla_get_u32(
5711 tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
5712 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
5713
5714 /* Fill feature combination matrix */
5715 feature_sets = 0;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305716 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5717 WIFI_FEATURE_P2P;
5718
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305719 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5720 WIFI_FEATURE_SOFT_AP;
5721
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305722 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
5723 WIFI_FEATURE_SOFT_AP;
5724
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305725 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5726 WIFI_FEATURE_SOFT_AP |
5727 WIFI_FEATURE_P2P;
5728
5729 /* Add more feature combinations here */
5730
5731 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
5732 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
5733 hddLog(LOG1, "Feature set matrix");
5734 for (i = 0; i < feature_sets; i++)
5735 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
5736
5737 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
5738 sizeof(u32) * feature_sets +
5739 NLMSG_HDRLEN);
5740
5741 if (reply_skb) {
5742 if (nla_put_u32(reply_skb,
5743 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
5744 feature_sets) ||
5745 nla_put(reply_skb,
5746 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
5747 sizeof(u32) * feature_sets, feature_set_matrix)) {
5748 hddLog(LOGE, FL("nla put fail"));
5749 kfree_skb(reply_skb);
5750 return -EINVAL;
5751 }
5752
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305753 ret = cfg80211_vendor_cmd_reply(reply_skb);
5754 EXIT();
5755 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305756 }
5757 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
5758 return -ENOMEM;
5759
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305760}
5761
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305762static int
5763wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
5764 struct wireless_dev *wdev,
5765 const void *data, int data_len)
5766{
5767 int ret = 0;
5768
5769 vos_ssr_protect(__func__);
5770 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
5771 data_len);
5772 vos_ssr_unprotect(__func__);
5773
5774 return ret;
5775}
5776
c_manjeecfd1efb2015-09-25 19:32:34 +05305777
5778static int
5779__wlan_hdd_cfg80211_get_fw_mem_dump(struct wiphy *wiphy,
5780 struct wireless_dev *wdev,
5781 const void *data, int data_len)
5782{
5783 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5784 int ret;
5785 ENTER();
5786
5787 ret = wlan_hdd_validate_context(pHddCtx);
5788 if (0 != ret)
5789 {
5790 return ret;
5791 }
5792
5793 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
5794 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
5795 {
5796 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
5797 return -EINVAL;
5798 }
5799 /*call common API for FW mem dump req*/
5800 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
5801
5802 EXIT();
5803 return ret;
5804}
5805
5806/**
5807 * wlan_hdd_cfg80211_get_fw_mem_dump() - Get FW memory dump
5808 * @wiphy: pointer to wireless wiphy structure.
5809 * @wdev: pointer to wireless_dev structure.
5810 * @data: Pointer to the NL data.
5811 * @data_len:Length of @data
5812 *
5813 * This is called when wlan driver needs to get the firmware memory dump
5814 * via vendor specific command.
5815 *
5816 * Return: 0 on success, error number otherwise.
5817 */
5818
5819static int
5820wlan_hdd_cfg80211_get_fw_mem_dump(struct wiphy *wiphy,
5821 struct wireless_dev *wdev,
5822 const void *data, int data_len)
Sushant Kaushik8e644982015-09-23 12:18:54 +05305823{
5824 int ret = 0;
5825 vos_ssr_protect(__func__);
5826 ret = __wlan_hdd_cfg80211_get_fw_mem_dump(wiphy, wdev, data,
5827 data_len);
5828 vos_ssr_unprotect(__func__);
5829 return ret;
5830}
c_manjeecfd1efb2015-09-25 19:32:34 +05305831
Sushant Kaushik8e644982015-09-23 12:18:54 +05305832static const struct
5833nla_policy
5834qca_wlan_vendor_wifi_logger_start_policy
5835[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1] = {
5836 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]
5837 = {.type = NLA_U32 },
5838 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]
5839 = {.type = NLA_U32 },
5840 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]
5841 = {.type = NLA_U32 },
5842};
5843
5844/**
5845 * __wlan_hdd_cfg80211_wifi_logger_start() - This function is used to enable
5846 * or disable the collection of packet statistics from the firmware
5847 * @wiphy: WIPHY structure pointer
5848 * @wdev: Wireless device structure pointer
5849 * @data: Pointer to the data received
5850 * @data_len: Length of the data received
5851 *
5852 * This function is used to enable or disable the collection of packet
5853 * statistics from the firmware
5854 *
5855 * Return: 0 on success and errno on failure
5856 */
5857static int __wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy,
5858 struct wireless_dev *wdev,
5859 const void *data,
5860 int data_len)
5861{
5862 eHalStatus status;
5863 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5864 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1];
5865 tAniWifiStartLog start_log;
5866
5867 status = wlan_hdd_validate_context(hdd_ctx);
5868 if (0 != status) {
5869 return -EINVAL;
5870 }
5871
5872 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX,
5873 data, data_len,
5874 qca_wlan_vendor_wifi_logger_start_policy)) {
5875 hddLog(LOGE, FL("Invalid attribute"));
5876 return -EINVAL;
5877 }
5878
5879 /* Parse and fetch ring id */
5880 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]) {
5881 hddLog(LOGE, FL("attr ATTR failed"));
5882 return -EINVAL;
5883 }
5884 start_log.ringId = nla_get_u32(
5885 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]);
5886 hddLog(LOG1, FL("Ring ID=%d"), start_log.ringId);
5887
5888 /* Parse and fetch verbose level */
5889 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]) {
5890 hddLog(LOGE, FL("attr verbose_level failed"));
5891 return -EINVAL;
5892 }
5893 start_log.verboseLevel = nla_get_u32(
5894 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]);
5895 hddLog(LOG1, FL("verbose_level=%d"), start_log.verboseLevel);
5896
5897 /* Parse and fetch flag */
5898 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]) {
5899 hddLog(LOGE, FL("attr flag failed"));
5900 return -EINVAL;
5901 }
5902 start_log.flag = nla_get_u32(
5903 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]);
5904 hddLog(LOG1, FL("flag=%d"), start_log.flag);
5905
5906 if ((RING_ID_PER_PACKET_STATS == start_log.ringId) &&
Sushant Kaushik33200572015-08-05 16:46:20 +05305907 (!hdd_ctx->cfg_ini->wlanPerPktStatsLogEnable ||
5908 !vos_isPktStatsEnabled()))
5909
Sushant Kaushik8e644982015-09-23 12:18:54 +05305910 {
5911 hddLog(LOGE, FL("per pkt stats not enabled"));
5912 return -EINVAL;
5913 }
Sushant Kaushik8e644982015-09-23 12:18:54 +05305914
Sushant Kaushik33200572015-08-05 16:46:20 +05305915 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
Sushant Kaushik8e644982015-09-23 12:18:54 +05305916 return 0;
5917}
5918
5919/**
5920 * wlan_hdd_cfg80211_wifi_logger_start() - Wrapper function used to enable
5921 * or disable the collection of packet statistics from the firmware
5922 * @wiphy: WIPHY structure pointer
5923 * @wdev: Wireless device structure pointer
5924 * @data: Pointer to the data received
5925 * @data_len: Length of the data received
5926 *
5927 * This function is used to enable or disable the collection of packet
5928 * statistics from the firmware
5929 *
5930 * Return: 0 on success and errno on failure
5931 */
5932static int wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy,
5933 struct wireless_dev *wdev,
5934 const void *data,
5935 int data_len)
c_manjeecfd1efb2015-09-25 19:32:34 +05305936{
5937 int ret = 0;
5938
5939 vos_ssr_protect(__func__);
Sushant Kaushik8e644982015-09-23 12:18:54 +05305940
5941 ret = __wlan_hdd_cfg80211_wifi_logger_start(wiphy,
5942 wdev, data, data_len);
c_manjeecfd1efb2015-09-25 19:32:34 +05305943 vos_ssr_unprotect(__func__);
5944
5945 return ret;
c_manjeecfd1efb2015-09-25 19:32:34 +05305946}
5947
5948
Agarwal Ashish738843c2014-09-25 12:27:56 +05305949static const struct nla_policy
5950wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
5951 +1] =
5952{
5953 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
5954};
5955
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305956static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305957 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305958 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305959 int data_len)
5960{
5961 struct net_device *dev = wdev->netdev;
5962 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5963 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5964 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5965 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
5966 eHalStatus status;
5967 u32 dfsFlag = 0;
5968
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305969 ENTER();
5970
Agarwal Ashish738843c2014-09-25 12:27:56 +05305971 status = wlan_hdd_validate_context(pHddCtx);
5972 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05305973 return -EINVAL;
5974 }
5975 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
5976 data, data_len,
5977 wlan_hdd_set_no_dfs_flag_config_policy)) {
5978 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5979 return -EINVAL;
5980 }
5981
5982 /* Parse and fetch required bandwidth kbps */
5983 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
5984 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
5985 return -EINVAL;
5986 }
5987
5988 dfsFlag = nla_get_u32(
5989 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
5990 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
5991 dfsFlag);
5992
5993 pHddCtx->disable_dfs_flag = dfsFlag;
5994
5995 sme_disable_dfs_channel(hHal, dfsFlag);
5996 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305997
5998 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05305999 return 0;
6000}
Atul Mittal115287b2014-07-08 13:26:33 +05306001
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306002static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
6003 struct wireless_dev *wdev,
6004 const void *data,
6005 int data_len)
6006{
6007 int ret = 0;
6008
6009 vos_ssr_protect(__func__);
6010 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
6011 vos_ssr_unprotect(__func__);
6012
6013 return ret;
6014
6015}
6016
Mukul Sharma2a271632014-10-13 14:59:01 +05306017const struct
6018nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
6019{
6020 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
6021 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
6022};
6023
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306024static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05306025 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05306026{
6027
6028 u8 bssid[6] = {0};
6029 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6030 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
6031 eHalStatus status = eHAL_STATUS_SUCCESS;
6032 v_U32_t isFwrRoamEnabled = FALSE;
6033 int ret;
6034
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306035 ENTER();
6036
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306037 ret = wlan_hdd_validate_context(pHddCtx);
6038 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306039 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05306040 }
6041
6042 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
6043 data, data_len,
6044 qca_wlan_vendor_attr);
6045 if (ret){
6046 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
6047 return -EINVAL;
6048 }
6049
6050 /* Parse and fetch Enable flag */
6051 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
6052 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
6053 return -EINVAL;
6054 }
6055
6056 isFwrRoamEnabled = nla_get_u32(
6057 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
6058
6059 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
6060
6061 /* Parse and fetch bssid */
6062 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
6063 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
6064 return -EINVAL;
6065 }
6066
6067 memcpy(bssid, nla_data(
6068 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
6069 sizeof(bssid));
6070 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
6071
6072 //Update roaming
6073 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306074 EXIT();
Mukul Sharma2a271632014-10-13 14:59:01 +05306075 return status;
6076}
6077
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306078static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
6079 struct wireless_dev *wdev, const void *data, int data_len)
6080{
6081 int ret = 0;
6082
6083 vos_ssr_protect(__func__);
6084 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
6085 vos_ssr_unprotect(__func__);
6086
6087 return ret;
6088}
6089
Sushant Kaushik847890c2015-09-28 16:05:17 +05306090static const struct
6091nla_policy
6092qca_wlan_vendor_get_wifi_info_policy[
6093 QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX +1] = {
6094 [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION] = {.type = NLA_U8 },
6095 [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION] = {.type = NLA_U8 },
6096};
6097
6098
6099/**
6100 * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info
6101 * @wiphy: pointer to wireless wiphy structure.
6102 * @wdev: pointer to wireless_dev structure.
6103 * @data: Pointer to the data to be passed via vendor interface
6104 * @data_len:Length of the data to be passed
6105 *
6106 * This is called when wlan driver needs to send wifi driver related info
6107 * (driver/fw version) to the user space application upon request.
6108 *
6109 * Return: Return the Success or Failure code.
6110 */
6111static int __wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
6112 struct wireless_dev *wdev,
6113 const void *data, int data_len)
6114{
6115 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6116 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX + 1];
6117 tSirVersionString version;
6118 uint32 version_len;
6119 uint8 attr;
6120 int status;
6121 struct sk_buff *reply_skb = NULL;
6122
6123 if (VOS_FTM_MODE == hdd_get_conparam()) {
6124 hddLog(LOGE, FL("Command not allowed in FTM mode"));
6125 return -EINVAL;
6126 }
6127
6128 status = wlan_hdd_validate_context(hdd_ctx);
6129 if (0 != status) {
6130 hddLog(LOGE, FL("HDD context is not valid"));
6131 return -EINVAL;
6132 }
6133
6134 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX, data,
6135 data_len, qca_wlan_vendor_get_wifi_info_policy)) {
6136 hddLog(LOGE, FL("WIFI_INFO_GET NL CMD parsing failed"));
6137 return -EINVAL;
6138 }
6139
6140 if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) {
6141 hddLog(LOG1, FL("Rcvd req for Driver version Driver version is %s"),
6142 QWLAN_VERSIONSTR);
6143 strlcpy(version, QWLAN_VERSIONSTR, sizeof(version));
6144 attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION;
6145 } else if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION]) {
6146 hddLog(LOG1, FL("Rcvd req for FW version FW version is %s"),
6147 hdd_ctx->fw_Version);
6148 strlcpy(version, hdd_ctx->fw_Version, sizeof(version));
6149 attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION;
6150 } else {
6151 hddLog(LOGE, FL("Invalid attribute in get wifi info request"));
6152 return -EINVAL;
6153 }
6154
6155 version_len = strlen(version);
6156 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
6157 version_len + NLA_HDRLEN + NLMSG_HDRLEN);
6158 if (!reply_skb) {
6159 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
6160 return -ENOMEM;
6161 }
6162
6163 if (nla_put(reply_skb, attr, version_len, version)) {
6164 hddLog(LOGE, FL("nla put fail"));
6165 kfree_skb(reply_skb);
6166 return -EINVAL;
6167 }
6168
6169 return cfg80211_vendor_cmd_reply(reply_skb);
6170}
6171
6172/**
6173 * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info
6174 * @wiphy: pointer to wireless wiphy structure.
6175 * @wdev: pointer to wireless_dev structure.
6176 * @data: Pointer to the data to be passed via vendor interface
6177 * @data_len:Length of the data to be passed
6178 * @data_len: Length of the data received
6179 *
6180 * This function is used to enable or disable the collection of packet
6181 * statistics from the firmware
6182 *
6183 * Return: 0 on success and errno on failure
6184 */
6185
6186static int
6187wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
6188 struct wireless_dev *wdev,
6189 const void *data, int data_len)
6190
6191
6192{
6193 int ret = 0;
6194
6195 vos_ssr_protect(__func__);
6196 ret = __wlan_hdd_cfg80211_get_wifi_info(wiphy,
6197 wdev, data, data_len);
6198 vos_ssr_unprotect(__func__);
6199
6200 return ret;
6201}
6202
6203
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306204/*
6205 * define short names for the global vendor params
6206 * used by __wlan_hdd_cfg80211_monitor_rssi()
6207 */
6208#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX
6209#define PARAM_REQUEST_ID QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID
6210#define PARAM_CONTROL QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CONTROL
6211#define PARAM_MIN_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MIN_RSSI
6212#define PARAM_MAX_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX_RSSI
6213
6214/**---------------------------------------------------------------------------
6215
6216 \brief hdd_rssi_monitor_start_done - callback to be executed when rssi
6217 monitor start is completed successfully.
6218
6219 \return - None
6220
6221 --------------------------------------------------------------------------*/
6222void hdd_rssi_monitor_start_done(void *fwRssiMonitorCbContext, VOS_STATUS status)
6223{
6224 hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext;
6225
6226 if (NULL == pHddCtx)
6227 {
6228 hddLog(VOS_TRACE_LEVEL_ERROR,
6229 "%s: HDD context is NULL",__func__);
6230 return;
6231 }
6232
6233 if (VOS_STATUS_SUCCESS == status)
6234 {
6235 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor start successful"));
6236 }
6237 else
6238 {
6239 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor start not successful"));
6240 }
6241
6242 return;
6243}
6244
6245/**---------------------------------------------------------------------------
6246
6247 \brief hdd_rssi_monitor_stop_done - callback to be executed when rssi monitor
6248 stop is completed successfully.
6249
6250 \return - None
6251
6252 --------------------------------------------------------------------------*/
6253void hdd_rssi_monitor_stop_done(void *fwRssiMonitorCbContext, VOS_STATUS status)
6254{
6255 hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext;
6256
6257 if (NULL == pHddCtx)
6258 {
6259 hddLog(VOS_TRACE_LEVEL_ERROR,
6260 "%s: HDD context is NULL",__func__);
6261 return;
6262 }
6263
6264 if (VOS_STATUS_SUCCESS == status)
6265 {
6266 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor stop successful"));
6267 }
6268 else
6269 {
6270 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor stop not successful"));
6271 }
6272
6273 return;
6274}
6275
6276/**
6277 * __wlan_hdd_cfg80211_monitor_rssi() - monitor rssi
6278 * @wiphy: Pointer to wireless phy
6279 * @wdev: Pointer to wireless device
6280 * @data: Pointer to data
6281 * @data_len: Data length
6282 *
6283 * Return: 0 on success, negative errno on failure
6284 */
6285
6286static int
6287__wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy,
6288 struct wireless_dev *wdev,
6289 const void *data,
6290 int data_len)
6291{
6292 struct net_device *dev = wdev->netdev;
6293 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6294 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6295 hdd_station_ctx_t *pHddStaCtx;
6296 struct nlattr *tb[PARAM_MAX + 1];
6297 tpSirRssiMonitorReq pReq;
6298 eHalStatus status;
6299 int ret;
6300 uint32_t control;
6301 static const struct nla_policy policy[PARAM_MAX + 1] = {
6302 [PARAM_REQUEST_ID] = { .type = NLA_U32 },
6303 [PARAM_CONTROL] = { .type = NLA_U32 },
6304 [PARAM_MIN_RSSI] = { .type = NLA_S8 },
6305 [PARAM_MAX_RSSI] = { .type = NLA_S8 },
6306 };
6307
6308 ENTER();
6309
6310 ret = wlan_hdd_validate_context(hdd_ctx);
6311 if (0 != ret) {
6312 return -EINVAL;
6313 }
6314
6315 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
6316 hddLog(LOGE, FL("Not in Connected state!"));
6317 return -ENOTSUPP;
6318 }
6319
6320 if (nla_parse(tb, PARAM_MAX, data, data_len, policy)) {
6321 hddLog(LOGE, FL("Invalid ATTR"));
6322 return -EINVAL;
6323 }
6324
6325 if (!tb[PARAM_REQUEST_ID]) {
6326 hddLog(LOGE, FL("attr request id failed"));
6327 return -EINVAL;
6328 }
6329
6330 if (!tb[PARAM_CONTROL]) {
6331 hddLog(LOGE, FL("attr control failed"));
6332 return -EINVAL;
6333 }
6334
6335 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6336
6337 pReq = vos_mem_malloc(sizeof(tSirRssiMonitorReq));
6338 if(NULL == pReq)
6339 {
6340 hddLog(LOGE,
6341 FL("vos_mem_alloc failed "));
6342 return eHAL_STATUS_FAILED_ALLOC;
6343 }
6344 vos_mem_set(pReq, sizeof(tSirRssiMonitorReq), 0);
6345
6346 pReq->requestId = nla_get_u32(tb[PARAM_REQUEST_ID]);
6347 pReq->sessionId = pAdapter->sessionId;
6348 pReq->rssiMonitorCbContext = hdd_ctx;
6349 control = nla_get_u32(tb[PARAM_CONTROL]);
6350 vos_mem_copy( &pReq->currentBssId, pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
6351
6352 hddLog(LOG1, FL("Request Id: %u Session_id: %d Control: %d"),
6353 pReq->requestId, pReq->sessionId, control);
6354
6355 if (control == QCA_WLAN_RSSI_MONITORING_START) {
6356 if (!tb[PARAM_MIN_RSSI]) {
6357 hddLog(LOGE, FL("attr min rssi failed"));
6358 return -EINVAL;
6359 }
6360
6361 if (!tb[PARAM_MAX_RSSI]) {
6362 hddLog(LOGE, FL("attr max rssi failed"));
6363 return -EINVAL;
6364 }
6365
6366 pReq->minRssi = nla_get_s8(tb[PARAM_MIN_RSSI]);
6367 pReq->maxRssi = nla_get_s8(tb[PARAM_MAX_RSSI]);
6368 pReq->rssiMonitorCallback = hdd_rssi_monitor_start_done;
6369
6370 if (!(pReq->minRssi < pReq->maxRssi)) {
6371 hddLog(LOGW, FL("min_rssi: %d must be less than max_rssi: %d"),
6372 pReq->minRssi, pReq->maxRssi);
6373 return -EINVAL;
6374 }
6375 hddLog(LOG1, FL("Min_rssi: %d Max_rssi: %d"),
6376 pReq->minRssi, pReq->maxRssi);
6377 status = sme_StartRssiMonitoring(hdd_ctx->hHal, pReq);
6378
6379 }
6380 else if (control == QCA_WLAN_RSSI_MONITORING_STOP) {
6381 pReq->rssiMonitorCallback = hdd_rssi_monitor_stop_done;
6382 status = sme_StopRssiMonitoring(hdd_ctx->hHal, pReq);
6383 }
6384 else {
6385 hddLog(LOGE, FL("Invalid control cmd: %d"), control);
6386 return -EINVAL;
6387 }
6388
6389 if (!HAL_STATUS_SUCCESS(status)) {
6390 hddLog(LOGE,
6391 FL("sme_set_rssi_monitoring failed(err=%d)"), status);
6392 return -EINVAL;
6393 }
6394
6395 return 0;
6396}
6397
6398/*
6399 * done with short names for the global vendor params
6400 * used by __wlan_hdd_cfg80211_monitor_rssi()
6401 */
6402#undef PARAM_MAX
6403#undef PARAM_CONTROL
6404#undef PARAM_REQUEST_ID
6405#undef PARAM_MAX_RSSI
6406#undef PARAM_MIN_RSSI
6407
6408/**
6409 * wlan_hdd_cfg80211_monitor_rssi() - SSR wrapper to rssi monitoring
6410 * @wiphy: wiphy structure pointer
6411 * @wdev: Wireless device structure pointer
6412 * @data: Pointer to the data received
6413 * @data_len: Length of @data
6414 *
6415 * Return: 0 on success; errno on failure
6416 */
6417static int
6418wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy, struct wireless_dev *wdev,
6419 const void *data, int data_len)
6420{
6421 int ret;
6422
6423 vos_ssr_protect(__func__);
6424 ret = __wlan_hdd_cfg80211_monitor_rssi(wiphy, wdev, data, data_len);
6425 vos_ssr_unprotect(__func__);
6426
6427 return ret;
6428}
6429
6430/**
6431 * hdd_rssi_threshold_breached_cb() - rssi breached NL event
6432 * @hddctx: HDD context
6433 * @data: rssi breached event data
6434 *
6435 * This function reads the rssi breached event %data and fill in the skb with
6436 * NL attributes and send up the NL event.
6437 * This callback execute in atomic context and must not invoke any
6438 * blocking calls.
6439 *
6440 * Return: none
6441 */
6442void hdd_rssi_threshold_breached_cb(void *hddctx,
6443 struct rssi_breach_event *data)
6444{
6445 hdd_context_t *pHddCtx = (hdd_context_t *)hddctx;
6446 int status;
6447 struct sk_buff *skb;
6448
6449 ENTER();
6450 status = wlan_hdd_validate_context(pHddCtx);
6451
6452 if (0 != status) {
6453 return;
6454 }
6455
6456 if (!data) {
6457 hddLog(LOGE, FL("data is null"));
6458 return;
6459 }
6460
6461 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
6462#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
6463 NULL,
6464#endif
6465 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
6466 QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX,
6467 GFP_KERNEL);
6468
6469 if (!skb) {
6470 hddLog(LOGE, FL("cfg80211_vendor_event_alloc failed"));
6471 return;
6472 }
6473
6474 hddLog(LOG1, "Req Id: %u Current rssi: %d",
6475 data->request_id, data->curr_rssi);
6476 hddLog(LOG1, "Current BSSID: "MAC_ADDRESS_STR,
6477 MAC_ADDR_ARRAY(data->curr_bssid.bytes));
6478
6479 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID,
6480 data->request_id) ||
6481 nla_put(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_BSSID,
6482 sizeof(data->curr_bssid), data->curr_bssid.bytes) ||
6483 nla_put_s8(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_RSSI,
6484 data->curr_rssi)) {
6485 hddLog(LOGE, FL("nla put fail"));
6486 goto fail;
6487 }
6488
6489 cfg80211_vendor_event(skb, GFP_KERNEL);
6490 return;
6491
6492fail:
6493 kfree_skb(skb);
6494 return;
6495}
6496
6497
6498
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306499/**
6500 * __wlan_hdd_cfg80211_setband() - set band
6501 * @wiphy: Pointer to wireless phy
6502 * @wdev: Pointer to wireless device
6503 * @data: Pointer to data
6504 * @data_len: Data length
6505 *
6506 * Return: 0 on success, negative errno on failure
6507 */
6508static int
6509__wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
6510 struct wireless_dev *wdev,
6511 const void *data,
6512 int data_len)
6513{
6514 struct net_device *dev = wdev->netdev;
6515 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6516 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
6517 int ret;
6518 static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1]
6519 = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 }};
6520
6521 ENTER();
6522
6523 ret = wlan_hdd_validate_context(hdd_ctx);
6524 if (0 != ret) {
6525 hddLog(LOGE, FL("HDD context is not valid"));
6526 return ret;
6527 }
6528
6529 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
6530 policy)) {
6531 hddLog(LOGE, FL("Invalid ATTR"));
6532 return -EINVAL;
6533 }
6534
6535 if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) {
6536 hddLog(LOGE, FL("attr QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE failed"));
6537 return -EINVAL;
6538 }
6539
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05306540 hdd_ctx->isSetBandByNL = TRUE;
6541 ret = hdd_setBand(dev,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306542 nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]));
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05306543 hdd_ctx->isSetBandByNL = FALSE;
6544
6545 EXIT();
6546 return ret;
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306547}
6548
6549/**
6550 * wlan_hdd_cfg80211_setband() - Wrapper to offload packets
6551 * @wiphy: wiphy structure pointer
6552 * @wdev: Wireless device structure pointer
6553 * @data: Pointer to the data received
6554 * @data_len: Length of @data
6555 *
6556 * Return: 0 on success; errno on failure
6557 */
6558static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
6559 struct wireless_dev *wdev,
6560 const void *data,
6561 int data_len)
6562{
6563 int ret = 0;
6564
6565 vos_ssr_protect(__func__);
6566 ret = __wlan_hdd_cfg80211_setband(wiphy,
6567 wdev, data, data_len);
6568 vos_ssr_unprotect(__func__);
6569
6570 return ret;
6571}
6572
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05306573#ifdef WLAN_FEATURE_OFFLOAD_PACKETS
6574/**
6575 * hdd_map_req_id_to_pattern_id() - map request id to pattern id
6576 * @hdd_ctx: HDD context
6577 * @request_id: [input] request id
6578 * @pattern_id: [output] pattern id
6579 *
6580 * This function loops through request id to pattern id array
6581 * if the slot is available, store the request id and return pattern id
6582 * if entry exists, return the pattern id
6583 *
6584 * Return: 0 on success and errno on failure
6585 */
6586static int hdd_map_req_id_to_pattern_id(hdd_context_t *hdd_ctx,
6587 uint32_t request_id,
6588 uint8_t *pattern_id)
6589{
6590 uint32_t i;
6591
6592 mutex_lock(&hdd_ctx->op_ctx.op_lock);
6593 for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++)
6594 {
6595 if (hdd_ctx->op_ctx.op_table[i].request_id == 0)
6596 {
6597 hdd_ctx->op_ctx.op_table[i].request_id = request_id;
6598 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6599 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6600 return 0;
6601 } else if (hdd_ctx->op_ctx.op_table[i].request_id ==
6602 request_id) {
6603 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6604 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6605 return 0;
6606 }
6607 }
6608 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6609 return -EINVAL;
6610}
6611
6612/**
6613 * hdd_unmap_req_id_to_pattern_id() - unmap request id to pattern id
6614 * @hdd_ctx: HDD context
6615 * @request_id: [input] request id
6616 * @pattern_id: [output] pattern id
6617 *
6618 * This function loops through request id to pattern id array
6619 * reset request id to 0 (slot available again) and
6620 * return pattern id
6621 *
6622 * Return: 0 on success and errno on failure
6623 */
6624static int hdd_unmap_req_id_to_pattern_id(hdd_context_t *hdd_ctx,
6625 uint32_t request_id,
6626 uint8_t *pattern_id)
6627{
6628 uint32_t i;
6629
6630 mutex_lock(&hdd_ctx->op_ctx.op_lock);
6631 for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++)
6632 {
6633 if (hdd_ctx->op_ctx.op_table[i].request_id == request_id)
6634 {
6635 hdd_ctx->op_ctx.op_table[i].request_id = 0;
6636 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6637 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6638 return 0;
6639 }
6640 }
6641 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6642 return -EINVAL;
6643}
6644
6645
6646/*
6647 * define short names for the global vendor params
6648 * used by __wlan_hdd_cfg80211_offloaded_packets()
6649 */
6650#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_MAX
6651#define PARAM_REQUEST_ID \
6652 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_REQUEST_ID
6653#define PARAM_CONTROL \
6654 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SENDING_CONTROL
6655#define PARAM_IP_PACKET \
6656 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_IP_PACKET_DATA
6657#define PARAM_SRC_MAC_ADDR \
6658 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SRC_MAC_ADDR
6659#define PARAM_DST_MAC_ADDR \
6660 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_DST_MAC_ADDR
6661#define PARAM_PERIOD QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_PERIOD
6662
6663/**
6664 * wlan_hdd_add_tx_ptrn() - add tx pattern
6665 * @adapter: adapter pointer
6666 * @hdd_ctx: hdd context
6667 * @tb: nl attributes
6668 *
6669 * This function reads the NL attributes and forms a AddTxPtrn message
6670 * posts it to SME.
6671 *
6672 */
6673static int
6674wlan_hdd_add_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx,
6675 struct nlattr **tb)
6676{
6677 struct sSirAddPeriodicTxPtrn *add_req;
6678 eHalStatus status;
6679 uint32_t request_id, ret, len;
6680 uint8_t pattern_id = 0;
6681 v_MACADDR_t dst_addr;
6682 uint16_t eth_type = htons(ETH_P_IP);
6683
6684 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(adapter)))
6685 {
6686 hddLog(LOGE, FL("Not in Connected state!"));
6687 return -ENOTSUPP;
6688 }
6689
6690 add_req = vos_mem_malloc(sizeof(*add_req));
6691 if (!add_req)
6692 {
6693 hddLog(LOGE, FL("memory allocation failed"));
6694 return -ENOMEM;
6695 }
6696
6697 /* Parse and fetch request Id */
6698 if (!tb[PARAM_REQUEST_ID])
6699 {
6700 hddLog(LOGE, FL("attr request id failed"));
6701 goto fail;
6702 }
6703
6704 request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
6705 hddLog(LOG1, FL("Request Id: %u"), request_id);
6706 if (request_id == 0)
6707 {
6708 hddLog(LOGE, FL("request_id cannot be zero"));
6709 return -EINVAL;
6710 }
6711
6712 if (!tb[PARAM_PERIOD])
6713 {
6714 hddLog(LOGE, FL("attr period failed"));
6715 goto fail;
6716 }
6717 add_req->usPtrnIntervalMs = nla_get_u32(tb[PARAM_PERIOD]);
6718 hddLog(LOG1, FL("Period: %u ms"), add_req->usPtrnIntervalMs);
6719 if (add_req->usPtrnIntervalMs == 0)
6720 {
6721 hddLog(LOGE, FL("Invalid interval zero, return failure"));
6722 goto fail;
6723 }
6724
6725 if (!tb[PARAM_SRC_MAC_ADDR])
6726 {
6727 hddLog(LOGE, FL("attr source mac address failed"));
6728 goto fail;
6729 }
6730 nla_memcpy(add_req->macAddress, tb[PARAM_SRC_MAC_ADDR],
6731 VOS_MAC_ADDR_SIZE);
6732 hddLog(LOG1, "input src mac address: "MAC_ADDRESS_STR,
6733 MAC_ADDR_ARRAY(add_req->macAddress));
6734
6735 if (memcmp(add_req->macAddress, adapter->macAddressCurrent.bytes,
6736 VOS_MAC_ADDR_SIZE))
6737 {
6738 hddLog(LOGE,
6739 FL("input src mac address and connected ap bssid are different"));
6740 goto fail;
6741 }
6742
6743 if (!tb[PARAM_DST_MAC_ADDR])
6744 {
6745 hddLog(LOGE, FL("attr dst mac address failed"));
6746 goto fail;
6747 }
6748 nla_memcpy(dst_addr.bytes, tb[PARAM_DST_MAC_ADDR], VOS_MAC_ADDR_SIZE);
6749 hddLog(LOG1, "input dst mac address: "MAC_ADDRESS_STR,
6750 MAC_ADDR_ARRAY(dst_addr.bytes));
6751
6752 if (!tb[PARAM_IP_PACKET])
6753 {
6754 hddLog(LOGE, FL("attr ip packet failed"));
6755 goto fail;
6756 }
6757 add_req->ucPtrnSize = nla_len(tb[PARAM_IP_PACKET]);
6758 hddLog(LOG1, FL("IP packet len: %u"), add_req->ucPtrnSize);
6759
6760 if (add_req->ucPtrnSize < 0 ||
6761 add_req->ucPtrnSize > (PERIODIC_TX_PTRN_MAX_SIZE -
6762 HDD_ETH_HEADER_LEN))
6763 {
6764 hddLog(LOGE, FL("Invalid IP packet len: %d"),
6765 add_req->ucPtrnSize);
6766 goto fail;
6767 }
6768
6769 len = 0;
6770 vos_mem_copy(&add_req->ucPattern[0], dst_addr.bytes, VOS_MAC_ADDR_SIZE);
6771 len += VOS_MAC_ADDR_SIZE;
6772 vos_mem_copy(&add_req->ucPattern[len], add_req->macAddress,
6773 VOS_MAC_ADDR_SIZE);
6774 len += VOS_MAC_ADDR_SIZE;
6775 vos_mem_copy(&add_req->ucPattern[len], &eth_type, 2);
6776 len += 2;
6777
6778 /*
6779 * This is the IP packet, add 14 bytes Ethernet (802.3) header
6780 * ------------------------------------------------------------
6781 * | 14 bytes Ethernet (802.3) header | IP header and payload |
6782 * ------------------------------------------------------------
6783 */
6784 vos_mem_copy(&add_req->ucPattern[len],
6785 nla_data(tb[PARAM_IP_PACKET]),
6786 add_req->ucPtrnSize);
6787 add_req->ucPtrnSize += len;
6788
6789 VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6790 add_req->ucPattern, add_req->ucPtrnSize);
6791
6792 ret = hdd_map_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id);
6793 if (ret)
6794 {
6795 hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret);
6796 goto fail;
6797 }
6798 add_req->ucPtrnId = pattern_id;
6799 hddLog(LOG1, FL("pattern id: %d"), add_req->ucPtrnId);
6800
6801 status = sme_AddPeriodicTxPtrn(hdd_ctx->hHal, add_req);
6802 if (!HAL_STATUS_SUCCESS(status))
6803 {
6804 hddLog(LOGE,
6805 FL("sme_AddPeriodicTxPtrn failed (err=%d)"), status);
6806 goto fail;
6807 }
6808
6809 EXIT();
6810 vos_mem_free(add_req);
6811 return 0;
6812
6813fail:
6814 vos_mem_free(add_req);
6815 return -EINVAL;
6816}
6817
6818/**
6819 * wlan_hdd_del_tx_ptrn() - delete tx pattern
6820 * @adapter: adapter pointer
6821 * @hdd_ctx: hdd context
6822 * @tb: nl attributes
6823 *
6824 * This function reads the NL attributes and forms a DelTxPtrn message
6825 * posts it to SME.
6826 *
6827 */
6828static int
6829wlan_hdd_del_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx,
6830 struct nlattr **tb)
6831{
6832 struct sSirDelPeriodicTxPtrn *del_req;
6833 eHalStatus status;
6834 uint32_t request_id, ret;
6835 uint8_t pattern_id = 0;
6836
6837 /* Parse and fetch request Id */
6838 if (!tb[PARAM_REQUEST_ID])
6839 {
6840 hddLog(LOGE, FL("attr request id failed"));
6841 return -EINVAL;
6842 }
6843 request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
6844 if (request_id == 0)
6845 {
6846 hddLog(LOGE, FL("request_id cannot be zero"));
6847 return -EINVAL;
6848 }
6849
6850 ret = hdd_unmap_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id);
6851 if (ret)
6852 {
6853 hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret);
6854 return -EINVAL;
6855 }
6856
6857 del_req = vos_mem_malloc(sizeof(*del_req));
6858 if (!del_req)
6859 {
6860 hddLog(LOGE, FL("memory allocation failed"));
6861 return -ENOMEM;
6862 }
6863
6864 vos_mem_set(del_req, sizeof(*del_req), 0);
6865 vos_mem_copy(del_req->macAddress, adapter->macAddressCurrent.bytes,
6866 VOS_MAC_ADDR_SIZE);
6867 hddLog(LOG1, MAC_ADDRESS_STR, MAC_ADDR_ARRAY(del_req->macAddress));
6868 del_req->ucPatternIdBitmap |= (0x1 << pattern_id);
6869 hddLog(LOG1, FL("Request Id: %u Pattern id: %d, bitmap %04x"),
6870 request_id, pattern_id, del_req->ucPatternIdBitmap);
6871
6872 status = sme_DelPeriodicTxPtrn(hdd_ctx->hHal, del_req);
6873 if (!HAL_STATUS_SUCCESS(status))
6874 {
6875 hddLog(LOGE,
6876 FL("sme_DelPeriodicTxPtrn failed (err=%d)"), status);
6877 goto fail;
6878 }
6879
6880 EXIT();
6881 vos_mem_free(del_req);
6882 return 0;
6883
6884fail:
6885 vos_mem_free(del_req);
6886 return -EINVAL;
6887}
6888
6889
6890/**
6891 * __wlan_hdd_cfg80211_offloaded_packets() - send offloaded packets
6892 * @wiphy: Pointer to wireless phy
6893 * @wdev: Pointer to wireless device
6894 * @data: Pointer to data
6895 * @data_len: Data length
6896 *
6897 * Return: 0 on success, negative errno on failure
6898 */
6899static int
6900__wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy,
6901 struct wireless_dev *wdev,
6902 const void *data,
6903 int data_len)
6904{
6905 struct net_device *dev = wdev->netdev;
6906 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6907 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6908 struct nlattr *tb[PARAM_MAX + 1];
6909 uint8_t control;
6910 int ret;
6911 static const struct nla_policy policy[PARAM_MAX + 1] =
6912 {
6913 [PARAM_REQUEST_ID] = { .type = NLA_U32 },
6914 [PARAM_CONTROL] = { .type = NLA_U32 },
6915 [PARAM_SRC_MAC_ADDR] = { .type = NLA_BINARY,
6916 .len = VOS_MAC_ADDR_SIZE },
6917 [PARAM_DST_MAC_ADDR] = { .type = NLA_BINARY,
6918 .len = VOS_MAC_ADDR_SIZE },
6919 [PARAM_PERIOD] = { .type = NLA_U32 },
6920 };
6921
6922 ENTER();
6923
6924 ret = wlan_hdd_validate_context(hdd_ctx);
6925 if (0 != ret)
6926 {
6927 hddLog(LOGE, FL("HDD context is not valid"));
6928 return ret;
6929 }
6930
6931 if (!sme_IsFeatureSupportedByFW(WLAN_PERIODIC_TX_PTRN))
6932 {
6933 hddLog(LOGE,
6934 FL("Periodic Tx Pattern Offload feature is not supported in FW!"));
6935 return -ENOTSUPP;
6936 }
6937
6938 if (nla_parse(tb, PARAM_MAX, data, data_len, policy))
6939 {
6940 hddLog(LOGE, FL("Invalid ATTR"));
6941 return -EINVAL;
6942 }
6943
6944 if (!tb[PARAM_CONTROL])
6945 {
6946 hddLog(LOGE, FL("attr control failed"));
6947 return -EINVAL;
6948 }
6949 control = nla_get_u32(tb[PARAM_CONTROL]);
6950 hddLog(LOG1, FL("Control: %d"), control);
6951
6952 if (control == WLAN_START_OFFLOADED_PACKETS)
6953 return wlan_hdd_add_tx_ptrn(adapter, hdd_ctx, tb);
6954 else if (control == WLAN_STOP_OFFLOADED_PACKETS)
6955 return wlan_hdd_del_tx_ptrn(adapter, hdd_ctx, tb);
6956 else
6957 {
6958 hddLog(LOGE, FL("Invalid control: %d"), control);
6959 return -EINVAL;
6960 }
6961}
6962
6963/*
6964 * done with short names for the global vendor params
6965 * used by __wlan_hdd_cfg80211_offloaded_packets()
6966 */
6967#undef PARAM_MAX
6968#undef PARAM_REQUEST_ID
6969#undef PARAM_CONTROL
6970#undef PARAM_IP_PACKET
6971#undef PARAM_SRC_MAC_ADDR
6972#undef PARAM_DST_MAC_ADDR
6973#undef PARAM_PERIOD
6974
6975/**
6976 * wlan_hdd_cfg80211_offloaded_packets() - Wrapper to offload packets
6977 * @wiphy: wiphy structure pointer
6978 * @wdev: Wireless device structure pointer
6979 * @data: Pointer to the data received
6980 * @data_len: Length of @data
6981 *
6982 * Return: 0 on success; errno on failure
6983 */
6984static int wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy,
6985 struct wireless_dev *wdev,
6986 const void *data,
6987 int data_len)
6988{
6989 int ret = 0;
6990
6991 vos_ssr_protect(__func__);
6992 ret = __wlan_hdd_cfg80211_offloaded_packets(wiphy,
6993 wdev, data, data_len);
6994 vos_ssr_unprotect(__func__);
6995
6996 return ret;
6997}
6998#endif
6999
Sunil Duttc69bccb2014-05-26 21:30:20 +05307000const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
7001{
Mukul Sharma2a271632014-10-13 14:59:01 +05307002 {
7003 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7004 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
7005 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7006 WIPHY_VENDOR_CMD_NEED_NETDEV |
7007 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307008 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05307009 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05307010
7011 {
7012 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7013 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
7014 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7015 WIPHY_VENDOR_CMD_NEED_NETDEV |
7016 WIPHY_VENDOR_CMD_NEED_RUNNING,
7017 .doit = wlan_hdd_cfg80211_nan_request
7018 },
7019
Sunil Duttc69bccb2014-05-26 21:30:20 +05307020#ifdef WLAN_FEATURE_LINK_LAYER_STATS
7021 {
7022 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7023 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
7024 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7025 WIPHY_VENDOR_CMD_NEED_NETDEV |
7026 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307027 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05307028 },
7029
7030 {
7031 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7032 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
7033 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7034 WIPHY_VENDOR_CMD_NEED_NETDEV |
7035 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307036 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05307037 },
7038
7039 {
7040 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7041 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
7042 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7043 WIPHY_VENDOR_CMD_NEED_NETDEV |
7044 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307045 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05307046 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05307047#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05307048#ifdef WLAN_FEATURE_EXTSCAN
7049 {
7050 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7051 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
7052 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7053 WIPHY_VENDOR_CMD_NEED_NETDEV |
7054 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307055 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05307056 },
7057 {
7058 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7059 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
7060 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7061 WIPHY_VENDOR_CMD_NEED_NETDEV |
7062 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307063 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05307064 },
7065 {
7066 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7067 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
7068 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7069 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307070 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05307071 },
7072 {
7073 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7074 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
7075 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7076 WIPHY_VENDOR_CMD_NEED_NETDEV |
7077 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307078 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05307079 },
7080 {
7081 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7082 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
7083 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7084 WIPHY_VENDOR_CMD_NEED_NETDEV |
7085 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307086 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05307087 },
7088 {
7089 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7090 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
7091 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7092 WIPHY_VENDOR_CMD_NEED_NETDEV |
7093 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307094 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05307095 },
7096 {
7097 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7098 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
7099 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7100 WIPHY_VENDOR_CMD_NEED_NETDEV |
7101 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307102 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05307103 },
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05307104 {
7105 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7106 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST,
7107 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7108 WIPHY_VENDOR_CMD_NEED_NETDEV |
7109 WIPHY_VENDOR_CMD_NEED_RUNNING,
7110 .doit = wlan_hdd_cfg80211_extscan_set_ssid_hotlist
7111 },
7112 {
7113 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7114 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SSID_HOTLIST,
7115 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7116 WIPHY_VENDOR_CMD_NEED_NETDEV |
7117 WIPHY_VENDOR_CMD_NEED_RUNNING,
7118 .doit = wlan_hdd_cfg80211_extscan_reset_ssid_hotlist
7119 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05307120#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05307121/*EXT TDLS*/
7122 {
7123 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7124 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
7125 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7126 WIPHY_VENDOR_CMD_NEED_NETDEV |
7127 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307128 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05307129 },
7130 {
7131 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7132 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
7133 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7134 WIPHY_VENDOR_CMD_NEED_NETDEV |
7135 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307136 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05307137 },
7138 {
7139 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7140 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
7141 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7142 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307143 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05307144 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05307145 {
7146 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7147 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
7148 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7149 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307150 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05307151 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05307152 {
7153 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7154 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
7155 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7156 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307157 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05307158 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05307159 {
7160 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7161 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
7162 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7163 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307164 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05307165 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05307166 {
7167 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7168 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
7169 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7170 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307171 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05307172 },
Srinivas Dasari41d97c92015-07-29 13:09:39 +05307173 {
7174 .info.vendor_id = QCA_NL80211_VENDOR_ID,
c_manjeecfd1efb2015-09-25 19:32:34 +05307175 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP,
7176 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7177 WIPHY_VENDOR_CMD_NEED_NETDEV |
7178 WIPHY_VENDOR_CMD_NEED_RUNNING,
7179 .doit = wlan_hdd_cfg80211_get_fw_mem_dump
7180 },
7181 {
7182 .info.vendor_id = QCA_NL80211_VENDOR_ID,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05307183 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND,
7184 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7185 WIPHY_VENDOR_CMD_NEED_NETDEV |
7186 WIPHY_VENDOR_CMD_NEED_RUNNING,
7187 .doit = wlan_hdd_cfg80211_setband
Sushant Kaushik8e644982015-09-23 12:18:54 +05307188 },
7189 {
7190 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7191 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_START,
7192 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7193 WIPHY_VENDOR_CMD_NEED_NETDEV,
7194 .doit = wlan_hdd_cfg80211_wifi_logger_start
7195 },
Sushant Kaushik847890c2015-09-28 16:05:17 +05307196 {
7197 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7198 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
7199 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7200 WIPHY_VENDOR_CMD_NEED_NETDEV|
7201 WIPHY_VENDOR_CMD_NEED_RUNNING,
7202 .doit = wlan_hdd_cfg80211_get_wifi_info
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307203 },
7204 {
7205 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7206 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_RING_DATA,
7207 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7208 WIPHY_VENDOR_CMD_NEED_NETDEV |
7209 WIPHY_VENDOR_CMD_NEED_RUNNING,
7210 .doit = wlan_hdd_cfg80211_wifi_logger_get_ring_data
Gupta, Kapil7c34b322015-09-30 13:12:35 +05307211 },
7212 {
7213 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7214 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI,
7215 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7216 WIPHY_VENDOR_CMD_NEED_NETDEV |
7217 WIPHY_VENDOR_CMD_NEED_RUNNING,
7218 .doit = wlan_hdd_cfg80211_monitor_rssi
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05307219 },
7220#ifdef WLAN_FEATURE_OFFLOAD_PACKETS
7221 {
7222 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7223 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OFFLOADED_PACKETS,
7224 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7225 WIPHY_VENDOR_CMD_NEED_NETDEV |
7226 WIPHY_VENDOR_CMD_NEED_RUNNING,
7227 .doit = wlan_hdd_cfg80211_offloaded_packets
Sushant Kaushik847890c2015-09-28 16:05:17 +05307228 }
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05307229#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +05307230};
7231
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007232/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05307233static const
7234struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007235{
7236#ifdef FEATURE_WLAN_CH_AVOID
7237 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05307238 .vendor_id = QCA_NL80211_VENDOR_ID,
7239 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007240 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05307241#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
7242#ifdef WLAN_FEATURE_LINK_LAYER_STATS
7243 {
7244 /* Index = 1*/
7245 .vendor_id = QCA_NL80211_VENDOR_ID,
7246 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
7247 },
7248 {
7249 /* Index = 2*/
7250 .vendor_id = QCA_NL80211_VENDOR_ID,
7251 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
7252 },
7253 {
7254 /* Index = 3*/
7255 .vendor_id = QCA_NL80211_VENDOR_ID,
7256 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
7257 },
7258 {
7259 /* Index = 4*/
7260 .vendor_id = QCA_NL80211_VENDOR_ID,
7261 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
7262 },
7263 {
7264 /* Index = 5*/
7265 .vendor_id = QCA_NL80211_VENDOR_ID,
7266 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
7267 },
7268 {
7269 /* Index = 6*/
7270 .vendor_id = QCA_NL80211_VENDOR_ID,
7271 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
7272 },
7273#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05307274#ifdef WLAN_FEATURE_EXTSCAN
7275 {
7276 .vendor_id = QCA_NL80211_VENDOR_ID,
7277 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
7278 },
7279 {
7280 .vendor_id = QCA_NL80211_VENDOR_ID,
7281 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
7282 },
7283 {
7284 .vendor_id = QCA_NL80211_VENDOR_ID,
7285 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
7286 },
7287 {
7288 .vendor_id = QCA_NL80211_VENDOR_ID,
7289 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
7290 },
7291 {
7292 .vendor_id = QCA_NL80211_VENDOR_ID,
7293 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
7294 },
7295 {
7296 .vendor_id = QCA_NL80211_VENDOR_ID,
7297 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
7298 },
7299 {
7300 .vendor_id = QCA_NL80211_VENDOR_ID,
7301 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
7302 },
7303 {
7304 .vendor_id = QCA_NL80211_VENDOR_ID,
7305 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
7306 },
7307 {
7308 .vendor_id = QCA_NL80211_VENDOR_ID,
7309 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
7310 },
7311 {
7312 .vendor_id = QCA_NL80211_VENDOR_ID,
7313 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
7314 },
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05307315 {
7316 .vendor_id = QCA_NL80211_VENDOR_ID,
7317 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST
7318 },
7319 {
7320 .vendor_id = QCA_NL80211_VENDOR_ID,
7321 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SSID_HOTLIST
7322 },
7323 [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND_INDEX] = {
7324 .vendor_id = QCA_NL80211_VENDOR_ID,
7325 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND
7326 },
7327 [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST_INDEX] = {
7328 .vendor_id = QCA_NL80211_VENDOR_ID,
7329 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST
7330 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05307331#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05307332/*EXT TDLS*/
7333 {
7334 .vendor_id = QCA_NL80211_VENDOR_ID,
7335 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
7336 },
c_manjeecfd1efb2015-09-25 19:32:34 +05307337 [QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP_INDEX] = {
7338 .vendor_id = QCA_NL80211_VENDOR_ID,
7339 .subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP
7340 },
7341
Srinivas Dasari030bad32015-02-18 23:23:54 +05307342
7343 {
7344 .vendor_id = QCA_NL80211_VENDOR_ID,
7345 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
7346 },
7347
Sushant Kaushik084f6592015-09-10 13:11:56 +05307348 {
7349 .vendor_id = QCA_NL80211_VENDOR_ID,
7350 .subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
Gupta, Kapil7c34b322015-09-30 13:12:35 +05307351 },
7352 [QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX] = {
7353 .vendor_id = QCA_NL80211_VENDOR_ID,
7354 .subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI
7355 },
Sushant Kaushik084f6592015-09-10 13:11:56 +05307356
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007357};
7358
Jeff Johnson295189b2012-06-20 16:38:30 -07007359/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307360 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307361 * This function is called by hdd_wlan_startup()
7362 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307363 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07007364 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307365struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07007366{
7367 struct wiphy *wiphy;
7368 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307369 /*
7370 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07007371 */
7372 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
7373
7374 if (!wiphy)
7375 {
7376 /* Print error and jump into err label and free the memory */
7377 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
7378 return NULL;
7379 }
7380
Sunil Duttc69bccb2014-05-26 21:30:20 +05307381
Jeff Johnson295189b2012-06-20 16:38:30 -07007382 return wiphy;
7383}
7384
7385/*
7386 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307387 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07007388 * private ioctl to change the band value
7389 */
7390int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
7391{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307392 int i, j;
7393 eNVChannelEnabledType channelEnabledState;
7394
Jeff Johnsone7245742012-09-05 17:12:55 -07007395 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307396
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307397 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07007398 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307399
7400 if (NULL == wiphy->bands[i])
7401 {
7402 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
7403 __func__, i);
7404 continue;
7405 }
7406
7407 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
7408 {
7409 struct ieee80211_supported_band *band = wiphy->bands[i];
7410
7411 channelEnabledState = vos_nv_getChannelEnabledState(
7412 band->channels[j].hw_value);
7413
7414 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
7415 {
Abhishek Singh678227a2014-11-04 10:52:38 +05307416 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307417 continue;
7418 }
7419 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
7420 {
7421 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
7422 continue;
7423 }
7424
7425 if (NV_CHANNEL_DISABLE == channelEnabledState ||
7426 NV_CHANNEL_INVALID == channelEnabledState)
7427 {
7428 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
7429 }
7430 else if (NV_CHANNEL_DFS == channelEnabledState)
7431 {
7432 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
7433 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
7434 }
7435 else
7436 {
7437 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
7438 |IEEE80211_CHAN_RADAR);
7439 }
7440 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007441 }
7442 return 0;
7443}
7444/*
7445 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307446 * This function is called by hdd_wlan_startup()
7447 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07007448 * This function is used to initialize and register wiphy structure.
7449 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307450int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07007451 struct wiphy *wiphy,
7452 hdd_config_t *pCfg
7453 )
7454{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307455 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05307456 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7457
Jeff Johnsone7245742012-09-05 17:12:55 -07007458 ENTER();
7459
Jeff Johnson295189b2012-06-20 16:38:30 -07007460 /* Now bind the underlying wlan device with wiphy */
7461 set_wiphy_dev(wiphy, dev);
7462
7463 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07007464
Kiet Lam6c583332013-10-14 05:37:09 +05307465#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07007466 /* the flag for the other case would be initialzed in
7467 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07007468 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05307469#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07007470
Amar Singhalfddc28c2013-09-05 13:03:40 -07007471 /* This will disable updating of NL channels from passive to
7472 * active if a beacon is received on passive channel. */
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307473#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
7474 wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS;
7475#else
Amar Singhalfddc28c2013-09-05 13:03:40 -07007476 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307477#endif
Amar Singhalfddc28c2013-09-05 13:03:40 -07007478
Amar Singhala49cbc52013-10-08 18:37:44 -07007479
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007480#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07007481 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
7482 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
7483 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07007484 | WIPHY_FLAG_OFFCHAN_TX;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307485#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
7486 wiphy->regulatory_flags = REGULATORY_COUNTRY_IE_IGNORE;
7487#else
7488 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
7489#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007490#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07007491
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007492#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07007493 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08007494#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07007495 || pCfg->isFastRoamIniFeatureEnabled
7496#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007497#ifdef FEATURE_WLAN_ESE
7498 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07007499#endif
7500 )
7501 {
7502 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
7503 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08007504#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007505#ifdef FEATURE_WLAN_TDLS
7506 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
7507 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
7508#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307509#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05307510 if (pCfg->configPNOScanSupport)
7511 {
7512 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
7513 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
7514 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
7515 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
7516 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307517#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007518
Abhishek Singh10d85972015-04-17 10:27:23 +05307519#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7520 wiphy->features |= NL80211_FEATURE_HT_IBSS;
7521#endif
7522
Amar Singhalfddc28c2013-09-05 13:03:40 -07007523#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07007524 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
7525 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07007526 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07007527 driver need to determine what to do with both
7528 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07007529
7530 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07007531#else
7532 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07007533#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007534
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307535 wiphy->max_scan_ssids = MAX_SCAN_SSID;
7536
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05307537 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07007538
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307539 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
7540
Jeff Johnson295189b2012-06-20 16:38:30 -07007541 /* Supports STATION & AD-HOC modes right now */
Bhargav Shah0d2e3e52015-07-24 16:51:01 +05307542 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
7543 | BIT(NL80211_IFTYPE_ADHOC)
7544 | BIT(NL80211_IFTYPE_P2P_CLIENT)
7545 | BIT(NL80211_IFTYPE_P2P_GO)
7546 | BIT(NL80211_IFTYPE_AP);
7547
7548 if (VOS_MONITOR_MODE == hdd_get_conparam())
7549 {
7550 wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR);
7551 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007552
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05307553 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08007554 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05307555#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7556 if( pCfg->enableMCC )
7557 {
7558 /* Currently, supports up to two channels */
7559 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08007560
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05307561 if( !pCfg->allowMCCGODiffBI )
7562 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08007563
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05307564 }
7565 wiphy->iface_combinations = &wlan_hdd_iface_combination;
7566 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08007567#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05307568 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08007569
Jeff Johnson295189b2012-06-20 16:38:30 -07007570 /* Before registering we need to update the ht capabilitied based
7571 * on ini values*/
7572 if( !pCfg->ShortGI20MhzEnable )
7573 {
7574 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
7575 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
7576 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
7577 }
7578
7579 if( !pCfg->ShortGI40MhzEnable )
7580 {
7581 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
7582 }
7583
7584 if( !pCfg->nChannelBondingMode5GHz )
7585 {
7586 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
7587 }
7588
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307589 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05307590 if (true == hdd_is_5g_supported(pHddCtx))
7591 {
7592 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
7593 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307594
7595 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
7596 {
7597
7598 if (NULL == wiphy->bands[i])
7599 {
Ratheesh S P36dbc932015-08-07 14:28:57 +05307600 hddLog(VOS_TRACE_LEVEL_INFO,"%s: wiphy->bands[i] is NULL, i = %d",
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307601 __func__, i);
7602 continue;
7603 }
7604
7605 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
7606 {
7607 struct ieee80211_supported_band *band = wiphy->bands[i];
7608
7609 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
7610 {
7611 // Enable social channels for P2P
7612 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
7613 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
7614 else
7615 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
7616 continue;
7617 }
7618 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
7619 {
7620 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
7621 continue;
7622 }
7623 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007624 }
7625 /*Initialise the supported cipher suite details*/
7626 wiphy->cipher_suites = hdd_cipher_suites;
7627 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
7628
7629 /*signal strength in mBm (100*dBm) */
7630 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
7631
7632#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05307633 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07007634#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007635
Sunil Duttc69bccb2014-05-26 21:30:20 +05307636 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
7637 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007638 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
7639 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
7640
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307641 EXIT();
7642 return 0;
7643}
7644
7645/* In this function we are registering wiphy. */
7646int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
7647{
7648 ENTER();
7649 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007650 if (0 > wiphy_register(wiphy))
7651 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307652 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07007653 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
7654 return -EIO;
7655 }
7656
7657 EXIT();
7658 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307659}
Jeff Johnson295189b2012-06-20 16:38:30 -07007660
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307661/* In this function we are updating channel list when,
7662 regulatory domain is FCC and country code is US.
7663 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
7664 As per FCC smart phone is not a indoor device.
7665 GO should not opeate on indoor channels */
7666void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
7667{
7668 int j;
7669 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7670 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
7671 //Default counrtycode from NV at the time of wiphy initialization.
7672 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
7673 &defaultCountryCode[0]))
7674 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007675 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307676 }
7677 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
7678 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307679 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
7680 {
7681 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
7682 return;
7683 }
7684 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
7685 {
7686 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
7687 // Mark UNII -1 band channel as passive
7688 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
7689 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
7690 }
7691 }
7692}
7693
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05307694/* This function registers for all frame which supplicant is interested in */
7695void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07007696{
Jeff Johnson295189b2012-06-20 16:38:30 -07007697 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7698 /* Register for all P2P action, public action etc frames */
7699 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
7700
Jeff Johnsone7245742012-09-05 17:12:55 -07007701 ENTER();
7702
Jeff Johnson295189b2012-06-20 16:38:30 -07007703 /* Right now we are registering these frame when driver is getting
7704 initialized. Once we will move to 2.6.37 kernel, in which we have
7705 frame register ops, we will move this code as a part of that */
7706 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307707 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07007708 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
7709
7710 /* GAS Initial Response */
7711 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
7712 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307713
Jeff Johnson295189b2012-06-20 16:38:30 -07007714 /* GAS Comeback Request */
7715 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
7716 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
7717
7718 /* GAS Comeback Response */
7719 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
7720 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
7721
7722 /* P2P Public Action */
7723 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307724 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07007725 P2P_PUBLIC_ACTION_FRAME_SIZE );
7726
7727 /* P2P Action */
7728 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
7729 (v_U8_t*)P2P_ACTION_FRAME,
7730 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07007731
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05307732 /* WNM BSS Transition Request frame */
7733 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
7734 (v_U8_t*)WNM_BSS_ACTION_FRAME,
7735 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07007736
7737 /* WNM-Notification */
7738 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
7739 (v_U8_t*)WNM_NOTIFICATION_FRAME,
7740 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07007741}
7742
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05307743void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07007744{
Jeff Johnson295189b2012-06-20 16:38:30 -07007745 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7746 /* Register for all P2P action, public action etc frames */
7747 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
7748
Jeff Johnsone7245742012-09-05 17:12:55 -07007749 ENTER();
7750
Jeff Johnson295189b2012-06-20 16:38:30 -07007751 /* Right now we are registering these frame when driver is getting
7752 initialized. Once we will move to 2.6.37 kernel, in which we have
7753 frame register ops, we will move this code as a part of that */
7754 /* GAS Initial Request */
7755
7756 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
7757 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
7758
7759 /* GAS Initial Response */
7760 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
7761 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307762
Jeff Johnson295189b2012-06-20 16:38:30 -07007763 /* GAS Comeback Request */
7764 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
7765 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
7766
7767 /* GAS Comeback Response */
7768 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
7769 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
7770
7771 /* P2P Public Action */
7772 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307773 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07007774 P2P_PUBLIC_ACTION_FRAME_SIZE );
7775
7776 /* P2P Action */
7777 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
7778 (v_U8_t*)P2P_ACTION_FRAME,
7779 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07007780 /* WNM-Notification */
7781 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
7782 (v_U8_t*)WNM_NOTIFICATION_FRAME,
7783 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07007784}
7785
7786#ifdef FEATURE_WLAN_WAPI
7787void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05307788 const u8 *mac_addr, const u8 *key , int key_Len)
Jeff Johnson295189b2012-06-20 16:38:30 -07007789{
7790 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7791 tCsrRoamSetKey setKey;
7792 v_BOOL_t isConnected = TRUE;
7793 int status = 0;
7794 v_U32_t roamId= 0xFF;
7795 tANI_U8 *pKeyPtr = NULL;
7796 int n = 0;
7797
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307798 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
7799 __func__, hdd_device_modetoString(pAdapter->device_mode),
7800 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007801
Gopichand Nakkalae7480202013-02-11 15:24:22 +05307802 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07007803 setKey.keyId = key_index; // Store Key ID
7804 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
7805 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
7806 setKey.paeRole = 0 ; // the PAE role
7807 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
7808 {
7809 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
7810 }
7811 else
7812 {
7813 isConnected = hdd_connIsConnected(pHddStaCtx);
7814 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
7815 }
7816 setKey.keyLength = key_Len;
7817 pKeyPtr = setKey.Key;
7818 memcpy( pKeyPtr, key, key_Len);
7819
Arif Hussain6d2a3322013-11-17 19:50:10 -08007820 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07007821 __func__, key_Len);
7822 for (n = 0 ; n < key_Len; n++)
7823 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
7824 __func__,n,setKey.Key[n]);
7825
7826 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
7827 if ( isConnected )
7828 {
7829 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
7830 pAdapter->sessionId, &setKey, &roamId );
7831 }
7832 if ( status != 0 )
7833 {
7834 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7835 "[%4d] sme_RoamSetKey returned ERROR status= %d",
7836 __LINE__, status );
7837 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
7838 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05307839 /* Need to clear any trace of key value in the memory.
7840 * Thus zero out the memory even though it is local
7841 * variable.
7842 */
7843 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07007844}
7845#endif /* FEATURE_WLAN_WAPI*/
7846
7847#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307848int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07007849 beacon_data_t **ppBeacon,
7850 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007851#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307852int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007853 beacon_data_t **ppBeacon,
7854 struct cfg80211_beacon_data *params,
7855 int dtim_period)
7856#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307857{
Jeff Johnson295189b2012-06-20 16:38:30 -07007858 int size;
7859 beacon_data_t *beacon = NULL;
7860 beacon_data_t *old = NULL;
7861 int head_len,tail_len;
7862
Jeff Johnsone7245742012-09-05 17:12:55 -07007863 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007864 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307865 {
7866 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7867 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007868 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307869 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007870
7871 old = pAdapter->sessionCtx.ap.beacon;
7872
7873 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307874 {
7875 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7876 FL("session(%d) old and new heads points to NULL"),
7877 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007878 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307879 }
7880
7881 if (params->tail && !params->tail_len)
7882 {
7883 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7884 FL("tail_len is zero but tail is not NULL"));
7885 return -EINVAL;
7886 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007887
Jeff Johnson295189b2012-06-20 16:38:30 -07007888#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
7889 /* Kernel 3.0 is not updating dtim_period for set beacon */
7890 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307891 {
7892 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7893 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007894 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307895 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007896#endif
7897
7898 if(params->head)
7899 head_len = params->head_len;
7900 else
7901 head_len = old->head_len;
7902
7903 if(params->tail || !old)
7904 tail_len = params->tail_len;
7905 else
7906 tail_len = old->tail_len;
7907
7908 size = sizeof(beacon_data_t) + head_len + tail_len;
7909
7910 beacon = kzalloc(size, GFP_KERNEL);
7911
7912 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307913 {
7914 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7915 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007916 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307917 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007918
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007919#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007920 if(params->dtim_period || !old )
7921 beacon->dtim_period = params->dtim_period;
7922 else
7923 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007924#else
7925 if(dtim_period || !old )
7926 beacon->dtim_period = dtim_period;
7927 else
7928 beacon->dtim_period = old->dtim_period;
7929#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307930
Jeff Johnson295189b2012-06-20 16:38:30 -07007931 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
7932 beacon->tail = beacon->head + head_len;
7933 beacon->head_len = head_len;
7934 beacon->tail_len = tail_len;
7935
7936 if(params->head) {
7937 memcpy (beacon->head,params->head,beacon->head_len);
7938 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307939 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07007940 if(old)
7941 memcpy (beacon->head,old->head,beacon->head_len);
7942 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307943
Jeff Johnson295189b2012-06-20 16:38:30 -07007944 if(params->tail) {
7945 memcpy (beacon->tail,params->tail,beacon->tail_len);
7946 }
7947 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307948 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07007949 memcpy (beacon->tail,old->tail,beacon->tail_len);
7950 }
7951
7952 *ppBeacon = beacon;
7953
7954 kfree(old);
7955
7956 return 0;
7957
7958}
Jeff Johnson295189b2012-06-20 16:38:30 -07007959
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05307960v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(
7961#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
7962 const v_U8_t *pIes,
7963#else
7964 v_U8_t *pIes,
7965#endif
7966 int length, v_U8_t eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07007967{
7968 int left = length;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05307969 v_U8_t *ptr = (v_U8_t *)pIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007970 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307971
Jeff Johnson295189b2012-06-20 16:38:30 -07007972 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307973 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007974 elem_id = ptr[0];
7975 elem_len = ptr[1];
7976 left -= 2;
7977 if(elem_len > left)
7978 {
7979 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07007980 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007981 eid,elem_len,left);
7982 return NULL;
7983 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307984 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07007985 {
7986 return ptr;
7987 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307988
Jeff Johnson295189b2012-06-20 16:38:30 -07007989 left -= elem_len;
7990 ptr += (elem_len + 2);
7991 }
7992 return NULL;
7993}
7994
Jeff Johnson295189b2012-06-20 16:38:30 -07007995/* Check if rate is 11g rate or not */
7996static int wlan_hdd_rate_is_11g(u8 rate)
7997{
Sanjay Devnani28322e22013-06-21 16:13:40 -07007998 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007999 u8 i;
8000 for (i = 0; i < 8; i++)
8001 {
8002 if(rate == gRateArray[i])
8003 return TRUE;
8004 }
8005 return FALSE;
8006}
8007
8008/* Check for 11g rate and set proper 11g only mode */
8009static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
8010 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
8011{
8012 u8 i, num_rates = pIe[0];
8013
8014 pIe += 1;
8015 for ( i = 0; i < num_rates; i++)
8016 {
8017 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
8018 {
8019 /* If rate set have 11g rate than change the mode to 11G */
8020 *pSapHw_mode = eSAP_DOT11_MODE_11g;
8021 if (pIe[i] & BASIC_RATE_MASK)
8022 {
8023 /* If we have 11g rate as basic rate, it means mode
8024 is 11g only mode.
8025 */
8026 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
8027 *pCheckRatesfor11g = FALSE;
8028 }
8029 }
8030 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
8031 {
8032 *require_ht = TRUE;
8033 }
8034 }
8035 return;
8036}
8037
8038static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
8039{
8040 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
8041 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8042 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
8043 u8 checkRatesfor11g = TRUE;
8044 u8 require_ht = FALSE;
8045 u8 *pIe=NULL;
8046
8047 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
8048
8049 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
8050 pBeacon->head_len, WLAN_EID_SUPP_RATES);
8051 if (pIe != NULL)
8052 {
8053 pIe += 1;
8054 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
8055 &pConfig->SapHw_mode);
8056 }
8057
8058 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
8059 WLAN_EID_EXT_SUPP_RATES);
8060 if (pIe != NULL)
8061 {
8062
8063 pIe += 1;
8064 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
8065 &pConfig->SapHw_mode);
8066 }
8067
8068 if( pConfig->channel > 14 )
8069 {
8070 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
8071 }
8072
8073 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
8074 WLAN_EID_HT_CAPABILITY);
8075
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308076 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07008077 {
8078 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
8079 if(require_ht)
8080 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
8081 }
8082}
8083
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308084static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
8085 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
8086{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07008087 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308088 v_U8_t *pIe = NULL;
8089 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8090
8091 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
8092 pBeacon->tail, pBeacon->tail_len);
8093
8094 if (pIe)
8095 {
8096 ielen = pIe[1] + 2;
8097 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
8098 {
8099 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
8100 }
8101 else
8102 {
8103 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
8104 return -EINVAL;
8105 }
8106 *total_ielen += ielen;
8107 }
8108 return 0;
8109}
8110
Arif Hussaine7f3ea52013-09-12 21:56:36 -07008111static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
8112 v_U8_t *genie, v_U8_t *total_ielen)
8113{
8114 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8115 int left = pBeacon->tail_len;
8116 v_U8_t *ptr = pBeacon->tail;
8117 v_U8_t elem_id, elem_len;
8118 v_U16_t ielen = 0;
8119
8120 if ( NULL == ptr || 0 == left )
8121 return;
8122
8123 while (left >= 2)
8124 {
8125 elem_id = ptr[0];
8126 elem_len = ptr[1];
8127 left -= 2;
8128 if (elem_len > left)
8129 {
8130 hddLog( VOS_TRACE_LEVEL_ERROR,
8131 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
8132 elem_id, elem_len, left);
8133 return;
8134 }
8135 if (IE_EID_VENDOR == elem_id)
8136 {
8137 /* skipping the VSIE's which we don't want to include or
8138 * it will be included by existing code
8139 */
8140 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
8141#ifdef WLAN_FEATURE_WFD
8142 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
8143#endif
8144 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
8145 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
8146 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
8147 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
8148 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
8149 {
8150 ielen = ptr[1] + 2;
8151 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
8152 {
8153 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
8154 *total_ielen += ielen;
8155 }
8156 else
8157 {
8158 hddLog( VOS_TRACE_LEVEL_ERROR,
8159 "IE Length is too big "
8160 "IEs eid=%d elem_len=%d total_ie_lent=%d",
8161 elem_id, elem_len, *total_ielen);
8162 }
8163 }
8164 }
8165
8166 left -= elem_len;
8167 ptr += (elem_len + 2);
8168 }
8169 return;
8170}
8171
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008172#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008173static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
8174 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008175#else
8176static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
8177 struct cfg80211_beacon_data *params)
8178#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008179{
8180 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308181 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008182 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07008183 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008184
8185 genie = vos_mem_malloc(MAX_GENIE_LEN);
8186
8187 if(genie == NULL) {
8188
8189 return -ENOMEM;
8190 }
8191
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308192 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
8193 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008194 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308195 hddLog(LOGE,
8196 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308197 ret = -EINVAL;
8198 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008199 }
8200
8201#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308202 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
8203 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
8204 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308205 hddLog(LOGE,
8206 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308207 ret = -EINVAL;
8208 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008209 }
8210#endif
8211
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308212 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
8213 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008214 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308215 hddLog(LOGE,
8216 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308217 ret = -EINVAL;
8218 goto done;
8219 }
8220
8221 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
8222 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07008223 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008224 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008225
8226 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8227 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
8228 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
8229 {
8230 hddLog(LOGE,
8231 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008232 ret = -EINVAL;
8233 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008234 }
8235
8236 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8237 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
8238 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
8239 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
8240 ==eHAL_STATUS_FAILURE)
8241 {
8242 hddLog(LOGE,
8243 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008244 ret = -EINVAL;
8245 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008246 }
8247
8248 // Added for ProResp IE
8249 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
8250 {
8251 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
8252 u8 probe_rsp_ie_len[3] = {0};
8253 u8 counter = 0;
8254 /* Check Probe Resp Length if it is greater then 255 then Store
8255 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
8256 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
8257 Store More then 255 bytes into One Variable.
8258 */
8259 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
8260 {
8261 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
8262 {
8263 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
8264 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
8265 }
8266 else
8267 {
8268 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
8269 rem_probe_resp_ie_len = 0;
8270 }
8271 }
8272
8273 rem_probe_resp_ie_len = 0;
8274
8275 if (probe_rsp_ie_len[0] > 0)
8276 {
8277 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8278 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
8279 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
8280 probe_rsp_ie_len[0], NULL,
8281 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8282 {
8283 hddLog(LOGE,
8284 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008285 ret = -EINVAL;
8286 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008287 }
8288 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
8289 }
8290
8291 if (probe_rsp_ie_len[1] > 0)
8292 {
8293 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8294 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
8295 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
8296 probe_rsp_ie_len[1], NULL,
8297 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8298 {
8299 hddLog(LOGE,
8300 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008301 ret = -EINVAL;
8302 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008303 }
8304 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
8305 }
8306
8307 if (probe_rsp_ie_len[2] > 0)
8308 {
8309 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8310 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
8311 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
8312 probe_rsp_ie_len[2], NULL,
8313 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8314 {
8315 hddLog(LOGE,
8316 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008317 ret = -EINVAL;
8318 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008319 }
8320 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
8321 }
8322
8323 if (probe_rsp_ie_len[1] == 0 )
8324 {
8325 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8326 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
8327 eANI_BOOLEAN_FALSE) )
8328 {
8329 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008330 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008331 }
8332 }
8333
8334 if (probe_rsp_ie_len[2] == 0 )
8335 {
8336 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8337 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
8338 eANI_BOOLEAN_FALSE) )
8339 {
8340 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008341 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008342 }
8343 }
8344
8345 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8346 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
8347 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
8348 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
8349 == eHAL_STATUS_FAILURE)
8350 {
8351 hddLog(LOGE,
8352 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008353 ret = -EINVAL;
8354 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008355 }
8356 }
8357 else
8358 {
8359 // Reset WNI_CFG_PROBE_RSP Flags
8360 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
8361
8362 hddLog(VOS_TRACE_LEVEL_INFO,
8363 "%s: No Probe Response IE received in set beacon",
8364 __func__);
8365 }
8366
8367 // Added for AssocResp IE
8368 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
8369 {
8370 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8371 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
8372 params->assocresp_ies_len, NULL,
8373 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8374 {
8375 hddLog(LOGE,
8376 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008377 ret = -EINVAL;
8378 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008379 }
8380
8381 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8382 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
8383 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
8384 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
8385 == eHAL_STATUS_FAILURE)
8386 {
8387 hddLog(LOGE,
8388 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008389 ret = -EINVAL;
8390 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008391 }
8392 }
8393 else
8394 {
8395 hddLog(VOS_TRACE_LEVEL_INFO,
8396 "%s: No Assoc Response IE received in set beacon",
8397 __func__);
8398
8399 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8400 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
8401 eANI_BOOLEAN_FALSE) )
8402 {
8403 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008404 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008405 }
8406 }
8407
Jeff Johnsone7245742012-09-05 17:12:55 -07008408done:
Jeff Johnson295189b2012-06-20 16:38:30 -07008409 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308410 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008411}
Jeff Johnson295189b2012-06-20 16:38:30 -07008412
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308413/*
Jeff Johnson295189b2012-06-20 16:38:30 -07008414 * FUNCTION: wlan_hdd_validate_operation_channel
8415 * called by wlan_hdd_cfg80211_start_bss() and
8416 * wlan_hdd_cfg80211_set_channel()
8417 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308418 * channel list.
8419 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07008420VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07008421{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308422
Jeff Johnson295189b2012-06-20 16:38:30 -07008423 v_U32_t num_ch = 0;
8424 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
8425 u32 indx = 0;
8426 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308427 v_U8_t fValidChannel = FALSE, count = 0;
8428 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308429
Jeff Johnson295189b2012-06-20 16:38:30 -07008430 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
8431
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308432 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07008433 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308434 /* Validate the channel */
8435 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07008436 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308437 if ( channel == rfChannels[count].channelNum )
8438 {
8439 fValidChannel = TRUE;
8440 break;
8441 }
8442 }
8443 if (fValidChannel != TRUE)
8444 {
8445 hddLog(VOS_TRACE_LEVEL_ERROR,
8446 "%s: Invalid Channel [%d]", __func__, channel);
8447 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008448 }
8449 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308450 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008451 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308452 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
8453 valid_ch, &num_ch))
8454 {
8455 hddLog(VOS_TRACE_LEVEL_ERROR,
8456 "%s: failed to get valid channel list", __func__);
8457 return VOS_STATUS_E_FAILURE;
8458 }
8459 for (indx = 0; indx < num_ch; indx++)
8460 {
8461 if (channel == valid_ch[indx])
8462 {
8463 break;
8464 }
8465 }
8466
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05308467 if (indx >= num_ch)
8468 {
8469 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
8470 {
8471 eCsrBand band;
8472 unsigned int freq;
8473
8474 sme_GetFreqBand(hHal, &band);
8475
8476 if (eCSR_BAND_5G == band)
8477 {
8478#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
8479 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
8480 {
8481 freq = ieee80211_channel_to_frequency(channel,
8482 IEEE80211_BAND_2GHZ);
8483 }
8484 else
8485 {
8486 freq = ieee80211_channel_to_frequency(channel,
8487 IEEE80211_BAND_5GHZ);
8488 }
8489#else
8490 freq = ieee80211_channel_to_frequency(channel);
8491#endif
8492 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
8493 return VOS_STATUS_SUCCESS;
8494 }
8495 }
8496
8497 hddLog(VOS_TRACE_LEVEL_ERROR,
8498 "%s: Invalid Channel [%d]", __func__, channel);
8499 return VOS_STATUS_E_FAILURE;
8500 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008501 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05308502
Jeff Johnson295189b2012-06-20 16:38:30 -07008503 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308504
Jeff Johnson295189b2012-06-20 16:38:30 -07008505}
8506
Viral Modi3a32cc52013-02-08 11:14:52 -08008507/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308508 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -08008509 * This function is used to set the channel number
8510 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308511static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -08008512 struct ieee80211_channel *chan,
8513 enum nl80211_channel_type channel_type
8514 )
8515{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308516 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08008517 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07008518 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08008519 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308520 hdd_context_t *pHddCtx;
8521 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08008522
8523 ENTER();
8524
8525 if( NULL == dev )
8526 {
8527 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008528 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08008529 return -ENODEV;
8530 }
8531 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308532
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308533 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8534 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
8535 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08008536 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308537 "%s: device_mode = %s (%d) freq = %d", __func__,
8538 hdd_device_modetoString(pAdapter->device_mode),
8539 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308540
8541 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8542 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308543 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08008544 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308545 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08008546 }
8547
8548 /*
8549 * Do freq to chan conversion
8550 * TODO: for 11a
8551 */
8552
8553 channel = ieee80211_frequency_to_channel(freq);
8554
8555 /* Check freq range */
8556 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
8557 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
8558 {
8559 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008560 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08008561 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
8562 WNI_CFG_CURRENT_CHANNEL_STAMAX);
8563 return -EINVAL;
8564 }
8565
8566 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
8567
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05308568 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
8569 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08008570 {
8571 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
8572 {
8573 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008574 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08008575 return -EINVAL;
8576 }
8577 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8578 "%s: set channel to [%d] for device mode =%d",
8579 __func__, channel,pAdapter->device_mode);
8580 }
8581 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08008582 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08008583 )
8584 {
8585 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8586 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
8587 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8588
8589 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
8590 {
8591 /* Link is up then return cant set channel*/
8592 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008593 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08008594 return -EINVAL;
8595 }
8596
8597 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
8598 pHddStaCtx->conn_info.operationChannel = channel;
8599 pRoamProfile->ChannelInfo.ChannelList =
8600 &pHddStaCtx->conn_info.operationChannel;
8601 }
8602 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08008603 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08008604 )
8605 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05308606 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
8607 {
8608 if(VOS_STATUS_SUCCESS !=
8609 wlan_hdd_validate_operation_channel(pAdapter,channel))
8610 {
8611 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008612 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05308613 return -EINVAL;
8614 }
8615 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
8616 }
8617 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08008618 {
8619 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
8620
8621 /* If auto channel selection is configured as enable/ 1 then ignore
8622 channel set by supplicant
8623 */
8624 if ( cfg_param->apAutoChannelSelection )
8625 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05308626 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
8627 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08008628 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308629 "%s: set channel to auto channel (0) for device mode =%s (%d)",
8630 __func__, hdd_device_modetoString(pAdapter->device_mode),
8631 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08008632 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05308633 else
8634 {
8635 if(VOS_STATUS_SUCCESS !=
8636 wlan_hdd_validate_operation_channel(pAdapter,channel))
8637 {
8638 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008639 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05308640 return -EINVAL;
8641 }
8642 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
8643 }
Viral Modi3a32cc52013-02-08 11:14:52 -08008644 }
8645 }
8646 else
8647 {
8648 hddLog(VOS_TRACE_LEVEL_FATAL,
8649 "%s: Invalid device mode failed to set valid channel", __func__);
8650 return -EINVAL;
8651 }
8652 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308653 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08008654}
8655
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308656static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
8657 struct net_device *dev,
8658 struct ieee80211_channel *chan,
8659 enum nl80211_channel_type channel_type
8660 )
8661{
8662 int ret;
8663
8664 vos_ssr_protect(__func__);
8665 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
8666 vos_ssr_unprotect(__func__);
8667
8668 return ret;
8669}
8670
Jeff Johnson295189b2012-06-20 16:38:30 -07008671#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
8672static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
8673 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008674#else
8675static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
8676 struct cfg80211_beacon_data *params,
8677 const u8 *ssid, size_t ssid_len,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05308678 enum nl80211_hidden_ssid hidden_ssid,
8679 v_U8_t auth_type)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008680#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008681{
8682 tsap_Config_t *pConfig;
8683 beacon_data_t *pBeacon = NULL;
8684 struct ieee80211_mgmt *pMgmt_frame;
8685 v_U8_t *pIe=NULL;
8686 v_U16_t capab_info;
8687 eCsrAuthType RSNAuthType;
8688 eCsrEncryptionType RSNEncryptType;
8689 eCsrEncryptionType mcRSNEncryptType;
8690 int status = VOS_STATUS_SUCCESS;
8691 tpWLAN_SAPEventCB pSapEventCallback;
8692 hdd_hostapd_state_t *pHostapdState;
8693 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
8694 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05308695 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008696 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05308697 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07008698 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08008699 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05308700 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07008701 v_BOOL_t MFPCapable = VOS_FALSE;
8702 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +05308703 v_BOOL_t sapEnable11AC =
8704 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Jeff Johnson295189b2012-06-20 16:38:30 -07008705 ENTER();
8706
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05308707 iniConfig = pHddCtx->cfg_ini;
8708
Jeff Johnson295189b2012-06-20 16:38:30 -07008709 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
8710
8711 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
8712
8713 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8714
8715 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
8716
8717 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
8718
8719 //channel is already set in the set_channel Call back
8720 //pConfig->channel = pCommitConfig->channel;
8721
8722 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308723 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07008724 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
8725
8726 pConfig->dtim_period = pBeacon->dtim_period;
8727
Arif Hussain6d2a3322013-11-17 19:50:10 -08008728 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07008729 pConfig->dtim_period);
8730
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08008731 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07008732 {
8733 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07008734 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05308735 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
8736 {
8737 tANI_BOOLEAN restartNeeded;
8738 pConfig->ieee80211d = 1;
8739 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
8740 sme_setRegInfo(hHal, pConfig->countryCode);
8741 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
8742 }
8743 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07008744 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07008745 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07008746 pConfig->ieee80211d = 1;
8747 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
8748 sme_setRegInfo(hHal, pConfig->countryCode);
8749 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07008750 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07008751 else
8752 {
8753 pConfig->ieee80211d = 0;
8754 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05308755 /*
8756 * If auto channel is configured i.e. channel is 0,
8757 * so skip channel validation.
8758 */
8759 if( AUTO_CHANNEL_SELECT != pConfig->channel )
8760 {
8761 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
8762 {
8763 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008764 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05308765 return -EINVAL;
8766 }
8767 }
8768 else
8769 {
8770 if(1 != pHddCtx->is_dynamic_channel_range_set)
8771 {
8772 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
8773 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
8774 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
8775 }
8776 pHddCtx->is_dynamic_channel_range_set = 0;
8777 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008778 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07008779 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008780 {
8781 pConfig->ieee80211d = 0;
8782 }
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05308783
8784#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
8785 if (params->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
8786 pConfig->authType = eSAP_OPEN_SYSTEM;
8787 else if (params->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
8788 pConfig->authType = eSAP_SHARED_KEY;
8789 else
8790 pConfig->authType = eSAP_AUTO_SWITCH;
8791#else
8792 if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
8793 pConfig->authType = eSAP_OPEN_SYSTEM;
8794 else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
8795 pConfig->authType = eSAP_SHARED_KEY;
8796 else
8797 pConfig->authType = eSAP_AUTO_SWITCH;
8798#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008799
8800 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308801
8802 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07008803 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
8804
8805 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
8806
8807 /*Set wps station to configured*/
8808 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
8809
8810 if(pIe)
8811 {
8812 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
8813 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008814 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07008815 return -EINVAL;
8816 }
8817 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
8818 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07008819 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07008820 /* Check 15 bit of WPS IE as it contain information for wps state
8821 * WPS state
8822 */
8823 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
8824 {
8825 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
8826 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
8827 {
8828 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
8829 }
8830 }
8831 }
8832 else
8833 {
8834 pConfig->wps_state = SAP_WPS_DISABLED;
8835 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308836 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07008837
c_hpothufe599e92014-06-16 11:38:55 +05308838 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
8839 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
8840 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
8841 eCSR_ENCRYPT_TYPE_NONE;
8842
Jeff Johnson295189b2012-06-20 16:38:30 -07008843 pConfig->RSNWPAReqIELength = 0;
8844 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308845 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07008846 WLAN_EID_RSN);
8847 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308848 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008849 pConfig->RSNWPAReqIELength = pIe[1] + 2;
8850 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
8851 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308852 /* The actual processing may eventually be more extensive than
8853 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07008854 * by the app.
8855 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308856 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07008857 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
8858 &RSNEncryptType,
8859 &mcRSNEncryptType,
8860 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08008861 &MFPCapable,
8862 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07008863 pConfig->pRSNWPAReqIE[1]+2,
8864 pConfig->pRSNWPAReqIE );
8865
8866 if( VOS_STATUS_SUCCESS == status )
8867 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308868 /* Now copy over all the security attributes you have
8869 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07008870 * */
8871 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
8872 pConfig->mcRSNEncryptType = mcRSNEncryptType;
8873 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
8874 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05308875 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08008876 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008877 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
8878 }
8879 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308880
Jeff Johnson295189b2012-06-20 16:38:30 -07008881 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
8882 pBeacon->tail, pBeacon->tail_len);
8883
8884 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
8885 {
8886 if (pConfig->pRSNWPAReqIE)
8887 {
8888 /*Mixed mode WPA/WPA2*/
8889 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
8890 pConfig->RSNWPAReqIELength += pIe[1] + 2;
8891 }
8892 else
8893 {
8894 pConfig->RSNWPAReqIELength = pIe[1] + 2;
8895 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
8896 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308897 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07008898 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
8899 &RSNEncryptType,
8900 &mcRSNEncryptType,
8901 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08008902 &MFPCapable,
8903 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07008904 pConfig->pRSNWPAReqIE[1]+2,
8905 pConfig->pRSNWPAReqIE );
8906
8907 if( VOS_STATUS_SUCCESS == status )
8908 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308909 /* Now copy over all the security attributes you have
8910 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07008911 * */
8912 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
8913 pConfig->mcRSNEncryptType = mcRSNEncryptType;
8914 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
8915 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05308916 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08008917 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008918 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
8919 }
8920 }
8921 }
8922
Jeff Johnson4416a782013-03-25 14:17:50 -07008923 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
8924 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
8925 return -EINVAL;
8926 }
8927
Jeff Johnson295189b2012-06-20 16:38:30 -07008928 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
8929
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008930#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008931 if (params->ssid != NULL)
8932 {
8933 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
8934 pConfig->SSIDinfo.ssid.length = params->ssid_len;
8935 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
8936 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
8937 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008938#else
8939 if (ssid != NULL)
8940 {
8941 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
8942 pConfig->SSIDinfo.ssid.length = ssid_len;
8943 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
8944 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
8945 }
8946#endif
8947
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308948 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07008949 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308950
Jeff Johnson295189b2012-06-20 16:38:30 -07008951 /* default value */
8952 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
8953 pConfig->num_accept_mac = 0;
8954 pConfig->num_deny_mac = 0;
8955
8956 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
8957 pBeacon->tail, pBeacon->tail_len);
8958
8959 /* pIe for black list is following form:
8960 type : 1 byte
8961 length : 1 byte
8962 OUI : 4 bytes
8963 acl type : 1 byte
8964 no of mac addr in black list: 1 byte
8965 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308966 */
8967 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008968 {
8969 pConfig->SapMacaddr_acl = pIe[6];
8970 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08008971 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008972 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308973 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
8974 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008975 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
8976 for (i = 0; i < pConfig->num_deny_mac; i++)
8977 {
8978 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
8979 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308980 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008981 }
8982 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
8983 pBeacon->tail, pBeacon->tail_len);
8984
8985 /* pIe for white list is following form:
8986 type : 1 byte
8987 length : 1 byte
8988 OUI : 4 bytes
8989 acl type : 1 byte
8990 no of mac addr in white list: 1 byte
8991 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308992 */
8993 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008994 {
8995 pConfig->SapMacaddr_acl = pIe[6];
8996 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08008997 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008998 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308999 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
9000 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009001 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
9002 for (i = 0; i < pConfig->num_accept_mac; i++)
9003 {
9004 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
9005 acl_entry++;
9006 }
9007 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309008
Jeff Johnson295189b2012-06-20 16:38:30 -07009009 wlan_hdd_set_sapHwmode(pHostapdAdapter);
9010
Jeff Johnsone7245742012-09-05 17:12:55 -07009011#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08009012 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309013 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
9014 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +05309015 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
9016 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08009017 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
9018 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309019 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
9020 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07009021 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309022 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07009023 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309024 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009025
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309026 /* If ACS disable and selected channel <= 14
9027 * OR
9028 * ACS enabled and ACS operating band is choosen as 2.4
9029 * AND
9030 * VHT in 2.4G Disabled
9031 * THEN
9032 * Fallback to 11N mode
9033 */
9034 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
9035 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05309036 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309037 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009038 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309039 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
9040 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009041 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
9042 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009043 }
9044#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309045
Jeff Johnson295189b2012-06-20 16:38:30 -07009046 // ht_capab is not what the name conveys,this is used for protection bitmap
9047 pConfig->ht_capab =
9048 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
9049
9050 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
9051 {
9052 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
9053 return -EINVAL;
9054 }
9055
9056 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309057 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07009058 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
9059 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309060 pConfig->obssProtEnabled =
9061 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07009062
Chet Lanctot8cecea22014-02-11 19:09:36 -08009063#ifdef WLAN_FEATURE_11W
9064 pConfig->mfpCapable = MFPCapable;
9065 pConfig->mfpRequired = MFPRequired;
9066 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
9067 pConfig->mfpCapable, pConfig->mfpRequired);
9068#endif
9069
Arif Hussain6d2a3322013-11-17 19:50:10 -08009070 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07009071 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08009072 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
9073 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
9074 (int)pConfig->channel);
9075 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
9076 pConfig->SapHw_mode, pConfig->privacy,
9077 pConfig->authType);
9078 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
9079 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
9080 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
9081 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07009082
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309083 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07009084 {
9085 //Bss already started. just return.
9086 //TODO Probably it should update some beacon params.
9087 hddLog( LOGE, "Bss Already started...Ignore the request");
9088 EXIT();
9089 return 0;
9090 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309091
Agarwal Ashish51325b52014-06-16 16:50:49 +05309092 if (vos_max_concurrent_connections_reached()) {
9093 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
9094 return -EINVAL;
9095 }
9096
Jeff Johnson295189b2012-06-20 16:38:30 -07009097 pConfig->persona = pHostapdAdapter->device_mode;
9098
Peng Xu2446a892014-09-05 17:21:18 +05309099 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
9100 if ( NULL != psmeConfig)
9101 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05309102 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +05309103 sme_GetConfigParam(hHal, psmeConfig);
9104 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05309105#ifdef WLAN_FEATURE_AP_HT40_24G
9106 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
9107 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
9108 && pHddCtx->cfg_ini->apHT40_24GEnabled)
9109 {
9110 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
9111 sme_UpdateConfig (hHal, psmeConfig);
9112 }
9113#endif
Peng Xu2446a892014-09-05 17:21:18 +05309114 vos_mem_free(psmeConfig);
9115 }
Peng Xuafc34e32014-09-25 13:23:55 +05309116 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05309117
Jeff Johnson295189b2012-06-20 16:38:30 -07009118 pSapEventCallback = hdd_hostapd_SAPEventCB;
9119 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
9120 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
9121 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009122 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009123 return -EINVAL;
9124 }
9125
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309126 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07009127 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
9128
9129 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309130
Jeff Johnson295189b2012-06-20 16:38:30 -07009131 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309132 {
9133 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009134 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07009135 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009136 VOS_ASSERT(0);
9137 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309138
Jeff Johnson295189b2012-06-20 16:38:30 -07009139 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05309140 /* Initialize WMM configuation */
9141 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05309142 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009143
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009144#ifdef WLAN_FEATURE_P2P_DEBUG
9145 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
9146 {
9147 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
9148 {
9149 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
9150 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08009151 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009152 }
9153 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
9154 {
9155 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
9156 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08009157 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009158 }
9159 }
9160#endif
9161
Jeff Johnson295189b2012-06-20 16:38:30 -07009162 pHostapdState->bCommit = TRUE;
9163 EXIT();
9164
9165 return 0;
9166}
9167
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009168#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309169static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309170 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009171 struct beacon_parameters *params)
9172{
9173 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309174 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309175 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009176
9177 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309178
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309179 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9180 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
9181 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309182 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
9183 hdd_device_modetoString(pAdapter->device_mode),
9184 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009185
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309186 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9187 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309188 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009189 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309190 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009191 }
9192
Agarwal Ashish51325b52014-06-16 16:50:49 +05309193 if (vos_max_concurrent_connections_reached()) {
9194 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
9195 return -EINVAL;
9196 }
9197
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309198 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009199 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07009200 )
9201 {
9202 beacon_data_t *old,*new;
9203
9204 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309205
Jeff Johnson295189b2012-06-20 16:38:30 -07009206 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309207 {
9208 hddLog(VOS_TRACE_LEVEL_WARN,
9209 FL("already beacon info added to session(%d)"),
9210 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009211 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309212 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009213
9214 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
9215
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309216 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07009217 {
9218 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009219 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009220 return -EINVAL;
9221 }
9222
9223 pAdapter->sessionCtx.ap.beacon = new;
9224
9225 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
9226 }
9227
9228 EXIT();
9229 return status;
9230}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309231
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309232static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
9233 struct net_device *dev,
9234 struct beacon_parameters *params)
9235{
9236 int ret;
9237
9238 vos_ssr_protect(__func__);
9239 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
9240 vos_ssr_unprotect(__func__);
9241
9242 return ret;
9243}
9244
9245static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009246 struct net_device *dev,
9247 struct beacon_parameters *params)
9248{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309249 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309250 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9251 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309252 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009253
9254 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309255
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309256 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9257 TRACE_CODE_HDD_CFG80211_SET_BEACON,
9258 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
9259 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9260 __func__, hdd_device_modetoString(pAdapter->device_mode),
9261 pAdapter->device_mode);
9262
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309263 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9264 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309265 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009266 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309267 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009268 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309269
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309270 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009271 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309272 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009273 {
9274 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309275
Jeff Johnson295189b2012-06-20 16:38:30 -07009276 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309277
Jeff Johnson295189b2012-06-20 16:38:30 -07009278 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309279 {
9280 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9281 FL("session(%d) old and new heads points to NULL"),
9282 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009283 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309284 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009285
9286 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
9287
9288 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309289 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009290 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009291 return -EINVAL;
9292 }
9293
9294 pAdapter->sessionCtx.ap.beacon = new;
9295
9296 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
9297 }
9298
9299 EXIT();
9300 return status;
9301}
9302
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309303static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
9304 struct net_device *dev,
9305 struct beacon_parameters *params)
9306{
9307 int ret;
9308
9309 vos_ssr_protect(__func__);
9310 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
9311 vos_ssr_unprotect(__func__);
9312
9313 return ret;
9314}
9315
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009316#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9317
9318#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309319static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009320 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009321#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309322static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009323 struct net_device *dev)
9324#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009325{
9326 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07009327 hdd_context_t *pHddCtx = NULL;
9328 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309329 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309330 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009331
9332 ENTER();
9333
9334 if (NULL == pAdapter)
9335 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309336 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009337 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009338 return -ENODEV;
9339 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009340
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309341 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9342 TRACE_CODE_HDD_CFG80211_STOP_AP,
9343 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309344 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9345 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309346 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009347 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309348 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07009349 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009350
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009351 pScanInfo = &pHddCtx->scan_info;
9352
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309353 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9354 __func__, hdd_device_modetoString(pAdapter->device_mode),
9355 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009356
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309357 ret = wlan_hdd_scan_abort(pAdapter);
9358
Girish Gowli4bf7a632014-06-12 13:42:11 +05309359 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07009360 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309361 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9362 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309363
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309364 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07009365 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9367 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08009368
Jeff Johnsone7245742012-09-05 17:12:55 -07009369 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309370 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07009371 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309372 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07009373 }
9374
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05309375 /* Delete all associated STAs before stopping AP/P2P GO */
9376 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05309377 hdd_hostapd_stop(dev);
9378
Jeff Johnson295189b2012-06-20 16:38:30 -07009379 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009380 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07009381 )
9382 {
9383 beacon_data_t *old;
9384
9385 old = pAdapter->sessionCtx.ap.beacon;
9386
9387 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309388 {
9389 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9390 FL("session(%d) beacon data points to NULL"),
9391 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009392 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309393 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009394
Jeff Johnson295189b2012-06-20 16:38:30 -07009395 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009396
9397 mutex_lock(&pHddCtx->sap_lock);
9398 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
9399 {
Jeff Johnson4416a782013-03-25 14:17:50 -07009400 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009401 {
9402 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
9403
9404 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
9405
9406 if (!VOS_IS_STATUS_SUCCESS(status))
9407 {
9408 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009409 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009410 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309411 }
9412 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009413 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05309414 /* BSS stopped, clear the active sessions for this device mode */
9415 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009416 }
9417 mutex_unlock(&pHddCtx->sap_lock);
9418
9419 if(status != VOS_STATUS_SUCCESS)
9420 {
9421 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009422 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009423 return -EINVAL;
9424 }
9425
Jeff Johnson4416a782013-03-25 14:17:50 -07009426 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07009427 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
9428 ==eHAL_STATUS_FAILURE)
9429 {
9430 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009431 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009432 }
9433
Jeff Johnson4416a782013-03-25 14:17:50 -07009434 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07009435 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
9436 eANI_BOOLEAN_FALSE) )
9437 {
9438 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009439 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009440 }
9441
9442 // Reset WNI_CFG_PROBE_RSP Flags
9443 wlan_hdd_reset_prob_rspies(pAdapter);
9444
9445 pAdapter->sessionCtx.ap.beacon = NULL;
9446 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009447#ifdef WLAN_FEATURE_P2P_DEBUG
9448 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
9449 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
9450 {
9451 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
9452 "GO got removed");
9453 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
9454 }
9455#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009456 }
9457 EXIT();
9458 return status;
9459}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009460
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309461#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9462static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
9463 struct net_device *dev)
9464{
9465 int ret;
9466
9467 vos_ssr_protect(__func__);
9468 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
9469 vos_ssr_unprotect(__func__);
9470
9471 return ret;
9472}
9473#else
9474static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
9475 struct net_device *dev)
9476{
9477 int ret;
9478
9479 vos_ssr_protect(__func__);
9480 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
9481 vos_ssr_unprotect(__func__);
9482
9483 return ret;
9484}
9485#endif
9486
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009487#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
9488
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309489static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309490 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009491 struct cfg80211_ap_settings *params)
9492{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309493 hdd_adapter_t *pAdapter;
9494 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309495 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009496
9497 ENTER();
9498
Girish Gowlib143d7a2015-02-18 19:39:55 +05309499 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07009500 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309501 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +05309502 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309503 return -ENODEV;
9504 }
9505
9506 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9507 if (NULL == pAdapter)
9508 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309509 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309510 "%s: HDD adapter is Null", __func__);
9511 return -ENODEV;
9512 }
9513
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309514 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9515 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
9516 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309517 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
9518 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309519 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309520 "%s: HDD adapter magic is invalid", __func__);
9521 return -ENODEV;
9522 }
9523
9524 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309525 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309526 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309527 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309528 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309529 }
9530
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309531 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
9532 __func__, hdd_device_modetoString(pAdapter->device_mode),
9533 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309534
9535 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009536 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009537 )
9538 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309539 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009540
9541 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309542
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009543 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309544 {
9545 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9546 FL("already beacon info added to session(%d)"),
9547 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009548 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309549 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009550
Girish Gowlib143d7a2015-02-18 19:39:55 +05309551#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9552 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
9553 &new,
9554 &params->beacon);
9555#else
9556 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
9557 &new,
9558 &params->beacon,
9559 params->dtim_period);
9560#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009561
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309562 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009563 {
9564 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309565 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009566 return -EINVAL;
9567 }
9568 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08009569#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07009570 wlan_hdd_cfg80211_set_channel(wiphy, dev,
9571#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
9572 params->channel, params->channel_type);
9573#else
9574 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
9575#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08009576#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009577 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05309578 params->ssid_len, params->hidden_ssid,
9579 params->auth_type);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009580 }
9581
9582 EXIT();
9583 return status;
9584}
9585
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309586static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
9587 struct net_device *dev,
9588 struct cfg80211_ap_settings *params)
9589{
9590 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009591
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309592 vos_ssr_protect(__func__);
9593 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
9594 vos_ssr_unprotect(__func__);
9595
9596 return ret;
9597}
9598
9599static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009600 struct net_device *dev,
9601 struct cfg80211_beacon_data *params)
9602{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309603 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309604 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309605 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009606
9607 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309608
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309609 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9610 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
9611 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08009612 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009613 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309614
9615 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9616 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309617 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07009618 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309619 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07009620 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009621
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309622 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009623 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309624 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009625 {
9626 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309627
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009628 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309629
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009630 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309631 {
9632 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9633 FL("session(%d) beacon data points to NULL"),
9634 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009635 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309636 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009637
9638 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
9639
9640 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309641 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009642 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009643 return -EINVAL;
9644 }
9645
9646 pAdapter->sessionCtx.ap.beacon = new;
9647
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05309648 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0,
9649 pAdapter->sessionCtx.ap.sapConfig.authType);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009650 }
9651
9652 EXIT();
9653 return status;
9654}
9655
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309656static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
9657 struct net_device *dev,
9658 struct cfg80211_beacon_data *params)
9659{
9660 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009661
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309662 vos_ssr_protect(__func__);
9663 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
9664 vos_ssr_unprotect(__func__);
9665
9666 return ret;
9667}
9668
9669#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009670
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05309671static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009672 struct net_device *dev,
9673 struct bss_parameters *params)
9674{
9675 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309676 hdd_context_t *pHddCtx;
9677 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009678
9679 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309680
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309681 if (NULL == pAdapter)
9682 {
9683 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9684 "%s: HDD adapter is Null", __func__);
9685 return -ENODEV;
9686 }
9687 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309688 ret = wlan_hdd_validate_context(pHddCtx);
9689 if (0 != ret)
9690 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309691 return ret;
9692 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309693 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9694 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
9695 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309696 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9697 __func__, hdd_device_modetoString(pAdapter->device_mode),
9698 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009699
9700 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009701 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309702 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009703 {
9704 /* ap_isolate == -1 means that in change bss, upper layer doesn't
9705 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309706 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07009707 {
9708 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309709 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009710 }
9711
9712 EXIT();
9713 return 0;
9714}
9715
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05309716static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
9717 struct net_device *dev,
9718 struct bss_parameters *params)
9719{
9720 int ret;
9721
9722 vos_ssr_protect(__func__);
9723 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
9724 vos_ssr_unprotect(__func__);
9725
9726 return ret;
9727}
Kiet Lam10841362013-11-01 11:36:50 +05309728/* FUNCTION: wlan_hdd_change_country_code_cd
9729* to wait for contry code completion
9730*/
9731void* wlan_hdd_change_country_code_cb(void *pAdapter)
9732{
9733 hdd_adapter_t *call_back_pAdapter = pAdapter;
9734 complete(&call_back_pAdapter->change_country_code);
9735 return NULL;
9736}
9737
Jeff Johnson295189b2012-06-20 16:38:30 -07009738/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05309739 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07009740 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
9741 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05309742int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009743 struct net_device *ndev,
9744 enum nl80211_iftype type,
9745 u32 *flags,
9746 struct vif_params *params
9747 )
9748{
9749 struct wireless_dev *wdev;
9750 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08009751 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07009752 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009753 tCsrRoamProfile *pRoamProfile = NULL;
9754 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309755 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009756 eMib_dot11DesiredBssType connectedBssType;
9757 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309758 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009759
9760 ENTER();
9761
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309762 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08009763 {
9764 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9765 "%s: Adapter context is null", __func__);
9766 return VOS_STATUS_E_FAILURE;
9767 }
9768
9769 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9770 if (!pHddCtx)
9771 {
9772 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9773 "%s: HDD context is null", __func__);
9774 return VOS_STATUS_E_FAILURE;
9775 }
9776
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309777 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9778 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
9779 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309780 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309781 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009782 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309783 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009784 }
9785
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309786 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9787 __func__, hdd_device_modetoString(pAdapter->device_mode),
9788 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009789
Agarwal Ashish51325b52014-06-16 16:50:49 +05309790 if (vos_max_concurrent_connections_reached()) {
9791 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
9792 return -EINVAL;
9793 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309794 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07009795 wdev = ndev->ieee80211_ptr;
9796
9797#ifdef WLAN_BTAMP_FEATURE
9798 if((NL80211_IFTYPE_P2P_CLIENT == type)||
9799 (NL80211_IFTYPE_ADHOC == type)||
9800 (NL80211_IFTYPE_AP == type)||
9801 (NL80211_IFTYPE_P2P_GO == type))
9802 {
9803 pHddCtx->isAmpAllowed = VOS_FALSE;
9804 // stop AMP traffic
9805 status = WLANBAP_StopAmp();
9806 if(VOS_STATUS_SUCCESS != status )
9807 {
9808 pHddCtx->isAmpAllowed = VOS_TRUE;
9809 hddLog(VOS_TRACE_LEVEL_FATAL,
9810 "%s: Failed to stop AMP", __func__);
9811 return -EINVAL;
9812 }
9813 }
9814#endif //WLAN_BTAMP_FEATURE
9815 /* Reset the current device mode bit mask*/
9816 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
9817
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05309818 if ((pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) &&
9819 ((type == NL80211_IFTYPE_P2P_CLIENT) ||
9820 (type == NL80211_IFTYPE_P2P_GO)))
9821 {
9822 /* Notify Mode change in case of concurrency.
9823 * Below function invokes TDLS teardown Functionality Since TDLS is
9824 * not Supported in case of concurrency i.e Once P2P session
9825 * is detected disable offchannel and teardown TDLS links
9826 */
9827 hddLog(LOG1,
9828 FL("Device mode = %d Interface type = %d"),
9829 pAdapter->device_mode, type);
9830 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
9831 }
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05309832
Jeff Johnson295189b2012-06-20 16:38:30 -07009833 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07009834 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07009835 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07009836 )
9837 {
9838 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08009839 if (!pWextState)
9840 {
9841 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9842 "%s: pWextState is null", __func__);
9843 return VOS_STATUS_E_FAILURE;
9844 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009845 pRoamProfile = &pWextState->roamProfile;
9846 LastBSSType = pRoamProfile->BSSType;
9847
9848 switch (type)
9849 {
9850 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07009851 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07009852 hddLog(VOS_TRACE_LEVEL_INFO,
9853 "%s: setting interface Type to INFRASTRUCTURE", __func__);
9854 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07009855#ifdef WLAN_FEATURE_11AC
9856 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
9857 {
9858 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
9859 }
9860#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309861 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07009862 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009863 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08009864 //Check for sub-string p2p to confirm its a p2p interface
9865 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309866 {
Mahesh A Saptasagarc48ae8a2015-08-09 00:04:35 +05309867#ifdef FEATURE_WLAN_TDLS
9868 mutex_lock(&pHddCtx->tdls_lock);
9869 wlan_hdd_tdls_exit(pAdapter, TRUE);
9870 mutex_unlock(&pHddCtx->tdls_lock);
9871#endif
Gopichand Nakkala864d3552012-12-31 16:08:51 -08009872 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
9873 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
9874 }
9875 else
9876 {
9877 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07009878 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08009879 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009880 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05309881
Jeff Johnson295189b2012-06-20 16:38:30 -07009882 case NL80211_IFTYPE_ADHOC:
9883 hddLog(VOS_TRACE_LEVEL_INFO,
9884 "%s: setting interface Type to ADHOC", __func__);
9885 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
9886 pRoamProfile->phyMode =
9887 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07009888 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009889 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +05309890 hdd_set_ibss_ops( pAdapter );
9891 hdd_ibss_init_tx_rx( pAdapter );
Nirav Shah7e3c8132015-06-22 23:51:42 +05309892
9893 status = hdd_sta_id_hash_attach(pAdapter);
9894 if (VOS_STATUS_SUCCESS != status) {
9895 hddLog(VOS_TRACE_LEVEL_ERROR,
9896 FL("Failed to initialize hash for IBSS"));
9897 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009898 break;
9899
9900 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07009901 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07009902 {
9903 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9904 "%s: setting interface Type to %s", __func__,
9905 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
9906
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08009907 //Cancel any remain on channel for GO mode
9908 if (NL80211_IFTYPE_P2P_GO == type)
9909 {
9910 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
9911 }
Mohit Khanna0f232092012-09-11 14:46:08 -07009912 if (NL80211_IFTYPE_AP == type)
9913 {
9914 /* As Loading WLAN Driver one interface being created for p2p device
9915 * address. This will take one HW STA and the max number of clients
9916 * that can connect to softAP will be reduced by one. so while changing
9917 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
9918 * interface as it is not required in SoftAP mode.
9919 */
9920
9921 // Get P2P Adapter
9922 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
9923
9924 if (pP2pAdapter)
9925 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05309926 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +05309927 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -07009928 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
9929 }
9930 }
Swaroop Goltia2e32212014-04-09 23:37:33 +05309931 //Disable IMPS & BMPS for SAP/GO
9932 if(VOS_STATUS_E_FAILURE ==
9933 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
9934 {
9935 //Fail to Exit BMPS
9936 VOS_ASSERT(0);
9937 }
Deepthi Gowri500fc472014-08-11 19:53:10 +05309938
9939 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
9940
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05309941#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07009942
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05309943 /* A Mutex Lock is introduced while changing the mode to
9944 * protect the concurrent access for the Adapters by TDLS
9945 * module.
9946 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05309947 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05309948#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009949 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +05309950 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009951 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07009952 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
9953 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05309954#ifdef FEATURE_WLAN_TDLS
9955 mutex_unlock(&pHddCtx->tdls_lock);
9956#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07009957 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
9958 (pConfig->apRandomBssidEnabled))
9959 {
9960 /* To meet Android requirements create a randomized
9961 MAC address of the form 02:1A:11:Fx:xx:xx */
9962 get_random_bytes(&ndev->dev_addr[3], 3);
9963 ndev->dev_addr[0] = 0x02;
9964 ndev->dev_addr[1] = 0x1A;
9965 ndev->dev_addr[2] = 0x11;
9966 ndev->dev_addr[3] |= 0xF0;
9967 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
9968 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08009969 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
9970 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07009971 }
9972
Jeff Johnson295189b2012-06-20 16:38:30 -07009973 hdd_set_ap_ops( pAdapter->dev );
9974
Kiet Lam10841362013-11-01 11:36:50 +05309975 /* This is for only SAP mode where users can
9976 * control country through ini.
9977 * P2P GO follows station country code
9978 * acquired during the STA scanning. */
9979 if((NL80211_IFTYPE_AP == type) &&
9980 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
9981 {
9982 int status = 0;
9983 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
9984 "%s: setting country code from INI ", __func__);
9985 init_completion(&pAdapter->change_country_code);
9986 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
9987 (void *)(tSmeChangeCountryCallback)
9988 wlan_hdd_change_country_code_cb,
9989 pConfig->apCntryCode, pAdapter,
9990 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05309991 eSIR_FALSE,
9992 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05309993 if (eHAL_STATUS_SUCCESS == status)
9994 {
9995 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309996 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05309997 &pAdapter->change_country_code,
9998 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309999 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +053010000 {
10001 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010002 FL("SME Timed out while setting country code %ld"),
10003 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -080010004
10005 if (pHddCtx->isLogpInProgress)
10006 {
10007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10008 "%s: LOGP in Progress. Ignore!!!", __func__);
10009 return -EAGAIN;
10010 }
Kiet Lam10841362013-11-01 11:36:50 +053010011 }
10012 }
10013 else
10014 {
10015 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010016 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +053010017 return -EINVAL;
10018 }
10019 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010020 status = hdd_init_ap_mode(pAdapter);
10021 if(status != VOS_STATUS_SUCCESS)
10022 {
10023 hddLog(VOS_TRACE_LEVEL_FATAL,
10024 "%s: Error initializing the ap mode", __func__);
10025 return -EINVAL;
10026 }
10027 hdd_set_conparam(1);
10028
Nirav Shah7e3c8132015-06-22 23:51:42 +053010029 status = hdd_sta_id_hash_attach(pAdapter);
10030 if (VOS_STATUS_SUCCESS != status)
10031 {
10032 hddLog(VOS_TRACE_LEVEL_ERROR,
10033 FL("Failed to initialize hash for AP"));
10034 return -EINVAL;
10035 }
10036
Jeff Johnson295189b2012-06-20 16:38:30 -070010037 /*interface type changed update in wiphy structure*/
10038 if(wdev)
10039 {
10040 wdev->iftype = type;
10041 pHddCtx->change_iface = type;
10042 }
10043 else
10044 {
10045 hddLog(VOS_TRACE_LEVEL_ERROR,
10046 "%s: ERROR !!!! Wireless dev is NULL", __func__);
10047 return -EINVAL;
10048 }
10049 goto done;
10050 }
10051
10052 default:
10053 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
10054 __func__);
10055 return -EOPNOTSUPP;
10056 }
10057 }
10058 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010059 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070010060 )
10061 {
10062 switch(type)
10063 {
10064 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070010065 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070010066 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +053010067
10068 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010069#ifdef FEATURE_WLAN_TDLS
10070
10071 /* A Mutex Lock is introduced while changing the mode to
10072 * protect the concurrent access for the Adapters by TDLS
10073 * module.
10074 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010075 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010076#endif
c_hpothu002231a2015-02-05 14:58:51 +053010077 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010078 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080010079 //Check for sub-string p2p to confirm its a p2p interface
10080 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010081 {
10082 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
10083 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
10084 }
10085 else
10086 {
10087 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070010088 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010089 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010090 hdd_set_conparam(0);
10091 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070010092 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
10093 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010094#ifdef FEATURE_WLAN_TDLS
10095 mutex_unlock(&pHddCtx->tdls_lock);
10096#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +053010097 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -070010098 if( VOS_STATUS_SUCCESS != status )
10099 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -070010100 /* In case of JB, for P2P-GO, only change interface will be called,
10101 * This is the right place to enable back bmps_imps()
10102 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053010103 if (pHddCtx->hdd_wlan_suspended)
10104 {
10105 hdd_set_pwrparams(pHddCtx);
10106 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010107 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070010108 goto done;
10109 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010110 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070010111 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070010112 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
10113 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -070010114 goto done;
10115 default:
10116 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
10117 __func__);
10118 return -EOPNOTSUPP;
10119
10120 }
10121
10122 }
10123 else
10124 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010125 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
10126 __func__, hdd_device_modetoString(pAdapter->device_mode),
10127 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010128 return -EOPNOTSUPP;
10129 }
10130
10131
10132 if(pRoamProfile)
10133 {
10134 if ( LastBSSType != pRoamProfile->BSSType )
10135 {
10136 /*interface type changed update in wiphy structure*/
10137 wdev->iftype = type;
10138
10139 /*the BSS mode changed, We need to issue disconnect
10140 if connected or in IBSS disconnect state*/
10141 if ( hdd_connGetConnectedBssType(
10142 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
10143 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
10144 {
10145 /*need to issue a disconnect to CSR.*/
10146 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10147 if( eHAL_STATUS_SUCCESS ==
10148 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10149 pAdapter->sessionId,
10150 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
10151 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010152 ret = wait_for_completion_interruptible_timeout(
10153 &pAdapter->disconnect_comp_var,
10154 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10155 if (ret <= 0)
10156 {
10157 hddLog(VOS_TRACE_LEVEL_ERROR,
10158 FL("wait on disconnect_comp_var failed %ld"), ret);
10159 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010160 }
10161 }
10162 }
10163 }
10164
10165done:
10166 /*set bitmask based on updated value*/
10167 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -070010168
10169 /* Only STA mode support TM now
10170 * all other mode, TM feature should be disabled */
10171 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
10172 (~VOS_STA & pHddCtx->concurrency_mode) )
10173 {
10174 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
10175 }
10176
Jeff Johnson295189b2012-06-20 16:38:30 -070010177#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010178 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053010179 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -070010180 {
10181 //we are ok to do AMP
10182 pHddCtx->isAmpAllowed = VOS_TRUE;
10183 }
10184#endif //WLAN_BTAMP_FEATURE
10185 EXIT();
10186 return 0;
10187}
10188
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053010189/*
10190 * FUNCTION: wlan_hdd_cfg80211_change_iface
10191 * wrapper function to protect the actual implementation from SSR.
10192 */
10193int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
10194 struct net_device *ndev,
10195 enum nl80211_iftype type,
10196 u32 *flags,
10197 struct vif_params *params
10198 )
10199{
10200 int ret;
10201
10202 vos_ssr_protect(__func__);
10203 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
10204 vos_ssr_unprotect(__func__);
10205
10206 return ret;
10207}
10208
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010209#ifdef FEATURE_WLAN_TDLS
10210static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053010211 struct net_device *dev,
10212#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
10213 const u8 *mac,
10214#else
10215 u8 *mac,
10216#endif
10217 bool update, tCsrStaParams *StaParams)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010218{
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010219 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010220 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010221 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010222 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010223 hdd_adapter_t *pAdapter;
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053010224 VOS_STATUS status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010225
10226 ENTER();
10227
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010228 if (!dev) {
10229 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
10230 return -EINVAL;
10231 }
10232
10233 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10234 if (!pAdapter) {
10235 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
10236 return -EINVAL;
10237 }
10238
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053010239 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010240 {
10241 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10242 "Invalid arguments");
10243 return -EINVAL;
10244 }
Hoonki Lee27511902013-03-14 18:19:06 -070010245
10246 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
10247 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
10248 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010249 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070010250 "%s: TDLS mode is disabled OR not enabled in FW."
10251 MAC_ADDRESS_STR " Request declined.",
10252 __func__, MAC_ADDR_ARRAY(mac));
10253 return -ENOTSUPP;
10254 }
10255
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010256 if (pHddCtx->isLogpInProgress)
10257 {
10258 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10259 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053010260 wlan_hdd_tdls_set_link_status(pAdapter,
10261 mac,
10262 eTDLS_LINK_IDLE,
10263 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010264 return -EBUSY;
10265 }
10266
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053010267 mutex_lock(&pHddCtx->tdls_lock);
Naresh Jayaram9c6f4462014-02-13 12:20:31 +053010268 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010269
10270 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010271 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010272 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
10273 __func__, MAC_ADDR_ARRAY(mac), update);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053010274 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010275 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010276 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053010277 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010278
10279 /* in add station, we accept existing valid staId if there is */
10280 if ((0 == update) &&
10281 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
10282 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010283 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010284 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010285 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010286 " link_status %d. staId %d. add station ignored.",
10287 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
10288 return 0;
10289 }
10290 /* in change station, we accept only when staId is valid */
10291 if ((1 == update) &&
10292 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
10293 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
10294 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010295 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010296 "%s: " MAC_ADDRESS_STR
10297 " link status %d. staId %d. change station %s.",
10298 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
10299 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
10300 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010301 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010302
10303 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053010304 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010305 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010306 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10307 "%s: " MAC_ADDRESS_STR
10308 " TDLS setup is ongoing. Request declined.",
10309 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -070010310 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010311 }
10312
10313 /* first to check if we reached to maximum supported TDLS peer.
10314 TODO: for now, return -EPERM looks working fine,
10315 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010316 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
10317 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010318 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010319 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10320 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010321 " TDLS Max peer already connected. Request declined."
10322 " Num of peers (%d), Max allowed (%d).",
10323 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
10324 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070010325 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010326 }
10327 else
10328 {
10329 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010330 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010331 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010332 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010333 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10334 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
10335 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010336 return -EPERM;
10337 }
10338 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010339 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +053010340 wlan_hdd_tdls_set_link_status(pAdapter,
10341 mac,
10342 eTDLS_LINK_CONNECTING,
10343 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010344
Jeff Johnsond75fe012013-04-06 10:53:06 -070010345 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053010346 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010347 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010348 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010349 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -070010350 if(StaParams->htcap_present)
10351 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010352 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070010353 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070010355 "ht_capa->extended_capabilities: %0x",
10356 StaParams->HTCap.extendedHtCapInfo);
10357 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010359 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010360 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070010361 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -070010362 if(StaParams->vhtcap_present)
10363 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010364 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070010365 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
10366 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
10367 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
10368 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010369 {
10370 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010371 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010372 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010373 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010374 "[%d]: %x ", i, StaParams->supported_rates[i]);
10375 }
Jeff Johnsond75fe012013-04-06 10:53:06 -070010376 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053010377 else if ((1 == update) && (NULL == StaParams))
10378 {
10379 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10380 "%s : update is true, but staParams is NULL. Error!", __func__);
10381 return -EPERM;
10382 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010383
10384 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
10385
10386 if (!update)
10387 {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053010388 /*Before adding sta make sure that device exited from BMPS*/
10389 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
10390 {
10391 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10392 "%s: Adding tdls peer sta. Disable BMPS", __func__);
10393 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
10394 if (status != VOS_STATUS_SUCCESS) {
10395 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
10396 }
10397 }
10398
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010399 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010400 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010401 if (ret != eHAL_STATUS_SUCCESS) {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053010402 hddLog(VOS_TRACE_LEVEL_ERROR,
10403 FL("Failed to add TDLS peer STA. Enable Bmps"));
10404 wlan_hdd_tdls_check_bmps(pAdapter);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010405 return -EPERM;
10406 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010407 }
10408 else
10409 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010410 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010411 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010412 if (ret != eHAL_STATUS_SUCCESS) {
10413 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
10414 return -EPERM;
10415 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010416 }
10417
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010418 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010419 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
10420
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010421 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010422 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010423 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010424 "%s: timeout waiting for tdls add station indication %ld",
10425 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010426 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010427 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010428
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010429 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
10430 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010431 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010432 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010433 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010434 }
10435
10436 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -070010437
10438error:
Atul Mittal115287b2014-07-08 13:26:33 +053010439 wlan_hdd_tdls_set_link_status(pAdapter,
10440 mac,
10441 eTDLS_LINK_IDLE,
10442 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -070010443 return -EPERM;
10444
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010445}
10446#endif
10447
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053010448static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010449 struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053010450#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
10451 const u8 *mac,
10452#else
Jeff Johnson295189b2012-06-20 16:38:30 -070010453 u8 *mac,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053010454#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010455 struct station_parameters *params)
10456{
10457 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053010458 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +053010459 hdd_context_t *pHddCtx;
10460 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010461 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010462 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070010463#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010464 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010465 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +053010466 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070010467#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070010468
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053010469 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010470
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053010471 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +053010472 if ((NULL == pAdapter))
10473 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010474 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053010475 "invalid adapter ");
10476 return -EINVAL;
10477 }
10478
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010479 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10480 TRACE_CODE_HDD_CHANGE_STATION,
10481 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +053010482 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +053010483
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010484 ret = wlan_hdd_validate_context(pHddCtx);
10485 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +053010486 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010487 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +053010488 }
10489
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010490 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10491
10492 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010493 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010494 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10495 "invalid HDD station context");
10496 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010497 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010498 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
10499
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010500 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
10501 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -070010502 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010503 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -070010504 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010505 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -070010506 WLANTL_STA_AUTHENTICATED);
10507
Gopichand Nakkala29149562013-05-10 21:43:41 +053010508 if (status != VOS_STATUS_SUCCESS)
10509 {
10510 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10511 "%s: Not able to change TL state to AUTHENTICATED", __func__);
10512 return -EINVAL;
10513 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010514 }
10515 }
Hoonki Leea6d49be2013-04-05 09:43:25 -070010516 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
10517 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +053010518#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010519 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
10520 StaParams.capability = params->capability;
10521 StaParams.uapsd_queues = params->uapsd_queues;
10522 StaParams.max_sp = params->max_sp;
10523
Naresh Jayaram3180aa42014-02-12 21:47:26 +053010524 /* Convert (first channel , number of channels) tuple to
10525 * the total list of channels. This goes with the assumption
10526 * that if the first channel is < 14, then the next channels
10527 * are an incremental of 1 else an incremental of 4 till the number
10528 * of channels.
10529 */
10530 if (0 != params->supported_channels_len) {
10531 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
10532 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
10533 {
10534 int wifi_chan_index;
10535 StaParams.supported_channels[j] = params->supported_channels[i];
10536 wifi_chan_index =
10537 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
10538 no_of_channels = params->supported_channels[i+1];
10539 for(k=1; k <= no_of_channels; k++)
10540 {
10541 StaParams.supported_channels[j+1] =
10542 StaParams.supported_channels[j] + wifi_chan_index;
10543 j+=1;
10544 }
10545 }
10546 StaParams.supported_channels_len = j;
10547 }
10548 vos_mem_copy(StaParams.supported_oper_classes,
10549 params->supported_oper_classes,
10550 params->supported_oper_classes_len);
10551 StaParams.supported_oper_classes_len =
10552 params->supported_oper_classes_len;
10553
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010554 if (0 != params->ext_capab_len)
10555 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
10556 sizeof(StaParams.extn_capability));
10557
10558 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070010559 {
10560 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010561 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070010562 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010563
10564 StaParams.supported_rates_len = params->supported_rates_len;
10565
10566 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
10567 * The supported_rates array , for all the structures propogating till Add Sta
10568 * to the firmware has to be modified , if the supplicant (ieee80211) is
10569 * modified to send more rates.
10570 */
10571
10572 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
10573 */
10574 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
10575 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
10576
10577 if (0 != StaParams.supported_rates_len) {
10578 int i = 0;
10579 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
10580 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010581 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010582 "Supported Rates with Length %d", StaParams.supported_rates_len);
10583 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010584 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010585 "[%d]: %0x", i, StaParams.supported_rates[i]);
10586 }
10587
10588 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070010589 {
10590 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010591 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070010592 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010593
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010594 if (0 != params->ext_capab_len ) {
10595 /*Define A Macro : TODO Sunil*/
10596 if ((1<<4) & StaParams.extn_capability[3]) {
10597 isBufSta = 1;
10598 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +053010599 /* TDLS Channel Switching Support */
10600 if ((1<<6) & StaParams.extn_capability[3]) {
10601 isOffChannelSupported = 1;
10602 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010603 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +053010604 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
10605 &StaParams, isBufSta,
10606 isOffChannelSupported);
10607
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010608 if (VOS_STATUS_SUCCESS != status) {
10609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10610 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
10611 return -EINVAL;
10612 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010613 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
10614
10615 if (VOS_STATUS_SUCCESS != status) {
10616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10617 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
10618 return -EINVAL;
10619 }
10620 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -070010621#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +053010622 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010623 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010624 return status;
10625}
10626
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053010627#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
10628static int wlan_hdd_change_station(struct wiphy *wiphy,
10629 struct net_device *dev,
10630 const u8 *mac,
10631 struct station_parameters *params)
10632#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053010633static int wlan_hdd_change_station(struct wiphy *wiphy,
10634 struct net_device *dev,
10635 u8 *mac,
10636 struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053010637#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053010638{
10639 int ret;
10640
10641 vos_ssr_protect(__func__);
10642 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
10643 vos_ssr_unprotect(__func__);
10644
10645 return ret;
10646}
10647
Jeff Johnson295189b2012-06-20 16:38:30 -070010648/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053010649 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -070010650 * This function is used to initialize the key information
10651 */
10652#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053010653static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010654 struct net_device *ndev,
10655 u8 key_index, bool pairwise,
10656 const u8 *mac_addr,
10657 struct key_params *params
10658 )
10659#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053010660static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010661 struct net_device *ndev,
10662 u8 key_index, const u8 *mac_addr,
10663 struct key_params *params
10664 )
10665#endif
10666{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010667 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070010668 tCsrRoamSetKey setKey;
10669 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010670 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010671 v_U32_t roamId= 0xFF;
10672 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070010673 hdd_hostapd_state_t *pHostapdState;
10674 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070010675 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010676 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010677
10678 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010679
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010680 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10681 TRACE_CODE_HDD_CFG80211_ADD_KEY,
10682 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010683 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10684 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010685 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010686 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010687 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010688 }
10689
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010690 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10691 __func__, hdd_device_modetoString(pAdapter->device_mode),
10692 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010693
10694 if (CSR_MAX_NUM_KEY <= key_index)
10695 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010696 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070010697 key_index);
10698
10699 return -EINVAL;
10700 }
10701
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010702 if (CSR_MAX_KEY_LEN < params->key_len)
10703 {
10704 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
10705 params->key_len);
10706
10707 return -EINVAL;
10708 }
10709
10710 hddLog(VOS_TRACE_LEVEL_INFO,
10711 "%s: called with key index = %d & key length %d",
10712 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070010713
10714 /*extract key idx, key len and key*/
10715 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
10716 setKey.keyId = key_index;
10717 setKey.keyLength = params->key_len;
10718 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
10719
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010720 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070010721 {
10722 case WLAN_CIPHER_SUITE_WEP40:
10723 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
10724 break;
10725
10726 case WLAN_CIPHER_SUITE_WEP104:
10727 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
10728 break;
10729
10730 case WLAN_CIPHER_SUITE_TKIP:
10731 {
10732 u8 *pKey = &setKey.Key[0];
10733 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
10734
10735 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
10736
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010737 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -070010738
10739 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010740 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070010741 |--------------|----------|----------|
10742 <---16bytes---><--8bytes--><--8bytes-->
10743
10744 */
10745 /*Sme expects the 32 bytes key to be in the below order
10746
10747 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010748 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070010749 |--------------|----------|----------|
10750 <---16bytes---><--8bytes--><--8bytes-->
10751 */
10752 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010753 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -070010754
10755 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010756 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070010757
10758 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010759 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070010760
10761
10762 break;
10763 }
10764
10765 case WLAN_CIPHER_SUITE_CCMP:
10766 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
10767 break;
10768
10769#ifdef FEATURE_WLAN_WAPI
10770 case WLAN_CIPHER_SUITE_SMS4:
10771 {
10772 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
10773 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
10774 params->key, params->key_len);
10775 return 0;
10776 }
10777#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070010778
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010779#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010780 case WLAN_CIPHER_SUITE_KRK:
10781 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
10782 break;
10783#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070010784
10785#ifdef WLAN_FEATURE_11W
10786 case WLAN_CIPHER_SUITE_AES_CMAC:
10787 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -070010788 break;
Chet Lanctot186b5732013-03-18 10:26:30 -070010789#endif
10790
Jeff Johnson295189b2012-06-20 16:38:30 -070010791 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -070010792 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070010793 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053010794 status = -EOPNOTSUPP;
10795 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070010796 }
10797
10798 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
10799 __func__, setKey.encType);
10800
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010801 if (
Jeff Johnson295189b2012-06-20 16:38:30 -070010802#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
10803 (!pairwise)
10804#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010805 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -070010806#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010807 )
10808 {
10809 /* set group key*/
10810 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10811 "%s- %d: setting Broadcast key",
10812 __func__, __LINE__);
10813 setKey.keyDirection = eSIR_RX_ONLY;
10814 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
10815 }
10816 else
10817 {
10818 /* set pairwise key*/
10819 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10820 "%s- %d: setting pairwise key",
10821 __func__, __LINE__);
10822 setKey.keyDirection = eSIR_TX_RX;
10823 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
10824 }
10825 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
10826 {
10827 setKey.keyDirection = eSIR_TX_RX;
10828 /*Set the group key*/
10829 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
10830 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010831
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010832 if ( 0 != status )
10833 {
10834 hddLog(VOS_TRACE_LEVEL_ERROR,
10835 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053010836 status = -EINVAL;
10837 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010838 }
10839 /*Save the keys here and call sme_RoamSetKey for setting
10840 the PTK after peer joins the IBSS network*/
10841 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
10842 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053010843 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010844 }
Gopichand Nakkala29149562013-05-10 21:43:41 +053010845 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
10846 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
10847 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010848 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010849 if( pHostapdState->bssState == BSS_START )
10850 {
Nirav Shah4b53d4b2015-05-08 05:35:00 -070010851 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10852 vos_status = wlan_hdd_check_ula_done(pAdapter);
10853
10854 if ( vos_status != VOS_STATUS_SUCCESS )
10855 {
10856 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10857 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
10858 __LINE__, vos_status );
10859
10860 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
10861
10862 status = -EINVAL;
10863 goto end;
10864 }
10865
Jeff Johnson295189b2012-06-20 16:38:30 -070010866 status = WLANSAP_SetKeySta( pVosContext, &setKey);
10867
10868 if ( status != eHAL_STATUS_SUCCESS )
10869 {
10870 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10871 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
10872 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053010873 status = -EINVAL;
10874 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070010875 }
10876 }
10877
10878 /* Saving WEP keys */
10879 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
10880 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
10881 {
10882 //Save the wep key in ap context. Issue setkey after the BSS is started.
10883 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
10884 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
10885 }
10886 else
10887 {
10888 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010889 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010890 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
10891 }
10892 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010893 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
10894 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010895 {
10896 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10897 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10898
Gopichand Nakkala3d295922013-05-07 16:19:14 +053010899#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
10900 if (!pairwise)
10901#else
10902 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
10903#endif
10904 {
10905 /* set group key*/
10906 if (pHddStaCtx->roam_info.deferKeyComplete)
10907 {
10908 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10909 "%s- %d: Perform Set key Complete",
10910 __func__, __LINE__);
10911 hdd_PerformRoamSetKeyComplete(pAdapter);
10912 }
10913 }
10914
Jeff Johnson295189b2012-06-20 16:38:30 -070010915 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
10916
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -080010917 pWextState->roamProfile.Keys.defaultIndex = key_index;
10918
10919
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070010920 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070010921 params->key, params->key_len);
10922
Gopichand Nakkala3d295922013-05-07 16:19:14 +053010923
Jeff Johnson295189b2012-06-20 16:38:30 -070010924 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
10925
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010926 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070010927 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010928 __func__, setKey.peerMac[0], setKey.peerMac[1],
10929 setKey.peerMac[2], setKey.peerMac[3],
10930 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070010931 setKey.keyDirection);
10932
Nirav Shah4b53d4b2015-05-08 05:35:00 -070010933 vos_status = wlan_hdd_check_ula_done(pAdapter);
Nirav Shah4f765af2015-01-21 19:51:30 +053010934
Nirav Shah4b53d4b2015-05-08 05:35:00 -070010935 if ( vos_status != VOS_STATUS_SUCCESS )
10936 {
10937 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010938 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
10939 __LINE__, vos_status );
10940
Nirav Shah4b53d4b2015-05-08 05:35:00 -070010941 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010942
Nirav Shah4b53d4b2015-05-08 05:35:00 -070010943 status = -EINVAL;
10944 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070010945
10946 }
10947
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070010948#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +053010949 /* The supplicant may attempt to set the PTK once pre-authentication
10950 is done. Save the key in the UMAC and include it in the ADD BSS
10951 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070010952 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +053010953 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070010954 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +053010955 hddLog(VOS_TRACE_LEVEL_INFO_MED,
10956 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053010957 status = 0;
10958 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +053010959 }
10960 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
10961 {
10962 hddLog(VOS_TRACE_LEVEL_ERROR,
10963 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053010964 status = -EINVAL;
10965 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070010966 }
10967#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -070010968
10969 /* issue set key request to SME*/
10970 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
10971 pAdapter->sessionId, &setKey, &roamId );
10972
10973 if ( 0 != status )
10974 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010975 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010976 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
10977 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053010978 status = -EINVAL;
10979 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070010980 }
10981
10982
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010983 /* in case of IBSS as there was no information available about WEP keys during
10984 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -070010985 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010986 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
10987 !( ( IW_AUTH_KEY_MGMT_802_1X
10988 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -070010989 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
10990 )
10991 &&
10992 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
10993 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
10994 )
10995 )
10996 {
10997 setKey.keyDirection = eSIR_RX_ONLY;
10998 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
10999
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011000 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011001 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011002 __func__, setKey.peerMac[0], setKey.peerMac[1],
11003 setKey.peerMac[2], setKey.peerMac[3],
11004 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070011005 setKey.keyDirection);
11006
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011007 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011008 pAdapter->sessionId, &setKey, &roamId );
11009
11010 if ( 0 != status )
11011 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011012 hddLog(VOS_TRACE_LEVEL_ERROR,
11013 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011014 __func__, status);
11015 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011016 status = -EINVAL;
11017 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011018 }
11019 }
11020 }
11021
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011022end:
11023 /* Need to clear any trace of key value in the memory.
11024 * Thus zero out the memory even though it is local
11025 * variable.
11026 */
11027 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011028 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011029 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011030}
11031
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011032#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11033static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
11034 struct net_device *ndev,
11035 u8 key_index, bool pairwise,
11036 const u8 *mac_addr,
11037 struct key_params *params
11038 )
11039#else
11040static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
11041 struct net_device *ndev,
11042 u8 key_index, const u8 *mac_addr,
11043 struct key_params *params
11044 )
11045#endif
11046{
11047 int ret;
11048 vos_ssr_protect(__func__);
11049#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11050 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
11051 mac_addr, params);
11052#else
11053 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
11054 params);
11055#endif
11056 vos_ssr_unprotect(__func__);
11057
11058 return ret;
11059}
11060
Jeff Johnson295189b2012-06-20 16:38:30 -070011061/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011062 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011063 * This function is used to get the key information
11064 */
11065#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011066static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011067 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011068 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011069 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070011070 const u8 *mac_addr, void *cookie,
11071 void (*callback)(void *cookie, struct key_params*)
11072 )
11073#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011074static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011075 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011076 struct net_device *ndev,
11077 u8 key_index, const u8 *mac_addr, void *cookie,
11078 void (*callback)(void *cookie, struct key_params*)
11079 )
11080#endif
11081{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011082 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011083 hdd_wext_state_t *pWextState = NULL;
11084 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011085 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011086 hdd_context_t *pHddCtx;
11087 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070011088
11089 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011090
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011091 if (NULL == pAdapter)
11092 {
11093 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11094 "%s: HDD adapter is Null", __func__);
11095 return -ENODEV;
11096 }
11097
11098 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11099 ret = wlan_hdd_validate_context(pHddCtx);
11100 if (0 != ret)
11101 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011102 return ret;
11103 }
11104
11105 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11106 pRoamProfile = &(pWextState->roamProfile);
11107
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011108 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11109 __func__, hdd_device_modetoString(pAdapter->device_mode),
11110 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011111
Jeff Johnson295189b2012-06-20 16:38:30 -070011112 memset(&params, 0, sizeof(params));
11113
11114 if (CSR_MAX_NUM_KEY <= key_index)
11115 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011116 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070011117 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011118 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011119
11120 switch(pRoamProfile->EncryptionType.encryptionType[0])
11121 {
11122 case eCSR_ENCRYPT_TYPE_NONE:
11123 params.cipher = IW_AUTH_CIPHER_NONE;
11124 break;
11125
11126 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
11127 case eCSR_ENCRYPT_TYPE_WEP40:
11128 params.cipher = WLAN_CIPHER_SUITE_WEP40;
11129 break;
11130
11131 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
11132 case eCSR_ENCRYPT_TYPE_WEP104:
11133 params.cipher = WLAN_CIPHER_SUITE_WEP104;
11134 break;
11135
11136 case eCSR_ENCRYPT_TYPE_TKIP:
11137 params.cipher = WLAN_CIPHER_SUITE_TKIP;
11138 break;
11139
11140 case eCSR_ENCRYPT_TYPE_AES:
11141 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
11142 break;
11143
11144 default:
11145 params.cipher = IW_AUTH_CIPHER_NONE;
11146 break;
11147 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011148
c_hpothuaaf19692014-05-17 17:01:48 +053011149 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11150 TRACE_CODE_HDD_CFG80211_GET_KEY,
11151 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011152
Jeff Johnson295189b2012-06-20 16:38:30 -070011153 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
11154 params.seq_len = 0;
11155 params.seq = NULL;
11156 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
11157 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011158 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011159 return 0;
11160}
11161
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011162#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11163static int wlan_hdd_cfg80211_get_key(
11164 struct wiphy *wiphy,
11165 struct net_device *ndev,
11166 u8 key_index, bool pairwise,
11167 const u8 *mac_addr, void *cookie,
11168 void (*callback)(void *cookie, struct key_params*)
11169 )
11170#else
11171static int wlan_hdd_cfg80211_get_key(
11172 struct wiphy *wiphy,
11173 struct net_device *ndev,
11174 u8 key_index, const u8 *mac_addr, void *cookie,
11175 void (*callback)(void *cookie, struct key_params*)
11176 )
11177#endif
11178{
11179 int ret;
11180
11181 vos_ssr_protect(__func__);
11182#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11183 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
11184 mac_addr, cookie, callback);
11185#else
11186 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
11187 callback);
11188#endif
11189 vos_ssr_unprotect(__func__);
11190
11191 return ret;
11192}
11193
Jeff Johnson295189b2012-06-20 16:38:30 -070011194/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011195 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011196 * This function is used to delete the key information
11197 */
11198#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011199static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011200 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011201 u8 key_index,
11202 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070011203 const u8 *mac_addr
11204 )
11205#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011206static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011207 struct net_device *ndev,
11208 u8 key_index,
11209 const u8 *mac_addr
11210 )
11211#endif
11212{
11213 int status = 0;
11214
11215 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011216 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -070011217 //it is observed that this is invalidating peer
11218 //key index whenever re-key is done. This is affecting data link.
11219 //It should be ok to ignore del_key.
11220#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011221 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
11222 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070011223 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
11224 tCsrRoamSetKey setKey;
11225 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011226
Jeff Johnson295189b2012-06-20 16:38:30 -070011227 ENTER();
11228
11229 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
11230 __func__,pAdapter->device_mode);
11231
11232 if (CSR_MAX_NUM_KEY <= key_index)
11233 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011234 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011235 key_index);
11236
11237 return -EINVAL;
11238 }
11239
11240 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11241 setKey.keyId = key_index;
11242
11243 if (mac_addr)
11244 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
11245 else
11246 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
11247
11248 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
11249
11250 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070011251 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011252 )
11253 {
11254
11255 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -070011256 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
11257 if( pHostapdState->bssState == BSS_START)
11258 {
11259 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011260
Jeff Johnson295189b2012-06-20 16:38:30 -070011261 if ( status != eHAL_STATUS_SUCCESS )
11262 {
11263 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11264 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
11265 __LINE__, status );
11266 }
11267 }
11268 }
11269 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011270 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -070011271 )
11272 {
11273 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11274
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011275 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
11276
11277 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011278 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011279 __func__, setKey.peerMac[0], setKey.peerMac[1],
11280 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -070011281 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011282 if(pAdapter->sessionCtx.station.conn_info.connState ==
11283 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -070011284 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011285 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011286 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011287
Jeff Johnson295189b2012-06-20 16:38:30 -070011288 if ( 0 != status )
11289 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011290 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011291 "%s: sme_RoamSetKey failure, returned %d",
11292 __func__, status);
11293 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
11294 return -EINVAL;
11295 }
11296 }
11297 }
11298#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070011299 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011300 return status;
11301}
11302
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011303#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11304static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
11305 struct net_device *ndev,
11306 u8 key_index,
11307 bool pairwise,
11308 const u8 *mac_addr
11309 )
11310#else
11311static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
11312 struct net_device *ndev,
11313 u8 key_index,
11314 const u8 *mac_addr
11315 )
11316#endif
11317{
11318 int ret;
11319
11320 vos_ssr_protect(__func__);
11321#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11322 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
11323 mac_addr);
11324#else
11325 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
11326#endif
11327 vos_ssr_unprotect(__func__);
11328
11329 return ret;
11330}
11331
Jeff Johnson295189b2012-06-20 16:38:30 -070011332/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011333 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011334 * This function is used to set the default tx key index
11335 */
11336#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011337static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011338 struct net_device *ndev,
11339 u8 key_index,
11340 bool unicast, bool multicast)
11341#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011342static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011343 struct net_device *ndev,
11344 u8 key_index)
11345#endif
11346{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011347 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011348 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +053011349 hdd_wext_state_t *pWextState;
11350 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011351 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011352
11353 ENTER();
11354
Gopichand Nakkala29149562013-05-10 21:43:41 +053011355 if ((NULL == pAdapter))
11356 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011357 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053011358 "invalid adapter");
11359 return -EINVAL;
11360 }
11361
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011362 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11363 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
11364 pAdapter->sessionId, key_index));
11365
Gopichand Nakkala29149562013-05-10 21:43:41 +053011366 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11367 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11368
11369 if ((NULL == pWextState) || (NULL == pHddStaCtx))
11370 {
11371 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11372 "invalid Wext state or HDD context");
11373 return -EINVAL;
11374 }
11375
Arif Hussain6d2a3322013-11-17 19:50:10 -080011376 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011377 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011378
Jeff Johnson295189b2012-06-20 16:38:30 -070011379 if (CSR_MAX_NUM_KEY <= key_index)
11380 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011381 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011382 key_index);
11383
11384 return -EINVAL;
11385 }
11386
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011387 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11388 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011389 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011390 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011391 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011392 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011393
Jeff Johnson295189b2012-06-20 16:38:30 -070011394 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070011395 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011396 )
Jeff Johnson295189b2012-06-20 16:38:30 -070011397 {
Gopichand Nakkala29149562013-05-10 21:43:41 +053011398 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -080011399 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011400 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -080011401 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -070011402 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011403 {
11404 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -070011405 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011406
Jeff Johnson295189b2012-06-20 16:38:30 -070011407 tCsrRoamSetKey setKey;
11408 v_U32_t roamId= 0xFF;
11409 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011410
11411 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011412 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011413
Jeff Johnson295189b2012-06-20 16:38:30 -070011414 Keys->defaultIndex = (u8)key_index;
11415 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11416 setKey.keyId = key_index;
11417 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011418
11419 vos_mem_copy(&setKey.Key[0],
11420 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070011421 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011422
Gopichand Nakkala29149562013-05-10 21:43:41 +053011423 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011424
11425 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -070011426 &pHddStaCtx->conn_info.bssId[0],
11427 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011428
Gopichand Nakkala29149562013-05-10 21:43:41 +053011429 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
11430 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
11431 eCSR_ENCRYPT_TYPE_WEP104)
11432 {
11433 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
11434 even though ap is configured for WEP-40 encryption. In this canse the key length
11435 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
11436 type(104) and switching encryption type to 40*/
11437 pWextState->roamProfile.EncryptionType.encryptionType[0] =
11438 eCSR_ENCRYPT_TYPE_WEP40;
11439 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
11440 eCSR_ENCRYPT_TYPE_WEP40;
11441 }
11442
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011443 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -070011444 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011445
Jeff Johnson295189b2012-06-20 16:38:30 -070011446 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011447 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011448 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011449
Jeff Johnson295189b2012-06-20 16:38:30 -070011450 if ( 0 != status )
11451 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011452 hddLog(VOS_TRACE_LEVEL_ERROR,
11453 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011454 status);
11455 return -EINVAL;
11456 }
11457 }
11458 }
11459
11460 /* In SoftAp mode setting key direction for default mode */
11461 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
11462 {
11463 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
11464 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
11465 (eCSR_ENCRYPT_TYPE_AES !=
11466 pWextState->roamProfile.EncryptionType.encryptionType[0])
11467 )
11468 {
11469 /* Saving key direction for default key index to TX default */
11470 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
11471 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
11472 }
11473 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011474 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011475 return status;
11476}
11477
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011478#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11479static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
11480 struct net_device *ndev,
11481 u8 key_index,
11482 bool unicast, bool multicast)
11483#else
11484static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
11485 struct net_device *ndev,
11486 u8 key_index)
11487#endif
11488{
11489 int ret;
11490 vos_ssr_protect(__func__);
11491#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11492 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
11493 multicast);
11494#else
11495 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
11496#endif
11497 vos_ssr_unprotect(__func__);
11498
11499 return ret;
11500}
11501
Jeff Johnson295189b2012-06-20 16:38:30 -070011502/*
11503 * FUNCTION: wlan_hdd_cfg80211_inform_bss
11504 * This function is used to inform the BSS details to nl80211 interface.
11505 */
11506static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
11507 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
11508{
11509 struct net_device *dev = pAdapter->dev;
11510 struct wireless_dev *wdev = dev->ieee80211_ptr;
11511 struct wiphy *wiphy = wdev->wiphy;
11512 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
11513 int chan_no;
11514 int ie_length;
11515 const char *ie;
11516 unsigned int freq;
11517 struct ieee80211_channel *chan;
11518 int rssi = 0;
11519 struct cfg80211_bss *bss = NULL;
11520
Jeff Johnson295189b2012-06-20 16:38:30 -070011521 if( NULL == pBssDesc )
11522 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011523 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011524 return bss;
11525 }
11526
11527 chan_no = pBssDesc->channelId;
11528 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
11529 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
11530
11531 if( NULL == ie )
11532 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011533 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011534 return bss;
11535 }
11536
11537#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
11538 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
11539 {
11540 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
11541 }
11542 else
11543 {
11544 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
11545 }
11546#else
11547 freq = ieee80211_channel_to_frequency(chan_no);
11548#endif
11549
11550 chan = __ieee80211_get_channel(wiphy, freq);
11551
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +053011552 if (!chan) {
11553 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
11554 return NULL;
11555 }
11556
Abhishek Singhaee43942014-06-16 18:55:47 +053011557 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -070011558
Anand N Sunkad9f80b742015-07-30 20:05:51 +053011559 return cfg80211_inform_bss(wiphy, chan,
11560#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11561 CFG80211_BSS_FTYPE_UNKNOWN,
11562#endif
11563 pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011564 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -070011565 pBssDesc->capabilityInfo,
11566 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +053011567 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -070011568}
11569
11570
11571
11572/*
11573 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
11574 * This function is used to inform the BSS details to nl80211 interface.
11575 */
11576struct cfg80211_bss*
11577wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
11578 tSirBssDescription *bss_desc
11579 )
11580{
11581 /*
11582 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
11583 already exists in bss data base of cfg80211 for that particular BSS ID.
11584 Using cfg80211_inform_bss_frame to update the bss entry instead of
11585 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
11586 now there is no possibility to get the mgmt(probe response) frame from PE,
11587 converting bss_desc to ieee80211_mgmt(probe response) and passing to
11588 cfg80211_inform_bss_frame.
11589 */
11590 struct net_device *dev = pAdapter->dev;
11591 struct wireless_dev *wdev = dev->ieee80211_ptr;
11592 struct wiphy *wiphy = wdev->wiphy;
11593 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080011594#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
11595 qcom_ie_age *qie_age = NULL;
11596 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
11597#else
Jeff Johnson295189b2012-06-20 16:38:30 -070011598 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080011599#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011600 const char *ie =
11601 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
11602 unsigned int freq;
11603 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053011604 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011605 struct cfg80211_bss *bss_status = NULL;
11606 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
11607 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -070011608 hdd_context_t *pHddCtx;
11609 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -070011610#ifdef WLAN_OPEN_SOURCE
11611 struct timespec ts;
11612#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011613
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011614
Wilson Yangf80a0542013-10-07 13:02:37 -070011615 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11616 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -070011617 if (0 != status)
11618 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070011619 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070011620 }
11621
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053011622 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -070011623 if (!mgmt)
11624 {
11625 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11626 "%s: memory allocation failed ", __func__);
11627 return NULL;
11628 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070011629
Jeff Johnson295189b2012-06-20 16:38:30 -070011630 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -070011631
11632#ifdef WLAN_OPEN_SOURCE
11633 /* Android does not want the timestamp from the frame.
11634 Instead it wants a monotonic increasing value */
11635 get_monotonic_boottime(&ts);
11636 mgmt->u.probe_resp.timestamp =
11637 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
11638#else
11639 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -070011640 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
11641 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -070011642
11643#endif
11644
Jeff Johnson295189b2012-06-20 16:38:30 -070011645 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
11646 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080011647
11648#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
11649 /* GPS Requirement: need age ie per entry. Using vendor specific. */
11650 /* Assuming this is the last IE, copy at the end */
11651 ie_length -=sizeof(qcom_ie_age);
11652 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
11653 qie_age->element_id = QCOM_VENDOR_IE_ID;
11654 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
11655 qie_age->oui_1 = QCOM_OUI1;
11656 qie_age->oui_2 = QCOM_OUI2;
11657 qie_age->oui_3 = QCOM_OUI3;
11658 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
11659 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
11660#endif
11661
Jeff Johnson295189b2012-06-20 16:38:30 -070011662 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +053011663 if (bss_desc->fProbeRsp)
11664 {
11665 mgmt->frame_control |=
11666 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
11667 }
11668 else
11669 {
11670 mgmt->frame_control |=
11671 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
11672 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011673
11674#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011675 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070011676 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
11677 {
11678 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
11679 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011680 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070011681 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
11682
11683 {
11684 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
11685 }
11686 else
11687 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053011688 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
11689 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -070011690 kfree(mgmt);
11691 return NULL;
11692 }
11693#else
11694 freq = ieee80211_channel_to_frequency(chan_no);
11695#endif
11696 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080011697 /*when the band is changed on the fly using the GUI, three things are done
11698 * 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)
11699 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
11700 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
11701 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
11702 * and discards the channels correponding to previous band and calls back with zero bss results.
11703 * 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
11704 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
11705 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
11706 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
11707 * So drop the bss and continue to next bss.
11708 */
11709 if(chan == NULL)
11710 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053011711 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -070011712 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080011713 return NULL;
11714 }
Hanumantha Reddy Pothula904bcef2015-06-19 11:56:29 +053011715 /*To keep the rssi icon of the connected AP in the scan window
11716 *and the rssi icon of the wireless networks in sync
11717 * */
11718 if (( eConnectionState_Associated ==
11719 pAdapter->sessionCtx.station.conn_info.connState ) &&
11720 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
11721 pAdapter->sessionCtx.station.conn_info.bssId,
11722 WNI_CFG_BSSID_LEN)) &&
11723 (pHddCtx->hdd_wlan_suspended == FALSE))
11724 {
11725 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
11726 rssi = (pAdapter->rssi * 100);
11727 }
11728 else
11729 {
11730 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
11731 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011732
Nirav Shah20ac06f2013-12-12 18:14:06 +053011733 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
Sushant Kaushik0b343422015-05-25 17:15:55 +053011734 " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
11735 vos_freq_to_chan(chan->center_freq), (int)(rssi/100));
Nirav Shah20ac06f2013-12-12 18:14:06 +053011736
Jeff Johnson295189b2012-06-20 16:38:30 -070011737 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
11738 frame_len, rssi, GFP_KERNEL);
11739 kfree(mgmt);
11740 return bss_status;
11741}
11742
11743/*
11744 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
11745 * This function is used to update the BSS data base of CFG8011
11746 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011747struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011748 tCsrRoamInfo *pRoamInfo
11749 )
11750{
11751 tCsrRoamConnectedProfile roamProfile;
11752 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11753 struct cfg80211_bss *bss = NULL;
11754
11755 ENTER();
11756
11757 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
11758 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
11759
11760 if (NULL != roamProfile.pBssDesc)
11761 {
Girish Gowlif4b68022014-08-28 23:18:57 +053011762 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
11763 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070011764
11765 if (NULL == bss)
11766 {
11767 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
11768 __func__);
11769 }
11770
11771 sme_RoamFreeConnectProfile(hHal, &roamProfile);
11772 }
11773 else
11774 {
11775 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
11776 __func__);
11777 }
11778 return bss;
11779}
11780
11781/*
11782 * FUNCTION: wlan_hdd_cfg80211_update_bss
11783 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011784static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
11785 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -070011786 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011787{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011788 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011789 tCsrScanResultInfo *pScanResult;
11790 eHalStatus status = 0;
11791 tScanResultHandle pResult;
11792 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070011793 hdd_context_t *pHddCtx;
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053011794 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070011795 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011796
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011797 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11798 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
11799 NO_SESSION, pAdapter->sessionId));
11800
Wilson Yangf80a0542013-10-07 13:02:37 -070011801 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11802
11803 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -070011804 {
Wilson Yangf80a0542013-10-07 13:02:37 -070011805 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11806 "%s:LOGP in Progress. Ignore!!!",__func__);
11807 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -070011808 }
11809
Wilson Yangf80a0542013-10-07 13:02:37 -070011810
11811 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +053011812 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -070011813 {
11814 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11815 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
11816 return VOS_STATUS_E_PERM;
11817 }
11818
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053011819 if (pAdapter->request != NULL)
11820 {
11821 if ((pAdapter->request->n_ssids == 1)
11822 && (pAdapter->request->ssids != NULL)
11823 && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7))
11824 is_p2p_scan = true;
11825 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011826 /*
11827 * start getting scan results and populate cgf80211 BSS database
11828 */
11829 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
11830
11831 /* no scan results */
11832 if (NULL == pResult)
11833 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053011834 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
11835 __func__, status);
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053011836 wlan_hdd_get_frame_logs(pAdapter,
11837 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Jeff Johnson295189b2012-06-20 16:38:30 -070011838 return status;
11839 }
11840
11841 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
11842
11843 while (pScanResult)
11844 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011845 /*
11846 * cfg80211_inform_bss() is not updating ie field of bss entry, if
11847 * entry already exists in bss data base of cfg80211 for that
11848 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
11849 * bss entry instead of cfg80211_inform_bss, But this call expects
11850 * mgmt packet as input. As of now there is no possibility to get
11851 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -070011852 * ieee80211_mgmt(probe response) and passing to c
11853 * fg80211_inform_bss_frame.
11854 * */
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053011855 if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) &&
11856 !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) )
11857 {
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053011858 pScanResult = sme_ScanResultGetNext(hHal, pResult);
11859 continue; //Skip the non p2p bss entries
11860 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011861 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
11862 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011863
Jeff Johnson295189b2012-06-20 16:38:30 -070011864
11865 if (NULL == bss_status)
11866 {
11867 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011868 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011869 }
11870 else
11871 {
Yue Maf49ba872013-08-19 12:04:25 -070011872 cfg80211_put_bss(
11873#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
11874 wiphy,
11875#endif
11876 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011877 }
11878
11879 pScanResult = sme_ScanResultGetNext(hHal, pResult);
11880 }
11881
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011882 sme_ScanResultPurge(hHal, pResult);
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053011883 is_p2p_scan = false;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011884 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070011885}
11886
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011887void
11888hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
11889{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011890 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080011891 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011892} /****** end hddPrintMacAddr() ******/
11893
11894void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070011895hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011896{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011897 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011898 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070011899 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
11900 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
11901 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011902} /****** end hddPrintPmkId() ******/
11903
11904//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
11905//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
11906
11907//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
11908//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
11909
11910#define dump_bssid(bssid) \
11911 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070011912 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
11913 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011914 }
11915
11916#define dump_pmkid(pMac, pmkid) \
11917 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070011918 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
11919 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011920 }
11921
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070011922#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011923/*
11924 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
11925 * This function is used to notify the supplicant of a new PMKSA candidate.
11926 */
11927int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011928 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011929 int index, bool preauth )
11930{
Jeff Johnsone7245742012-09-05 17:12:55 -070011931#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011932 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011933 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011934
11935 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070011936 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011937
11938 if( NULL == pRoamInfo )
11939 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011940 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011941 return -EINVAL;
11942 }
11943
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011944 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
11945 {
11946 dump_bssid(pRoamInfo->bssid);
11947 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011948 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070011949 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011950#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011951 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011952}
11953#endif //FEATURE_WLAN_LFR
11954
Yue Maef608272013-04-08 23:09:17 -070011955#ifdef FEATURE_WLAN_LFR_METRICS
11956/*
11957 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
11958 * 802.11r/LFR metrics reporting function to report preauth initiation
11959 *
11960 */
11961#define MAX_LFR_METRICS_EVENT_LENGTH 100
11962VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
11963 tCsrRoamInfo *pRoamInfo)
11964{
11965 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
11966 union iwreq_data wrqu;
11967
11968 ENTER();
11969
11970 if (NULL == pAdapter)
11971 {
11972 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
11973 return VOS_STATUS_E_FAILURE;
11974 }
11975
11976 /* create the event */
11977 memset(&wrqu, 0, sizeof(wrqu));
11978 memset(metrics_notification, 0, sizeof(metrics_notification));
11979
11980 wrqu.data.pointer = metrics_notification;
11981 wrqu.data.length = scnprintf(metrics_notification,
11982 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
11983 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
11984
11985 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
11986
11987 EXIT();
11988
11989 return VOS_STATUS_SUCCESS;
11990}
11991
11992/*
11993 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
11994 * 802.11r/LFR metrics reporting function to report preauth completion
11995 * or failure
11996 */
11997VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
11998 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
11999{
12000 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12001 union iwreq_data wrqu;
12002
12003 ENTER();
12004
12005 if (NULL == pAdapter)
12006 {
12007 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12008 return VOS_STATUS_E_FAILURE;
12009 }
12010
12011 /* create the event */
12012 memset(&wrqu, 0, sizeof(wrqu));
12013 memset(metrics_notification, 0, sizeof(metrics_notification));
12014
12015 scnprintf(metrics_notification, sizeof(metrics_notification),
12016 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
12017 MAC_ADDR_ARRAY(pRoamInfo->bssid));
12018
12019 if (1 == preauth_status)
12020 strncat(metrics_notification, " TRUE", 5);
12021 else
12022 strncat(metrics_notification, " FALSE", 6);
12023
12024 wrqu.data.pointer = metrics_notification;
12025 wrqu.data.length = strlen(metrics_notification);
12026
12027 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12028
12029 EXIT();
12030
12031 return VOS_STATUS_SUCCESS;
12032}
12033
12034/*
12035 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
12036 * 802.11r/LFR metrics reporting function to report handover initiation
12037 *
12038 */
12039VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
12040 tCsrRoamInfo *pRoamInfo)
12041{
12042 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12043 union iwreq_data wrqu;
12044
12045 ENTER();
12046
12047 if (NULL == pAdapter)
12048 {
12049 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12050 return VOS_STATUS_E_FAILURE;
12051 }
12052
12053 /* create the event */
12054 memset(&wrqu, 0, sizeof(wrqu));
12055 memset(metrics_notification, 0, sizeof(metrics_notification));
12056
12057 wrqu.data.pointer = metrics_notification;
12058 wrqu.data.length = scnprintf(metrics_notification,
12059 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
12060 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
12061
12062 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12063
12064 EXIT();
12065
12066 return VOS_STATUS_SUCCESS;
12067}
12068#endif
12069
Jeff Johnson295189b2012-06-20 16:38:30 -070012070/*
12071 * FUNCTION: hdd_cfg80211_scan_done_callback
12072 * scanning callback function, called after finishing scan
12073 *
12074 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012075static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070012076 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
12077{
12078 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012079 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070012080 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012081 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012082 struct cfg80211_scan_request *req = NULL;
12083 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012084 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012085 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012086 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012087 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012088
12089 ENTER();
12090
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012091 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal5c2e02d2015-05-05 17:35:29 +053012092 if (NULL == pHddCtx) {
12093 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null"));
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012094 goto allow_suspend;
12095 }
12096
12097 pScanInfo = &pHddCtx->scan_info;
12098
Jeff Johnson295189b2012-06-20 16:38:30 -070012099 hddLog(VOS_TRACE_LEVEL_INFO,
12100 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080012101 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012102 __func__, halHandle, pContext, (int) scanId, (int) status);
12103
Kiet Lamac06e2c2013-10-23 16:25:07 +053012104 pScanInfo->mScanPendingCounter = 0;
12105
Jeff Johnson295189b2012-06-20 16:38:30 -070012106 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012107 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070012108 &pScanInfo->scan_req_completion_event,
12109 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012110 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070012111 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012112 hddLog(VOS_TRACE_LEVEL_ERROR,
12113 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070012114 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070012115 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070012116 }
12117
Yue Maef608272013-04-08 23:09:17 -070012118 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070012119 {
12120 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070012121 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070012122 }
12123
12124 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012125 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070012126 {
12127 hddLog(VOS_TRACE_LEVEL_INFO,
12128 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080012129 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070012130 (int) scanId);
12131 }
12132
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012133 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012134 pAdapter);
12135
12136 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012137 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012138
12139
12140 /* If any client wait scan result through WEXT
12141 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012142 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070012143 {
12144 /* The other scan request waiting for current scan finish
12145 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012146 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070012147 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012148 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070012149 }
12150 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012151 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070012152 {
12153 struct net_device *dev = pAdapter->dev;
12154 union iwreq_data wrqu;
12155 int we_event;
12156 char *msg;
12157
12158 memset(&wrqu, '\0', sizeof(wrqu));
12159 we_event = SIOCGIWSCAN;
12160 msg = NULL;
12161 wireless_send_event(dev, we_event, &wrqu, msg);
12162 }
12163 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012164 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012165
12166 /* Get the Scan Req */
12167 req = pAdapter->request;
12168
12169 if (!req)
12170 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012171 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070012172 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -070012173 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070012174 }
12175
Jeff Johnson295189b2012-06-20 16:38:30 -070012176 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -070012177 /* Scan is no longer pending */
12178 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012179
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012180 /* last_scan_timestamp is used to decide if new scan
12181 * is needed or not on station interface. If last station
12182 * scan time and new station scan time is less then
12183 * last_scan_timestamp ; driver will return cached scan.
12184 */
12185 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
12186 {
12187 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
12188
12189 if ( req->n_channels )
12190 {
12191 for (i = 0; i < req->n_channels ; i++ )
12192 {
12193 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
12194 }
12195 /* store no of channel scanned */
12196 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
12197 }
12198
12199 }
12200
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070012201 /*
12202 * cfg80211_scan_done informing NL80211 about completion
12203 * of scanning
12204 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012205 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
12206 {
12207 aborted = true;
12208 }
12209 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080012210 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070012211
Siddharth Bhal76972212014-10-15 16:22:51 +053012212 if (pHddCtx->spoofMacAddr.isEnabled || pHddCtx->spoofMacAddr.isReqDeferred) {
12213 /* Generate new random mac addr for next scan */
12214 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
12215 hdd_processSpoofMacAddrRequest(pHddCtx);
12216 }
12217
Jeff Johnsone7245742012-09-05 17:12:55 -070012218allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070012219 /* release the wake lock at the end of the scan*/
Sushant Kaushik83392fa2015-05-05 17:44:40 +053012220 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070012221
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070012222 /* Acquire wakelock to handle the case where APP's tries to suspend
12223 * immediatly after the driver gets connect request(i.e after scan)
12224 * from supplicant, this result in app's is suspending and not able
12225 * to process the connect request to AP */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053012226 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070012227
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070012228#ifdef FEATURE_WLAN_TDLS
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053012229 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070012230#endif
12231
Jeff Johnson295189b2012-06-20 16:38:30 -070012232 EXIT();
12233 return 0;
12234}
12235
12236/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053012237 * FUNCTION: hdd_isConnectionInProgress
12238 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012239 *
12240 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012241v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012242{
12243 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
12244 hdd_station_ctx_t *pHddStaCtx = NULL;
12245 hdd_adapter_t *pAdapter = NULL;
12246 VOS_STATUS status = 0;
12247 v_U8_t staId = 0;
12248 v_U8_t *staMac = NULL;
12249
c_hpothu9b781ba2013-12-30 20:57:45 +053012250 if (TRUE == pHddCtx->btCoexModeSet)
12251 {
12252 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +053012253 FL("BTCoex Mode operation in progress"));
12254 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +053012255 }
12256
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012257 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
12258
12259 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
12260 {
12261 pAdapter = pAdapterNode->pAdapter;
12262
12263 if( pAdapter )
12264 {
12265 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012266 "%s: Adapter with device mode %s (%d) exists",
12267 __func__, hdd_device_modetoString(pAdapter->device_mode),
12268 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012269 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053012270 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
12271 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
12272 (eConnectionState_Connecting ==
12273 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
12274 {
12275 hddLog(VOS_TRACE_LEVEL_ERROR,
12276 "%s: %p(%d) Connection is in progress", __func__,
12277 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
12278 return VOS_TRUE;
12279 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012280 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053012281 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012282 {
12283 hddLog(VOS_TRACE_LEVEL_ERROR,
12284 "%s: %p(%d) Reassociation is in progress", __func__,
12285 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
12286 return VOS_TRUE;
12287 }
12288 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012289 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
12290 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012291 {
12292 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12293 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012294 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012295 {
12296 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
12297 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080012298 "%s: client " MAC_ADDRESS_STR
12299 " is in the middle of WPS/EAPOL exchange.", __func__,
12300 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053012301 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012302 }
12303 }
12304 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
12305 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
12306 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012307 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
12308 ptSapContext pSapCtx = NULL;
12309 pSapCtx = VOS_GET_SAP_CB(pVosContext);
12310 if(pSapCtx == NULL){
12311 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12312 FL("psapCtx is NULL"));
12313 return VOS_FALSE;
12314 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012315 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
12316 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012317 if ((pSapCtx->aStaInfo[staId].isUsed) &&
12318 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012319 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012320 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012321
12322 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080012323 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
12324 "middle of WPS/EAPOL exchange.", __func__,
12325 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053012326 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012327 }
12328 }
12329 }
12330 }
12331 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
12332 pAdapterNode = pNext;
12333 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053012334 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012335}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012336
12337/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012338 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070012339 * this scan respond to scan trigger and update cfg80211 scan database
12340 * later, scan dump command can be used to recieve scan results
12341 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012342int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080012343#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
12344 struct net_device *dev,
12345#endif
12346 struct cfg80211_scan_request *request)
12347{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053012348 hdd_adapter_t *pAdapter = NULL;
12349 hdd_context_t *pHddCtx = NULL;
12350 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012351 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012352 tCsrScanRequest scanRequest;
12353 tANI_U8 *channelList = NULL, i;
12354 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012355 int status;
12356 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012357 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012358 int ret = 0;
Sushant Kaushik86592172015-04-27 16:35:03 +053012359 v_U8_t *pWpsIe=NULL;
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053012360 bool is_p2p_scan = false;
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053012361 v_S7_t rssi=0;
12362 hdd_station_ctx_t *pHddStaCtx=NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012363
Siddharth Bhal0c162d02014-05-06 19:50:42 +053012364#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
12365 struct net_device *dev = NULL;
12366 if (NULL == request)
12367 {
12368 hddLog(VOS_TRACE_LEVEL_ERROR,
12369 "%s: scan req param null", __func__);
12370 return -EINVAL;
12371 }
12372 dev = request->wdev->netdev;
12373#endif
12374
12375 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
12376 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
12377 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12378
Jeff Johnson295189b2012-06-20 16:38:30 -070012379 ENTER();
12380
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012381 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
12382 __func__, hdd_device_modetoString(pAdapter->device_mode),
12383 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012384
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012385 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012386 if (0 != status)
12387 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012388 return status;
12389 }
12390
Siddharth Bhal0c162d02014-05-06 19:50:42 +053012391 if (NULL == pwextBuf)
12392 {
12393 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
12394 __func__);
12395 return -EIO;
12396 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012397 cfg_param = pHddCtx->cfg_ini;
12398 pScanInfo = &pHddCtx->scan_info;
12399
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053012400 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12401 if ( (pHddStaCtx != NULL) && (TRUE == hdd_connIsConnected(pHddStaCtx)))
12402 {
12403 wlan_hdd_get_roam_rssi(pAdapter, &rssi);
12404 hddLog(VOS_TRACE_LEVEL_INFO, FL("rssi: %d"), rssi);
12405 }
12406
Jeff Johnson295189b2012-06-20 16:38:30 -070012407#ifdef WLAN_BTAMP_FEATURE
12408 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012409 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070012410 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080012411 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012412 "%s: No scanning when AMP is on", __func__);
12413 return -EOPNOTSUPP;
12414 }
12415#endif
12416 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012417 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070012418 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012419 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012420 "%s: Not scanning on device_mode = %s (%d)",
12421 __func__, hdd_device_modetoString(pAdapter->device_mode),
12422 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012423 return -EOPNOTSUPP;
12424 }
12425
12426 if (TRUE == pScanInfo->mScanPending)
12427 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053012428 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
12429 {
12430 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
12431 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012432 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070012433 }
12434
Hanumantha Reddy Pothula4b6be062015-08-18 14:06:24 +053012435 // Don't allow scan if PNO scan is going on.
12436 if (pHddCtx->isPnoEnable)
12437 {
12438 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12439 FL("pno scan in progress"));
12440 return -EBUSY;
12441 }
12442
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012443 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070012444 //Channel and action frame is pending
12445 //Otherwise Cancel Remain On Channel and allow Scan
12446 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012447 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070012448 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053012449 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070012450 return -EBUSY;
12451 }
12452
Jeff Johnson295189b2012-06-20 16:38:30 -070012453 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
12454 {
12455 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080012456 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012457 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012458 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012459 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
12460 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053012461 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012462 "%s: MAX TM Level Scan not allowed", __func__);
12463 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012464 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070012465 }
12466 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
12467
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012468 /* Check if scan is allowed at this point of time.
12469 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012470 if (hdd_isConnectionInProgress(pHddCtx))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012471 {
12472 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
12473 return -EBUSY;
12474 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012475
Jeff Johnson295189b2012-06-20 16:38:30 -070012476 vos_mem_zero( &scanRequest, sizeof(scanRequest));
12477
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012478 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
12479 * Becasue of this, driver is assuming that this is not wildcard scan and so
12480 * is not aging out the scan results.
12481 */
12482 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070012483 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012484 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012485 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012486
12487 if ((request->ssids) && (0 < request->n_ssids))
12488 {
12489 tCsrSSIDInfo *SsidInfo;
12490 int j;
12491 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
12492 /* Allocate num_ssid tCsrSSIDInfo structure */
12493 SsidInfo = scanRequest.SSIDs.SSIDList =
12494 ( tCsrSSIDInfo *)vos_mem_malloc(
12495 request->n_ssids*sizeof(tCsrSSIDInfo));
12496
12497 if(NULL == scanRequest.SSIDs.SSIDList)
12498 {
12499 hddLog(VOS_TRACE_LEVEL_ERROR,
12500 "%s: memory alloc failed SSIDInfo buffer", __func__);
12501 return -ENOMEM;
12502 }
12503
12504 /* copy all the ssid's and their length */
12505 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
12506 {
12507 /* get the ssid length */
12508 SsidInfo->SSID.length = request->ssids[j].ssid_len;
12509 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
12510 SsidInfo->SSID.length);
12511 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
12512 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
12513 j, SsidInfo->SSID.ssId);
12514 }
12515 /* set the scan type to active */
12516 scanRequest.scanType = eSIR_ACTIVE_SCAN;
12517 }
12518 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070012519 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053012520 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12521 TRACE_CODE_HDD_CFG80211_SCAN,
12522 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070012523 /* set the scan type to active */
12524 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070012525 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012526 else
12527 {
12528 /*Set the scan type to default type, in this case it is ACTIVE*/
12529 scanRequest.scanType = pScanInfo->scan_mode;
12530 }
12531 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
12532 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070012533
12534 /* set BSSType to default type */
12535 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
12536
12537 /*TODO: scan the requested channels only*/
12538
12539 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012540 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070012541 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012542 hddLog(VOS_TRACE_LEVEL_WARN,
12543 "No of Scan Channels exceeded limit: %d", request->n_channels);
12544 request->n_channels = MAX_CHANNEL;
12545 }
12546
12547 hddLog(VOS_TRACE_LEVEL_INFO,
12548 "No of Scan Channels: %d", request->n_channels);
12549
12550
12551 if( request->n_channels )
12552 {
12553 char chList [(request->n_channels*5)+1];
12554 int len;
12555 channelList = vos_mem_malloc( request->n_channels );
12556 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053012557 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012558 hddLog(VOS_TRACE_LEVEL_ERROR,
12559 "%s: memory alloc failed channelList", __func__);
12560 status = -ENOMEM;
12561 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053012562 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012563
12564 for( i = 0, len = 0; i < request->n_channels ; i++ )
12565 {
12566 channelList[i] = request->channels[i]->hw_value;
12567 len += snprintf(chList+len, 5, "%d ", channelList[i]);
12568 }
12569
Nirav Shah20ac06f2013-12-12 18:14:06 +053012570 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012571 "Channel-List: %s ", chList);
12572 }
c_hpothu53512302014-04-15 18:49:53 +053012573
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012574 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
12575 scanRequest.ChannelInfo.ChannelList = channelList;
12576
12577 /* set requestType to full scan */
12578 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
12579
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012580 /* if there is back to back scan happening in driver with in
12581 * nDeferScanTimeInterval interval driver should defer new scan request
12582 * and should provide last cached scan results instead of new channel list.
12583 * This rule is not applicable if scan is p2p scan.
12584 * This condition will work only in case when last request no of channels
12585 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053012586 * This should be done only in connected state
Sushant Kaushik86592172015-04-27 16:35:03 +053012587 * Scan shouldn't be defered for WPS scan case.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012588 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012589
Sushant Kaushik86592172015-04-27 16:35:03 +053012590 pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len);
12591 /* if wps ie is NULL , then only defer scan */
12592 if ( pWpsIe == NULL &&
12593 (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
Agarwal Ashish57e84372014-12-05 18:26:53 +053012594 {
12595 if ( pScanInfo->last_scan_timestamp !=0 &&
12596 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
12597 {
12598 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
12599 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
12600 vos_mem_compare(pScanInfo->last_scan_channelList,
12601 channelList, pScanInfo->last_scan_numChannels))
12602 {
12603 hddLog(VOS_TRACE_LEVEL_WARN,
12604 " New and old station scan time differ is less then %u",
12605 pHddCtx->cfg_ini->nDeferScanTimeInterval);
12606
12607 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012608 pAdapter);
12609
Agarwal Ashish57e84372014-12-05 18:26:53 +053012610 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053012611 "Return old cached scan as all channels and no of channels are same");
12612
Agarwal Ashish57e84372014-12-05 18:26:53 +053012613 if (0 > ret)
12614 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012615
Agarwal Ashish57e84372014-12-05 18:26:53 +053012616 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053012617
12618 status = eHAL_STATUS_SUCCESS;
12619 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053012620 }
12621 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012622 }
12623
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012624 /* Flush the scan results(only p2p beacons) for STA scan and P2P
12625 * search (Flush on both full scan and social scan but not on single
12626 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
12627 */
12628
12629 /* Supplicant does single channel scan after 8-way handshake
12630 * and in that case driver shoudnt flush scan results. If
12631 * driver flushes the scan results here and unfortunately if
12632 * the AP doesnt respond to our probe req then association
12633 * fails which is not desired
12634 */
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053012635 if ((request->n_ssids == 1)
12636 && (request->ssids != NULL)
12637 && vos_mem_compare(&request->ssids[0], "DIRECT-", 7))
12638 is_p2p_scan = true;
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012639
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053012640 if( is_p2p_scan ||
12641 (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) )
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012642 {
12643 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
12644 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
12645 pAdapter->sessionId );
12646 }
12647
12648 if( request->ie_len )
12649 {
12650 /* save this for future association (join requires this) */
12651 /*TODO: Array needs to be converted to dynamic allocation,
12652 * as multiple ie.s can be sent in cfg80211_scan_request structure
12653 * CR 597966
12654 */
12655 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
12656 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
12657 pScanInfo->scanAddIE.length = request->ie_len;
12658
12659 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
12660 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
12661 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070012662 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053012663 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070012664 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012665 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
12666 memcpy( pwextBuf->roamProfile.addIEScan,
12667 request->ie, request->ie_len);
12668 }
12669 else
12670 {
12671 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
12672 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070012673 }
12674
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012675 }
12676 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
12677 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
12678
12679 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
12680 request->ie_len);
12681 if (pP2pIe != NULL)
12682 {
12683#ifdef WLAN_FEATURE_P2P_DEBUG
12684 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
12685 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
12686 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053012687 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012688 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
12689 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
12690 "Go nego completed to Connection is started");
12691 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
12692 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053012693 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012694 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
12695 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070012696 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012697 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
12698 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
12699 "Disconnected state to Connection is started");
12700 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
12701 "for 4way Handshake");
12702 }
12703#endif
12704
12705 /* no_cck will be set during p2p find to disable 11b rates */
12706 if(TRUE == request->no_cck)
12707 {
12708 hddLog(VOS_TRACE_LEVEL_INFO,
12709 "%s: This is a P2P Search", __func__);
12710 scanRequest.p2pSearch = 1;
12711
12712 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053012713 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012714 /* set requestType to P2P Discovery */
12715 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
12716 }
12717
12718 /*
12719 Skip Dfs Channel in case of P2P Search
12720 if it is set in ini file
12721 */
12722 if(cfg_param->skipDfsChnlInP2pSearch)
12723 {
12724 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012725 }
12726 else
12727 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012728 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012729 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012730
Agarwal Ashish4f616132013-12-30 23:32:50 +053012731 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012732 }
12733 }
12734
12735 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
12736
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053012737#ifdef FEATURE_WLAN_TDLS
12738 /* if tdls disagree scan right now, return immediately.
12739 tdls will schedule the scan when scan is allowed. (return SUCCESS)
12740 or will reject the scan if any TDLS is in progress. (return -EBUSY)
12741 */
12742 status = wlan_hdd_tdls_scan_callback (pAdapter,
12743 wiphy,
12744#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
12745 dev,
12746#endif
12747 request);
12748 if(status <= 0)
12749 {
12750 if(!status)
12751 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
12752 "scan rejected %d", __func__, status);
12753 else
12754 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
12755 __func__, status);
12756
12757 return status;
12758 }
12759#endif
12760
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070012761 /* acquire the wakelock to avoid the apps suspend during the scan. To
12762 * address the following issues.
12763 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
12764 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
12765 * for long time, this result in apps running at full power for long time.
12766 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
12767 * be stuck in full power because of resume BMPS
12768 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053012769 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070012770
Nirav Shah20ac06f2013-12-12 18:14:06 +053012771 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
12772 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012773 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
12774 scanRequest.requestType, scanRequest.scanType,
12775 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053012776 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
12777
Siddharth Bhal76972212014-10-15 16:22:51 +053012778 if (pHddCtx->spoofMacAddr.isEnabled)
12779 {
12780 hddLog(VOS_TRACE_LEVEL_INFO,
12781 "%s: MAC Spoofing enabled for current scan", __func__);
12782 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
12783 * to fill TxBds for probe request during current scan
12784 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053012785 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053012786 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053012787
12788 if(status != VOS_STATUS_SUCCESS)
12789 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +053012790 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053012791 status = -EFAULT;
Ganesh Kondabattini6d3b4902015-05-12 23:19:22 +053012792#ifdef FEATURE_WLAN_TDLS
12793 wlan_hdd_tdls_scan_done_callback(pAdapter);
12794#endif
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053012795 goto free_mem;
12796 }
Siddharth Bhal76972212014-10-15 16:22:51 +053012797 }
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053012798 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
Jeff Johnsone7245742012-09-05 17:12:55 -070012799 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070012800 pAdapter->sessionId, &scanRequest, &scanId,
12801 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070012802
Jeff Johnson295189b2012-06-20 16:38:30 -070012803 if (eHAL_STATUS_SUCCESS != status)
12804 {
12805 hddLog(VOS_TRACE_LEVEL_ERROR,
12806 "%s: sme_ScanRequest returned error %d", __func__, status);
12807 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070012808 if(eHAL_STATUS_RESOURCES == status)
12809 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053012810 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
12811 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070012812 status = -EBUSY;
12813 } else {
12814 status = -EIO;
12815 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +053012816 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053012817
12818#ifdef FEATURE_WLAN_TDLS
12819 wlan_hdd_tdls_scan_done_callback(pAdapter);
12820#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012821 goto free_mem;
12822 }
12823
12824 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053012825 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012826 pAdapter->request = request;
12827 pScanInfo->scanId = scanId;
12828
12829 complete(&pScanInfo->scan_req_completion_event);
12830
12831free_mem:
12832 if( scanRequest.SSIDs.SSIDList )
12833 {
12834 vos_mem_free(scanRequest.SSIDs.SSIDList);
12835 }
12836
12837 if( channelList )
12838 vos_mem_free( channelList );
12839
12840 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012841 return status;
12842}
12843
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012844int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
12845#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
12846 struct net_device *dev,
12847#endif
12848 struct cfg80211_scan_request *request)
12849{
12850 int ret;
12851
12852 vos_ssr_protect(__func__);
12853 ret = __wlan_hdd_cfg80211_scan(wiphy,
12854#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
12855 dev,
12856#endif
12857 request);
12858 vos_ssr_unprotect(__func__);
12859
12860 return ret;
12861}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012862
12863void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
12864{
12865 v_U8_t iniDot11Mode =
12866 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
12867 eHddDot11Mode hddDot11Mode = iniDot11Mode;
12868
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012869 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
12870 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012871 switch ( iniDot11Mode )
12872 {
12873 case eHDD_DOT11_MODE_AUTO:
12874 case eHDD_DOT11_MODE_11ac:
12875 case eHDD_DOT11_MODE_11ac_ONLY:
12876#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053012877 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
12878 sme_IsFeatureSupportedByFW(DOT11AC) )
12879 hddDot11Mode = eHDD_DOT11_MODE_11ac;
12880 else
12881 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012882#else
12883 hddDot11Mode = eHDD_DOT11_MODE_11n;
12884#endif
12885 break;
12886 case eHDD_DOT11_MODE_11n:
12887 case eHDD_DOT11_MODE_11n_ONLY:
12888 hddDot11Mode = eHDD_DOT11_MODE_11n;
12889 break;
12890 default:
12891 hddDot11Mode = iniDot11Mode;
12892 break;
12893 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053012894#ifdef WLAN_FEATURE_AP_HT40_24G
12895 if (operationChannel > SIR_11B_CHANNEL_END)
12896#endif
12897 {
12898 /* This call decides required channel bonding mode */
12899 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012900 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
12901 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053012902 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012903}
12904
Jeff Johnson295189b2012-06-20 16:38:30 -070012905/*
12906 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012907 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070012908 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012909int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053012910 const u8 *ssid, size_t ssid_len, const u8 *bssid,
12911 const u8 *bssid_hint, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070012912{
12913 int status = 0;
12914 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080012915 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012916 v_U32_t roamId;
12917 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070012918 eCsrAuthType RSNAuthType;
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053012919 const u8 *pValidBssid = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012920
12921 ENTER();
12922
12923 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080012924 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12925
12926 status = wlan_hdd_validate_context(pHddCtx);
12927 if (status)
12928 {
Yue Mae36e3552014-03-05 17:06:20 -080012929 return status;
12930 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012931
Jeff Johnson295189b2012-06-20 16:38:30 -070012932 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
12933 {
12934 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
12935 return -EINVAL;
12936 }
12937
12938 pRoamProfile = &pWextState->roamProfile;
12939
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012940 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070012941 {
Jeff Johnsone7245742012-09-05 17:12:55 -070012942 hdd_station_ctx_t *pHddStaCtx;
12943 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012944
Siddharth Bhalda0d1622015-04-24 15:47:49 +053012945 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
12946
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012947 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070012948 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
12949 {
12950 /*QoS not enabled in cfg file*/
12951 pRoamProfile->uapsd_mask = 0;
12952 }
12953 else
12954 {
12955 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012956 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070012957 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
12958 }
12959
12960 pRoamProfile->SSIDs.numOfSSIDs = 1;
12961 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
12962 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012963 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070012964 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
12965 ssid, ssid_len);
12966
12967 if (bssid)
12968 {
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053012969 pValidBssid = bssid;
12970 }
12971 else if (bssid_hint)
12972 {
12973 pValidBssid = bssid_hint;
12974 }
12975 if (pValidBssid)
12976 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012977 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053012978 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), pValidBssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070012979 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012980 /* Save BSSID in seperate variable as well, as RoamProfile
12981 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070012982 case of join failure we should send valid BSSID to supplicant
12983 */
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053012984 vos_mem_copy((void *)(pWextState->req_bssId), pValidBssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070012985 WNI_CFG_BSSID_LEN);
12986 }
Dhanashri Atre51981c62013-06-13 11:47:57 -070012987 else
12988 {
12989 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
12990 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012991
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012992 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
12993 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070012994 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
12995 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012996 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012997 /*set gen ie*/
12998 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
12999 /*set auth*/
13000 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
13001 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013002#ifdef FEATURE_WLAN_WAPI
13003 if (pAdapter->wapi_info.nWapiMode)
13004 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013005 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013006 switch (pAdapter->wapi_info.wapiAuthMode)
13007 {
13008 case WAPI_AUTH_MODE_PSK:
13009 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013010 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013011 pAdapter->wapi_info.wapiAuthMode);
13012 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
13013 break;
13014 }
13015 case WAPI_AUTH_MODE_CERT:
13016 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013017 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013018 pAdapter->wapi_info.wapiAuthMode);
13019 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
13020 break;
13021 }
13022 } // End of switch
13023 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
13024 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
13025 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013026 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013027 pRoamProfile->AuthType.numEntries = 1;
13028 pRoamProfile->EncryptionType.numEntries = 1;
13029 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
13030 pRoamProfile->mcEncryptionType.numEntries = 1;
13031 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
13032 }
13033 }
13034#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013035#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053013036 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013037 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
13038 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
13039 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053013040 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
13041 sizeof (tSirGtkOffloadParams));
13042 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013043 }
13044#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013045 pRoamProfile->csrPersona = pAdapter->device_mode;
13046
Jeff Johnson32d95a32012-09-10 13:15:23 -070013047 if( operatingChannel )
13048 {
13049 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
13050 pRoamProfile->ChannelInfo.numOfChannels = 1;
13051 }
Chet Lanctot186b5732013-03-18 10:26:30 -070013052 else
13053 {
13054 pRoamProfile->ChannelInfo.ChannelList = NULL;
13055 pRoamProfile->ChannelInfo.numOfChannels = 0;
13056 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013057 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
13058 {
13059 hdd_select_cbmode(pAdapter,operatingChannel);
13060 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053013061
Agarwal Ashish40f9b872015-09-01 16:17:35 +053013062 /*
13063 * Change conn_state to connecting before sme_RoamConnect(),
13064 * because sme_RoamConnect() has a direct path to call
13065 * hdd_smeRoamCallback(), which will change the conn_state
13066 * If direct path, conn_state will be accordingly changed
13067 * to NotConnected or Associated by either
13068 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
13069 * in sme_RoamCallback()
13070 * if sme_RomConnect is to be queued,
13071 * Connecting state will remain until it is completed.
13072 * If connection state is not changed,
13073 * connection state will remain in eConnectionState_NotConnected state.
13074 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
13075 * if conn state is eConnectionState_NotConnected.
13076 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
13077 * informed of connect result indication which is an issue.
13078 */
13079
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053013080 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
13081 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053013082 {
13083 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish40f9b872015-09-01 16:17:35 +053013084 FL("Set HDD connState to eConnectionState_Connecting"));
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080013085 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
13086 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053013087 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013088 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070013089 pAdapter->sessionId, pRoamProfile, &roamId);
13090
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053013091 if ((eHAL_STATUS_SUCCESS != status) &&
13092 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
13093 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053013094
13095 {
Agarwal Ashish40f9b872015-09-01 16:17:35 +053013096 hddLog(VOS_TRACE_LEVEL_ERROR,
13097 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
13098 pAdapter->sessionId, status);
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080013099 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053013100 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080013101 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053013102 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080013103
13104 pRoamProfile->ChannelInfo.ChannelList = NULL;
13105 pRoamProfile->ChannelInfo.numOfChannels = 0;
13106
Jeff Johnson295189b2012-06-20 16:38:30 -070013107 }
13108 else
13109 {
13110 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
13111 return -EINVAL;
13112 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080013113 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013114 return status;
13115}
13116
13117/*
13118 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
13119 * This function is used to set the authentication type (OPEN/SHARED).
13120 *
13121 */
13122static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
13123 enum nl80211_auth_type auth_type)
13124{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013125 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013126 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13127
13128 ENTER();
13129
13130 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013131 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070013132 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013133 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053013134 hddLog(VOS_TRACE_LEVEL_INFO,
13135 "%s: set authentication type to AUTOSWITCH", __func__);
13136 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
13137 break;
13138
13139 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013140#ifdef WLAN_FEATURE_VOWIFI_11R
13141 case NL80211_AUTHTYPE_FT:
13142#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013143 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070013144 "%s: set authentication type to OPEN", __func__);
13145 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
13146 break;
13147
13148 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013149 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070013150 "%s: set authentication type to SHARED", __func__);
13151 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
13152 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013153#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070013154 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013155 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070013156 "%s: set authentication type to CCKM WPA", __func__);
13157 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
13158 break;
13159#endif
13160
13161
13162 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013163 hddLog(VOS_TRACE_LEVEL_ERROR,
13164 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013165 auth_type);
13166 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
13167 return -EINVAL;
13168 }
13169
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013170 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070013171 pHddStaCtx->conn_info.authType;
13172 return 0;
13173}
13174
13175/*
13176 * FUNCTION: wlan_hdd_set_akm_suite
13177 * This function is used to set the key mgmt type(PSK/8021x).
13178 *
13179 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013180static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070013181 u32 key_mgmt
13182 )
13183{
13184 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13185 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053013186 /* Should be in ieee802_11_defs.h */
13187#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
13188#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070013189 /*set key mgmt type*/
13190 switch(key_mgmt)
13191 {
13192 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053013193 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053013194#ifdef WLAN_FEATURE_VOWIFI_11R
13195 case WLAN_AKM_SUITE_FT_PSK:
13196#endif
13197 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070013198 __func__);
13199 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
13200 break;
13201
13202 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053013203 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053013204#ifdef WLAN_FEATURE_VOWIFI_11R
13205 case WLAN_AKM_SUITE_FT_8021X:
13206#endif
13207 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070013208 __func__);
13209 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
13210 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013211#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070013212#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
13213#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
13214 case WLAN_AKM_SUITE_CCKM:
13215 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
13216 __func__);
13217 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
13218 break;
13219#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070013220#ifndef WLAN_AKM_SUITE_OSEN
13221#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
13222 case WLAN_AKM_SUITE_OSEN:
13223 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
13224 __func__);
13225 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
13226 break;
13227#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013228
13229 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013230 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013231 __func__, key_mgmt);
13232 return -EINVAL;
13233
13234 }
13235 return 0;
13236}
13237
13238/*
13239 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013240 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070013241 * (NONE/WEP40/WEP104/TKIP/CCMP).
13242 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013243static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
13244 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070013245 bool ucast
13246 )
13247{
13248 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013249 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013250 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13251
13252 ENTER();
13253
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013254 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070013255 {
Ratheesh S P36dbc932015-08-07 14:28:57 +053013256 hddLog(VOS_TRACE_LEVEL_INFO, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070013257 __func__, cipher);
13258 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
13259 }
13260 else
13261 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013262
Jeff Johnson295189b2012-06-20 16:38:30 -070013263 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013264 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070013265 {
13266 case IW_AUTH_CIPHER_NONE:
13267 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
13268 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013269
Jeff Johnson295189b2012-06-20 16:38:30 -070013270 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053013271 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070013272 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013273
Jeff Johnson295189b2012-06-20 16:38:30 -070013274 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053013275 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070013276 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013277
Jeff Johnson295189b2012-06-20 16:38:30 -070013278 case WLAN_CIPHER_SUITE_TKIP:
13279 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
13280 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013281
Jeff Johnson295189b2012-06-20 16:38:30 -070013282 case WLAN_CIPHER_SUITE_CCMP:
13283 encryptionType = eCSR_ENCRYPT_TYPE_AES;
13284 break;
13285#ifdef FEATURE_WLAN_WAPI
13286 case WLAN_CIPHER_SUITE_SMS4:
13287 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
13288 break;
13289#endif
13290
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013291#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070013292 case WLAN_CIPHER_SUITE_KRK:
13293 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
13294 break;
13295#endif
13296 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013297 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013298 __func__, cipher);
13299 return -EOPNOTSUPP;
13300 }
13301 }
13302
13303 if (ucast)
13304 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013305 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013306 __func__, encryptionType);
13307 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
13308 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013309 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070013310 encryptionType;
13311 }
13312 else
13313 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013314 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013315 __func__, encryptionType);
13316 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
13317 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
13318 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
13319 }
13320
13321 return 0;
13322}
13323
13324
13325/*
13326 * FUNCTION: wlan_hdd_cfg80211_set_ie
13327 * This function is used to parse WPA/RSN IE's.
13328 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013329int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013330#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
13331 const u8 *ie,
13332#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013333 u8 *ie,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013334#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013335 size_t ie_len
13336 )
13337{
13338 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013339#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
13340 const u8 *genie = ie;
13341#else
Jeff Johnson295189b2012-06-20 16:38:30 -070013342 u8 *genie = ie;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013343#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013344 v_U16_t remLen = ie_len;
13345#ifdef FEATURE_WLAN_WAPI
13346 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
13347 u16 *tmp;
13348 v_U16_t akmsuiteCount;
13349 int *akmlist;
13350#endif
13351 ENTER();
13352
13353 /* clear previous assocAddIE */
13354 pWextState->assocAddIE.length = 0;
13355 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070013356 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013357
13358 while (remLen >= 2)
13359 {
13360 v_U16_t eLen = 0;
13361 v_U8_t elementId;
13362 elementId = *genie++;
13363 eLen = *genie++;
13364 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013365
Arif Hussain6d2a3322013-11-17 19:50:10 -080013366 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070013367 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013368
13369 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070013370 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013371 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013372 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 -070013373 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013374 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013375 "%s: Invalid WPA IE", __func__);
13376 return -EINVAL;
13377 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013378 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070013379 {
13380 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013381 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070013382 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013383
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013384 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013385 {
Jeff Johnson902c9832012-12-10 14:28:09 -080013386 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
13387 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070013388 VOS_ASSERT(0);
13389 return -ENOMEM;
13390 }
13391 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
13392 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
13393 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013394
Jeff Johnson295189b2012-06-20 16:38:30 -070013395 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
13396 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
13397 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
13398 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013399 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
13400 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013401 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
13402 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
13403 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
13404 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
13405 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
13406 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013407 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053013408 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070013409 {
13410 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013411 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070013412 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013413
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013414 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013415 {
Jeff Johnson902c9832012-12-10 14:28:09 -080013416 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
13417 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070013418 VOS_ASSERT(0);
13419 return -ENOMEM;
13420 }
13421 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
13422 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
13423 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013424
Jeff Johnson295189b2012-06-20 16:38:30 -070013425 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
13426 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
13427 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013428#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013429 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
13430 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013431 /*Consider WFD IE, only for P2P Client */
13432 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
13433 {
13434 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013435 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070013436 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013437
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013438 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013439 {
Jeff Johnson902c9832012-12-10 14:28:09 -080013440 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
13441 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070013442 VOS_ASSERT(0);
13443 return -ENOMEM;
13444 }
13445 // WFD IE is saved to Additional IE ; it should be accumulated to handle
13446 // WPS IE + P2P IE + WFD IE
13447 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
13448 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013449
Jeff Johnson295189b2012-06-20 16:38:30 -070013450 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
13451 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
13452 }
13453#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013454 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013455 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070013456 HS20_OUI_TYPE_SIZE)) )
13457 {
13458 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013459 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070013460 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013461
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013462 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070013463 {
Jeff Johnson902c9832012-12-10 14:28:09 -080013464 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
13465 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070013466 VOS_ASSERT(0);
13467 return -ENOMEM;
13468 }
13469 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
13470 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013471
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070013472 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
13473 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
13474 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070013475 /* Appending OSEN Information Element in Assiciation Request */
13476 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
13477 OSEN_OUI_TYPE_SIZE)) )
13478 {
13479 v_U16_t curAddIELen = pWextState->assocAddIE.length;
13480 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
13481 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013482
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013483 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070013484 {
13485 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
13486 "Need bigger buffer space");
13487 VOS_ASSERT(0);
13488 return -ENOMEM;
13489 }
13490 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
13491 pWextState->assocAddIE.length += eLen + 2;
13492
13493 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
13494 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
13495 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
13496 }
13497
Abhishek Singh4322e622015-06-10 15:42:54 +053013498 /* Update only for WPA IE */
13499 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
13500 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070013501
13502 /* populating as ADDIE in beacon frames */
13503 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013504 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, (u8 *)genie - 2, eLen + 2,
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070013505 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
13506 {
13507 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
13508 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
13509 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
13510 {
13511 hddLog(LOGE,
13512 "Coldn't pass "
13513 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
13514 }
13515 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
13516 else
13517 hddLog(LOGE,
13518 "Could not pass on "
13519 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
13520
13521 /* IBSS mode doesn't contain params->proberesp_ies still
13522 beaconIE's need to be populated in probe response frames */
13523 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
13524 {
13525 u16 rem_probe_resp_ie_len = eLen + 2;
13526 u8 probe_rsp_ie_len[3] = {0};
13527 u8 counter = 0;
13528
13529 /* Check Probe Resp Length if it is greater then 255 then
13530 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
13531 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
13532 not able Store More then 255 bytes into One Variable */
13533
13534 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
13535 {
13536 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
13537 {
13538 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
13539 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
13540 }
13541 else
13542 {
13543 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
13544 rem_probe_resp_ie_len = 0;
13545 }
13546 }
13547
13548 rem_probe_resp_ie_len = 0;
13549
13550 if (probe_rsp_ie_len[0] > 0)
13551 {
13552 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
13553 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
13554 (tANI_U8*)(genie - 2),
13555 probe_rsp_ie_len[0], NULL,
13556 eANI_BOOLEAN_FALSE)
13557 == eHAL_STATUS_FAILURE)
13558 {
13559 hddLog(LOGE,
13560 "Could not pass"
13561 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
13562 }
13563 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
13564 }
13565
13566 if (probe_rsp_ie_len[1] > 0)
13567 {
13568 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
13569 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
13570 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
13571 probe_rsp_ie_len[1], NULL,
13572 eANI_BOOLEAN_FALSE)
13573 == eHAL_STATUS_FAILURE)
13574 {
13575 hddLog(LOGE,
13576 "Could not pass"
13577 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
13578 }
13579 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
13580 }
13581
13582 if (probe_rsp_ie_len[2] > 0)
13583 {
13584 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
13585 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
13586 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
13587 probe_rsp_ie_len[2], NULL,
13588 eANI_BOOLEAN_FALSE)
13589 == eHAL_STATUS_FAILURE)
13590 {
13591 hddLog(LOGE,
13592 "Could not pass"
13593 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
13594 }
13595 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
13596 }
13597
13598 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
13599 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
13600 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
13601 {
13602 hddLog(LOGE,
13603 "Could not pass"
13604 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
13605 }
13606 }
13607 else
13608 {
13609 // Reset WNI_CFG_PROBE_RSP Flags
13610 wlan_hdd_reset_prob_rspies(pAdapter);
13611
13612 hddLog(VOS_TRACE_LEVEL_INFO,
13613 "%s: No Probe Response IE received in set beacon",
13614 __func__);
13615 }
13616 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070013617 break;
13618 case DOT11F_EID_RSN:
13619 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
13620 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
13621 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
13622 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
13623 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
13624 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053013625
13626 /* Appending Extended Capabilities with Interworking bit set
13627 * in Assoc Req.
13628 *
13629 * In assoc req this EXT Cap will only be taken into account if
13630 * interworkingService bit is set to 1. Currently
13631 * driver is only interested in interworkingService capability
13632 * from supplicant. If in future any other EXT Cap info is
13633 * required from supplicat, it needs to be handled while
13634 * sending Assoc Req in LIM.
13635 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013636 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013637 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013638 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013639 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013640 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013641
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013642 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013643 {
Jeff Johnson902c9832012-12-10 14:28:09 -080013644 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
13645 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013646 VOS_ASSERT(0);
13647 return -ENOMEM;
13648 }
13649 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
13650 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013651
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013652 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
13653 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
13654 break;
13655 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013656#ifdef FEATURE_WLAN_WAPI
13657 case WLAN_EID_WAPI:
13658 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070013659 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070013660 pAdapter->wapi_info.nWapiMode);
13661 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013662 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070013663 akmsuiteCount = WPA_GET_LE16(tmp);
13664 tmp = tmp + 1;
13665 akmlist = (int *)(tmp);
13666 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
13667 {
13668 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
13669 }
13670 else
13671 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013672 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070013673 VOS_ASSERT(0);
13674 return -EINVAL;
13675 }
13676
13677 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
13678 {
13679 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013680 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013681 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013682 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013683 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013684 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013685 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013686 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013687 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
13688 }
13689 break;
13690#endif
13691 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013692 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013693 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013694 /* when Unknown IE is received we should break and continue
13695 * to the next IE in the buffer instead we were returning
13696 * so changing this to break */
13697 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013698 }
13699 genie += eLen;
13700 remLen -= eLen;
13701 }
13702 EXIT();
13703 return 0;
13704}
13705
13706/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053013707 * FUNCTION: hdd_isWPAIEPresent
13708 * Parse the received IE to find the WPA IE
13709 *
13710 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013711static bool hdd_isWPAIEPresent(
13712#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
13713 const u8 *ie,
13714#else
13715 u8 *ie,
13716#endif
13717 u8 ie_len)
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053013718{
13719 v_U8_t eLen = 0;
13720 v_U16_t remLen = ie_len;
13721 v_U8_t elementId = 0;
13722
13723 while (remLen >= 2)
13724 {
13725 elementId = *ie++;
13726 eLen = *ie++;
13727 remLen -= 2;
13728 if (eLen > remLen)
13729 {
13730 hddLog(VOS_TRACE_LEVEL_ERROR,
13731 "%s: IE length is wrong %d", __func__, eLen);
13732 return FALSE;
13733 }
13734 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
13735 {
13736 /* OUI - 0x00 0X50 0XF2
13737 WPA Information Element - 0x01
13738 WPA version - 0x01*/
13739 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
13740 return TRUE;
13741 }
13742 ie += eLen;
13743 remLen -= eLen;
13744 }
13745 return FALSE;
13746}
13747
13748/*
Jeff Johnson295189b2012-06-20 16:38:30 -070013749 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013750 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070013751 * parameters during connect operation.
13752 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013753int wlan_hdd_cfg80211_set_privacy(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070013754 struct cfg80211_connect_params *req
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013755 )
Jeff Johnson295189b2012-06-20 16:38:30 -070013756{
13757 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013758 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013759 ENTER();
13760
13761 /*set wpa version*/
13762 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
13763
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013764 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070013765 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053013766 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070013767 {
13768 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
13769 }
13770 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
13771 {
13772 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
13773 }
13774 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013775
13776 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013777 pWextState->wpaVersion);
13778
13779 /*set authentication type*/
13780 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
13781
13782 if (0 > status)
13783 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013784 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013785 "%s: failed to set authentication type ", __func__);
13786 return status;
13787 }
13788
13789 /*set key mgmt type*/
13790 if (req->crypto.n_akm_suites)
13791 {
13792 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
13793 if (0 > status)
13794 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013795 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070013796 __func__);
13797 return status;
13798 }
13799 }
13800
13801 /*set pairwise cipher type*/
13802 if (req->crypto.n_ciphers_pairwise)
13803 {
13804 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
13805 req->crypto.ciphers_pairwise[0], true);
13806 if (0 > status)
13807 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013808 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013809 "%s: failed to set unicast cipher type", __func__);
13810 return status;
13811 }
13812 }
13813 else
13814 {
13815 /*Reset previous cipher suite to none*/
13816 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
13817 if (0 > status)
13818 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013819 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013820 "%s: failed to set unicast cipher type", __func__);
13821 return status;
13822 }
13823 }
13824
13825 /*set group cipher type*/
13826 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
13827 false);
13828
13829 if (0 > status)
13830 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013831 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070013832 __func__);
13833 return status;
13834 }
13835
Chet Lanctot186b5732013-03-18 10:26:30 -070013836#ifdef WLAN_FEATURE_11W
13837 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
13838#endif
13839
Jeff Johnson295189b2012-06-20 16:38:30 -070013840 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
13841 if (req->ie_len)
13842 {
13843 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
13844 if ( 0 > status)
13845 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013846 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070013847 __func__);
13848 return status;
13849 }
13850 }
13851
13852 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013853 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070013854 {
13855 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
13856 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
13857 )
13858 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013859 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070013860 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
13861 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013862 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070013863 __func__);
13864 return -EOPNOTSUPP;
13865 }
13866 else
13867 {
13868 u8 key_len = req->key_len;
13869 u8 key_idx = req->key_idx;
13870
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013871 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070013872 && (CSR_MAX_NUM_KEY > key_idx)
13873 )
13874 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013875 hddLog(VOS_TRACE_LEVEL_INFO,
13876 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013877 __func__, key_idx, key_len);
13878 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013879 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070013880 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013881 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070013882 (u8)key_len;
13883 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
13884 }
13885 }
13886 }
13887 }
13888
13889 return status;
13890}
13891
13892/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053013893 * FUNCTION: wlan_hdd_try_disconnect
13894 * This function is used to disconnect from previous
13895 * connection
13896 */
13897static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
13898{
13899 long ret = 0;
13900 hdd_station_ctx_t *pHddStaCtx;
13901 eMib_dot11DesiredBssType connectedBssType;
13902
13903 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13904
13905 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
13906
13907 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
13908 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
13909 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
13910 {
13911 /* Issue disconnect to CSR */
13912 INIT_COMPLETION(pAdapter->disconnect_comp_var);
13913 if( eHAL_STATUS_SUCCESS ==
13914 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
13915 pAdapter->sessionId,
13916 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
13917 {
13918 ret = wait_for_completion_interruptible_timeout(
13919 &pAdapter->disconnect_comp_var,
13920 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
13921 if (0 >= ret)
13922 {
13923 hddLog(LOGE, FL("Failed to receive disconnect event"));
13924 return -EALREADY;
13925 }
13926 }
13927 }
13928 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
13929 {
13930 ret = wait_for_completion_interruptible_timeout(
13931 &pAdapter->disconnect_comp_var,
13932 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
13933 if (0 >= ret)
13934 {
13935 hddLog(LOGE, FL("Failed to receive disconnect event"));
13936 return -EALREADY;
13937 }
13938 }
13939
13940 return 0;
13941}
13942
13943/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053013944 * FUNCTION: __wlan_hdd_cfg80211_connect
13945 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070013946 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053013947static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013948 struct net_device *ndev,
13949 struct cfg80211_connect_params *req
13950 )
13951{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013952 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013953 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070013954 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053013955 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013956
13957 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013958
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013959 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13960 TRACE_CODE_HDD_CFG80211_CONNECT,
13961 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013962 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013963 "%s: device_mode = %s (%d)", __func__,
13964 hdd_device_modetoString(pAdapter->device_mode),
13965 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070013966
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013967 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080013968 if (!pHddCtx)
13969 {
13970 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13971 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053013972 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080013973 }
13974
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013975 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013976 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070013977 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013978 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013979 }
13980
Agarwal Ashish51325b52014-06-16 16:50:49 +053013981 if (vos_max_concurrent_connections_reached()) {
13982 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
13983 return -ECONNREFUSED;
13984 }
13985
Jeff Johnson295189b2012-06-20 16:38:30 -070013986#ifdef WLAN_BTAMP_FEATURE
13987 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013988 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070013989 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013990 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013991 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080013992 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070013993 }
13994#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053013995
13996 //If Device Mode is Station Concurrent Sessions Exit BMps
13997 //P2P Mode will be taken care in Open/close adapter
13998 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053013999 (vos_concurrent_open_sessions_running())) {
14000 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
14001 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014002 }
14003
14004 /*Try disconnecting if already in connected state*/
14005 status = wlan_hdd_try_disconnect(pAdapter);
14006 if ( 0 > status)
14007 {
14008 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
14009 " connection"));
14010 return -EALREADY;
14011 }
14012
Jeff Johnson295189b2012-06-20 16:38:30 -070014013 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014014 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070014015
14016 if ( 0 > status)
14017 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014018 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070014019 __func__);
14020 return status;
14021 }
Mohit Khanna765234a2012-09-11 15:08:35 -070014022 if ( req->channel )
14023 {
14024 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
14025 req->ssid_len, req->bssid,
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053014026 req->bssid_hint,
Mohit Khanna765234a2012-09-11 15:08:35 -070014027 req->channel->hw_value);
14028 }
14029 else
14030 {
14031 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053014032 req->ssid_len, req->bssid,
14033 req->bssid_hint, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -070014034 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014035
Sushant Kaushikd7083982015-03-18 14:33:24 +053014036 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070014037 {
14038 //ReEnable BMPS if disabled
14039 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
14040 (NULL != pHddCtx))
14041 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053014042 if (pHddCtx->hdd_wlan_suspended)
14043 {
14044 hdd_set_pwrparams(pHddCtx);
14045 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014046 //ReEnable Bmps and Imps back
14047 hdd_enable_bmps_imps(pHddCtx);
14048 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053014049 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014050 return status;
14051 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014052 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014053 EXIT();
14054 return status;
14055}
14056
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014057static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
14058 struct net_device *ndev,
14059 struct cfg80211_connect_params *req)
14060{
14061 int ret;
14062 vos_ssr_protect(__func__);
14063 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
14064 vos_ssr_unprotect(__func__);
14065
14066 return ret;
14067}
Jeff Johnson295189b2012-06-20 16:38:30 -070014068
14069/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014070 * FUNCTION: wlan_hdd_disconnect
14071 * This function is used to issue a disconnect request to SME
14072 */
14073int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
14074{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014075 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014076 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014077 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014078 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014079
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014080 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014081
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014082 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014083 if (0 != status)
14084 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014085 return status;
14086 }
14087
Sushant Kaushikb4834d22015-07-15 15:29:05 +053014088 if (pHddStaCtx->conn_info.connState == eConnectionState_Connecting)
14089 {
14090 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
14091 pAdapter->sessionId);
14092 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014093 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053014094
Agarwal Ashish47d18112014-08-04 19:55:07 +053014095 /* Need to apply spin lock before decreasing active sessions
14096 * as there can be chance for double decrement if context switch
14097 * Calls hdd_DisConnectHandler.
14098 */
14099
14100 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053014101 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
14102 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053014103 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
14104 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053014105 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
14106 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053014107
Abhishek Singhf4669da2014-05-26 15:07:49 +053014108 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053014109 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
14110
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014111 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014112
Mihir Shete182a0b22014-08-18 16:08:48 +053014113 /*
14114 * stop tx queues before deleting STA/BSS context from the firmware.
14115 * tx has to be disabled because the firmware can get busy dropping
14116 * the tx frames after BSS/STA has been deleted and will not send
14117 * back a response resulting in WDI timeout
14118 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053014119 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053014120 netif_tx_disable(pAdapter->dev);
14121 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053014122
Mihir Shete182a0b22014-08-18 16:08:48 +053014123 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014124 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
14125 pAdapter->sessionId, reason);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014126 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
14127 {
14128 hddLog(VOS_TRACE_LEVEL_INFO,
14129 FL("status = %d, already disconnected"),
14130 (int)status );
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014131
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014132 }
14133 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014134 {
14135 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080014136 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014137 __func__, (int)status );
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014138 result = -EINVAL;
14139 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014140 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014141 ret = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014142 &pAdapter->disconnect_comp_var,
14143 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014144 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status ))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014145 {
14146 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053014147 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014148 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053014149 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014150 else if (ret == -ERESTARTSYS)
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053014151 {
14152 hddLog(VOS_TRACE_LEVEL_ERROR,
14153 "%s: Failed to disconnect, wait interrupted", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014154 result = -ERESTARTSYS;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014155 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014156disconnected:
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014157 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14158 FL("Set HDD connState to eConnectionState_NotConnected"));
14159 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
14160
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014161 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014162 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014163}
14164
14165
14166/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014167 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070014168 * This function is used to issue a disconnect request to SME
14169 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014170static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070014171 struct net_device *dev,
14172 u16 reason
14173 )
14174{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014175 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014176 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014177 tCsrRoamProfile *pRoamProfile;
14178 hdd_station_ctx_t *pHddStaCtx;
14179 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053014180#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080014181 tANI_U8 staIdx;
14182#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014183
Jeff Johnson295189b2012-06-20 16:38:30 -070014184 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014185
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014186 if (!pAdapter) {
14187 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
14188 return -EINVAL;
14189 }
14190
14191 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14192 if (!pHddStaCtx) {
14193 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
14194 return -EINVAL;
14195 }
14196
14197 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14198 status = wlan_hdd_validate_context(pHddCtx);
14199 if (0 != status)
14200 {
14201 return status;
14202 }
14203
14204 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
14205
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014206 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14207 TRACE_CODE_HDD_CFG80211_DISCONNECT,
14208 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053014209 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
14210 __func__, hdd_device_modetoString(pAdapter->device_mode),
14211 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070014212
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014213 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
14214 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070014215
Jeff Johnson295189b2012-06-20 16:38:30 -070014216 if (NULL != pRoamProfile)
14217 {
14218 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053014219 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
14220 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070014221 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014222 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070014223 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053014224 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070014225 switch(reason)
14226 {
14227 case WLAN_REASON_MIC_FAILURE:
14228 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
14229 break;
14230
14231 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
14232 case WLAN_REASON_DISASSOC_AP_BUSY:
14233 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
14234 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
14235 break;
14236
14237 case WLAN_REASON_PREV_AUTH_NOT_VALID:
14238 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053014239 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070014240 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
14241 break;
14242
Jeff Johnson295189b2012-06-20 16:38:30 -070014243 default:
14244 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
14245 break;
14246 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053014247 pScanInfo = &pHddCtx->scan_info;
14248 if (pScanInfo->mScanPending)
14249 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053014250 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053014251 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053014252 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053014253 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053014254 }
Agarwal Ashishc089cec2015-08-10 13:10:04 +053014255 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080014256#ifdef FEATURE_WLAN_TDLS
14257 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080014258 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080014259 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080014260 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
14261 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080014262 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014263 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080014264 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014266 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080014267 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014268 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014269 status = sme_DeleteTdlsPeerSta(
14270 WLAN_HDD_GET_HAL_CTX(pAdapter),
14271 pAdapter->sessionId,
14272 mac);
14273 if (status != eHAL_STATUS_SUCCESS) {
14274 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
14275 return -EPERM;
14276 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080014277 }
14278 }
14279#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053014280 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014281 status = wlan_hdd_disconnect(pAdapter, reasonCode);
14282 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070014283 {
14284 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080014285 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014286 __func__, (int)status );
14287 return -EINVAL;
14288 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014289 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053014290 else
14291 {
14292 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
14293 "called while in %d state", __func__,
14294 pHddStaCtx->conn_info.connState);
14295 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014296 }
14297 else
14298 {
14299 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
14300 }
14301
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014302 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070014303 return status;
14304}
14305
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014306static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
14307 struct net_device *dev,
14308 u16 reason
14309 )
14310{
14311 int ret;
14312 vos_ssr_protect(__func__);
14313 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
14314 vos_ssr_unprotect(__func__);
14315
14316 return ret;
14317}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014318
Jeff Johnson295189b2012-06-20 16:38:30 -070014319/*
14320 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014321 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070014322 * settings in IBSS mode.
14323 */
14324static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014325 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070014326 struct cfg80211_ibss_params *params
14327 )
14328{
14329 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014330 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070014331 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
14332 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014333
Jeff Johnson295189b2012-06-20 16:38:30 -070014334 ENTER();
14335
14336 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070014337 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070014338
14339 if (params->ie_len && ( NULL != params->ie) )
14340 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070014341 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
14342 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070014343 {
14344 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
14345 encryptionType = eCSR_ENCRYPT_TYPE_AES;
14346 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070014347 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070014348 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070014349 tDot11fIEWPA dot11WPAIE;
14350 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070014351 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070014352
Wilson Yang00256342013-10-10 23:13:38 -070014353 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070014354 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
14355 params->ie_len, DOT11F_EID_WPA);
14356 if ( NULL != ie )
14357 {
14358 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
14359 // Unpack the WPA IE
14360 //Skip past the EID byte and length byte - and four byte WiFi OUI
14361 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
14362 &ie[2+4],
14363 ie[1] - 4,
14364 &dot11WPAIE);
14365 /*Extract the multicast cipher, the encType for unicast
14366 cipher for wpa-none is none*/
14367 encryptionType =
14368 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
14369 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014370 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070014371
Jeff Johnson295189b2012-06-20 16:38:30 -070014372 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
14373
14374 if (0 > status)
14375 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014376 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070014377 __func__);
14378 return status;
14379 }
14380 }
14381
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014382 pWextState->roamProfile.AuthType.authType[0] =
14383 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070014384 eCSR_AUTH_TYPE_OPEN_SYSTEM;
14385
14386 if (params->privacy)
14387 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014388 /* Security enabled IBSS, At this time there is no information available
14389 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070014390 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014391 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070014392 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014393 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070014394 *enable privacy bit in beacons */
14395
14396 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
14397 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070014398 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
14399 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070014400 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
14401 pWextState->roamProfile.EncryptionType.numEntries = 1;
14402 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070014403 return status;
14404}
14405
14406/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014407 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014408 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070014409 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014410static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070014411 struct net_device *dev,
14412 struct cfg80211_ibss_params *params
14413 )
14414{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014415 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070014416 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
14417 tCsrRoamProfile *pRoamProfile;
14418 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014419 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14420 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014421 tSirMacAddr bssid;
Jeff Johnson295189b2012-06-20 16:38:30 -070014422
14423 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014424
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014425 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14426 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
14427 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014428 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053014429 "%s: device_mode = %s (%d)", __func__,
14430 hdd_device_modetoString(pAdapter->device_mode),
14431 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070014432
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014433 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014434 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070014435 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014436 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014437 }
14438
14439 if (NULL == pWextState)
14440 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014441 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070014442 __func__);
14443 return -EIO;
14444 }
14445
Agarwal Ashish51325b52014-06-16 16:50:49 +053014446 if (vos_max_concurrent_connections_reached()) {
14447 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
14448 return -ECONNREFUSED;
14449 }
14450
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014451 /*Try disconnecting if already in connected state*/
14452 status = wlan_hdd_try_disconnect(pAdapter);
14453 if ( 0 > status)
14454 {
14455 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
14456 " IBSS connection"));
14457 return -EALREADY;
14458 }
14459
Jeff Johnson295189b2012-06-20 16:38:30 -070014460 pRoamProfile = &pWextState->roamProfile;
14461
14462 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
14463 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014464 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080014465 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014466 return -EINVAL;
14467 }
14468
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070014469 /* BSSID is provided by upper layers hence no need to AUTO generate */
14470 if (NULL != params->bssid) {
14471 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
14472 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
14473 hddLog (VOS_TRACE_LEVEL_ERROR,
14474 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
14475 return -EIO;
14476 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014477 vos_mem_copy((v_U8_t *)bssid, (v_U8_t *)params->bssid, sizeof(bssid));
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070014478 }
krunal sonie9002db2013-11-25 14:24:17 -080014479 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
14480 {
14481 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
14482 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
14483 {
14484 hddLog (VOS_TRACE_LEVEL_ERROR,
14485 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
14486 return -EIO;
14487 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014488
14489 vos_mem_copy((v_U8_t *)bssid,
krunal sonie9002db2013-11-25 14:24:17 -080014490 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014491 sizeof(bssid));
krunal sonie9002db2013-11-25 14:24:17 -080014492 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070014493
Jeff Johnson295189b2012-06-20 16:38:30 -070014494 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070014495 if (NULL !=
14496#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
14497 params->chandef.chan)
14498#else
14499 params->channel)
14500#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014501 {
14502 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014503 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
14504 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
14505 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14506 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070014507
14508 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014509 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070014510 ieee80211_frequency_to_channel(
14511#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
14512 params->chandef.chan->center_freq);
14513#else
14514 params->channel->center_freq);
14515#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014516
14517 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
14518 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070014519 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014520 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
14521 __func__);
14522 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070014523 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014524
14525 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070014526 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014527 if (channelNum == validChan[indx])
14528 {
14529 break;
14530 }
14531 }
14532 if (indx >= numChans)
14533 {
14534 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014535 __func__, channelNum);
14536 return -EINVAL;
14537 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014538 /* Set the Operational Channel */
14539 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
14540 channelNum);
14541 pRoamProfile->ChannelInfo.numOfChannels = 1;
14542 pHddStaCtx->conn_info.operationChannel = channelNum;
14543 pRoamProfile->ChannelInfo.ChannelList =
14544 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070014545 }
14546
14547 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014548 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070014549 if (status < 0)
14550 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014551 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070014552 __func__);
14553 return status;
14554 }
14555
14556 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014557 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053014558 params->ssid_len, params->bssid, NULL,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014559 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070014560
14561 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -070014562 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014563
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014564 EXIT();
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014565 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014566}
14567
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014568static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
14569 struct net_device *dev,
14570 struct cfg80211_ibss_params *params
14571 )
14572{
14573 int ret = 0;
14574
14575 vos_ssr_protect(__func__);
14576 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
14577 vos_ssr_unprotect(__func__);
14578
14579 return ret;
14580}
14581
Jeff Johnson295189b2012-06-20 16:38:30 -070014582/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014583 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014584 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070014585 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014586static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070014587 struct net_device *dev
14588 )
14589{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014590 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014591 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
14592 tCsrRoamProfile *pRoamProfile;
14593 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014594 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014595
14596 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014597
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014598 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14599 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
14600 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014601 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014602 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014603 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014604 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014605 }
14606
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053014607 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
14608 hdd_device_modetoString(pAdapter->device_mode),
14609 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070014610 if (NULL == pWextState)
14611 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014612 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070014613 __func__);
14614 return -EIO;
14615 }
14616
14617 pRoamProfile = &pWextState->roamProfile;
14618
14619 /* Issue disconnect only if interface type is set to IBSS */
14620 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
14621 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014622 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070014623 __func__);
14624 return -EINVAL;
14625 }
14626
14627 /* Issue Disconnect request */
14628 INIT_COMPLETION(pAdapter->disconnect_comp_var);
14629 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
14630 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
14631
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014632 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070014633 return 0;
14634}
14635
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014636static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
14637 struct net_device *dev
14638 )
14639{
14640 int ret = 0;
14641
14642 vos_ssr_protect(__func__);
14643 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
14644 vos_ssr_unprotect(__func__);
14645
14646 return ret;
14647}
14648
Jeff Johnson295189b2012-06-20 16:38:30 -070014649/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053014650 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070014651 * This function is used to set the phy parameters
14652 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
14653 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053014654static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070014655 u32 changed)
14656{
14657 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
14658 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014659 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014660
14661 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014662
14663 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014664 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
14665 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014666
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014667 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014668 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014669 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014670 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014671 }
14672
Jeff Johnson295189b2012-06-20 16:38:30 -070014673 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
14674 {
14675 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
14676 WNI_CFG_RTS_THRESHOLD_STAMAX :
14677 wiphy->rts_threshold;
14678
14679 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014680 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070014681 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014682 hddLog(VOS_TRACE_LEVEL_ERROR,
14683 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070014684 __func__, rts_threshold);
14685 return -EINVAL;
14686 }
14687
14688 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
14689 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014690 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070014691 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014692 hddLog(VOS_TRACE_LEVEL_ERROR,
14693 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070014694 __func__, rts_threshold);
14695 return -EIO;
14696 }
14697
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014698 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014699 rts_threshold);
14700 }
14701
14702 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
14703 {
14704 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
14705 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
14706 wiphy->frag_threshold;
14707
14708 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014709 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014710 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014711 hddLog(VOS_TRACE_LEVEL_ERROR,
14712 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014713 frag_threshold);
14714 return -EINVAL;
14715 }
14716
14717 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
14718 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014719 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070014720 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014721 hddLog(VOS_TRACE_LEVEL_ERROR,
14722 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070014723 __func__, frag_threshold);
14724 return -EIO;
14725 }
14726
14727 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
14728 frag_threshold);
14729 }
14730
14731 if ((changed & WIPHY_PARAM_RETRY_SHORT)
14732 || (changed & WIPHY_PARAM_RETRY_LONG))
14733 {
14734 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
14735 wiphy->retry_short :
14736 wiphy->retry_long;
14737
14738 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
14739 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
14740 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014741 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070014742 __func__, retry_value);
14743 return -EINVAL;
14744 }
14745
14746 if (changed & WIPHY_PARAM_RETRY_SHORT)
14747 {
14748 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
14749 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014750 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070014751 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014752 hddLog(VOS_TRACE_LEVEL_ERROR,
14753 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070014754 __func__, retry_value);
14755 return -EIO;
14756 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014757 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070014758 __func__, retry_value);
14759 }
14760 else if (changed & WIPHY_PARAM_RETRY_SHORT)
14761 {
14762 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
14763 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014764 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070014765 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014766 hddLog(VOS_TRACE_LEVEL_ERROR,
14767 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070014768 __func__, retry_value);
14769 return -EIO;
14770 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014771 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070014772 __func__, retry_value);
14773 }
14774 }
14775
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014776 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070014777 return 0;
14778}
14779
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053014780static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
14781 u32 changed)
14782{
14783 int ret;
14784
14785 vos_ssr_protect(__func__);
14786 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
14787 vos_ssr_unprotect(__func__);
14788
14789 return ret;
14790}
14791
Jeff Johnson295189b2012-06-20 16:38:30 -070014792/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053014793 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070014794 * This function is used to set the txpower
14795 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053014796static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070014797#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
14798 struct wireless_dev *wdev,
14799#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014800#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014801 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070014802#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014803 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070014804#endif
14805 int dbm)
14806{
14807 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014808 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014809 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
14810 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014811 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014812
14813 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014814
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014815 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14816 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
14817 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014818 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014819 if (0 != status)
14820 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014821 return status;
14822 }
14823
14824 hHal = pHddCtx->hHal;
14825
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014826 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
14827 dbm, ccmCfgSetCallback,
14828 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070014829 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014830 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014831 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
14832 return -EIO;
14833 }
14834
14835 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
14836 dbm);
14837
14838 switch(type)
14839 {
14840 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
14841 /* Fall through */
14842 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
14843 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
14844 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014845 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
14846 __func__);
14847 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070014848 }
14849 break;
14850 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014851 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070014852 __func__);
14853 return -EOPNOTSUPP;
14854 break;
14855 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014856 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
14857 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070014858 return -EIO;
14859 }
14860
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014861 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070014862 return 0;
14863}
14864
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053014865static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
14866#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
14867 struct wireless_dev *wdev,
14868#endif
14869#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
14870 enum tx_power_setting type,
14871#else
14872 enum nl80211_tx_power_setting type,
14873#endif
14874 int dbm)
14875{
14876 int ret;
14877 vos_ssr_protect(__func__);
14878 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
14879#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
14880 wdev,
14881#endif
14882#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
14883 type,
14884#else
14885 type,
14886#endif
14887 dbm);
14888 vos_ssr_unprotect(__func__);
14889
14890 return ret;
14891}
14892
Jeff Johnson295189b2012-06-20 16:38:30 -070014893/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014894 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070014895 * This function is used to read the txpower
14896 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014897static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070014898#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
14899 struct wireless_dev *wdev,
14900#endif
14901 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070014902{
14903
14904 hdd_adapter_t *pAdapter;
14905 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014906 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014907
Jeff Johnsone7245742012-09-05 17:12:55 -070014908 ENTER();
14909
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014910 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014911 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014912 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014913 *dbm = 0;
14914 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014915 }
14916
Jeff Johnson295189b2012-06-20 16:38:30 -070014917 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
14918 if (NULL == pAdapter)
14919 {
14920 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
14921 return -ENOENT;
14922 }
14923
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014924 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14925 TRACE_CODE_HDD_CFG80211_GET_TXPOWER,
14926 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070014927 wlan_hdd_get_classAstats(pAdapter);
14928 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
14929
Jeff Johnsone7245742012-09-05 17:12:55 -070014930 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070014931 return 0;
14932}
14933
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014934static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
14935#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
14936 struct wireless_dev *wdev,
14937#endif
14938 int *dbm)
14939{
14940 int ret;
14941
14942 vos_ssr_protect(__func__);
14943 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
14944#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
14945 wdev,
14946#endif
14947 dbm);
14948 vos_ssr_unprotect(__func__);
14949
14950 return ret;
14951}
14952
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014953static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014954#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
14955 const u8* mac,
14956#else
14957 u8* mac,
14958#endif
14959 struct station_info *sinfo)
Jeff Johnson295189b2012-06-20 16:38:30 -070014960{
14961 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
14962 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14963 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053014964 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070014965
14966 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
14967 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070014968
14969 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
14970 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
14971 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
14972 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
14973 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
14974 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
14975 tANI_U16 maxRate = 0;
14976 tANI_U16 myRate;
14977 tANI_U16 currentRate = 0;
14978 tANI_U8 maxSpeedMCS = 0;
14979 tANI_U8 maxMCSIdx = 0;
14980 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053014981 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070014982 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014983 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014984
Leo Chang6f8870f2013-03-26 18:11:36 -070014985#ifdef WLAN_FEATURE_11AC
14986 tANI_U32 vht_mcs_map;
14987 eDataRate11ACMaxMcs vhtMaxMcs;
14988#endif /* WLAN_FEATURE_11AC */
14989
Jeff Johnsone7245742012-09-05 17:12:55 -070014990 ENTER();
14991
Jeff Johnson295189b2012-06-20 16:38:30 -070014992 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
14993 (0 == ssidlen))
14994 {
14995 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
14996 " Invalid ssidlen, %d", __func__, ssidlen);
14997 /*To keep GUI happy*/
14998 return 0;
14999 }
15000
Mukul Sharma811205f2014-07-09 21:07:30 +053015001 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
15002 {
15003 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15004 "%s: Roaming in progress, so unable to proceed this request", __func__);
15005 return 0;
15006 }
15007
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015008 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015009 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015010 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015011 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015012 }
15013
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +053015014 wlan_hdd_get_station_stats(pAdapter);
15015 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070015016
Kiet Lam3b17fc82013-09-27 05:24:08 +053015017 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
15018 sinfo->filled |= STATION_INFO_SIGNAL;
15019
c_hpothu09f19542014-05-30 21:53:31 +053015020 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053015021 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
15022 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053015023 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053015024 {
15025 rate_flags = pAdapter->maxRateFlags;
15026 }
c_hpothu44ff4e02014-05-08 00:13:57 +053015027
Jeff Johnson295189b2012-06-20 16:38:30 -070015028 //convert to the UI units of 100kbps
15029 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
15030
15031#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070015032 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 -070015033 sinfo->signal,
15034 pCfg->reportMaxLinkSpeed,
15035 myRate,
15036 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070015037 (int) pCfg->linkSpeedRssiMid,
15038 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070015039 (int) rate_flags,
15040 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070015041#endif //LINKSPEED_DEBUG_ENABLED
15042
15043 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
15044 {
15045 // we do not want to necessarily report the current speed
15046 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
15047 {
15048 // report the max possible speed
15049 rssidx = 0;
15050 }
15051 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
15052 {
15053 // report the max possible speed with RSSI scaling
15054 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
15055 {
15056 // report the max possible speed
15057 rssidx = 0;
15058 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070015059 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070015060 {
15061 // report middle speed
15062 rssidx = 1;
15063 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070015064 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
15065 {
15066 // report middle speed
15067 rssidx = 2;
15068 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015069 else
15070 {
15071 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070015072 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070015073 }
15074 }
15075 else
15076 {
15077 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
15078 hddLog(VOS_TRACE_LEVEL_ERROR,
15079 "%s: Invalid value for reportMaxLinkSpeed: %u",
15080 __func__, pCfg->reportMaxLinkSpeed);
15081 rssidx = 0;
15082 }
15083
15084 maxRate = 0;
15085
15086 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053015087 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
15088 OperationalRates, &ORLeng))
15089 {
15090 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
15091 /*To keep GUI happy*/
15092 return 0;
15093 }
15094
Jeff Johnson295189b2012-06-20 16:38:30 -070015095 for (i = 0; i < ORLeng; i++)
15096 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015097 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070015098 {
15099 /* Validate Rate Set */
15100 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
15101 {
15102 currentRate = supported_data_rate[j].supported_rate[rssidx];
15103 break;
15104 }
15105 }
15106 /* Update MAX rate */
15107 maxRate = (currentRate > maxRate)?currentRate:maxRate;
15108 }
15109
15110 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053015111 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
15112 ExtendedRates, &ERLeng))
15113 {
15114 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
15115 /*To keep GUI happy*/
15116 return 0;
15117 }
15118
Jeff Johnson295189b2012-06-20 16:38:30 -070015119 for (i = 0; i < ERLeng; i++)
15120 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015121 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070015122 {
15123 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
15124 {
15125 currentRate = supported_data_rate[j].supported_rate[rssidx];
15126 break;
15127 }
15128 }
15129 /* Update MAX rate */
15130 maxRate = (currentRate > maxRate)?currentRate:maxRate;
15131 }
c_hpothu79aab322014-07-14 21:11:01 +053015132
Kiet Lamb69f8dc2013-11-15 15:34:27 +053015133 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053015134 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053015135 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053015136 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070015137 {
c_hpothu79aab322014-07-14 21:11:01 +053015138 if (rate_flags & eHAL_TX_RATE_VHT80)
15139 mode = 2;
15140 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
15141 mode = 1;
15142 else
15143 mode = 0;
15144
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053015145 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
15146 MCSRates, &MCSLeng))
15147 {
15148 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
15149 /*To keep GUI happy*/
15150 return 0;
15151 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015152 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070015153#ifdef WLAN_FEATURE_11AC
15154 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015155 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070015156 {
Leo Chang6f8870f2013-03-26 18:11:36 -070015157 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015158 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070015159 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070015160 {
Leo Chang6f8870f2013-03-26 18:11:36 -070015161 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070015162 }
Leo Chang6f8870f2013-03-26 18:11:36 -070015163 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070015164 {
Leo Chang6f8870f2013-03-26 18:11:36 -070015165 maxMCSIdx = 7;
15166 }
15167 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
15168 {
15169 maxMCSIdx = 8;
15170 }
15171 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
15172 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015173 //VHT20 is supporting 0~8
15174 if (rate_flags & eHAL_TX_RATE_VHT20)
15175 maxMCSIdx = 8;
15176 else
15177 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070015178 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015179
c_hpothu79aab322014-07-14 21:11:01 +053015180 if (0 != rssidx)/*check for scaled */
15181 {
15182 //get middle rate MCS index if rssi=1/2
15183 for (i=0; i <= maxMCSIdx; i++)
15184 {
15185 if (sinfo->signal <= rssiMcsTbl[mode][i])
15186 {
15187 maxMCSIdx = i;
15188 break;
15189 }
15190 }
15191 }
15192
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015193 if (rate_flags & eHAL_TX_RATE_VHT80)
15194 {
15195 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
15196 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
15197 }
15198 else if (rate_flags & eHAL_TX_RATE_VHT40)
15199 {
15200 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
15201 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
15202 }
15203 else if (rate_flags & eHAL_TX_RATE_VHT20)
15204 {
15205 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
15206 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
15207 }
15208
Leo Chang6f8870f2013-03-26 18:11:36 -070015209 maxSpeedMCS = 1;
15210 if (currentRate > maxRate)
15211 {
15212 maxRate = currentRate;
15213 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015214
Leo Chang6f8870f2013-03-26 18:11:36 -070015215 }
15216 else
15217#endif /* WLAN_FEATURE_11AC */
15218 {
15219 if (rate_flags & eHAL_TX_RATE_HT40)
15220 {
15221 rateFlag |= 1;
15222 }
15223 if (rate_flags & eHAL_TX_RATE_SGI)
15224 {
15225 rateFlag |= 2;
15226 }
15227
Girish Gowli01abcee2014-07-31 20:18:55 +053015228 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053015229 if (rssidx == 1 || rssidx == 2)
15230 {
15231 //get middle rate MCS index if rssi=1/2
15232 for (i=0; i <= 7; i++)
15233 {
15234 if (sinfo->signal <= rssiMcsTbl[mode][i])
15235 {
15236 temp = i+1;
15237 break;
15238 }
15239 }
15240 }
c_hpothu79aab322014-07-14 21:11:01 +053015241
15242 for (i = 0; i < MCSLeng; i++)
15243 {
Leo Chang6f8870f2013-03-26 18:11:36 -070015244 for (j = 0; j < temp; j++)
15245 {
15246 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
15247 {
15248 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053015249 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070015250 break;
15251 }
15252 }
15253 if ((j < temp) && (currentRate > maxRate))
15254 {
15255 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070015256 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015257 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053015258 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070015259 }
15260 }
15261
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015262 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
15263 {
15264 maxRate = myRate;
15265 maxSpeedMCS = 1;
15266 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
15267 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015268 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053015269 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070015270 {
15271 maxRate = myRate;
15272 if (rate_flags & eHAL_TX_RATE_LEGACY)
15273 {
15274 maxSpeedMCS = 0;
15275 }
15276 else
15277 {
15278 maxSpeedMCS = 1;
15279 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
15280 }
15281 }
15282
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015283 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070015284 {
15285 sinfo->txrate.legacy = maxRate;
15286#ifdef LINKSPEED_DEBUG_ENABLED
15287 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
15288#endif //LINKSPEED_DEBUG_ENABLED
15289 }
15290 else
15291 {
15292 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070015293#ifdef WLAN_FEATURE_11AC
15294 sinfo->txrate.nss = 1;
15295 if (rate_flags & eHAL_TX_RATE_VHT80)
15296 {
15297 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015298 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070015299 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015300 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070015301 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015302 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
15303 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
15304 }
15305 else if (rate_flags & eHAL_TX_RATE_VHT20)
15306 {
15307 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
15308 }
15309#endif /* WLAN_FEATURE_11AC */
15310 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
15311 {
15312 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
15313 if (rate_flags & eHAL_TX_RATE_HT40)
15314 {
15315 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
15316 }
Leo Chang6f8870f2013-03-26 18:11:36 -070015317 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015318 if (rate_flags & eHAL_TX_RATE_SGI)
15319 {
15320 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
15321 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015322
Jeff Johnson295189b2012-06-20 16:38:30 -070015323#ifdef LINKSPEED_DEBUG_ENABLED
15324 pr_info("Reporting MCS rate %d flags %x\n",
15325 sinfo->txrate.mcs,
15326 sinfo->txrate.flags );
15327#endif //LINKSPEED_DEBUG_ENABLED
15328 }
15329 }
15330 else
15331 {
15332 // report current rate instead of max rate
15333
15334 if (rate_flags & eHAL_TX_RATE_LEGACY)
15335 {
15336 //provide to the UI in units of 100kbps
15337 sinfo->txrate.legacy = myRate;
15338#ifdef LINKSPEED_DEBUG_ENABLED
15339 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
15340#endif //LINKSPEED_DEBUG_ENABLED
15341 }
15342 else
15343 {
15344 //must be MCS
15345 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070015346#ifdef WLAN_FEATURE_11AC
15347 sinfo->txrate.nss = 1;
15348 if (rate_flags & eHAL_TX_RATE_VHT80)
15349 {
15350 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
15351 }
15352 else
15353#endif /* WLAN_FEATURE_11AC */
15354 {
15355 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
15356 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015357 if (rate_flags & eHAL_TX_RATE_SGI)
15358 {
15359 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
15360 }
15361 if (rate_flags & eHAL_TX_RATE_HT40)
15362 {
15363 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
15364 }
Leo Chang6f8870f2013-03-26 18:11:36 -070015365#ifdef WLAN_FEATURE_11AC
15366 else if (rate_flags & eHAL_TX_RATE_VHT80)
15367 {
15368 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
15369 }
15370#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070015371#ifdef LINKSPEED_DEBUG_ENABLED
15372 pr_info("Reporting actual MCS rate %d flags %x\n",
15373 sinfo->txrate.mcs,
15374 sinfo->txrate.flags );
15375#endif //LINKSPEED_DEBUG_ENABLED
15376 }
15377 }
15378 sinfo->filled |= STATION_INFO_TX_BITRATE;
15379
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070015380 sinfo->tx_packets =
15381 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
15382 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
15383 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
15384 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
15385
15386 sinfo->tx_retries =
15387 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
15388 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
15389 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
15390 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
15391
15392 sinfo->tx_failed =
15393 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
15394 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
15395 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
15396 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
15397
15398 sinfo->filled |=
15399 STATION_INFO_TX_PACKETS |
15400 STATION_INFO_TX_RETRIES |
15401 STATION_INFO_TX_FAILED;
15402
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015403 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15404 TRACE_CODE_HDD_CFG80211_GET_STA,
15405 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070015406 EXIT();
15407 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015408}
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015409#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
15410static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
15411 const u8* mac, struct station_info *sinfo)
15412#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015413static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
15414 u8* mac, struct station_info *sinfo)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015415#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015416{
15417 int ret;
15418
15419 vos_ssr_protect(__func__);
15420 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
15421 vos_ssr_unprotect(__func__);
15422
15423 return ret;
15424}
15425
15426static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070015427 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070015428{
15429 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053015430 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070015431 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015432 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015433
Jeff Johnsone7245742012-09-05 17:12:55 -070015434 ENTER();
15435
Jeff Johnson295189b2012-06-20 16:38:30 -070015436 if (NULL == pAdapter)
15437 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080015438 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015439 return -ENODEV;
15440 }
15441
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015442 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15443 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
15444 pAdapter->sessionId, timeout));
15445
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053015446 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015447 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015448 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015449 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015450 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015451 }
15452
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053015453 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
15454 (TRUE == pHddCtx->hdd_wlan_suspended) &&
15455 (pHddCtx->cfg_ini->fhostArpOffload) &&
15456 (eConnectionState_Associated ==
15457 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
15458 {
Amar Singhald53568e2013-09-26 11:03:45 -070015459
15460 hddLog(VOS_TRACE_LEVEL_INFO,
15461 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053015462 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053015463 if (!VOS_IS_STATUS_SUCCESS(vos_status))
15464 {
15465 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015466 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053015467 __func__, vos_status);
15468 }
15469 }
15470
Jeff Johnson295189b2012-06-20 16:38:30 -070015471 /**The get power cmd from the supplicant gets updated by the nl only
15472 *on successful execution of the function call
15473 *we are oppositely mapped w.r.t mode in the driver
15474 **/
15475 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
15476
15477 if (VOS_STATUS_E_FAILURE == vos_status)
15478 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015479 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15480 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015481 return -EINVAL;
15482 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015483 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015484 return 0;
15485}
15486
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015487static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
15488 struct net_device *dev, bool mode, int timeout)
15489{
15490 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070015491
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015492 vos_ssr_protect(__func__);
15493 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
15494 vos_ssr_unprotect(__func__);
15495
15496 return ret;
15497}
Sushant Kaushik084f6592015-09-10 13:11:56 +053015498
Jeff Johnson295189b2012-06-20 16:38:30 -070015499#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015500static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
15501 struct net_device *netdev,
15502 u8 key_index)
15503{
15504 ENTER();
15505 return 0;
15506}
15507
Jeff Johnson295189b2012-06-20 16:38:30 -070015508static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015509 struct net_device *netdev,
15510 u8 key_index)
15511{
15512 int ret;
15513 vos_ssr_protect(__func__);
15514 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
15515 vos_ssr_unprotect(__func__);
15516 return ret;
15517}
15518#endif //LINUX_VERSION_CODE
15519
15520#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
15521static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
15522 struct net_device *dev,
15523 struct ieee80211_txq_params *params)
15524{
15525 ENTER();
15526 return 0;
15527}
15528#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
15529static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
15530 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070015531{
Jeff Johnsone7245742012-09-05 17:12:55 -070015532 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070015533 return 0;
15534}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015535#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070015536
15537#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
15538static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015539 struct net_device *dev,
15540 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070015541{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015542 int ret;
15543
15544 vos_ssr_protect(__func__);
15545 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
15546 vos_ssr_unprotect(__func__);
15547 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070015548}
15549#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
15550static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
15551 struct ieee80211_txq_params *params)
15552{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015553 int ret;
15554
15555 vos_ssr_protect(__func__);
15556 ret = __wlan_hdd_set_txq_params(wiphy, params);
15557 vos_ssr_unprotect(__func__);
15558 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070015559}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015560#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015561
Naresh Jayaram69e3f282014-10-14 12:29:12 +053015562static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015563 struct net_device *dev,
15564 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070015565{
15566 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015567 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015568 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015569 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015570 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053015571 v_CONTEXT_t pVosContext = NULL;
15572 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015573
Jeff Johnsone7245742012-09-05 17:12:55 -070015574 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015575
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015576 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070015577 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015578 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015579 return -EINVAL;
15580 }
15581
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015582 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15583 TRACE_CODE_HDD_CFG80211_DEL_STA,
15584 pAdapter->sessionId, pAdapter->device_mode));
15585
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015586 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15587 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015588 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015589 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015590 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015591 }
15592
Jeff Johnson295189b2012-06-20 16:38:30 -070015593 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070015594 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070015595 )
15596 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053015597 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
15598 pSapCtx = VOS_GET_SAP_CB(pVosContext);
15599 if(pSapCtx == NULL){
15600 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15601 FL("psapCtx is NULL"));
15602 return -ENOENT;
15603 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015604 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070015605 {
15606 v_U16_t i;
15607 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
15608 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053015609 if ((pSapCtx->aStaInfo[i].isUsed) &&
15610 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070015611 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015612 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053015613 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015614 ETHER_ADDR_LEN);
15615
Jeff Johnson295189b2012-06-20 16:38:30 -070015616 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080015617 "%s: Delete STA with MAC::"
15618 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015619 __func__,
15620 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
15621 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070015622 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053015623 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015624 }
15625 }
15626 }
15627 else
15628 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015629
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015630 vos_status = hdd_softap_GetStaId(pAdapter,
15631 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015632 if (!VOS_IS_STATUS_SUCCESS(vos_status))
15633 {
15634 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080015635 "%s: Skip this DEL STA as this is not used::"
15636 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015637 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015638 return -ENOENT;
15639 }
15640
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053015641 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015642 {
15643 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080015644 "%s: Skip this DEL STA as deauth is in progress::"
15645 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015646 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015647 return -ENOENT;
15648 }
15649
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053015650 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015651
Jeff Johnson295189b2012-06-20 16:38:30 -070015652 hddLog(VOS_TRACE_LEVEL_INFO,
15653 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080015654 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015655 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015656 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015657
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015658 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015659 if (!VOS_IS_STATUS_SUCCESS(vos_status))
15660 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053015661 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015662 hddLog(VOS_TRACE_LEVEL_INFO,
15663 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080015664 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015665 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015666 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080015667 return -ENOENT;
15668 }
15669
Jeff Johnson295189b2012-06-20 16:38:30 -070015670 }
15671 }
15672
15673 EXIT();
15674
15675 return 0;
15676}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053015677
15678#ifdef CFG80211_DEL_STA_V2
15679static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
15680 struct net_device *dev,
15681 struct station_del_parameters *param)
15682#else
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015683#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
15684static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
15685 struct net_device *dev, const u8 *mac)
15686#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015687static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
15688 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053015689#endif
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015690#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015691{
15692 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015693 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070015694
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015695 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015696
Naresh Jayaram69e3f282014-10-14 12:29:12 +053015697#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015698 if (NULL == param) {
15699 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015700 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015701 return -EINVAL;
15702 }
15703
15704 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
15705 param->subtype, &delStaParams);
15706
Naresh Jayaram69e3f282014-10-14 12:29:12 +053015707#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053015708 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015709 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053015710#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053015711 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
15712
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015713 vos_ssr_unprotect(__func__);
15714
15715 return ret;
15716}
15717
15718static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015719 struct net_device *dev,
15720#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15721 const u8 *mac,
15722#else
15723 u8 *mac,
15724#endif
15725 struct station_parameters *params)
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015726{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015727 hdd_adapter_t *pAdapter;
15728 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015729 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015730#ifdef FEATURE_WLAN_TDLS
15731 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015732
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015733 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015734
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015735 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15736 if (NULL == pAdapter)
15737 {
15738 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15739 "%s: Adapter is NULL",__func__);
15740 return -EINVAL;
15741 }
15742 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15743 status = wlan_hdd_validate_context(pHddCtx);
15744 if (0 != status)
15745 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015746 return status;
15747 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015748
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015749 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15750 TRACE_CODE_HDD_CFG80211_ADD_STA,
15751 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015752 mask = params->sta_flags_mask;
15753
15754 set = params->sta_flags_set;
15755
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015756 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015757 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
15758 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015759
15760 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
15761 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080015762 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015763 }
15764 }
15765#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015766 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015767 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015768}
15769
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015770#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
15771static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
15772 struct net_device *dev, const u8 *mac,
15773 struct station_parameters *params)
15774#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015775static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
15776 struct net_device *dev, u8 *mac, struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015777#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015778{
15779 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015780
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015781 vos_ssr_protect(__func__);
15782 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
15783 vos_ssr_unprotect(__func__);
15784
15785 return ret;
15786}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015787#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070015788
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053015789static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070015790 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015791{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015792 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15793 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015794 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015795 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015796 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053015797 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070015798
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015799 ENTER();
15800
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015801 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015802 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015803 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015804 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015805 return -EINVAL;
15806 }
15807
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053015808 if (!pmksa) {
15809 hddLog(LOGE, FL("pmksa is NULL"));
15810 return -EINVAL;
15811 }
15812
15813 if (!pmksa->bssid || !pmksa->pmkid) {
15814 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
15815 pmksa->bssid, pmksa->pmkid);
15816 return -EINVAL;
15817 }
15818
15819 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
15820 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
15821
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015822 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15823 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015824 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015825 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015826 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015827 }
15828
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015829 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015830 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
15831
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053015832 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
15833 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015834
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053015835 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015836 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053015837 &pmk_id, 1, FALSE);
15838
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015839 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15840 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
15841 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053015842
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015843 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053015844 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015845}
15846
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053015847static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
15848 struct cfg80211_pmksa *pmksa)
15849{
15850 int ret;
15851
15852 vos_ssr_protect(__func__);
15853 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
15854 vos_ssr_unprotect(__func__);
15855
15856 return ret;
15857}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015858
Wilson Yang6507c4e2013-10-01 20:11:19 -070015859
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053015860static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070015861 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015862{
Wilson Yang6507c4e2013-10-01 20:11:19 -070015863 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15864 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070015865 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080015866 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070015867
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015868 ENTER();
15869
Wilson Yang6507c4e2013-10-01 20:11:19 -070015870 /* Validate pAdapter */
15871 if (NULL == pAdapter)
15872 {
15873 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
15874 return -EINVAL;
15875 }
15876
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053015877 if (!pmksa) {
15878 hddLog(LOGE, FL("pmksa is NULL"));
15879 return -EINVAL;
15880 }
15881
15882 if (!pmksa->bssid) {
15883 hddLog(LOGE, FL("pmksa->bssid is NULL"));
15884 return -EINVAL;
15885 }
15886
Kiet Lam98c46a12014-10-31 15:34:57 -070015887 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
15888 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
15889
Wilson Yang6507c4e2013-10-01 20:11:19 -070015890 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15891 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070015892 if (0 != status)
15893 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070015894 return status;
15895 }
15896
15897 /*Retrieve halHandle*/
15898 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
15899
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053015900 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15901 TRACE_CODE_HDD_CFG80211_DEL_PMKSA,
15902 pAdapter->sessionId, 0));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053015903 /* Delete the PMKID CSR cache */
15904 if (eHAL_STATUS_SUCCESS !=
15905 sme_RoamDelPMKIDfromCache(halHandle,
15906 pAdapter->sessionId, pmksa->bssid, FALSE)) {
15907 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
15908 MAC_ADDR_ARRAY(pmksa->bssid));
15909 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070015910 }
15911
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015912 EXIT();
15913 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015914}
15915
Wilson Yang6507c4e2013-10-01 20:11:19 -070015916
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053015917static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
15918 struct cfg80211_pmksa *pmksa)
15919{
15920 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070015921
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053015922 vos_ssr_protect(__func__);
15923 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
15924 vos_ssr_unprotect(__func__);
15925
15926 return ret;
15927
15928}
15929
15930static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015931{
Wilson Yang6507c4e2013-10-01 20:11:19 -070015932 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15933 tHalHandle halHandle;
15934 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080015935 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070015936
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015937 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070015938
15939 /* Validate pAdapter */
15940 if (NULL == pAdapter)
15941 {
15942 hddLog(VOS_TRACE_LEVEL_ERROR,
15943 "%s: Invalid Adapter" ,__func__);
15944 return -EINVAL;
15945 }
15946
15947 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15948 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070015949 if (0 != status)
15950 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070015951 return status;
15952 }
15953
15954 /*Retrieve halHandle*/
15955 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
15956
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053015957 /* Flush the PMKID cache in CSR */
15958 if (eHAL_STATUS_SUCCESS !=
15959 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
15960 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
15961 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070015962 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015963 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080015964 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015965}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053015966
15967static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
15968{
15969 int ret;
15970
15971 vos_ssr_protect(__func__);
15972 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
15973 vos_ssr_unprotect(__func__);
15974
15975 return ret;
15976}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015977#endif
15978
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070015979#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015980static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
15981 struct net_device *dev,
15982 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070015983{
15984 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15985 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053015986 hdd_context_t *pHddCtx;
15987 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070015988
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015989 ENTER();
15990
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070015991 if (NULL == pAdapter)
15992 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080015993 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070015994 return -ENODEV;
15995 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053015996 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15997 ret = wlan_hdd_validate_context(pHddCtx);
15998 if (0 != ret)
15999 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016000 return ret;
16001 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016002 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016003 if (NULL == pHddStaCtx)
16004 {
16005 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
16006 return -EINVAL;
16007 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016008
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016009 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16010 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
16011 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016012 // Added for debug on reception of Re-assoc Req.
16013 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
16014 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080016015 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016016 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080016017 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016018 }
16019
16020#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080016021 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016022 ftie->ie_len);
16023#endif
16024
16025 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053016026 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
16027 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016028 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016029
16030 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016031 return 0;
16032}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016033
16034static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
16035 struct net_device *dev,
16036 struct cfg80211_update_ft_ies_params *ftie)
16037{
16038 int ret;
16039
16040 vos_ssr_protect(__func__);
16041 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
16042 vos_ssr_unprotect(__func__);
16043
16044 return ret;
16045}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016046#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016047
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016048#ifdef FEATURE_WLAN_SCAN_PNO
16049
16050void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
16051 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
16052{
16053 int ret;
16054 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
16055 hdd_context_t *pHddCtx;
16056
Nirav Shah80830bf2013-12-31 16:35:12 +053016057 ENTER();
16058
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016059 if (NULL == pAdapter)
16060 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053016061 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016062 "%s: HDD adapter is Null", __func__);
16063 return ;
16064 }
16065
16066 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16067 if (NULL == pHddCtx)
16068 {
16069 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16070 "%s: HDD context is Null!!!", __func__);
16071 return ;
16072 }
16073
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016074 spin_lock(&pHddCtx->schedScan_lock);
16075 if (TRUE == pHddCtx->isWiphySuspended)
16076 {
16077 pHddCtx->isSchedScanUpdatePending = TRUE;
16078 spin_unlock(&pHddCtx->schedScan_lock);
16079 hddLog(VOS_TRACE_LEVEL_INFO,
16080 "%s: Update cfg80211 scan database after it resume", __func__);
16081 return ;
16082 }
16083 spin_unlock(&pHddCtx->schedScan_lock);
16084
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016085 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
16086
16087 if (0 > ret)
16088 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
16089
16090 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016091 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16092 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016093}
16094
16095/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016096 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053016097 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016098 */
16099static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
16100{
16101 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
16102 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016103 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016104 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16105 int status = 0;
16106 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
16107
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053016108 /* The current firmware design does not allow PNO during any
16109 * active sessions. Hence, determine the active sessions
16110 * and return a failure.
16111 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016112 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
16113 {
16114 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016115 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016116
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016117 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
16118 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
16119 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
16120 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
16121 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053016122 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016123 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016124 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016125 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016126 }
16127 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
16128 pAdapterNode = pNext;
16129 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016130 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016131}
16132
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016133void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
16134{
16135 hdd_adapter_t *pAdapter = callbackContext;
16136 hdd_context_t *pHddCtx;
16137
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016138 ENTER();
16139
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016140 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
16141 {
16142 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16143 FL("Invalid adapter or adapter has invalid magic"));
16144 return;
16145 }
16146
16147 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16148 if (0 != wlan_hdd_validate_context(pHddCtx))
16149 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016150 return;
16151 }
16152
c_hpothub53c45d2014-08-18 16:53:14 +053016153 if (VOS_STATUS_SUCCESS != status)
16154 {
16155 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016156 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053016157 pHddCtx->isPnoEnable = FALSE;
16158 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016159
16160 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
16161 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016162 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016163}
16164
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016165/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053016166 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
16167 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016168 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053016169static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016170 struct net_device *dev, struct cfg80211_sched_scan_request *request)
16171{
16172 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016173 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016174 hdd_context_t *pHddCtx;
16175 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053016176 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053016177 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
16178 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016179 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
16180 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016181 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053016182 hdd_config_t *pConfig = NULL;
16183 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016184
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016185 ENTER();
16186
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016187 if (NULL == pAdapter)
16188 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016190 "%s: HDD adapter is Null", __func__);
16191 return -ENODEV;
16192 }
16193
16194 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016195 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016196
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016197 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016198 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016199 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016200 }
16201
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053016202 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016203 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
16204 if (NULL == hHal)
16205 {
16206 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16207 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016208 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016209 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016210 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16211 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START,
16212 pAdapter->sessionId, pAdapter->device_mode));
Sushant Kaushik2fe89932014-09-03 10:58:09 +053016213 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053016214 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053016215 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053016216 {
16217 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16218 "%s: aborting the existing scan is unsuccessfull", __func__);
16219 return -EBUSY;
16220 }
16221
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016222 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016223 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053016224 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016225 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016226 return -EBUSY;
16227 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016228
c_hpothu37f21312014-04-09 21:49:54 +053016229 if (TRUE == pHddCtx->isPnoEnable)
16230 {
16231 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
16232 FL("already PNO is enabled"));
16233 return -EBUSY;
16234 }
c_hpothu225aa7c2014-10-22 17:45:13 +053016235
16236 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
16237 {
16238 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16239 "%s: abort ROC failed ", __func__);
16240 return -EBUSY;
16241 }
16242
c_hpothu37f21312014-04-09 21:49:54 +053016243 pHddCtx->isPnoEnable = TRUE;
16244
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016245 pnoRequest.enable = 1; /*Enable PNO */
16246 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016247
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016248 if (( !pnoRequest.ucNetworksCount ) ||
16249 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016250 {
16251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053016252 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016253 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053016254 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016255 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016256 goto error;
16257 }
16258
16259 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
16260 {
16261 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053016262 "%s: Incorrect number of channels %d",
16263 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016264 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016265 goto error;
16266 }
16267
16268 /* Framework provides one set of channels(all)
16269 * common for all saved profile */
16270 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
16271 channels_allowed, &num_channels_allowed))
16272 {
16273 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16274 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016275 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016276 goto error;
16277 }
16278 /* Checking each channel against allowed channel list */
16279 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053016280 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016281 {
Nirav Shah80830bf2013-12-31 16:35:12 +053016282 char chList [(request->n_channels*5)+1];
16283 int len;
16284 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016285 {
Nirav Shah80830bf2013-12-31 16:35:12 +053016286 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016287 {
Nirav Shah80830bf2013-12-31 16:35:12 +053016288 if (request->channels[i]->hw_value == channels_allowed[indx])
16289 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053016290 if ((!pConfig->enableDFSPnoChnlScan) &&
16291 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
16292 {
16293 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16294 "%s : Dropping DFS channel : %d",
16295 __func__,channels_allowed[indx]);
16296 num_ignore_dfs_ch++;
16297 break;
16298 }
16299
Nirav Shah80830bf2013-12-31 16:35:12 +053016300 valid_ch[num_ch++] = request->channels[i]->hw_value;
16301 len += snprintf(chList+len, 5, "%d ",
16302 request->channels[i]->hw_value);
16303 break ;
16304 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016305 }
16306 }
Nirav Shah80830bf2013-12-31 16:35:12 +053016307 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016308
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053016309 /*If all channels are DFS and dropped, then ignore the PNO request*/
16310 if (num_ignore_dfs_ch == request->n_channels)
16311 {
16312 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16313 "%s : All requested channels are DFS channels", __func__);
16314 ret = -EINVAL;
16315 goto error;
16316 }
16317 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016318
16319 pnoRequest.aNetworks =
16320 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
16321 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016322 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016323 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16324 FL("failed to allocate memory aNetworks %u"),
16325 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
16326 goto error;
16327 }
16328 vos_mem_zero(pnoRequest.aNetworks,
16329 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
16330
16331 /* Filling per profile params */
16332 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
16333 {
16334 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016335 request->match_sets[i].ssid.ssid_len;
16336
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016337 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
16338 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016339 {
16340 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053016341 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016342 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016343 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016344 goto error;
16345 }
16346
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016347 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016348 request->match_sets[i].ssid.ssid,
16349 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053016350 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16351 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016352 i, pnoRequest.aNetworks[i].ssId.ssId);
16353 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
16354 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
16355 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016356
16357 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016358 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
16359 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016360
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016361 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016362 }
16363
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053016364 for (i = 0; i < request->n_ssids; i++)
16365 {
16366 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016367 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053016368 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016369 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053016370 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016371 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053016372 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016373 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053016374 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016375 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053016376 break;
16377 }
16378 j++;
16379 }
16380 }
16381 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16382 "Number of hidden networks being Configured = %d",
16383 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053016384 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080016385 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016386
16387 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
16388 if (pnoRequest.p24GProbeTemplate == NULL)
16389 {
16390 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16391 FL("failed to allocate memory p24GProbeTemplate %u"),
16392 SIR_PNO_MAX_PB_REQ_SIZE);
16393 goto error;
16394 }
16395
16396 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
16397 if (pnoRequest.p5GProbeTemplate == NULL)
16398 {
16399 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16400 FL("failed to allocate memory p5GProbeTemplate %u"),
16401 SIR_PNO_MAX_PB_REQ_SIZE);
16402 goto error;
16403 }
16404
16405 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
16406 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
16407
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053016408 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
16409 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053016410 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016411 pnoRequest.us24GProbeTemplateLen = request->ie_len;
16412 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
16413 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053016414
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016415 pnoRequest.us5GProbeTemplateLen = request->ie_len;
16416 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
16417 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053016418 }
16419
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053016420 /* Driver gets only one time interval which is hardcoded in
16421 * supplicant for 10000ms. Taking power consumption into account 6 timers
16422 * will be used, Timervalue is increased exponentially i.e 10,20,40,
16423 * 80,160,320 secs. And number of scan cycle for each timer
16424 * is configurable through INI param gPNOScanTimerRepeatValue.
16425 * If it is set to 0 only one timer will be used and PNO scan cycle
16426 * will be repeated after each interval specified by supplicant
16427 * till PNO is disabled.
16428 */
16429 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016430 pnoRequest.scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053016431 else
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016432 pnoRequest.scanTimers.ucScanTimersCount =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053016433 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
16434
16435 tempInterval = (request->interval)/1000;
16436 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16437 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
16438 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016439 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++)
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053016440 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016441 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053016442 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016443 pnoRequest.scanTimers.aTimerValues[i].uTimerValue = tempInterval;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053016444 tempInterval *= 2;
16445 }
16446 //Repeat last timer until pno disabled.
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016447 pnoRequest.scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053016448
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016449 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016450
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016451 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016452 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
16453 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016454 pAdapter->pno_req_status = 0;
16455
Nirav Shah80830bf2013-12-31 16:35:12 +053016456 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16457 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016458 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
16459 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053016460
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016461 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016462 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016463 hdd_cfg80211_sched_scan_done_callback, pAdapter);
16464 if (eHAL_STATUS_SUCCESS != status)
16465 {
16466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053016467 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016468 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016469 goto error;
16470 }
16471
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016472 ret = wait_for_completion_timeout(
16473 &pAdapter->pno_comp_var,
16474 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
16475 if (0 >= ret)
16476 {
16477 // Did not receive the response for PNO enable in time.
16478 // Assuming the PNO enable was success.
16479 // Returning error from here, because we timeout, results
16480 // in side effect of Wifi (Wifi Setting) not to work.
16481 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16482 FL("Timed out waiting for PNO to be Enabled"));
16483 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016484 }
16485
16486 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053016487 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016488
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016489error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016490 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16491 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053016492 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016493 if (pnoRequest.aNetworks)
16494 vos_mem_free(pnoRequest.aNetworks);
16495 if (pnoRequest.p24GProbeTemplate)
16496 vos_mem_free(pnoRequest.p24GProbeTemplate);
16497 if (pnoRequest.p5GProbeTemplate)
16498 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016499
16500 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016501 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016502}
16503
16504/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053016505 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
16506 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016507 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053016508static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
16509 struct net_device *dev, struct cfg80211_sched_scan_request *request)
16510{
16511 int ret;
16512
16513 vos_ssr_protect(__func__);
16514 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
16515 vos_ssr_unprotect(__func__);
16516
16517 return ret;
16518}
16519
16520/*
16521 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
16522 * Function to disable PNO
16523 */
16524static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016525 struct net_device *dev)
16526{
16527 eHalStatus status = eHAL_STATUS_FAILURE;
16528 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16529 hdd_context_t *pHddCtx;
16530 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016531 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016532 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016533
16534 ENTER();
16535
16536 if (NULL == pAdapter)
16537 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016538 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016539 "%s: HDD adapter is Null", __func__);
16540 return -ENODEV;
16541 }
16542
16543 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016544
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016545 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016546 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016547 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016548 "%s: HDD context is Null", __func__);
16549 return -ENODEV;
16550 }
16551
16552 /* The return 0 is intentional when isLogpInProgress and
16553 * isLoadUnloadInProgress. We did observe a crash due to a return of
16554 * failure in sched_scan_stop , especially for a case where the unload
16555 * of the happens at the same time. The function __cfg80211_stop_sched_scan
16556 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
16557 * success. If it returns a failure , then its next invocation due to the
16558 * clean up of the second interface will have the dev pointer corresponding
16559 * to the first one leading to a crash.
16560 */
16561 if (pHddCtx->isLogpInProgress)
16562 {
16563 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16564 "%s: LOGP in Progress. Ignore!!!", __func__);
16565 return ret;
16566 }
16567
Mihir Shete18156292014-03-11 15:38:30 +053016568 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016569 {
16570 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16571 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
16572 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016573 }
16574
16575 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
16576 if (NULL == hHal)
16577 {
16578 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16579 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016580 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016581 }
16582
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016583 pnoRequest.enable = 0; /* Disable PNO */
16584 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016585
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016586 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16587 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP,
16588 pAdapter->sessionId, pAdapter->device_mode));
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016589 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016590 pAdapter->sessionId,
16591 NULL, pAdapter);
16592 if (eHAL_STATUS_SUCCESS != status)
16593 {
16594 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16595 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016596 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016597 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016598 }
c_hpothu37f21312014-04-09 21:49:54 +053016599 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016600
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016601error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016602 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016603 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016604
16605 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016606 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016607}
16608
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053016609/*
16610 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
16611 * NL interface to disable PNO
16612 */
16613static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
16614 struct net_device *dev)
16615{
16616 int ret;
16617
16618 vos_ssr_protect(__func__);
16619 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
16620 vos_ssr_unprotect(__func__);
16621
16622 return ret;
16623}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016624#endif /*FEATURE_WLAN_SCAN_PNO*/
16625
16626
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016627#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053016628#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053016629static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
16630 struct net_device *dev,
16631 u8 *peer, u8 action_code,
16632 u8 dialog_token,
16633 u16 status_code, u32 peer_capability,
16634 const u8 *buf, size_t len)
16635#else /* TDLS_MGMT_VERSION2 */
16636#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
16637static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
16638 struct net_device *dev,
16639 const u8 *peer, u8 action_code,
16640 u8 dialog_token, u16 status_code,
16641 u32 peer_capability, bool initiator,
16642 const u8 *buf, size_t len)
16643#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
16644static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
16645 struct net_device *dev,
16646 const u8 *peer, u8 action_code,
16647 u8 dialog_token, u16 status_code,
16648 u32 peer_capability, const u8 *buf,
16649 size_t len)
16650#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
16651static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
16652 struct net_device *dev,
16653 u8 *peer, u8 action_code,
16654 u8 dialog_token,
16655 u16 status_code, u32 peer_capability,
16656 const u8 *buf, size_t len)
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053016657#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053016658static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
16659 struct net_device *dev,
16660 u8 *peer, u8 action_code,
16661 u8 dialog_token,
16662 u16 status_code, const u8 *buf,
16663 size_t len)
16664#endif
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053016665#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016666{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016667 hdd_adapter_t *pAdapter;
16668 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016669 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070016670 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080016671 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070016672 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053016673 int ret;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053016674#if !(TDLS_MGMT_VERSION2) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0))
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053016675 u32 peer_capability = 0;
16676#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053016677 tANI_U16 numCurrTdlsPeers;
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053016678 hdd_station_ctx_t *pHddStaCtx = NULL;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016679
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016680 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16681 if (NULL == pAdapter)
16682 {
16683 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16684 "%s: Adapter is NULL",__func__);
16685 return -EINVAL;
16686 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016687 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16688 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
16689 pAdapter->sessionId, action_code));
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053016690
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016691 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016692 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016693 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016694 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016695 "Invalid arguments");
16696 return -EINVAL;
16697 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053016698
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080016699 if (pHddCtx->isLogpInProgress)
16700 {
16701 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16702 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053016703 wlan_hdd_tdls_set_link_status(pAdapter,
16704 peer,
16705 eTDLS_LINK_IDLE,
16706 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080016707 return -EBUSY;
16708 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053016709
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016710 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
16711 {
16712 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16713 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
16714 return -EAGAIN;
16715 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053016716
Hoonki Lee27511902013-03-14 18:19:06 -070016717 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016718 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053016719 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070016720 "%s: TDLS mode is disabled OR not enabled in FW."
16721 MAC_ADDRESS_STR " action %d declined.",
16722 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016723 return -ENOTSUPP;
16724 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080016725
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053016726 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16727
16728 if( NULL == pHddStaCtx )
16729 {
16730 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16731 "%s: HDD station context NULL ",__func__);
16732 return -EINVAL;
16733 }
16734
16735 /* STA should be connected and authenticated
16736 * before sending any TDLS frames
16737 */
16738 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
16739 (FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
16740 {
16741 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16742 "STA is not connected or unauthenticated. "
16743 "connState %u, uIsAuthenticated %u",
16744 pHddStaCtx->conn_info.connState,
16745 pHddStaCtx->conn_info.uIsAuthenticated);
16746 return -EAGAIN;
16747 }
16748
Hoonki Lee27511902013-03-14 18:19:06 -070016749 /* other than teardown frame, other mgmt frames are not sent if disabled */
16750 if (SIR_MAC_TDLS_TEARDOWN != action_code)
16751 {
16752 /* if tdls_mode is disabled to respond to peer's request */
16753 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
16754 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053016755 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070016756 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070016757 " TDLS mode is disabled. action %d declined.",
16758 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070016759
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053016760 return -ENOTSUPP;
Hoonki Lee27511902013-03-14 18:19:06 -070016761 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053016762
16763 if (vos_max_concurrent_connections_reached())
16764 {
16765 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
16766 return -EINVAL;
16767 }
Hoonki Lee27511902013-03-14 18:19:06 -070016768 }
16769
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016770 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
16771 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053016772 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016773 {
16774 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016775 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070016776 " TDLS setup is ongoing. action %d declined.",
16777 __func__, MAC_ADDR_ARRAY(peer), action_code);
16778 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016779 }
16780 }
16781
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016782 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
16783 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080016784 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053016785 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
16786 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080016787 {
16788 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
16789 we return error code at 'add_station()'. Hence we have this
16790 check again in addtion to add_station().
16791 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016792 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080016793 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016794 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16795 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053016796 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
16797 __func__, MAC_ADDR_ARRAY(peer), action_code,
16798 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053016799 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080016800 }
16801 else
16802 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016803 /* maximum reached. tweak to send error code to peer and return
16804 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080016805 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016806 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16807 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053016808 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
16809 __func__, MAC_ADDR_ARRAY(peer), status_code,
16810 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070016811 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016812 /* fall through to send setup resp with failure status
16813 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080016814 }
16815 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016816 else
16817 {
16818 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053016819 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070016820 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016821 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016822 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070016823 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
16824 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016825 return -EPERM;
16826 }
16827 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080016828 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016829
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053016830 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053016831 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016832 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
16833 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016834
Hoonki Leea34dd892013-02-05 22:56:02 -080016835 /*Except teardown responder will not be used so just make 0*/
16836 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016837 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080016838 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070016839
16840 hddTdlsPeer_t *pTdlsPeer;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053016841 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070016842
16843 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
16844 responder = pTdlsPeer->is_responder;
16845 else
Hoonki Leea34dd892013-02-05 22:56:02 -080016846 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070016847 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053016848 "%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 -070016849 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
16850 dialog_token, status_code, len);
16851 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080016852 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016853 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016854
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053016855 /* For explicit trigger of DIS_REQ come out of BMPS for
16856 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070016857 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053016858 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
16859 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070016860 {
16861 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
16862 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053016863 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053016864 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053016865 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
16866 if (status != VOS_STATUS_SUCCESS) {
16867 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
16868 }
Hoonki Lee14621352013-04-16 17:51:19 -070016869 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053016870 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053016871 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053016872 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
16873 }
16874 }
Hoonki Lee14621352013-04-16 17:51:19 -070016875 }
16876
Hoonki Lee5305c3a2013-04-29 23:28:59 -070016877 /* make sure doesn't call send_mgmt() while it is pending */
16878 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
16879 {
16880 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080016881 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070016882 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053016883 ret = -EBUSY;
16884 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070016885 }
16886
16887 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016888 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
16889
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053016890 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter),
16891 pAdapter->sessionId, peer, action_code, dialog_token,
16892 status_code, peer_capability, (tANI_U8 *)buf, len,
16893 responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016894
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016895 if (VOS_STATUS_SUCCESS != status)
16896 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016897 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16898 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070016899 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053016900 ret = -EINVAL;
16901 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016902 }
16903
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053016904 if ((SIR_MAC_TDLS_DIS_REQ == action_code) ||
16905 (SIR_MAC_TDLS_DIS_RSP == action_code))
16906 {
16907 /* for DIS_REQ/DIS_RSP, supplicant don't consider the return status.
16908 * So we no need to wait for tdls_mgmt_comp for sending ack status.
16909 */
16910 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16911 "%s: tx done for frm %u", __func__, action_code);
16912 return 0;
16913 }
16914
16915 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16916 "%s: Wait for tdls_mgmt_comp. Timeout %u ms", __func__,
16917 WAIT_TIME_TDLS_MGMT);
16918
Hoonki Leed37cbb32013-04-20 00:31:14 -070016919 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
16920 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
16921
16922 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016923 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070016924 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070016925 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070016926 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070016927 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080016928
16929 if (pHddCtx->isLogpInProgress)
16930 {
16931 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16932 "%s: LOGP in Progress. Ignore!!!", __func__);
16933 return -EAGAIN;
16934 }
Abhishek Singh837adf22015-10-01 17:37:37 +053016935 if (rc <= 0)
16936 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
16937 WLAN_LOG_INDICATOR_HOST_DRIVER,
16938 WLAN_LOG_REASON_HDD_TIME_OUT,
16939 TRUE, TRUE);
Yue Ma4f55ef32014-01-23 16:45:33 -080016940
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053016941 ret = -EINVAL;
16942 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016943 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053016944 else
16945 {
16946 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16947 "%s: Mgmt Tx Completion status %ld TxCompletion %u",
16948 __func__, rc, pAdapter->mgmtTxCompletionStatus);
16949 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016950
Gopichand Nakkala05922802013-03-14 12:23:19 -070016951 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070016952 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053016953 ret = max_sta_failed;
16954 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070016955 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016956
Hoonki Leea34dd892013-02-05 22:56:02 -080016957 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
16958 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053016959 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, TRUE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053016960 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
16961 }
Hoonki Leea34dd892013-02-05 22:56:02 -080016962 }
16963 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
16964 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053016965 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, FALSE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053016966 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
16967 }
Hoonki Leea34dd892013-02-05 22:56:02 -080016968 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016969
16970 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053016971
16972tx_failed:
16973 /* add_station will be called before sending TDLS_SETUP_REQ and
16974 * TDLS_SETUP_RSP and as part of add_station driver will enable
16975 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
16976 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
16977 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
16978 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
16979 */
16980
16981 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
16982 (SIR_MAC_TDLS_SETUP_RSP == action_code))
16983 wlan_hdd_tdls_check_bmps(pAdapter);
16984 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016985}
16986
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016987#if TDLS_MGMT_VERSION2
16988static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
16989 u8 *peer, u8 action_code, u8 dialog_token,
16990 u16 status_code, u32 peer_capability,
16991 const u8 *buf, size_t len)
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053016992#else /* TDLS_MGMT_VERSION2 */
16993#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
16994static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
16995 struct net_device *dev,
16996 const u8 *peer, u8 action_code,
16997 u8 dialog_token, u16 status_code,
16998 u32 peer_capability, bool initiator,
16999 const u8 *buf, size_t len)
17000#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
17001static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17002 struct net_device *dev,
17003 const u8 *peer, u8 action_code,
17004 u8 dialog_token, u16 status_code,
17005 u32 peer_capability, const u8 *buf,
17006 size_t len)
17007#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
17008static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17009 struct net_device *dev,
17010 u8 *peer, u8 action_code,
17011 u8 dialog_token,
17012 u16 status_code, u32 peer_capability,
17013 const u8 *buf, size_t len)
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017014#else
17015static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
17016 u8 *peer, u8 action_code, u8 dialog_token,
17017 u16 status_code, const u8 *buf, size_t len)
17018#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017019#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017020{
17021 int ret;
17022
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017023 vos_ssr_protect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017024#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017025 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17026 dialog_token, status_code,
17027 peer_capability, buf, len);
17028#else /* TDLS_MGMT_VERSION2 */
17029#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
17030 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17031 dialog_token, status_code,
17032 peer_capability, initiator,
17033 buf, len);
17034#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
17035 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17036 dialog_token, status_code,
17037 peer_capability, buf, len);
17038#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
17039 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17040 dialog_token, status_code,
17041 peer_capability, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017042#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017043 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17044 dialog_token, status_code, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017045#endif
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017046#endif
17047 vos_ssr_unprotect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017048
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017049 return ret;
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017050}
Atul Mittal115287b2014-07-08 13:26:33 +053017051
17052int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017053#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
17054 const u8 *peer,
17055#else
Atul Mittal115287b2014-07-08 13:26:33 +053017056 u8 *peer,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017057#endif
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017058 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053017059 cfg80211_exttdls_callback callback)
17060{
17061
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017062 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053017063 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053017064 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053017065 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17066 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
17067 __func__, MAC_ADDR_ARRAY(peer));
17068
17069 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
17070 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
17071
17072 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017073 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
17074 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
17075 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053017076 return -ENOTSUPP;
17077 }
17078
17079 /* To cater the requirement of establishing the TDLS link
17080 * irrespective of the data traffic , get an entry of TDLS peer.
17081 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053017082 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053017083 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
17084 if (pTdlsPeer == NULL) {
17085 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17086 "%s: peer " MAC_ADDRESS_STR " not existing",
17087 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053017088 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053017089 return -EINVAL;
17090 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053017091 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053017092
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053017093 /* check FW TDLS Off Channel capability */
17094 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053017095 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053017096 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017097 {
17098 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
17099 pTdlsPeer->peerParams.global_operating_class =
17100 tdls_peer_params->global_operating_class;
17101 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
17102 pTdlsPeer->peerParams.min_bandwidth_kbps =
17103 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053017104 /* check configured channel is valid, non dfs and
17105 * not current operating channel */
17106 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
17107 tdls_peer_params->channel)) &&
17108 (pHddStaCtx) &&
17109 (tdls_peer_params->channel !=
17110 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017111 {
17112 pTdlsPeer->isOffChannelConfigured = TRUE;
17113 }
17114 else
17115 {
17116 pTdlsPeer->isOffChannelConfigured = FALSE;
17117 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17118 "%s: Configured Tdls Off Channel is not valid", __func__);
17119
17120 }
17121 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053017122 "%s: tdls_off_channel %d isOffChannelConfigured %d "
17123 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017124 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053017125 pTdlsPeer->isOffChannelConfigured,
17126 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017127 }
17128 else
17129 {
17130 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053017131 "%s: TDLS off channel FW capability %d, "
17132 "host capab %d or Invalid TDLS Peer Params", __func__,
17133 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
17134 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017135 }
17136
Atul Mittal115287b2014-07-08 13:26:33 +053017137 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
17138
17139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17140 " %s TDLS Add Force Peer Failed",
17141 __func__);
17142 return -EINVAL;
17143 }
17144 /*EXT TDLS*/
17145
17146 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
17147 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17148 " %s TDLS set callback Failed",
17149 __func__);
17150 return -EINVAL;
17151 }
17152
17153 return(0);
17154
17155}
17156
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017157int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter,
17158#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
17159 const u8 *peer
17160#else
17161 u8 *peer
17162#endif
17163)
Atul Mittal115287b2014-07-08 13:26:33 +053017164{
17165
17166 hddTdlsPeer_t *pTdlsPeer;
17167 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17168 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17169 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
17170 __func__, MAC_ADDR_ARRAY(peer));
17171
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053017172 if (0 != wlan_hdd_validate_context(pHddCtx)) {
17173 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
17174 return -EINVAL;
17175 }
17176
Atul Mittal115287b2014-07-08 13:26:33 +053017177 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
17178 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
17179
17180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017181 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
17182 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
17183 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053017184 return -ENOTSUPP;
17185 }
17186
17187
17188 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
17189
17190 if ( NULL == pTdlsPeer ) {
17191 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053017192 " peer not existing",
Atul Mittal115287b2014-07-08 13:26:33 +053017193 __func__, MAC_ADDR_ARRAY(peer));
17194 return -EINVAL;
17195 }
17196 else {
17197 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
17198 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017199 /* if channel switch is configured, reset
17200 the channel for this peer */
17201 if (TRUE == pTdlsPeer->isOffChannelConfigured)
17202 {
17203 pTdlsPeer->peerParams.channel = 0;
17204 pTdlsPeer->isOffChannelConfigured = FALSE;
17205 }
Atul Mittal115287b2014-07-08 13:26:33 +053017206 }
17207
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017208 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
17209 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053017210 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017211 }
Atul Mittal115287b2014-07-08 13:26:33 +053017212
17213 /*EXT TDLS*/
17214
17215 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
17216
17217 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17218 " %s TDLS set callback Failed",
17219 __func__);
17220 return -EINVAL;
17221 }
17222 return(0);
17223
17224}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017225static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017226#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
17227 const u8 *peer,
17228#else
17229 u8 *peer,
17230#endif
17231 enum nl80211_tdls_operation oper)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017232{
17233 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17234 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017235 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017236 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017237
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017238 ENTER();
17239
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053017240 if (!pAdapter) {
17241 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
17242 return -EINVAL;
17243 }
17244
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017245 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17246 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
17247 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017248 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017249 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017250 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070017251 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017252 return -EINVAL;
17253 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080017254
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017255 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017256 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080017257 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017258 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080017259 }
17260
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017261
17262 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080017263 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017264 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080017265 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017266 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
17267 "Cannot process TDLS commands",
17268 pHddCtx->cfg_ini->fEnableTDLSSupport,
17269 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017270 return -ENOTSUPP;
17271 }
17272
17273 switch (oper) {
17274 case NL80211_TDLS_ENABLE_LINK:
17275 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017276 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053017277 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053017278 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Agarwal Ashish16020c42014-12-29 22:01:11 +053017279 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017280 tANI_U16 numCurrTdlsPeers = 0;
17281 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053017282 tANI_U8 suppChannelLen = 0;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017283
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053017284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17285 " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR,
17286 __func__, MAC_ADDR_ARRAY(peer));
Sunil Dutt41de4e22013-11-14 18:09:02 +053017287 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053017288 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053017289 if ( NULL == pTdlsPeer ) {
17290 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
17291 " (oper %d) not exsting. ignored",
17292 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
17293 return -EINVAL;
17294 }
17295
17296 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17297 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
17298 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
17299 "NL80211_TDLS_ENABLE_LINK");
17300
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070017301 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
17302 {
17303 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
17304 MAC_ADDRESS_STR " failed",
17305 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
17306 return -EINVAL;
17307 }
17308
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053017309 /* before starting tdls connection, set tdls
17310 * off channel established status to default value */
17311 pTdlsPeer->isOffChannelEstablished = FALSE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017312 /* TDLS Off Channel, Disable tdls channel switch,
17313 when there are more than one tdls link */
17314 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053017315 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017316 {
17317 /* get connected peer and send disable tdls off chan */
17318 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053017319 if ((connPeer) &&
17320 (connPeer->isOffChannelSupported == TRUE) &&
17321 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017322 {
17323 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17324 "%s: More then one peer connected, Disable "
17325 "TDLS channel switch", __func__);
17326
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053017327 connPeer->isOffChannelEstablished = FALSE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017328 ret = sme_SendTdlsChanSwitchReq(
17329 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017330 pAdapter->sessionId,
17331 connPeer->peerMac,
17332 connPeer->peerParams.channel,
17333 TDLS_OFF_CHANNEL_BW_OFFSET,
17334 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017335 if (ret != VOS_STATUS_SUCCESS) {
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053017336 hddLog(VOS_TRACE_LEVEL_ERROR,
17337 FL("Failed to send TDLS switch channel request"));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017338 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017339 }
17340 else
17341 {
17342 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17343 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053017344 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017345 "isOffChannelConfigured %d",
17346 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053017347 (connPeer ? (connPeer->isOffChannelSupported)
17348 : -1),
17349 (connPeer ? (connPeer->isOffChannelConfigured)
17350 : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017351 }
17352 }
17353
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017354 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017355 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053017356 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053017357
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053017358 if (0 != wlan_hdd_tdls_get_link_establish_params(
17359 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017360 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053017361 return -EINVAL;
17362 }
17363 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053017364
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017365 ret = sme_SendTdlsLinkEstablishParams(
17366 WLAN_HDD_GET_HAL_CTX(pAdapter),
17367 pAdapter->sessionId, peer,
17368 &tdlsLinkEstablishParams);
17369 if (ret != VOS_STATUS_SUCCESS) {
17370 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
17371 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053017372 /* Send TDLS peer UAPSD capabilities to the firmware and
17373 * register with the TL on after the response for this operation
17374 * is received .
17375 */
17376 ret = wait_for_completion_interruptible_timeout(
17377 &pAdapter->tdls_link_establish_req_comp,
17378 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
17379 if (ret <= 0)
17380 {
17381 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053017382 FL("Link Establish Request Failed Status %ld"),
17383 ret);
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053017384 return -EINVAL;
17385 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053017386 }
Atul Mittal115287b2014-07-08 13:26:33 +053017387 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
17388 eTDLS_LINK_CONNECTED,
17389 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053017390 staDesc.ucSTAId = pTdlsPeer->staId;
17391 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017392 ret = WLANTL_UpdateTdlsSTAClient(
17393 pHddCtx->pvosContext,
17394 &staDesc);
17395 if (ret != VOS_STATUS_SUCCESS) {
17396 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
17397 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053017398
Gopichand Nakkala471708b2013-06-04 20:03:01 +053017399 /* Mark TDLS client Authenticated .*/
17400 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
17401 pTdlsPeer->staId,
17402 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070017403 if (VOS_STATUS_SUCCESS == status)
17404 {
Hoonki Lee14621352013-04-16 17:51:19 -070017405 if (pTdlsPeer->is_responder == 0)
17406 {
17407 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +053017408 tdlsConnInfo_t *tdlsInfo;
17409
17410 tdlsInfo = wlan_hdd_get_conn_info(pHddCtx, staId);
17411
17412 /* Initialize initiator wait callback */
17413 vos_timer_init(
17414 &pTdlsPeer->initiatorWaitTimeoutTimer,
17415 VOS_TIMER_TYPE_SW,
17416 wlan_hdd_tdls_initiator_wait_cb,
17417 tdlsInfo);
Hoonki Lee14621352013-04-16 17:51:19 -070017418
17419 wlan_hdd_tdls_timer_restart(pAdapter,
17420 &pTdlsPeer->initiatorWaitTimeoutTimer,
17421 WAIT_TIME_TDLS_INITIATOR);
17422 /* suspend initiator TX until it receives direct packet from the
17423 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017424 ret = WLANTL_SuspendDataTx(
17425 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
17426 &staId, NULL);
17427 if (ret != VOS_STATUS_SUCCESS) {
17428 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
17429 }
Hoonki Lee14621352013-04-16 17:51:19 -070017430 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017431
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053017432 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053017433 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053017434 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053017435 suppChannelLen =
17436 tdlsLinkEstablishParams.supportedChannelsLen;
17437
17438 if ((suppChannelLen > 0) &&
17439 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
17440 {
17441 tANI_U8 suppPeerChannel = 0;
17442 int i = 0;
17443 for (i = 0U; i < suppChannelLen; i++)
17444 {
17445 suppPeerChannel =
17446 tdlsLinkEstablishParams.supportedChannels[i];
17447
17448 pTdlsPeer->isOffChannelSupported = FALSE;
17449 if (suppPeerChannel ==
17450 pTdlsPeer->peerParams.channel)
17451 {
17452 pTdlsPeer->isOffChannelSupported = TRUE;
17453 break;
17454 }
17455 }
17456 }
17457 else
17458 {
17459 pTdlsPeer->isOffChannelSupported = FALSE;
17460 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053017461 }
17462 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17463 "%s: TDLS channel switch request for channel "
17464 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053017465 "%d isOffChannelSupported %d", __func__,
17466 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053017467 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053017468 suppChannelLen,
17469 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053017470
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017471 /* TDLS Off Channel, Enable tdls channel switch,
17472 when their is only one tdls link and it supports */
17473 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
17474 if ((numCurrTdlsPeers == 1) &&
17475 (TRUE == pTdlsPeer->isOffChannelSupported) &&
17476 (TRUE == pTdlsPeer->isOffChannelConfigured))
17477 {
17478 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17479 "%s: Send TDLS channel switch request for channel %d",
17480 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053017481
17482 pTdlsPeer->isOffChannelEstablished = TRUE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017483 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
17484 pAdapter->sessionId,
17485 pTdlsPeer->peerMac,
17486 pTdlsPeer->peerParams.channel,
17487 TDLS_OFF_CHANNEL_BW_OFFSET,
17488 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017489 if (ret != VOS_STATUS_SUCCESS) {
17490 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
17491 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017492 }
17493 else
17494 {
17495 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17496 "%s: TDLS channel switch request not sent"
17497 " numCurrTdlsPeers %d "
17498 "isOffChannelSupported %d "
17499 "isOffChannelConfigured %d",
17500 __func__, numCurrTdlsPeers,
17501 pTdlsPeer->isOffChannelSupported,
17502 pTdlsPeer->isOffChannelConfigured);
17503 }
17504
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070017505 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017506 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053017507
17508 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053017509 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
17510 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053017511 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053017512 int ac;
17513 uint8 ucAc[4] = { WLANTL_AC_VO,
17514 WLANTL_AC_VI,
17515 WLANTL_AC_BK,
17516 WLANTL_AC_BE };
17517 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
17518 for(ac=0; ac < 4; ac++)
17519 {
17520 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
17521 pTdlsPeer->staId, ucAc[ac],
17522 tlTid[ac], tlTid[ac], 0, 0,
17523 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017524 if (status != VOS_STATUS_SUCCESS) {
17525 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
17526 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053017527 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053017528 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017529 }
17530
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017531 }
17532 break;
17533 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080017534 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017535 tANI_U16 numCurrTdlsPeers = 0;
17536 hddTdlsPeer_t *connPeer = NULL;
17537
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053017538 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17539 " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR,
17540 __func__, MAC_ADDR_ARRAY(peer));
17541
Sunil Dutt41de4e22013-11-14 18:09:02 +053017542 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
17543
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053017544
Sunil Dutt41de4e22013-11-14 18:09:02 +053017545 if ( NULL == pTdlsPeer ) {
17546 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
17547 " (oper %d) not exsting. ignored",
17548 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
17549 return -EINVAL;
17550 }
17551
17552 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17553 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
17554 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
17555 "NL80211_TDLS_DISABLE_LINK");
17556
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017557 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080017558 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070017559 long status;
17560
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053017561 /* set tdls off channel status to false for this peer */
17562 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053017563 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
17564 eTDLS_LINK_TEARING,
17565 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
17566 eTDLS_LINK_UNSPECIFIED:
17567 eTDLS_LINK_DROPPED_BY_REMOTE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070017568 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
17569
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017570 status = sme_DeleteTdlsPeerSta(
17571 WLAN_HDD_GET_HAL_CTX(pAdapter),
17572 pAdapter->sessionId, peer );
17573 if (status != VOS_STATUS_SUCCESS) {
17574 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
17575 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070017576
17577 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
17578 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Atul Mittal271a7652014-09-12 13:18:22 +053017579 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053017580 eTDLS_LINK_IDLE,
17581 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070017582 if (status <= 0)
17583 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070017584 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17585 "%s: Del station failed status %ld",
17586 __func__, status);
17587 return -EPERM;
17588 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017589
17590 /* TDLS Off Channel, Enable tdls channel switch,
17591 when their is only one tdls link and it supports */
17592 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
17593 if (numCurrTdlsPeers == 1)
17594 {
17595 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
17596 if ((connPeer) &&
17597 (connPeer->isOffChannelSupported == TRUE) &&
17598 (connPeer->isOffChannelConfigured == TRUE))
17599 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053017600 connPeer->isOffChannelEstablished = TRUE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017601 status = sme_SendTdlsChanSwitchReq(
17602 WLAN_HDD_GET_HAL_CTX(pAdapter),
17603 pAdapter->sessionId,
17604 connPeer->peerMac,
17605 connPeer->peerParams.channel,
17606 TDLS_OFF_CHANNEL_BW_OFFSET,
17607 TDLS_CHANNEL_SWITCH_ENABLE);
17608 if (status != VOS_STATUS_SUCCESS) {
17609 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
17610 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017611 }
17612 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17613 "%s: TDLS channel switch "
17614 "isOffChannelSupported %d "
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053017615 "isOffChannelConfigured %d "
17616 "isOffChannelEstablished %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017617 __func__,
17618 (connPeer ? connPeer->isOffChannelSupported : -1),
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053017619 (connPeer ? connPeer->isOffChannelConfigured : -1),
17620 (connPeer ? connPeer->isOffChannelEstablished : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017621 }
17622 else
17623 {
17624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17625 "%s: TDLS channel switch request not sent "
17626 "numCurrTdlsPeers %d ",
17627 __func__, numCurrTdlsPeers);
17628 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080017629 }
17630 else
17631 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017632 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17633 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080017634 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080017635 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017636 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017637 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053017638 {
Atul Mittal115287b2014-07-08 13:26:33 +053017639 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053017640
Atul Mittal115287b2014-07-08 13:26:33 +053017641 if (0 != status)
17642 {
17643 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053017644 FL("Error in TDLS Teardown"));
Atul Mittal115287b2014-07-08 13:26:33 +053017645 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053017646 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053017647 break;
17648 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017649 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053017650 {
Atul Mittal115287b2014-07-08 13:26:33 +053017651 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
17652 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017653 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053017654 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053017655
Atul Mittal115287b2014-07-08 13:26:33 +053017656 if (0 != status)
17657 {
17658 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053017659 FL("Error in TDLS Setup"));
Atul Mittal115287b2014-07-08 13:26:33 +053017660 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053017661 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053017662 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053017663 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017664 case NL80211_TDLS_DISCOVERY_REQ:
17665 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053017666 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053017667 "%s: Driver doesn't support in-driver setup/teardown/discovery "
c_hpothu6ff1c3c2013-10-01 19:01:57 +053017668 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017669 return -ENOTSUPP;
17670 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053017671 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17672 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017673 return -ENOTSUPP;
17674 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017675
17676 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017677 return 0;
17678}
Chilam NG571c65a2013-01-19 12:27:36 +053017679
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017680static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017681#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
17682 const u8 *peer,
17683#else
17684 u8 *peer,
17685#endif
17686 enum nl80211_tdls_operation oper)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017687{
17688 int ret;
17689
17690 vos_ssr_protect(__func__);
17691 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
17692 vos_ssr_unprotect(__func__);
17693
17694 return ret;
17695}
17696
Chilam NG571c65a2013-01-19 12:27:36 +053017697int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
17698 struct net_device *dev, u8 *peer)
17699{
Arif Hussaina7c8e412013-11-20 11:06:42 -080017700 hddLog(VOS_TRACE_LEVEL_INFO,
17701 "tdls send discover req: "MAC_ADDRESS_STR,
17702 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053017703
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017704#if TDLS_MGMT_VERSION2
17705 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
17706 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
17707#else
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017708#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
17709 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
17710 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, 0, NULL, 0);
17711#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
17712 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
17713 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
17714#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
17715 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
17716 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
17717#else
Chilam NG571c65a2013-01-19 12:27:36 +053017718 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
17719 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017720#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017721#endif /* KERNEL_VERSION */
Chilam NG571c65a2013-01-19 12:27:36 +053017722}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017723#endif
17724
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053017725#ifdef WLAN_FEATURE_GTK_OFFLOAD
17726/*
17727 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
17728 * Callback rountine called upon receiving response for
17729 * get offload info
17730 */
17731void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
17732 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
17733{
17734
17735 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053017736 tANI_U8 tempReplayCounter[8];
17737 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053017738
17739 ENTER();
17740
17741 if (NULL == pAdapter)
17742 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053017743 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053017744 "%s: HDD adapter is Null", __func__);
17745 return ;
17746 }
17747
17748 if (NULL == pGtkOffloadGetInfoRsp)
17749 {
17750 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17751 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
17752 return ;
17753 }
17754
17755 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
17756 {
17757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17758 "%s: wlan Failed to get replay counter value",
17759 __func__);
17760 return ;
17761 }
17762
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053017763 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
17764 /* Update replay counter */
17765 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
17766 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
17767
17768 {
17769 /* changing from little to big endian since supplicant
17770 * works on big endian format
17771 */
17772 int i;
17773 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
17774
17775 for (i = 0; i < 8; i++)
17776 {
17777 tempReplayCounter[7-i] = (tANI_U8)p[i];
17778 }
17779 }
17780
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053017781 /* Update replay counter to NL */
17782 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053017783 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053017784}
17785
17786/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017787 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053017788 * This function is used to offload GTK rekeying job to the firmware.
17789 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017790int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053017791 struct cfg80211_gtk_rekey_data *data)
17792{
17793 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17794 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
17795 hdd_station_ctx_t *pHddStaCtx;
17796 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017797 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053017798 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053017799 eHalStatus status = eHAL_STATUS_FAILURE;
17800
17801 ENTER();
17802
17803 if (NULL == pAdapter)
17804 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017805 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053017806 "%s: HDD adapter is Null", __func__);
17807 return -ENODEV;
17808 }
17809
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017810 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17811 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
17812 pAdapter->sessionId, pAdapter->device_mode));
17813
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017814 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017815 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053017816 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017817 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053017818 }
17819
17820 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
17821 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
17822 if (NULL == hHal)
17823 {
17824 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17825 "%s: HAL context is Null!!!", __func__);
17826 return -EAGAIN;
17827 }
17828
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053017829 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
17830 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
17831 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
17832 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053017833 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053017834 {
17835 /* changing from big to little endian since driver
17836 * works on little endian format
17837 */
17838 tANI_U8 *p =
17839 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
17840 int i;
17841
17842 for (i = 0; i < 8; i++)
17843 {
17844 p[7-i] = data->replay_ctr[i];
17845 }
17846 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053017847
17848 if (TRUE == pHddCtx->hdd_wlan_suspended)
17849 {
17850 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053017851 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
17852 sizeof (tSirGtkOffloadParams));
17853 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053017854 pAdapter->sessionId);
17855
17856 if (eHAL_STATUS_SUCCESS != status)
17857 {
17858 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17859 "%s: sme_SetGTKOffload failed, returned %d",
17860 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053017861
17862 /* Need to clear any trace of key value in the memory.
17863 * Thus zero out the memory even though it is local
17864 * variable.
17865 */
17866 vos_mem_zero(&hddGtkOffloadReqParams,
17867 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053017868 return status;
17869 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053017870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17871 "%s: sme_SetGTKOffload successfull", __func__);
17872 }
17873 else
17874 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053017875 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17876 "%s: wlan not suspended GTKOffload request is stored",
17877 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053017878 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053017879
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053017880 /* Need to clear any trace of key value in the memory.
17881 * Thus zero out the memory even though it is local
17882 * variable.
17883 */
17884 vos_mem_zero(&hddGtkOffloadReqParams,
17885 sizeof(hddGtkOffloadReqParams));
17886
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017887 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053017888 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053017889}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053017890
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017891int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
17892 struct cfg80211_gtk_rekey_data *data)
17893{
17894 int ret;
17895
17896 vos_ssr_protect(__func__);
17897 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
17898 vos_ssr_unprotect(__func__);
17899
17900 return ret;
17901}
17902#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053017903/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017904 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053017905 * This function is used to set access control policy
17906 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017907static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
17908 struct net_device *dev,
17909 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053017910{
17911 int i;
17912 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17913 hdd_hostapd_state_t *pHostapdState;
17914 tsap_Config_t *pConfig;
17915 v_CONTEXT_t pVosContext = NULL;
17916 hdd_context_t *pHddCtx;
17917 int status;
17918
17919 ENTER();
17920
17921 if (NULL == pAdapter)
17922 {
17923 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
17924 "%s: HDD adapter is Null", __func__);
17925 return -ENODEV;
17926 }
17927
17928 if (NULL == params)
17929 {
17930 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
17931 "%s: params is Null", __func__);
17932 return -EINVAL;
17933 }
17934
17935 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17936 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053017937 if (0 != status)
17938 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053017939 return status;
17940 }
17941
17942 pVosContext = pHddCtx->pvosContext;
17943 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
17944
17945 if (NULL == pHostapdState)
17946 {
17947 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
17948 "%s: pHostapdState is Null", __func__);
17949 return -EINVAL;
17950 }
17951
17952 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
17953 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053017954 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17955 TRACE_CODE_HDD_CFG80211_SET_MAC_ACL,
17956 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053017957
17958 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
17959 {
17960 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
17961
17962 /* default value */
17963 pConfig->num_accept_mac = 0;
17964 pConfig->num_deny_mac = 0;
17965
17966 /**
17967 * access control policy
17968 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
17969 * listed in hostapd.deny file.
17970 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
17971 * listed in hostapd.accept file.
17972 */
17973 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
17974 {
17975 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
17976 }
17977 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
17978 {
17979 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
17980 }
17981 else
17982 {
17983 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17984 "%s:Acl Policy : %d is not supported",
17985 __func__, params->acl_policy);
17986 return -ENOTSUPP;
17987 }
17988
17989 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
17990 {
17991 pConfig->num_accept_mac = params->n_acl_entries;
17992 for (i = 0; i < params->n_acl_entries; i++)
17993 {
17994 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17995 "** Add ACL MAC entry %i in WhiletList :"
17996 MAC_ADDRESS_STR, i,
17997 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
17998
17999 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
18000 sizeof(qcmacaddr));
18001 }
18002 }
18003 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
18004 {
18005 pConfig->num_deny_mac = params->n_acl_entries;
18006 for (i = 0; i < params->n_acl_entries; i++)
18007 {
18008 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18009 "** Add ACL MAC entry %i in BlackList :"
18010 MAC_ADDRESS_STR, i,
18011 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
18012
18013 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
18014 sizeof(qcmacaddr));
18015 }
18016 }
18017
18018 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
18019 {
18020 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18021 "%s: SAP Set Mac Acl fail", __func__);
18022 return -EINVAL;
18023 }
18024 }
18025 else
18026 {
18027 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053018028 "%s: Invalid device_mode = %s (%d)",
18029 __func__, hdd_device_modetoString(pAdapter->device_mode),
18030 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018031 return -EINVAL;
18032 }
18033
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018034 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018035 return 0;
18036}
18037
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018038static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
18039 struct net_device *dev,
18040 const struct cfg80211_acl_data *params)
18041{
18042 int ret;
18043 vos_ssr_protect(__func__);
18044 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
18045 vos_ssr_unprotect(__func__);
18046
18047 return ret;
18048}
18049
Leo Chang9056f462013-08-01 19:21:11 -070018050#ifdef WLAN_NL80211_TESTMODE
18051#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070018052void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070018053(
18054 void *pAdapter,
18055 void *indCont
18056)
18057{
Leo Changd9df8aa2013-09-26 13:32:26 -070018058 tSirLPHBInd *lphbInd;
18059 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053018060 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070018061
18062 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070018063 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070018064
c_hpothu73f35e62014-04-18 13:40:08 +053018065 if (pAdapter == NULL)
18066 {
18067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18068 "%s: pAdapter is NULL\n",__func__);
18069 return;
18070 }
18071
Leo Chang9056f462013-08-01 19:21:11 -070018072 if (NULL == indCont)
18073 {
18074 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070018075 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070018076 return;
18077 }
18078
c_hpothu73f35e62014-04-18 13:40:08 +053018079 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070018080 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070018081 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053018082 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070018083 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070018084 GFP_ATOMIC);
18085 if (!skb)
18086 {
18087 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18088 "LPHB timeout, NL buffer alloc fail");
18089 return;
18090 }
18091
Leo Changac3ba772013-10-07 09:47:04 -070018092 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070018093 {
18094 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18095 "WLAN_HDD_TM_ATTR_CMD put fail");
18096 goto nla_put_failure;
18097 }
Leo Changac3ba772013-10-07 09:47:04 -070018098 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070018099 {
18100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18101 "WLAN_HDD_TM_ATTR_TYPE put fail");
18102 goto nla_put_failure;
18103 }
Leo Changac3ba772013-10-07 09:47:04 -070018104 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070018105 sizeof(tSirLPHBInd), lphbInd))
18106 {
18107 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18108 "WLAN_HDD_TM_ATTR_DATA put fail");
18109 goto nla_put_failure;
18110 }
Leo Chang9056f462013-08-01 19:21:11 -070018111 cfg80211_testmode_event(skb, GFP_ATOMIC);
18112 return;
18113
18114nla_put_failure:
18115 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18116 "NLA Put fail");
18117 kfree_skb(skb);
18118
18119 return;
18120}
18121#endif /* FEATURE_WLAN_LPHB */
18122
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018123static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070018124{
18125 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
18126 int err = 0;
18127#ifdef FEATURE_WLAN_LPHB
18128 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070018129 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018130
18131 ENTER();
18132
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053018133 err = wlan_hdd_validate_context(pHddCtx);
18134 if (0 != err)
18135 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053018136 return err;
18137 }
Leo Chang9056f462013-08-01 19:21:11 -070018138#endif /* FEATURE_WLAN_LPHB */
18139
18140 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
18141 if (err)
18142 {
18143 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18144 "%s Testmode INV ATTR", __func__);
18145 return err;
18146 }
18147
18148 if (!tb[WLAN_HDD_TM_ATTR_CMD])
18149 {
18150 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18151 "%s Testmode INV CMD", __func__);
18152 return -EINVAL;
18153 }
18154
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053018155 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18156 TRACE_CODE_HDD_CFG80211_TESTMODE,
18157 NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])));
Leo Chang9056f462013-08-01 19:21:11 -070018158 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
18159 {
18160#ifdef FEATURE_WLAN_LPHB
18161 /* Low Power Heartbeat configuration request */
18162 case WLAN_HDD_TM_CMD_WLAN_HB:
18163 {
18164 int buf_len;
18165 void *buf;
18166 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080018167 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070018168
18169 if (!tb[WLAN_HDD_TM_ATTR_DATA])
18170 {
18171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18172 "%s Testmode INV DATA", __func__);
18173 return -EINVAL;
18174 }
18175
18176 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
18177 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080018178
18179 hb_params_temp =(tSirLPHBReq *)buf;
18180 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
18181 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
18182 return -EINVAL;
18183
Leo Chang9056f462013-08-01 19:21:11 -070018184 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
18185 if (NULL == hb_params)
18186 {
18187 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18188 "%s Request Buffer Alloc Fail", __func__);
18189 return -EINVAL;
18190 }
18191
18192 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070018193 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
18194 hb_params,
18195 wlan_hdd_cfg80211_lphb_ind_handler);
18196 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070018197 {
Leo Changd9df8aa2013-09-26 13:32:26 -070018198 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18199 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070018200 vos_mem_free(hb_params);
18201 }
Leo Chang9056f462013-08-01 19:21:11 -070018202 return 0;
18203 }
18204#endif /* FEATURE_WLAN_LPHB */
18205 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018206 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18207 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070018208 return -EOPNOTSUPP;
18209 }
18210
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018211 EXIT();
18212 return err;
Leo Chang9056f462013-08-01 19:21:11 -070018213}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018214
Anand N Sunkade9adb1b2015-07-29 09:56:45 +053018215static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy,
18216#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
18217 struct wireless_dev *wdev,
18218#endif
18219 void *data, int len)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018220{
18221 int ret;
18222
18223 vos_ssr_protect(__func__);
18224 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
18225 vos_ssr_unprotect(__func__);
18226
18227 return ret;
18228}
Leo Chang9056f462013-08-01 19:21:11 -070018229#endif /* CONFIG_NL80211_TESTMODE */
18230
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018231static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018232 struct net_device *dev,
18233 int idx, struct survey_info *survey)
18234{
18235 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
18236 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053018237 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018238 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053018239 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018240 v_S7_t snr,rssi;
18241 int status, i, j, filled = 0;
18242
18243 ENTER();
18244
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018245 if (NULL == pAdapter)
18246 {
18247 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
18248 "%s: HDD adapter is Null", __func__);
18249 return -ENODEV;
18250 }
18251
18252 if (NULL == wiphy)
18253 {
18254 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
18255 "%s: wiphy is Null", __func__);
18256 return -ENODEV;
18257 }
18258
18259 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
18260 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018261 if (0 != status)
18262 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018263 return status;
18264 }
18265
Mihir Sheted9072e02013-08-21 17:02:29 +053018266 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
18267
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018268 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053018269 0 != pAdapter->survey_idx ||
18270 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018271 {
18272 /* The survey dump ops when implemented completely is expected to
18273 * return a survey of all channels and the ops is called by the
18274 * kernel with incremental values of the argument 'idx' till it
18275 * returns -ENONET. But we can only support the survey for the
18276 * operating channel for now. survey_idx is used to track
18277 * that the ops is called only once and then return -ENONET for
18278 * the next iteration
18279 */
18280 pAdapter->survey_idx = 0;
18281 return -ENONET;
18282 }
18283
Mukul Sharma9d5233b2015-06-11 20:28:20 +053018284 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
18285 {
18286 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18287 "%s: Roaming in progress, hence return ", __func__);
18288 return -ENONET;
18289 }
18290
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018291 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
18292
18293 wlan_hdd_get_snr(pAdapter, &snr);
18294 wlan_hdd_get_rssi(pAdapter, &rssi);
18295
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053018296 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18297 TRACE_CODE_HDD_CFG80211_DUMP_SURVEY,
18298 pAdapter->sessionId, pAdapter->device_mode));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018299 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
18300 hdd_wlan_get_freq(channel, &freq);
18301
18302
18303 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
18304 {
18305 if (NULL == wiphy->bands[i])
18306 {
18307 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
18308 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
18309 continue;
18310 }
18311
18312 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
18313 {
18314 struct ieee80211_supported_band *band = wiphy->bands[i];
18315
18316 if (band->channels[j].center_freq == (v_U16_t)freq)
18317 {
18318 survey->channel = &band->channels[j];
18319 /* The Rx BDs contain SNR values in dB for the received frames
18320 * while the supplicant expects noise. So we calculate and
18321 * return the value of noise (dBm)
18322 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
18323 */
18324 survey->noise = rssi - snr;
18325 survey->filled = SURVEY_INFO_NOISE_DBM;
18326 filled = 1;
18327 }
18328 }
18329 }
18330
18331 if (filled)
18332 pAdapter->survey_idx = 1;
18333 else
18334 {
18335 pAdapter->survey_idx = 0;
18336 return -ENONET;
18337 }
18338
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018339 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018340 return 0;
18341}
18342
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018343static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
18344 struct net_device *dev,
18345 int idx, struct survey_info *survey)
18346{
18347 int ret;
18348
18349 vos_ssr_protect(__func__);
18350 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
18351 vos_ssr_unprotect(__func__);
18352
18353 return ret;
18354}
18355
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018356/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053018357 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018358 * this is called when cfg80211 driver resume
18359 * driver updates latest sched_scan scan result(if any) to cfg80211 database
18360 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053018361int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018362{
18363 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
18364 hdd_adapter_t *pAdapter;
18365 hdd_adapter_list_node_t *pAdapterNode, *pNext;
18366 VOS_STATUS status = VOS_STATUS_SUCCESS;
18367
18368 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018369
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053018370 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018371 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018372 return 0;
18373 }
18374
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053018375 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN,
18376 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018377 spin_lock(&pHddCtx->schedScan_lock);
18378 pHddCtx->isWiphySuspended = FALSE;
18379 if (TRUE != pHddCtx->isSchedScanUpdatePending)
18380 {
18381 spin_unlock(&pHddCtx->schedScan_lock);
18382 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18383 "%s: Return resume is not due to PNO indication", __func__);
18384 return 0;
18385 }
18386 // Reset flag to avoid updatating cfg80211 data old results again
18387 pHddCtx->isSchedScanUpdatePending = FALSE;
18388 spin_unlock(&pHddCtx->schedScan_lock);
18389
18390 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
18391
18392 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
18393 {
18394 pAdapter = pAdapterNode->pAdapter;
18395 if ( (NULL != pAdapter) &&
18396 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
18397 {
18398 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053018399 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018400 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
18401 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053018402 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018403 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053018404 {
18405 /* Acquire wakelock to handle the case where APP's tries to
18406 * suspend immediately after updating the scan results. Whis
18407 * results in app's is in suspended state and not able to
18408 * process the connect request to AP
18409 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053018410 hdd_prevent_suspend_timeout(2000,
18411 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018412 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053018413 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018414
18415 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18416 "%s : cfg80211 scan result database updated", __func__);
18417
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018418 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018419 return 0;
18420
18421 }
18422 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
18423 pAdapterNode = pNext;
18424 }
18425
18426 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18427 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018428 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018429 return 0;
18430}
18431
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053018432int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
18433{
18434 int ret;
18435
18436 vos_ssr_protect(__func__);
18437 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
18438 vos_ssr_unprotect(__func__);
18439
18440 return ret;
18441}
18442
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018443/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053018444 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018445 * this is called when cfg80211 driver suspends
18446 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053018447int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018448 struct cfg80211_wowlan *wow)
18449{
18450 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053018451 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018452
18453 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018454
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053018455 ret = wlan_hdd_validate_context(pHddCtx);
18456 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018457 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053018458 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018459 }
18460
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053018461
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053018462 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18463 TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN,
18464 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018465 pHddCtx->isWiphySuspended = TRUE;
18466
18467 EXIT();
18468
18469 return 0;
18470}
18471
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053018472int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
18473 struct cfg80211_wowlan *wow)
18474{
18475 int ret;
18476
18477 vos_ssr_protect(__func__);
18478 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
18479 vos_ssr_unprotect(__func__);
18480
18481 return ret;
18482}
Jeff Johnson295189b2012-06-20 16:38:30 -070018483/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018484static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070018485{
18486 .add_virtual_intf = wlan_hdd_add_virtual_intf,
18487 .del_virtual_intf = wlan_hdd_del_virtual_intf,
18488 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
18489 .change_station = wlan_hdd_change_station,
18490#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
18491 .add_beacon = wlan_hdd_cfg80211_add_beacon,
18492 .del_beacon = wlan_hdd_cfg80211_del_beacon,
18493 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070018494#else
18495 .start_ap = wlan_hdd_cfg80211_start_ap,
18496 .change_beacon = wlan_hdd_cfg80211_change_beacon,
18497 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070018498#endif
18499 .change_bss = wlan_hdd_cfg80211_change_bss,
18500 .add_key = wlan_hdd_cfg80211_add_key,
18501 .get_key = wlan_hdd_cfg80211_get_key,
18502 .del_key = wlan_hdd_cfg80211_del_key,
18503 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080018504#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070018505 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080018506#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070018507 .scan = wlan_hdd_cfg80211_scan,
18508 .connect = wlan_hdd_cfg80211_connect,
18509 .disconnect = wlan_hdd_cfg80211_disconnect,
18510 .join_ibss = wlan_hdd_cfg80211_join_ibss,
18511 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
18512 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
18513 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
18514 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070018515 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
18516 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053018517 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070018518#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
18519 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
18520 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
18521 .set_txq_params = wlan_hdd_set_txq_params,
18522#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070018523 .get_station = wlan_hdd_cfg80211_get_station,
18524 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
18525 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070018526 .add_station = wlan_hdd_cfg80211_add_station,
18527#ifdef FEATURE_WLAN_LFR
18528 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
18529 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
18530 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
18531#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070018532#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
18533 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
18534#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018535#ifdef FEATURE_WLAN_TDLS
18536 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
18537 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
18538#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018539#ifdef WLAN_FEATURE_GTK_OFFLOAD
18540 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
18541#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018542#ifdef FEATURE_WLAN_SCAN_PNO
18543 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
18544 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
18545#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018546 .resume = wlan_hdd_cfg80211_resume_wlan,
18547 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018548 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070018549#ifdef WLAN_NL80211_TESTMODE
18550 .testmode_cmd = wlan_hdd_cfg80211_testmode,
18551#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018552 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070018553};
18554